You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PreToolUse rewrite misses find ... | wc -l and never maps standalone head -n <file> to rtk read #4072
find | head, find | grep, and find | cat all rewrite correctly (the find | head case was fixed between 0.43.0 and 0.49.0). Only wc as the
pipe target breaks it — for both find . | wc -l and find . -type f -name "*.php" | wc -l.
Bug 2: standalone head -n <file> is never rewritten to rtk read
$ rtk hook check 'head -n 50 foo.txt'
No rewrite for: head -n 50 foo.txt
rtk read (per rtk --help) is described as handling exactly this case, and cat file.txt does correctly rewrite:
$ rtk hook check 'cat file.txt'
rtk read file.txt
Impact
Found via rtk discover on a real project: it flagged head -n (55
occurrences, ~19.8K tokens) and find . (56 occurrences) as "missed savings
— existing" capability, meaning real Claude Code sessions were silently
bypassing the PreToolUse hook for these exact patterns despite the hook
being active and correctly configured. Adoption measured by discover was
only 2.2% of Bash commands over 30 days, and these two blind spots (plus
the already-fixed find | head) account for a meaningful share of that gap.
Expected
Both patterns should rewrite the same way their non-piped / cat-based
equivalents already do.
PreToolUse hook fails to rewrite find ... | wc -l and standalone head -n <file> (should map to rtk read); fix rewrite rule coverage for these two patterns.
This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.
📁 Relevant files
src/rewrite.rs
src/hook.rs
Triaged automatically by wshm · This is an automated analysis, not a human review.
Both halves are settled on the current release, so closing. head -n 50 foo.txt is rewritten to rtk read foo.txt --head-lines 50 since #3941, which shipped in v0.50.0 (also head -50 file and plain head file). find ... | wc -l is left alone on purpose: rtk find prints a condensed listing whose line count can differ from native find's (filtered entries, hint lines), so rewriting the producer would change what wc -l reports, and the same holds for any pipeline that ends in wc. That is why | head, | cat and | grep rewrite (they only trim or filter what they are shown) and | wc does not; a test pins that behaviour. If you see a wc pipeline where the rewritten count would be correct and worth having, open a new issue for that shape.
Activity
rtk-wshm-sync-bot commentedon Sep 15, 2026
🔍 Automated Triage
bugmediumSummary
PreToolUse hook fails to rewrite
find ... | wc -land standalonehead -n <file>(should map tortk read); fix rewrite rule coverage for these two patterns.📁 Relevant files
src/rewrite.rssrc/hook.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
KuSh commentedon Sep 27, 2026
Both halves are settled on the current release, so closing.
head -n 50 foo.txtis rewritten tortk read foo.txt --head-lines 50since #3941, which shipped in v0.50.0 (alsohead -50 fileand plainhead file).find ... | wc -lis left alone on purpose:rtk findprints a condensed listing whose line count can differ from native find's (filtered entries, hint lines), so rewriting the producer would change whatwc -lreports, and the same holds for any pipeline that ends inwc. That is why| head,| catand| greprewrite (they only trim or filter what they are shown) and| wcdoes not; a test pins that behaviour. If you see awcpipeline where the rewritten count would be correct and worth having, open a new issue for that shape.