Repository navigation
Description
Problem
There are two implementations of the Claude Code rewrite hook in this repo, and
they have diverged while both declaring # rtk-hook-version: 3.
hooks/claude/rtk-rewrite.sh (authoritative) |
.claude/hooks/rtk-rewrite.sh (what this repo dogfoods) |
|
|---|---|---|
| sha256 | 742418d7… |
100bfefe… |
missing jq/rtk |
warns on stderr | silent exit |
rtk >= 0.23.0 guard |
yes, cached | absent |
| heredoc skip | — | yes |
set -euo pipefail |
— | yes |
audit logging (RTK_HOOK_AUDIT=1) |
— | yes |
jq spawns per call |
5 | 6 |
src/hooks/hook_check.rs:53 treats anything with rtk-hook-version >= 3 as
HookStatus::Ok, so RTK's own staleness check cannot distinguish them. Both
report healthy while running materially different logic.
The copy is stale, not ahead
The authoritative file's two most recent commits are fix(hooks): reduce jq invocations in rtk-rewrite (#968) and fix(hook): reduce rewrite hook spawn overhead. .claude/hooks/rtk-rewrite.sh last changed in #893, before both,
and still uses the pre-#968 shape:
CMD=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
ORIGINAL_INPUT=$(echo "$INPUT" | jq -c '.tool_input')
UPDATED_INPUT=$(echo "$ORIGINAL_INPUT" | jq --arg cmd "$REWRITTEN" '.command = $cmd')This hook runs on every Bash tool call, so the extra process spawns work
directly against the <10ms / Zero Overhead goal — and the version most likely to
be exercised while developing RTK is the slow one.
The three features unique to the copy were never in the authoritative file
(git log -S across all refs finds no commit adding or removing them there), so
this is not a case of something being deliberately dropped.
Proposed fix
- Port into
hooks/claude/rtk-rewrite.sh, keeping its jq-spawn reductions,
version guard and dependency warnings:set -euo pipefail- the heredoc early-skip
- opt-in audit logging
- Bump
# rtk-hook-version:to4andCURRENT_HOOK_VERSIONin
src/hooks/hook_check.rs, so existing installs are correctly reported
outdated rather than silently mismatched. - Delete
.claude/hooks/rtk-rewrite.shand dogfood the shipped hook via
rtk init, like any user.
A symlink was considered and rejected: with core.symlinks=false (the Windows
default) Git checks the link out as a plain text file containing the target
path, which would break Windows contributors silently.
Also worth deciding here
- The version marker is a weak signal.
integrity.rsalready does SHA-256 on
the installed hook;hook_check.rscould use that instead of trusting a
comment line, which is what allowed two different scripts to both claim v3.
Context
Found while adding CI path filtering (#189). The gate initially classified
.claude/ as documentation, which meant a change to these executable scripts
skipped CI entirely; that has been narrowed so .claude/hooks/ still builds.
Activity
rtk-release-bot commentedon Nov 30, 2026
This issue has been automatically marked as stale due to 90 days of inactivity. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet.