#[non_exhaustive]pub enum HookEvent {
Show 34 variants
PreToolUse,
PostToolUse,
PostToolUseFailure,
PostToolBatch,
PermissionRequest,
PermissionDenied,
Notification,
UserPromptSubmit,
UserPromptExpansion,
Stop,
StopFailure,
SubagentStart,
SubagentStop,
PreCompact,
PostCompact,
Elicitation,
ElicitationResult,
TeammateIdle,
TaskCreated,
TaskCompleted,
Setup,
InstructionsLoaded,
CwdChanged,
FileChanged,
ConfigChange,
WorktreeCreate,
WorktreeRemove,
SessionStart,
SessionEnd,
PreModelSwitch,
PostModelSwitch,
MessageDisplay,
DirectoryAdded,
Other(String),
}Expand description
A hook event: a key of hooks.
Docs: settings reference.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
PreToolUse
Runs after Claude creates tool parameters and before processing the tool call.
Docs: PreToolUse.
PostToolUse
Runs immediately after a tool completes successfully.
Docs: PostToolUse.
PostToolUseFailure
Runs when a tool that started executing fails: the tool threw an error, or an MCP tool returned an error result.
Docs: PostToolUseFailure.
PostToolBatch
Runs once after every tool call in a batch has resolved, before Claude Code sends the next request to the model.
Docs: PostToolBatch.
PermissionRequest
Runs when Claude Code is about to ask you for permission to use a tool.
Docs: PermissionRequest.
PermissionDenied
Runs when auto mode denies a tool call, including when it denies without a classifier verdict because a safety check separate from auto mode refused the classifier’s own request or its response didn’t parse.
Docs: PermissionDenied.
Notification
Runs when Claude Code sends notifications.
Docs: Notification.
UserPromptSubmit
Runs when a prompt is submitted, before Claude processes it.
Docs: UserPromptSubmit.
UserPromptExpansion
Runs when a user-typed command expands into a prompt before reaching Claude.
Docs: UserPromptExpansion.
Stop
Runs when the main Claude Code agent has finished responding.
Docs: Stop.
StopFailure
Runs instead of Stop when the turn ends due to an API error.
Docs: StopFailure.
SubagentStart
Runs when Claude spawns a subagent with the Agent tool, when Claude resumes a subagent, and each time an in-process agent team teammate handles a new message.
Docs: SubagentStart.
SubagentStop
Runs when a Claude Code subagent has finished responding.
Docs: SubagentStop.
PreCompact
Runs before Claude Code is about to run a compact operation.
Docs: PreCompact.
PostCompact
Runs after Claude Code completes a compact operation.
Docs: PostCompact.
Elicitation
Runs when an MCP server requests user input mid-task.
Docs: Elicitation.
ElicitationResult
Runs after a user responds to an MCP elicitation.
Docs: ElicitationResult.
TeammateIdle
Runs when an agent team teammate is about to go idle after finishing its turn.
Docs: TeammateIdle.
TaskCreated
Runs when a task is being created via the TaskCreate tool.
Docs: TaskCreated.
TaskCompleted
Runs when a task is being marked as completed.
Docs: TaskCompleted.
Setup
Fires only when you launch Claude Code with --init-only, or with --init or
--maintenance in non-interactive mode
with the -p flag.
Docs: Setup.
InstructionsLoaded
Fires when a CLAUDE.md or .claude/rules/*.md file is loaded into context.
Docs: InstructionsLoaded.
CwdChanged
Runs when a shell command in the main conversation changes the working directory,
for example when Claude executes a cd command.
Docs: CwdChanged.
FileChanged
Runs when a watched file changes on disk.
Docs: FileChanged.
ConfigChange
Runs when a configuration file changes during a session.
Docs: ConfigChange.
WorktreeCreate
Runs when Claude Code creates a worktree in cases such as these:
Docs: WorktreeCreate.
WorktreeRemove
Runs when Claude Code cleans up a worktree that your
WorktreeCreate hook
created.
Docs: WorktreeRemove.
SessionStart
Runs when Claude Code starts a new session or resumes an existing session.
Docs: SessionStart.
SessionEnd
Runs when a Claude Code session ends.
Docs: SessionEnd.
PreModelSwitch
Runs before Claude Code applies a model switch that you or a client requested.
Docs: PreModelSwitch.
PostModelSwitch
Runs after the session’s model changes.
Docs: PostModelSwitch.
MessageDisplay
Runs while an assistant message streams to the screen.
Docs: MessageDisplay.
DirectoryAdded
Runs after you add a working directory mid-session with the /add-dir command, or
after an SDK client adds one with the register_repo_root control request.
Docs: DirectoryAdded.
Other(String)
A value this crate doesn’t know, as written.