delegates call `rtk rewrite <cmd>` without `--`, so a command of `--help` or `-h` comes back as rtk's help text with exit 0

Open Beginner friendly
#5,127 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
bash, python, shell, typescript
Domain
tooling

Research direction

Reproduce first: run rtk rewrite "--help" (usage text, exit 0) against rtk rewrite -- "--help" (exit 1, the expected refusal). Then fix all six call sites named in the issue so the command is passed after --: hooks/pi/rtk.ts:46, hooks/hermes/rtk-rewrite/__init__.py:63, openclaw/index.ts:85, and the rtk rewrite "$CMD" lines in hooks/claude/rtk-rewrite.sh, hooks/cursor/rtk-rewrite.sh and .claude/hooks/rtk-rewrite.sh. Done when --help and -h come back non-zero at every site while normal commands like git status still rewrite unchanged.

Written by the indexing model from the issue text.

Description

area:cli area:security bug priority:medium

rtk rewrite takes the command as one positional argument. When that argument reads as an option of rtk rewrite itself, clap handles it as one (rtk 1.2.0 and develop):

$ rtk rewrite "--help"; echo " -> exit $?"     # 1789 bytes of usage text on stdout
 -> exit 0
$ rtk rewrite "-h"; echo " -> exit $?"         # 453 bytes of usage text
 -> exit 0
$ rtk rewrite -- "--help"; echo " -> exit $?"
 -> exit 1
$ rtk rewrite -- "git status"; echo " -> exit $?"
rtk git status -> exit 3

Exit 0 with non-empty stdout is the "rewrite, allowed" answer, so a delegate hands the usage text to the shell as the command to run. The Claude Code and Cursor shell hooks also mark it auto-allowed, since exit 0 is their allow case. Six call sites pass the command without --:

  • hooks/pi/rtk.ts:46 — pi.exec("rtk", ["rewrite", cmd], …)
  • hooks/hermes/rtk-rewrite/__init__.py:63 — ["rtk", "rewrite", command]
  • openclaw/index.ts:85 — execFileSync("rtk", ["rewrite", command], …)
  • hooks/claude/rtk-rewrite.sh:59, hooks/cursor/rtk-rewrite.sh:48, .claude/hooks/rtk-rewrite.sh:54 — rtk rewrite "$CMD"

--help or -h is not a valid shell command on its own, so the practical harm is small: the agent gets "command not found" errors from usage lines instead of the same error for --help. The fix is to pass -- before the command at each site. rtk rewrite -- "<cmd>" works on 1.1.0, 1.2.0 and develop. The embedding guide (#3918) now documents the -- form.

Dominant language
Rust
Stars
86.4k
Forks
5.5k
Avg merge
6d 18h
Merged PRs (30d)
51

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rtk-ai/rtk

All issues in rtk-ai/rtk

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.