Skip to content

fix(hooks): send hook_event_name so Claude Code hooks can tell events apart - #3482

Open
nosey-dewdrop wants to merge 1 commit into
charmbracelet:mainfrom
nosey-dewdrop:fix/hook-payload-carries-hook-event-name
Open

fix(hooks): send hook_event_name so Claude Code hooks can tell events apart#3482
nosey-dewdrop wants to merge 1 commit into
charmbracelet:mainfrom
nosey-dewdrop:fix/hook-payload-carries-hook-event-name

Conversation

@nosey-dewdrop

Copy link
Copy Markdown

What

BuildPayload names the event event. Claude Code names the same field hook_event_name. A Claude Code hook is a single command wired to every event and branches on that key, so under Crush it falls through to its default branch and does nothing. Nothing errors and nothing is logged.

The payload already emits tool_input as an object for Claude Code compatibility, and parseStdout already understands hookSpecificOutput, and the runner already honours exit code 2. The greeting is the one part of the contract that is still Crush-only.

Reproduction

A third-party Claude Code PreToolUse guard, same repo, same command (git push --force origin main), fed the payload Crush sends today:

events recorded: 0

Same guard, same command, with hook_event_name present:

events recorded: 2   (CHECK_FAIL, STOP)

Change

The event name is emitted under both keys. event is untouched, so hooks written for Crush are unaffected.

Verification

  • go test ./internal/hooks/... passes; the new test fails without the change (expected: "PreToolUse", actual: <nil>)
  • gofmt -l internal/hooks/ clean
  • go vet ./internal/hooks/... clean

AI disclosure

Written with AI assistance. I understand the change, can debug it independently, and can discuss it without AI help.

… apart

The payload already emits tool_input as an object for Claude Code compatibility,
but it names the event 'event' while Claude Code names it 'hook_event_name'. A
Claude Code hook is a single command wired to every event and branches on that
key, so under Crush it falls through to its default branch and does nothing.
Nothing errors and nothing is logged.

Reproduced with a third-party Claude Code PreToolUse guard: fed today's payload
for 'git push --force origin main' it records no events at all; with
hook_event_name present the same guard, same command, same repo emits CHECK_FAIL
and STOP.

The existing 'event' key is unchanged, so hooks written for Crush keep working.
@charmcli

charmcli commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@nosey-dewdrop

Copy link
Copy Markdown
Author

I have read the Contributor License Agreement (CLA) and hereby sign the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants