fix: correct Claude Code hooks config to match actual schema (#1388)

The hooks configuration example used a format that was valid when
originally written but broke across two Claude Code releases:

- v1.0.41: Added `hook_event_name` to hook input, replacing the
  previous field name. The hook script was still reading `.event`,
  causing the case statement to always fall through to unknown.

- v2.1.63: Added HTTP hooks with `{ "type": "command", "command": "..." }`
  object format. Bare string paths in the hooks array are no longer
  valid now that hook type disambiguation is required.

Changes:
- Stop hooks now use the full matcher/hooks object structure
- PostToolUse inner hooks use typed command objects
- Hook script reads `hook_event_name` instead of `event`

Ref: https://docs.anthropic.com/en/docs/claude-code/hooks
This commit is contained in:
Max Schmitt 2026-03-15 16:49:42 -07:00 committed by GitHub
parent 9b377a930f
commit 1460c97e85
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -158,7 +158,7 @@ printf '\\e]99;i=1;e=1;d=1;p=body:All tests passed\\e\\\\'`}</CodeBlock>
[ -S /tmp/cmux.sock ] || exit 0
EVENT=$(cat)
EVENT_TYPE=$(echo "$EVENT" | jq -r '.event // "unknown"')
EVENT_TYPE=$(echo "$EVENT" | jq -r '.hook_event_name // "unknown"')
TOOL=$(echo "$EVENT" | jq -r '.tool_name // ""')
case "$EVENT_TYPE" in
@ -174,11 +174,26 @@ esac`}</CodeBlock>
<h3>{t("configureClaude")}</h3>
<CodeBlock title="~/.claude/settings.json" lang="json">{`{
"hooks": {
"Stop": ["~/.claude/hooks/cmux-notify.sh"],
"Stop": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/cmux-notify.sh"
}
]
}
],
"PostToolUse": [
{
"matcher": "Task",
"hooks": ["~/.claude/hooks/cmux-notify.sh"]
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/cmux-notify.sh"
}
]
}
]
}