feat(hooks): switch PreToolUse to JSON permissionDecision protocol#6
Merged
HeinrichvH merged 1 commit intomainfrom Apr 22, 2026
Merged
feat(hooks): switch PreToolUse to JSON permissionDecision protocol#6HeinrichvH merged 1 commit intomainfrom
HeinrichvH merged 1 commit intomainfrom
Conversation
Replace the exit-2 + stderr pattern with the documented JSON protocol:
emit `{"hookSpecificOutput": {"permissionDecision": "deny",
"permissionDecisionReason": ...}}` on stdout and exit 0 for all three
blocking paths (cache hit, successful worker routing, strict-mode worker
failure).
Claude Code's current rendering treats both protocols as "hook blocking
error" in the transcript, so there is no user-visible UX change today.
The switch is a semantic correctness improvement: we are using the
documented hook-decision API rather than repurposing exit 2. If Anthropic
adds a true result-override primitive (e.g. `toolResultOverride`) or
changes the rendering for `deny`-with-reason, we inherit it for free.
Loose-mode fallback stays on exit 0 + stderr warning (unchanged).
post_tool_use still uses exit 2 — untouched in this pass.
Tests updated to parse JSON stdout and assert `permissionDecision: deny`
plus the reason text. All 43 pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Replace the exit-2 + stderr pattern with the documented JSON protocol: emit
{"hookSpecificOutput": {"permissionDecision": "deny", "permissionDecisionReason": ...}}on stdout and exit 0 for all three blocking paths (cache hit, successful worker routing, strict-mode worker failure).Claude Code's current rendering treats both protocols as "hook blocking error" in the transcript, so there is no user-visible UX change today. The switch is a semantic correctness improvement: we are using the documented hook-decision API rather than repurposing exit 2. If Anthropic adds a true result-override primitive (e.g.
toolResultOverride) or changes the rendering fordeny-with-reason, we inherit it for free.Loose-mode fallback stays on exit 0 + stderr warning (unchanged). post_tool_use still uses exit 2 — untouched in this pass.
Tests updated to parse JSON stdout and assert
permissionDecision: denyplus the reason text. All 43 pass.