Skip to content

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

Closed
SrHuevo wants to merge 1 commit into
rtk-ai:developfrom
SrHuevo:fix/hook-check-detect-claude-md-on-windows
Closed

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

Conversation

@SrHuevo

@SrHuevo SrHuevo commented Apr 8, 2026

Copy link
Copy Markdown

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

CLAassistant commented Apr 8, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rtk-release-bot

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale due to 90 days of inactivity. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. Your contribution is very much appreciated — we're sorry we haven't been able to review it yet.

@rtk-release-bot rtk-release-bot Bot added the stale label Sep 3, 2026
@KuSh

KuSh commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the careful Windows reproduction. Hook based mode now works on Windows since PR #1399 (merged 2026-04-19), which dropped the Unix only guard and registers the native rtk hook in settings.json, so rtk init -g installs a real PreToolUse hook there and the "No hook installed" warning is both accurate and actionable. The claude-md fallback this patch recognized is no longer the only integration available on Windows, so the special case is not needed, and treating it as Ok would now hide the prompt to migrate to the hook. If you still see the warning after running rtk init -g on current develop, please comment and we can reopen.

@KuSh KuSh closed this Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants