fix(hook): emit explicit allow for non-rewritten commands (#1033)#2479
Open
ousamabenyounes wants to merge 1 commit into
Open
fix(hook): emit explicit allow for non-rewritten commands (#1033)#2479ousamabenyounes wants to merge 1 commit into
ousamabenyounes wants to merge 1 commit into
Conversation
When the PreToolUse hook exits 0 with no stdout output, Claude Code
treats it differently from having no hook installed and falls through to
its default permission prompt — making --dangerously-skip-permissions
ineffective for any command RTK has no rewrite rule for.
Add _rtk_allow_passthrough() that emits:
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"allow"}}
and call it in all "no opinion" exit paths (exit codes 1, 0-no-change,
unknown, and the early guards for missing jq/rtk/old version). The
deny-rule path (exit 2) retains bare exit 0 so Claude Code can apply
its own deny semantics.
Update test-rtk-rewrite.sh:
- test_rewrite now verifies permissionDecision=allow + no updatedInput
for passthrough cases (replaces the empty-output check)
- Add test_passthrough_allows() section that directly reproduces the
three commands from the bug report: which rtk, rtk --version,
claude mcp list
Bump hook-version comment to 4.
Generated by Claude Code
Vibe coded by ousamabenyounes
Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1033.
When the hook had no rewrite to apply it exited 0 with no output. Claude Code treats "hook exits 0 with no output" differently from "no hook installed": under
--dangerously-skip-permissionsthe silent exit still produced an unexpected permission prompt for non-rewritten commands.Fix
Bump the hook to version 4 and emit an explicit
{"permissionDecision":"allow"}on every passthrough path via a small_rtk_allow_passthroughhelper (plainprintf, no jq dependency on the early-exit paths), so Claude Code honours--dangerously-skip-permissionsfor commands RTK does not rewrite.Test verification (RED → GREEN)
Section 5b of
hooks/claude/test-rtk-rewrite.sh("Passthrough must emit allow").RED — hook reverted to develop (bare
exit 0):GREEN — with the explicit allow:
(Re-proposes the accidentally-closed #1218, rebased onto current
develop.)