[bug] .github/hooks/rtk-rewrite.json with broken "rtk hook" command causes spurious parse_failure entries per session
#836 建立於 2026年3月25日
描述
Summary
Users who ran an earlier version of rtk init --copilot (or rtk init when Copilot support was first introduced in #605) end up with a .github/hooks/rtk-rewrite.json containing:
{
"hooks": {
"PreToolUse": [
{
"type": "command",
"command": "rtk hook",
"cwd": ".",
"timeout": 5
}
]
}
}
"rtk hook" requires a subcommand (gemini or copilot). Without one, it prints help and exits non-zero. This fires on every Bash tool call, silently logging a parse_failure with raw_command = "hook" in history.db.
Reproduction
- Have
.github/hooks/rtk-rewrite.jsonwith"command": "rtk hook"in your project - Run any Bash command through Claude Code
- Run
rtk gain --failures→ seeNx hookentries withfallback_succeeded = 0 - Query the DB directly:
→ Returns the fullsqlite3 ~/Library/Application\ Support/rtk/history.db \ "SELECT error_message FROM parse_failures WHERE raw_command = 'hook' LIMIT 1;"rtk hook --helpoutput as the error message
Impact
- Inflated failure count in
rtk gain --failures - Spurious
fallback_succeeded = 0entries (no actual fallback occurs — the hook returns non-zero, Claude Code runs the original command unchanged) - Silent — no visible error to the user
Root cause
Commit #605 (feat(copilot): add Copilot hook support) included .github/hooks/rtk-rewrite.json with "command": "rtk hook" instead of "command": "rtk hook copilot". The fix in the pending Copilot integration (see #823) generates the correct "rtk hook copilot" command, but does not migrate or clean up existing broken files.
Neither rtk init --show nor rtk init --uninstall check .github/hooks/ for orphaned files.
Note: different from #712
Issue #712 reports that rtk init doesn't wire up rtk hook at all.
This issue is the inverse: rtk init did write .github/hooks/rtk-rewrite.json, but with an incomplete command that silently breaks on every invocation.
Proposed fix
rtk init --showdetects.github/hooks/rtk-rewrite.jsonwith"rtk hook"and warns with actionable guidancertk init -g --uninstallremoves the broken file as part of cleanup
PR with the fix is attached.