Purpose: Quick reference for all Claude Code hook events
| Event | When It Fires | Can Block? |
|---|---|---|
PreToolUse |
Before tool calls | Yes (exit 2) |
PostToolUse |
After tool calls complete | No |
PermissionRequest |
Permission dialog shown | Yes (allow/deny) |
UserPromptSubmit |
User submits prompt | No |
Notification |
Claude sends notification | No |
Stop |
Claude finishes responding | No |
SubagentStop |
Subagent task completes | No |
PreCompact |
Before compact operation | No |
SessionStart |
New/resumed session | No |
SessionEnd |
Session ends | No |
"Bash" - Match specific tool"Edit|Write" - Match multiple tools (OR)"*" - Match all tools"" - Match all (for Notification)| Code | Behavior |
|---|---|
| 0 | Success, continue execution |
| 1 | Error logged, continue execution |
| 2 | Block operation, feed stderr to Claude |
Hooks receive JSON via stdin:
{
"tool_name": "Bash",
"tool_input": { "command": "ls -la" },
"session_id": "...",
"transcript_path": "..."
}
Output to stderr is fed back to Claude when blocking (exit 2).
../concepts/hooks-system.md - Hooks overview../examples/hooks/ - Hook examplesReference: https://docs.anthropic.com/en/docs/claude-code/hooks