Repository navigation
Description
Summary
rtk hook claude (the Claude Code PreToolUse:Bash auto-rewrite hook) silently declines to rewrite two very common command shapes, leaving them running uncompressed with no RTK savings and no indication anything was skipped:
- Piped commands, e.g.
git show HEAD | head -50— passes through unchanged. The same command without a pipe (git show HEAD,git show --name-only HEAD,git show origin/main:file.txt) rewrites fine tortk git show .... gh prwith--json, e.g.gh pr view 123 --json body— passes through unchanged. Without--json(gh pr view 123,gh pr diff 123,gh pr checks 123,gh pr list --state open) it rewrites fine tortk gh pr ....
Why this matters
Ran rtk discover over 30 days / 950 sessions / ~30K Bash commands in a real project. git show (5,936 calls) and gh pr (2,824 calls) were the two single biggest sources of missed savings — an estimated ~1.8M and ~1.4M tokens respectively — almost entirely because real-world usage of both commands very commonly involves a pipe (| head, | grep) or --json (the standard way to get structured, scriptable output from gh). So the hook is technically "working" but silently opts out on exactly the highest-value, highest-frequency real usage patterns for these two commands.
Reproduction
$ echo '{"tool_name":"Bash","tool_input":{"command":"git show HEAD | head -50"}}' | rtk hook claude
# (no output — command passes through unmodified)
$ echo '{"tool_name":"Bash","tool_input":{"command":"git show HEAD"}}' | rtk hook claude
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecisionReason":"RTK auto-rewrite","updatedInput":{"command":"rtk git show HEAD"}}}
$ echo '{"tool_name":"Bash","tool_input":{"command":"gh pr view 123 --json body"}}' | rtk hook claude
# (no output — command passes through unmodified)
$ echo '{"tool_name":"Bash","tool_input":{"command":"gh pr view 123"}}' | rtk hook claude
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecisionReason":"RTK auto-rewrite","updatedInput":{"command":"rtk gh pr view 123"}}}
(rtk 0.42.4, Windows/Git Bash)
Ask
- For the piped case: consider whether
rtk git show HEAD | head -50would actually preserve correct semantics (rtk's compression happening before the pipe, same as today just with the RTK-processed stream feeding intohead) — if so, this may just need the hook's pipe-detection to stop bailing out entirely and instead rewrite only the first command in the pipeline. - For
gh pr --json: if the concern is not wanting to reformat/break parseable JSON, that's reasonable — but it'd help to have this be a documented, discoverable behavior (e.g.rtk discoverorrtk gainflagging "N commands skipped due to --json/pipe, by design") rather than a silent pass-through that looks identical to "not installed."
Happy to provide more repro data from rtk discover output if useful.
Activity
pszymkowiak commentedon Aug 24, 2026
🔍 Automated Triage
bughighSummary
PreToolUse hook silently passes through piped commands (e.g. 'git show HEAD | head -50') and 'gh pr ... --json ...' without rewriting or reporting skip, losing RTK savings on two of the highest-frequency command patterns; overlaps with #3578's piped-command report but adds the gh --json case and quantified impact data.
Triaged automatically by wshm · This is an automated analysis, not a human review.
KuSh commentedon Sep 13, 2026
Closing as a duplicate of #3722, which tracks the same problem with the more complete discussion. Please follow up there; if your case differs in a way that issue does not cover, comment here and it can be reopened.