Skip to content

hook claude: JSON key mismatch — tool/input vs tool_name/tool_input #2493

Description

@9clg6

Problem

rtk hook claude parses tool_name / tool_input from stdin, but Claude Code now sends tool / input.

Result: hook exits 0 with no output → no rewrite → commands (grep, head, cat) bypass RTK.

Reproduction

# ❌ What Claude Code sends (no rewrite)
echo '{"tool":"Bash","input":{"command":"grep -r hello ."}}' | rtk hook claude
# exit 0, empty output

# ✅ What RTK expects (rewrite works)
echo '{"tool_name":"Bash","tool_input":{"command":"grep -r hello ."}}' | rtk hook claude
# {"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecisionReason":"RTK auto-rewrite","updatedInput":{"command":"rtk grep -r hello ."}}}

Version

  • rtk 0.42.4 (Homebrew)
  • Claude Code — latest (June 2026)

Suggested fix

Accept both key formats in the JSON parser — fall back from tool_name to tool (and tool_input to input).

Workaround

Wrapper script that remaps keys before piping to rtk hook claude:

#!/bin/bash
cat | python3 -c "
import sys, json
d = json.load(sys.stdin)
if 'tool_name' not in d and 'tool' in d:
    d['tool_name'] = d.pop('tool')
if 'tool_input' not in d and 'input' in d:
    d['tool_input'] = d.pop('input')
print(json.dumps(d))
" | rtk hook claude

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions