Repository navigation
Description
Description
When rtk hook claude encounters a command that RTK cannot rewrite, it returns empty output (0 bytes) instead of valid JSON. This breaks Claude Code's hook system, which expects all hooks to return valid JSON responses.
Steps to Reproduce
- Create a test JSON input for a command RTK doesn't rewrite:
echo '{"tool_name":"Bash","tool_input":{"command":"head -c 100 /etc/hosts"}}' | rtk hook claude-
Observe: Empty output (0 bytes) with exit code 1
-
Expected: Valid JSON response, even if no rewrite is available
Current Behavior
$ echo '{"tool_name":"Bash","tool_input":{"command":"head -c 100 file.txt"}}' | rtk hook claude
# Returns: empty (0 bytes)
# Exit code: 1Expected Behavior
Should return valid JSON indicating passthrough:
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecisionReason": "no RTK rewrite available",
"updatedInput": {
"command": "head -c 100 file.txt"
},
"permissionDecision": "allow"
}
}Affected Commands
Commands that RTK doesn't have rewrites for:
head -cwc -lsedyarn test(and other yarn subcommands)npm run(and other npm subcommands)- And others...
Impact
- Claude Code's hook system breaks when encountering these commands
- Users implementing RTK integration must wrap the hook with error handling
- Reduces reliability of the RTK ↔ Claude Code integration
Environment
- RTK version: 0.37.1
- Platform: macOS (arm64)
- Integration: Claude Code
PreToolUsehook
Root Cause
The rtk hook claude command checks if a rewrite is available and only outputs JSON when a rewrite exists. When no rewrite is found, it returns nothing instead of a passthrough response.
Suggested Fix
Always output valid JSON from rtk hook claude, even when no rewrite is available. Return a passthrough response that tells Claude Code to execute the command unchanged.
Workaround
Until this is fixed, use a wrapper script that detects empty output and generates valid JSON:
#!/bin/bash
input=$(cat)
output=$(rtk hook claude <<< "$input" 2>&1) || rtk_exit=$?
if [[ -z "$output" ]]; then
command=$(echo "$input" | python3 -c "import json,sys; d=json.load(sys.stdin); print(d['tool_input']['command'])" 2>/dev/null)
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecisionReason\":\"no rewrite\",\"updatedInput\":{\"command\":\"$command\"},\"permissionDecision\":\"allow\"}}"
else
echo "$output"
fiThen update Claude Code settings to use the wrapper instead of rtk hook claude directly.
Activity
fix(hooks): emit passthrough JSON when no rewrite available for rtk h…
pszymkowiak commentedon May 27, 2026
🔍 Automated Triage
bugmediumSummary
rtk hook claude emits empty output instead of valid JSON passthrough when no rewrite is available, breaking Claude Code hooks; PR #1775 already open.
Triaged automatically by wshm · This is an automated analysis, not a human review.
KuSh commentedon Sep 27, 2026
This is the intended behaviour under Claude Code's hook protocol, not a defect. A PreToolUse hook that exits 0 with no output tells Claude Code to proceed with the tool call unchanged; hooks are not required to emit JSON, and
rtk hook claudedoes exactly that for commands it has no rewrite for. On the current code the exit status in that case is 0 (the exit 1 from the report no longer reproduces). EmittingpermissionDecision: "allow"for a command rtk did not rewrite would bypass the user's own permission rules, which the hook deliberately avoids: it only asserts allow when one of the user's explicit allow rules matches. Closing as working as intended.