Claude Code Hooks Builder
A hook is a command Claude Code runs automatically at moments like “waiting for your approval” or
“finished responding”. Build the config here, copy it, and paste it into
~/.claude/settings.json — that is all it takes.
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, add only the per-event arrays inside it (if an event name is already there, append to its array). Otherwise paste the whole object. - If the command is a script file, make it executable with
chmod +x. 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.
claude --version before adding newer events like StopFailure or PostCompact.
Want to know when Claude is waiting — without writing the hook?
AgentManager sets up the same thing as the “Notify me” and “Track session status” presets above, automatically. It lists the status of every Claude Code session and notifies you the moment one is waiting for you. Free to use, no account required.