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
grep counting zero added lines is a silent wrong answer — in an agent session it reads as "no changes", and we traced a real misdiagnosis back to exactly this.
The 0.43 never-worse guard protects the reading consumer, but a piped consumer parses structure (^+ prefixes, column layouts) that compression removes. Compression is for the model's eyes; anything behind a pipe needs raw bytes.
Suggested fix, either layer works:
rtk passthrough when !isatty(stdout) (same convention as git's pager/color handling), or
the hook engine skips rewriting a command whose proxied stage is followed by a pipe.
Related earlier reports from this setup: #3025, #3026.
rtk hook claude rewrites piped/chained commands to a compressed format, causing downstream parsers (e.g. grep) to consume the wrong data and silently produce incorrect results; recommend passthrough when stdout isn't a tty or skipping rewrite when the proxied command is piped.
📁 Relevant files
src/hook/claude.rs
src/hook/rewrite.rs
Triaged automatically by wshm · This is an automated analysis, not a human review.
Variant: the rewritten command is grep itself, and stdout is empty rather than compressed
Same family as this issue, but worth recording because the failure presents differently. Here the piped command is the rewritten one, and nothing reaches the pipe at all.
rtk 0.46.0, macOS, Claude Code hook install (rtk init --global). Against a 6222-line file containing 12 matches:
wc -l reporting 0 rules out display truncation — no lines reach the pipe. Exit status is 0 throughout, so nothing signals a problem.
The reason I'm adding it here rather than opening a separate issue: in the case above, a downstream parser gets malformed data and returns a wrong number. In this variant the consumer gets nothing, and for grep specifically an empty result is not a malformed answer — it's a meaningful one. It reads as "this pattern does not appear in this file," which is a conclusion. In my case an AI agent acted on that conclusion and spent several steps investigating why source code was "missing" from a repository it was in fact present in. Silent-wrong-number is bad; silent-wrong-absence from a search tool is worse, because there's nothing anomalous to notice.
The !isatty(stdout) passthrough proposed above would fix this case too.
Fixed by #3343, shipped in v0.49.0, the second of the two layers you suggested. The hook now leaves a piped producer alone and only rewrites a stage whose consumer is safe, so your command comes back as git diff main..HEAD | rtk grep -c "^+" with git's real output feeding grep; on this repo the rtk and /usr/bin/git forms both count 5402. The variant reported in the thread also behaves: grep -n ... | wc -l is not rewritten, and piping rtk grep into wc/head/cat returns all 12 matching lines. If you find another shape where compressed output reaches a parser, comment here and we'll reopen.
Activity
pszymkowiak commentedon Aug 13, 2026
🔍 Automated Triage
bughighSummary
rtk hook claude rewrites piped/chained commands to a compressed format, causing downstream parsers (e.g. grep) to consume the wrong data and silently produce incorrect results; recommend passthrough when stdout isn't a tty or skipping rewrite when the proxied command is piped.
📁 Relevant files
src/hook/claude.rssrc/hook/rewrite.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
vishae commentedon Sep 6, 2026
Variant: the rewritten command is
grepitself, and stdout is empty rather than compressedSame family as this issue, but worth recording because the failure presents differently. Here the piped command is the rewritten one, and nothing reaches the pipe at all.
rtk 0.46.0, macOS, Claude Code hook install (
rtk init --global). Against a 6222-line file containing 12 matches:wc -lreporting 0 rules out display truncation — no lines reach the pipe. Exit status is 0 throughout, so nothing signals a problem.The reason I'm adding it here rather than opening a separate issue: in the case above, a downstream parser gets malformed data and returns a wrong number. In this variant the consumer gets nothing, and for
grepspecifically an empty result is not a malformed answer — it's a meaningful one. It reads as "this pattern does not appear in this file," which is a conclusion. In my case an AI agent acted on that conclusion and spent several steps investigating why source code was "missing" from a repository it was in fact present in. Silent-wrong-number is bad; silent-wrong-absence from a search tool is worse, because there's nothing anomalous to notice.The
!isatty(stdout)passthrough proposed above would fix this case too.KuSh commentedon Sep 13, 2026
Fixed by #3343, shipped in v0.49.0, the second of the two layers you suggested. The hook now leaves a piped producer alone and only rewrites a stage whose consumer is safe, so your command comes back as
git diff main..HEAD | rtk grep -c "^+"with git's real output feeding grep; on this repo the rtk and /usr/bin/git forms both count 5402. The variant reported in the thread also behaves:grep -n ... | wc -lis not rewritten, and piping rtk grep into wc/head/cat returns all 12 matching lines. If you find another shape where compressed output reaches a parser, comment here and we'll reopen.