Claude Code Hooks Builder
Pick the events you care about, write one command, and copy a
settings.json snippet that Claude Code accepts as-is. Every one of the
33 hook events is here with its matcher values, plus the statusLine setting.
If you need the field-by-field details, see the
hooks reference.
~/.claude/settings.json
- Open
~/.claude/settings.json(create it if it doesn't exist). - If the file already has a
"hooks"key, paste each event array inside it; otherwise paste the whole object. - Make the command executable:
chmod +xyour script. Hooks run with your user's permissions. - Run
/hooksinside Claude Code to confirm it picked up the change.
What you're generating
A hook is a shell command Claude Code runs at a lifecycle event, with a JSON payload on stdin
(session_id, hook_event_name, cwd, and per-event fields such as
tool_name or notification_type). The shape the builder produces is:
{
"hooks": {
"<EventName>": [
{
"matcher": "<optional filter>",
"hooks": [ { "type": "command", "command": "<your command>", "timeout": 600 } ]
}
]
}
}
- matcher filters which occurrences fire the hook: tool names for tool events, notification types for
Notification, and so on. Plain names separated by|match exactly; anything with regex characters is treated as a JavaScript regex. Leave it empty to match everything. - One command for all events is the common pattern — read
hook_event_namefrom stdin and branch inside the script. The builder writes the same handler under each selected event. - Exit code 2 blocks the action on events that support it (
PreToolUse,UserPromptSubmit,PermissionRequest…), with stderr shown as the reason. Any other exit code lets it proceed. - statusLine is a separate top-level key with a single slot. Its command gets
context_window.used_percentage,rate_limitsandmodel— data that hooks never receive.
Check the version. Claude Code releases before 2.1.101 ignore the whole settings file when it contains an unknown event name — and that silently disables every hook and permission rule in it. Run
claude --version before adding newer events like StopFailure or PostCompact.
Don't want to write the status script?
AgentManager installs a ready-made hook, registers these events for you, and turns them into a live status board for every Claude Code session — free to use, no account required.
macOS 13+ — free plan shows up to 2 sessions at once