-
Notifications
You must be signed in to change notification settings - Fork 336
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
The rtk-rewrite.sh hook blindly prefixes rtk to find commands without translating POSIX find syntax to the rtk find CLI format. This causes errors for common find invocations used by Claude Code.
Steps to reproduce
Original command executed by Claude Code:
find /root/git/my-project/tests -name "*.py" -type f | head -20
The hook rewrites it to:
rtk find /root/git/my-project/tests -name "*.py" -type f | head -20
Error
error: unexpected argument '-n' foundtip: to pass '-n' as a value, use '-- -n'
Usage: rtk find [OPTIONS] <PATTERN> [PATH]
For more information, try '--help'.
Root cause
In rtk-rewrite.sh, the find rewrite rule is a simple sed substitution:
elif echo "$MATCH_CMD" | grep -qE '^find[[:space:]]+'; then
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^find /rtk find /')"
This just prepends rtk without any argument translation. But rtk find (defined in main.rs) expects a completely different syntax than POSIX find:
| POSIX find | rtk find | |
|---|---|---|
| Pattern | -name "*.py" | First positional arg: "*.py" |
| Path | First positional arg: /path | Second positional arg: /path |
| Type filter | -type f | -t f |
So rtk find /path -name "*.py" -type f fails because Clap tries to parse -name as a flag, interprets -n as an unknown short option, and errors out.
Expected behavior
Either:
- Translate POSIX arguments — parse
-name,-typefrom the original command and remap them tortk find <PATTERN> [PATH] [-t type]format, or - Skip rewriting when the
findcommand uses POSIX-style arguments (-name,-type,-maxdepth, etc.) thatrtk finddoesn't understand
Environment
- rtk version: 0.20.0
- Hook:
rtk-rewrite.sh(Claude CodePreToolUse:Bash)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working