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
Hook doesn't rewrite ls when piped or chained with other commands #3442
Bug
The Claude Code hook correctly rewrites a bare ls <path> to rtk ls <path>, but skips rewriting when the command is piped or chained:
# rewritten fine:
$ ls /some/path
-> rtk ls /some/path
# NOT rewritten (runs raw ls, no filtering/tracking):
$ ls /some/path | head -5
$ echo hi; ls /some/path | head -5
Meanwhile in the same compound command, catdoes get rewritten to rtk read even inside a ;-chained command, so the compound-command handling isn't uniformly broken — it looks specific to how ls (possibly piped ls) is matched.
Repro
echo '{"tool_name":"Bash","tool_input":{"command":"ls /tmp 2>&1 | head -5"}}' | rtk hook claude
# -> no output / no rewrite
echo '{"tool_name":"Bash","tool_input":{"command":"ls /tmp"}}' | rtk hook claude
# -> correctly rewrites to `rtk ls /tmp`
Impact rtk discover flags these as missed savings after the fact, but the hook silently lets the raw, unfiltered command execute in the moment — so the token savings are lost for any piped/chained ls.
Expected
Hook should rewrite ls to rtk ls (or otherwise route through rtk's filter) even when piped or part of a compound ;-chained command, consistent with how cat/read is already handled in that context.
PreToolUse hook fails to rewrite ls to rtk ls when piped or ;-chained (unlike cat→read), so filtering/tracking silently skips those invocations; fix ls-matching logic in compound-command parsing.
This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.
📁 Relevant files
src/hook/claude.rs
src/rewrite/rules.rs
Triaged automatically by wshm · This is an automated analysis, not a human review.
Closing as a duplicate of #3722, which covers the same hook behaviour: a command in the producer position of a pipeline is left unrewritten. Please follow up there.
Activity
pszymkowiak commentedon Aug 5, 2026
🔍 Automated Triage
bugmediumSummary
PreToolUse hook fails to rewrite
lstortk lswhen piped or;-chained (unlikecat→read), so filtering/tracking silently skips those invocations; fix ls-matching logic in compound-command parsing.📁 Relevant files
src/hook/claude.rssrc/rewrite/rules.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
KuSh commentedon Sep 13, 2026
Closing as a duplicate of #3722, which covers the same hook behaviour: a command in the producer position of a pipeline is left unrewritten. Please follow up there.