rtk icon indicating copy to clipboard operation
rtk copied to clipboard

Custom Claude hook without a version tag is reported as outdated; suppress_hook_warning does not cover it, and rtk init -g would remove it

Open ludobos opened this issue 1 month ago • 1 comments

Summary

A hand-written Claude Code hook kept at ~/.claude/hooks/rtk-rewrite.sh, registered in settings.json and delegating every decision to rtk rewrite, is reported as outdated by rtk gain:

[warn] Hook outdated — run `rtk init -g` to update

Three things combine:

  1. hook_status() (src/hooks/init/claude.rs) takes the legacy-script path and reads # rtk-hook-version: N in the first 5 lines. A custom script has no such tag, so it is version 0, which is below CURRENT_HOOK_VERSION (4), so the hook is reported as outdated. The tag is not documented in docs/guide/getting-started/configuration.md or in the hook docs.
  2. warn_hook_issues() (src/analytics/gain.rs) never suppresses the outdated arm. suppress_hook_warning = true in [hooks] and RTK_SUPPRESS_HOOK_WARNING=1 both leave the line in place.
  3. The advice does damage in this case. rtk init -g removes the legacy rtk-rewrite.sh entry from settings.json ("Removed legacy rtk-rewrite.sh entry from settings.json") and installs rtk hook claude. That drops whatever the custom script adds. Ours adds an exemption that keeps git unwrapped inside worktree-isolated sessions, because the Claude Code isolation guard refuses rtk git .... A previous rtk init replaced the script in the same way and every worktree session lost git.

Related: #4512 (missing-hook arm, non-Claude harnesses). This issue is about the outdated arm and a custom Claude hook.

Reproduction

rtk 1.1.0 (Homebrew, macOS arm64).

# settings.json PreToolUse:Bash -> ~/.claude/hooks/rtk-rewrite.sh (custom script, no version tag)
printf '[hooks]\nsuppress_hook_warning = true\n' >> "$HOME/Library/Application Support/rtk/config.toml"
rtk gain | head -1                                # [warn] Hook outdated
RTK_SUPPRESS_HOOK_WARNING=1 rtk gain | head -1    # [warn] Hook outdated
# add "# rtk-hook-version: 4" as line 2 of the script
rtk gain | head -1                                # no warning

Request

Any one of these would close it:

  • let suppress_hook_warning cover the outdated arm too, or add a separate key for it;
  • document # rtk-hook-version: as the contract for custom hooks;
  • for a legacy script whose body calls rtk rewrite, say that rtk init -g will replace it, instead of only recommending it.

ludobos avatar Oct 28 '26 10:10 ludobos

wshm · Automated triage by AI

🔍 Automated Triage

🐛 Category bug
🟠 Priority high
🎯 Confidence 86%

Summary

Custom Claude hooks without a version tag are falsely flagged outdated, suppress_hook_warning doesn't cover it, and rtk init -g's fix destroys custom hook logic — add a suppression key/fix and document the version tag contract.

📁 Relevant files
  • src/hooks/init/claude.rs
  • src/analytics/gain.rs
  • docs/guide/getting-started/configuration.md

Suggested Actions

  1. Make suppress_hook_warning / RTK_SUPPRESS_HOOK_WARNING also suppress the outdated arm in warn_hook_issues() (src/analyt…
  2. Document # rtk-hook-version: N as the required contract for custom hooks in configuration.md
  3. Have rtk init -g warn before overwriting a custom script that delegates to rtk rewrite, instead of silently replacing…
  4. Cross-reference #4512 (missing-hook arm) and #4757 (CLAUDE_CONFIG_DIR outdated-never-clears) — related hook-status logic

Triaged automatically by wshm · This is an automated analysis, not a human review.

rtk-wshm-sync-bot avatar Oct 28 '26 10:10 rtk-wshm-sync-bot