Repository navigation
Description
Summary
Since 1.0, rtk hook claude evaluates pipeline rules (hook.before_tool.shell) before the rewrite. rtk hook check, described as "Check how a command would be rewritten by the hook engine (dry-run)", does not: for a command that a pipeline rule denies or passes through, it prints the default rewrite and exits 0.
As a result, none of the dry-run commands shows the decision the hook actually makes:
rtk hook checksees permission rules but not pipeline rules.rtk pipeline explainsees pipeline rules but not permission rules.rtk rewriteignores pipeline rules, although its help says that exit 2 with a printed message means "an rtk pipeline rule denied or routed the command". If pipeline rules act on Claude Code only by design (1.0.0 changelog: "pipeline hook rules act on Claude Code only"), the help text should say so.
Related: #3476 (rtk hook check does not expose the host permission decision) and #4518 (rtk hook check --agent opencode judges differently from the OpenCode plugin).
Environment
- rtk 1.0.1, default edition (with rtk-engine), on Windows 11 with Git Bash and on Ubuntu 24.04 x86_64
- Same results with the develop prerelease dev-1.0.2-rc.551 (commit 7bff768) on Ubuntu 24.04
- No user pipeline file
Steps to reproduce
mkdir -p hc && cd hc
mkdir -p .claude .rtk && git init -q
printf '{"permissions":{"deny":["Bash(git push:*)"]}}' > .claude/settings.json
cat > .rtk/pipeline.toml <<'EOF'
schema_version = 1
[pipeline]
name = "repro"
extends = "rtk:default"
[[hook.before_tool.shell]]
name = "deny-git-status"
when = { command_matches = '''^\s*git\s+status\b''' }
action = "deny"
message = "project pipeline: git status denied"
[[hook.before_tool.shell]]
name = "keep-git-log"
when = { command_matches = '''^\s*git\s+log\b''' }
action = "passthrough"
EOF
rtk trust --yes > /dev/null 2>&1
payload() { printf '{"hook_event_name":"PreToolUse","tool_name":"Bash","cwd":"%s","tool_input":{"command":"%s"}}' "$PWD" "$1"; }
for c in "git status" "git log -n 1" "git push" "echo hi"; do
echo "== $c"
echo " pipeline explain: $(rtk pipeline explain --tool Bash --command "$c" | sed -n 2p)"
echo " hook claude: $(payload "$c" | rtk hook claude)"
echo " rewrite: $(rtk rewrite "$c" 2>&1) [exit $?]"
echo " hook check: $(rtk hook check "$c" 2>&1) [exit $?]"
done
rtk untrustObserved
| Command | rtk hook claude (the real decision) |
rtk pipeline explain |
rtk hook check |
rtk rewrite |
|---|---|---|---|---|
git status (pipeline deny) |
"permissionDecision":"deny" |
rule deny-git-status -> action deny |
rtk git status, exit 0 |
rtk git status, exit 3 |
git log -n 1 (pipeline passthrough) |
no output: runs unchanged | rule keep-git-log -> action passthrough |
rtk git log -n 1, exit 0 |
rtk git log -n 1, exit 3 |
git push (permission deny) |
no output: defers to the host deny | rule rtk-rewrite -> action rewrite |
Denied by a permission rule: git push, exit 1 |
no output, exit 2 |
echo hi (nothing to rewrite) |
no output | rule rtk-rewrite -> action rewrite |
No rewrite for: echo hi, exit 1 |
no output, exit 1 |
rtk hook check also exits 1 both for "Denied by a permission rule" and for "No rewrite", so a script cannot tell them apart.
Expected
rtk hook check follows the same decision path as rtk hook claude (pipeline rules, then the permission gate, then the rewrite) and prints the resulting decision with its source (pipeline rule name or permission rule), with exit codes that distinguish deny, passthrough or no rewrite, and rewrite; for example the same 0/1/2/3 scheme as rtk rewrite, as also suggested in #3476.
Why it matters
Someone debugging a pipeline, for example a passthrough added so git log reaches the agent unfiltered, gets a misleading answer from the documented dry-run command and may conclude that the rule does not work.
Reported by Alfredo Pons Menargues (GitHub: alfredopons).
Activity
rtk-wshm-sync-bot commentedon Oct 17, 2026
🔍 Automated Triage
bughighSummary
rtk hook checkandrtk rewriteskip pipeline rules and conflate deny/no-rewrite exit codes, giving a misleading dry-run of the actual hook decision; align withrtk hook claude's decision path and distinct exit codes.Suggested Actions
rtk hook checkevaluate pipeline rules before the rewrite, matchingrtk hook claude's decision pathrtk hook check/rtk rewritedistinct exit codes for deny/passthrough/no-rewrite/rewrite (0/1/2/3 scheme)rtk hook check --agent opencodejudges differently from the plugin #4518 — overlapping root cause of hook-check decision mismatchrtk rewrite --helptext to state that explicitlyTriaged automatically by wshm · This is an automated analysis, not a human review.
alponme commentedon Oct 28, 2026
One more divergence on 1.1.0: the Claude Code worktree exclusion from #3879 is applied only in
rtk hook claude, from the payloadcwd. Inside<repo>/.claude/worktrees/<name>,rtk hook check 'git status'still printsrtk git status(exit 0) andrtk pipeline explain --tool Bash --command 'git status'reports thertk-rewriterule, whilertk hook claudewith thatcwdleaves the command untouched. Seen on Windows 11 (Git Bash). Today the only way to see the real decision there is feeding the PreToolUse JSON withcwdtortk hook claude.