Reference · hook events
Every event, and whether it has a veto
You need one event, not the whole hooks lesson. 33 events, each with its own page: when it fires, what lands on stdin, what each exit code does on that event, and which JSON fields it honours. Module 09 teaches the mechanism; this is the directory.
Exit 2 blocks The exit code alone carries a veto.
- 04
UserPromptSubmitUserPromptSubmit can reject a submitted prompt or attach context before Claude processes it. - 05
UserPromptExpansionUserPromptExpansion intercepts a typed command or MCP prompt before its expanded prompt reaches Claude. - 07
PreToolUsePreToolUse can inspect, rewrite, approve, escalate, defer, or deny a tool call before it runs. - 11
PostToolBatchPostToolBatch sees a complete parallel tool batch once, before the next model request. - 12
StopStop checks the main agent's completed response and can keep the conversation going with feedback. - 15
SubagentStopSubagentStop checks a finished subagent response and can keep that subagent working with feedback. - 16
TeammateIdleTeammateIdle can return feedback to a finished teammate or stop that teammate entirely before it goes idle. - 17
TaskCreatedTaskCreated validates a pending TaskCreate operation and can roll the new task back. - 18
TaskCompletedTaskCompleted enforces a completion gate and treats teammate-turn and TaskUpdate triggers differently. - 21
PreCompactPreCompact can stop manual or automatic context compaction before it changes the conversation context. - 23
ConfigChangeConfigChange audits a changed settings, policy, or skill file and can reject the live update unless it comes from managed policy. - 24
ElicitationElicitation intercepts an MCP server's input request and can answer it programmatically or deny it before a dialog appears. - 25
ElicitationResultElicitationResult inspects or replaces a user's MCP elicitation response before the server receives it. - 32
PreModelSwitchPreModelSwitch is the v2.1.251 gate that can approve, reject, or confirm a requested change of session model. v2.1.251
Any non-zero exit blocks The one exception to the exit-2 rule.
The exit code cannot block Whatever you return. Some decide through JSON instead; most only observe.
- 01
SessionStartA session-start hook loads dynamic context or setup when a session begins, resumes, clears, compacts, or forks. - 02
SetupSetup runs one-time initialisation or maintenance only when an init or maintenance flag asks for it. - 03
InstructionsLoadedInstructionsLoaded observes each instruction file added to context, including startup, nested, conditional, included, and post-compaction loads. - 06
MessageDisplayMessageDisplay rewrites assistant text on screen while leaving Claude's context and the transcript unchanged. - 08
PermissionRequestPermissionRequest answers a pending tool-permission prompt through JSON; exit code 2 alone has no effect. - 09
PostToolUsePostToolUse can annotate or replace a successful tool result after the tool's real effects have already occurred. - 10
PostToolUseFailurePostToolUseFailure reports a tool execution error and can add corrective context after the failure has happened. - 13
StopFailureStopFailure reports an API error that ended the turn and cannot change that outcome. - 14
SubagentStartSubagentStart adds context when an Agent tool spawns a subagent but cannot prevent creation. - 19
NotificationNotification forwards Claude Code alerts to hook side effects without changing or blocking the original notification. - 20
PermissionDeniedPermissionDenied observes an auto-mode denial and may tell the model to retry without reversing that denial. - 22
PostCompactPostCompact observes the generated summary after manual or automatic compaction has finished. - 27
WorktreeRemoveWorktreeRemove performs cleanup for a hook-created isolated checkout without gaining a veto over removal. - 28
CwdChangedCwdChanged reacts to a completed directory change and can update the session environment or watched paths. - 29
DirectoryAddedDirectoryAdded starts background setup after a new working directory and its permissions are active in the session. - 30
FileChangedFileChanged observes watched filesystem state after a file is created, modified, or deleted by any process. - 31
SessionEndSessionEnd gives cleanup hooks a bounded final window while the session terminates. - 33
PostModelSwitchPostModelSwitch is the v2.1.251 observer that adds context after the session's model has changed. v2.1.251