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
The Claude Code PreToolUse hook (rtk hook claude) rewrites rg (ripgrep) commands into rtk grep ..., treating rg as an alias for grep. This breaks any rg command that relies on ripgrep's recursive-by-default search over a directory, since the rewritten command shells out to plain grep without -r.
Steps to reproduce
rtk --version
# rtk 0.42.4
mkdir -p /tmp/rtktest &&echo"hello world"> /tmp/rtktest/a.txt
# Simulate what the PreToolUse hook does with an `rg` commandecho'{"tool_name":"Bash","tool_input":{"command":"rg -l foo /tmp/rtktest"}}'| rtk hook claude
$ rtk grep -l "hello" /tmp/rtktest
/usr/bin/grep: /tmp/rtktest: Es un directorio
Expected output
rg -l foo /tmp/rtktest is valid ripgrep syntax — ripgrep is recursive by default and does not need -r. The hook should either:
Not rewrite rg at all (it's already a fast, self-sufficient binary — there's no token-savings reason to route it through rtk grep), or
If routed through rtk grep, inject -r automatically when the target is a directory, so the semantics of the original rg invocation are preserved.
Additional context
Confirmed that passing -r explicitly to the rewritten command works around the bug: rtk grep -r "hello" /tmp/rtktest succeeds.
Confirmed fd, bat, sd, and eza are not rewritten by the hook (pass through unmodified).
Confirmed ls → rtk ls, find → rtk find, and cat → rtk read rewrites work correctly on directory/file targets — this issue appears specific to the rg/grep mapping.
Environment
rtk --version: 0.42.4
OS: Ubuntu (Linux 6.17.0-40-generic)
Invoked via Claude Code's PreToolUse hook (rtk hook claude)
rg->rtk grep rewrite in the Claude PreToolUse hook drops ripgrep's recursive-by-default semantics on directory targets, breaking valid rg invocations; hook should skip rewriting rg or inject -r for directory targets.
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/grep.rs
Triaged automatically by wshm · This is an automated analysis, not a human review.
Fixed — rg now routes to its own rtk rg handler instead of being remapped onto rtk grep, so ripgrep's recursive-by-default behaviour is preserved. Running the reported payload on the current build returns rtk rg -l foo /tmp/rtktest, matching the confirmation on v0.45.0. Please reopen or comment if you still see it on the latest version.
Activity
pszymkowiak commentedon Aug 19, 2026
🔍 Automated Triage
bughighSummary
rg->rtk grep rewrite in the Claude PreToolUse hook drops ripgrep's recursive-by-default semantics on directory targets, breaking valid rg invocations; hook should skip rewriting rg or inject -r for directory targets.
📁 Relevant files
src/hook/claude.rssrc/rewrite/grep.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
bvierra commentedon Aug 23, 2026
This appears fixed in 0.45.0:
rtk --version:rtk 0.45.0echo '{"tool_name":"Bash","tool_input":{"command":"rg -l foo /tmp/rtktest"}}' | rtk hook claude{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecisionReason":"RTK auto-rewrite","updatedInput":{"command":"rtk rg -l foo /tmp/rtktest"}}}KuSh commentedon Sep 5, 2026
Fixed —
rgnow routes to its ownrtk rghandler instead of being remapped ontortk grep, so ripgrep's recursive-by-default behaviour is preserved. Running the reported payload on the current build returnsrtk rg -l foo /tmp/rtktest, matching the confirmation on v0.45.0. Please reopen or comment if you still see it on the latest version.