fix(claude_code): wrap hook output in hookSpecificOutput envelope#64
Open
PabloLION wants to merge 1 commit intoClyra-AI:mainfrom
Open
fix(claude_code): wrap hook output in hookSpecificOutput envelope#64PabloLION wants to merge 1 commit intoClyra-AI:mainfrom
PabloLION wants to merge 1 commit intoClyra-AI:mainfrom
Conversation
Claude Code's PreToolUse hook protocol requires responses wrapped in
{"hookSpecificOutput": {"hookEventName": "PreToolUse", "permissionDecision": ...}}.
The previous implementation output permissionDecision at the top level, which
Claude Code silently ignores — making all gait verdicts (allow, deny, ask)
unenforceable regardless of policy.
Fix wraps both emit_response() and the inline emit() function in the required
envelope. Verified against Claude Code v2.1.47–v2.1.49 with all three verdict
paths (allow, require_approval, block) in live interactive sessions.
🤖 Generated with [Claude Code](https://claude.ai/code)
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.
Summary
gait-gate.shoutputs{permissionDecision: "deny", ...}at the top level, but Claude Code requires{hookSpecificOutput: {hookEventName: "PreToolUse", permissionDecision: "deny", ...}}emit_response()and the inlineemit()function in the requiredhookSpecificOutputenvelopeDetail
Claude Code's PreToolUse hook protocol expects stdout JSON in this shape:
{ "hookSpecificOutput": { "hookEventName": "PreToolUse", "permissionDecision": "allow|deny|ask", "permissionDecisionReason": "..." } }The current script outputs
permissionDecisionat the top level, which CC ignores without error. This affects all three verdict paths (allow, deny, ask).Test plan
Tested in Claude Code v2.1.47–v2.1.49 with a mixed-verdict policy (
allowfor reads,require_approvalfor exec,blockfor writes):Read→ gait maps totool.read→ allow → CC auto-runs (no prompt)Bash(python3) → gait maps totool.exec→ require_approval → CC prompts user with gait reasonWrite→ gait maps totool.write→ block → CC blocks with gait reasonAll paths verified in both manual pipe tests and live interactive CC sessions.
🤖 Generated with Claude Code