Skip to content

fix(hook_check): skip hook warning on Windows when --claude-md mode is installed#1083

Open
SrHuevo wants to merge 1 commit intortk-ai:developfrom
SrHuevo:fix/hook-check-detect-claude-md-on-windows
Open

fix(hook_check): skip hook warning on Windows when --claude-md mode is installed#1083
SrHuevo wants to merge 1 commit intortk-ai:developfrom
SrHuevo:fix/hook-check-detect-claude-md-on-windows

Conversation

@SrHuevo
Copy link
Copy Markdown

@SrHuevo SrHuevo commented Apr 8, 2026

Summary

  • On Windows, rtk init -g cannot install a PreToolUse hook — it falls back to --claude-md mode and writes the RTK instructions block into ~/.claude/CLAUDE.md. That's the only valid integration on this platform.
  • But status() still returns Missing in that configuration, so maybe_warn() keeps printing /!\ No hook installed — run `rtk init -g` for automatic token savings every 24h.
  • The advice is impossible to follow: running rtk init -g on Windows just re-emits the --claude-md fallback message (Hook-based mode requires Unix (macOS/Linux). Windows: use --claude-md mode). The user is nagged forever about an integration they can never install.
  • This PR teaches status() to recognize the --claude-md integration on Windows by looking for the <!-- rtk-instructions marker in ~/.claude/CLAUDE.md, and return HookStatus::Ok in that case.
  • The check is narrowly gated on cfg!(windows) to stay minimal and avoid reopening the broader "hook masking" discussion from d85fe33 — on macOS/Linux, behavior is unchanged.

Reproduction (before this patch, on Windows)

> rtk init -g --no-patch
[rtk] Hook-based mode requires Unix (macOS/Linux).
       Windows: use --claude-md mode (automatic fallback).
> rtk init -g --claude-md
[rtk] Installed RTK instructions into ~/.claude/CLAUDE.md
> rtk git status
[rtk] /!\ No hook installed — run `rtk init -g` for automatic token savings
...

After the patch, once <!-- rtk-instructions is present in ~/.claude/CLAUDE.md, the warning stops — on Windows only.

Test plan

  • New unit tests cover the three shapes of claude_md_mode_installed: marker present, marker absent, file missing.
  • test_status_returns_valid_variant extended with a Windows + --claude-md branch asserting HookStatus::Ok.
  • cargo fmt --all && cargo clippy --all-targets && cargo test — I don't have a Rust toolchain on the Windows machine where I reproduced this, so relying on CI for the pre-commit gate.
  • Manual testing on Windows: confirmed the warning fires in v0.35.0 with ~/.claude/CLAUDE.md containing the RTK block; after this patch it should go silent.

Targets develop per CONTRIBUTING.md.

…s installed

On Windows, `rtk init -g` does not install a PreToolUse hook — it falls
back to `--claude-md` mode and writes the RTK instructions block into
`~/.claude/CLAUDE.md`. That is the only supported integration on this
platform.

However, `status()` still reports `Missing` in that configuration, so
`maybe_warn()` prints `/!\ No hook installed — run 'rtk init -g' for
automatic token savings` every 24h. The advice is impossible to follow:
running `rtk init -g` on Windows just re-emits the `--claude-md`
fallback, so the user is nagged forever about a hook they can never
install.

Detect the `--claude-md` integration on Windows by looking for the
`<!-- rtk-instructions` marker in `~/.claude/CLAUDE.md`, and return
`HookStatus::Ok` in that case. The check is gated on `cfg!(windows)` to
stay narrowly scoped and avoid reopening the broader "hook masking"
discussion from d85fe33.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 8, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants