Note: Setup fires separately via --init/--maintenance CLI flags. Notification, TeammateIdle, TaskCompleted, TaskCreated, ConfigChange, WorktreeCreate, WorktreeRemove, InstructionsLoaded, Elicitation, ElicitationResult, StopFailure, CwdChanged, FileChanged, and PermissionDenied hooks fire asynchronously at any point during the session โ they are not part of the sequential flow above.
1SessionStartCannot Block
When It Triggers
When you start Claude Code or resume an existing session. This is the first hook to fire.
How to Trigger
Run Claude Code from your terminal to start a new session:
$ claude
Or resume an existing session:
$ claude --resume
Trigger Sources:startupresumeclearcompact
Input Fields
model โ Model identifier (e.g., claude-sonnet-4-6)
agent_type โ Agent name if started with --agent flag (since v2.1.43)
Use Cases
๐
Voice: "Claude session started"Audio notification when Claude Code is ready
๐
Load Git StatusInject current branch, uncommitted changes into Claude's context
๐ง
Set Environment VariablesConfigure API keys, paths, or project-specific settings
๐
Load Project MemoryRestore previous context or project-specific instructions
Voice: "Notification"Audio cue for system notifications
๐ฅ๏ธ
Desktop NotificationsRoute notifications to macOS/Windows notification center
๐ฌ
External IntegrationsSend to Slack, Discord, or webhook endpoints
๐ Sound: notification.wav โ System notification sound
8SubagentStartCannot Block
When It Triggers
When a subagent is spawned via the Task tool. Can happen multiple times per session (subagents can spawn subagents). Includes agent_id (unique identifier) and agent_type (agent name).
How to Trigger
Ask Claude to perform a task that spawns a subagent:
> Use Explore agent to read the README.md file
> Search for all API endpoints in this project
Claude will spawn an Explore, Plan, or Bash agent to help.
Input Fields:agent_idagent_type
Agent Types:BashExplorePlanCustomAgentName
Use Cases
๐
Voice: "Subagent started"Audio notification when a subagent begins work
๐ก๏ธ
Inject Security GuidelinesAdd security rules to subagent context
๐
Monitor Subagent SpawningTrack which agents are created and when
๐
Add Project ContextInject project-specific instructions into subagents
When a subagent finishes responding. Can be blocked to force the subagent to continue working. Includes agent_id, agent_type, last_assistant_message (since v2.1.47), and agent_transcript_path.
How to Trigger
Fires automatically when a subagent completes its task:
> Explore the codebase and find where authentication is handled
After the Explore agent finishes searching, SubagentStop fires.
When Claude finishes responding and is ready to stop. Does NOT fire on user interrupts (Ctrl+C). Includes last_assistant_message field with Claude's final response text (since v2.1.47).
How to Trigger
Simply wait for Claude to finish responding to any prompt:
> Explain how this function works
When Claude completes its response and returns to the prompt, Stop fires.
Note: Does NOT fire if you press Ctrl+C to interrupt.
Use Cases
๐
Voice: "Task completed"Audio confirmation that Claude finished responding
๐งช
Verify Tests PassBlock stopping until all tests pass
๐
Check Task ListPrevent stopping if there are unfinished tasks
๐
Analyze Last ResponseUse last_assistant_message to log or validate Claude's final output
๐ Sound: stop.wav โ "Task completed"
11PreCompactCannot Block
When It Triggers
Before context compaction occurs โ either automatically when context window fills up, or when user runs /compact.
How to Trigger
Manually run the compact command:
> /compact
Or automatically when context window fills up after a long conversation.
Trigger Types:manualauto
Use Cases
๐
Voice: "Compacting context"Audio alert before context is compressed
๐พ
Preserve Critical ContextSave important information before it's compacted
๐
Monitor Context UsageTrack how often context fills up
๐
Re-Inject GuidelinesAdd project rules to be included after compaction
After context compaction completes โ either automatically when context window fills up, or after user runs /compact. Use this to react to the new compacted state.
How to Trigger
Fires automatically after any compaction:
> /compact โ Triggers PreCompact then PostCompact
Or automatically after auto-compact when context window fills up.
Trigger Types:manualauto
Use Cases
๐
Voice: "Context compacted"Audio confirmation that compaction finished
๐
Log Compact SummarySave the generated conversation summary for audit
๐
Update External StateSync external tools with the new compacted context
๐
Track Compaction FrequencyMonitor how often context fills up and gets compressed
When a session terminates. This is the last hook to fire โ cannot prevent session from ending.
How to Trigger
End the session in any of these ways:
> /clear โ Clears conversation and ends session
> exit โ Type exit at the prompt
Press Ctrl+D or Ctrl+C to exit
End Reasons:clearresumelogoutprompt_input_exitbypass_permissions_disabledother
Use Cases
๐
Voice: "Session ended"Audio farewell when closing Claude Code
๐งน
Cleanup OperationsDelete temporary files, close connections
๐
Log Session StatisticsRecord session duration, tools used, etc.
๐พ
Save Session StateArchive transcript or project state
๐ Sound: sessionend.wav โ "Session ended"
14SetupCannot Block
When It Triggers
When Claude Code runs the /setup command for project initialization. Rarely used compared to other hooks.
How to Trigger
Run setup hooks without starting interactive mode:
$ claude --init-only
Note: claude --init does NOT trigger the Setup hook.
Use Cases
๐
Voice: "Setup initiated"Audio notification when project setup begins
๐ฆ
Install DependenciesRun npm install, pip install, etc.
โ๏ธ
Configure ProjectSet up MCP servers, linters, formatters
โ
Validate EnvironmentCheck required tools and versions are installed
๐ Sound: setup.wav โ "Setup initiated"
15TeammateIdleCan Block
When It Triggers
When a teammate agent becomes idle in an experimental agent teams session. Requires the agent teams feature to be enabled. Includes teammate_name and team_name input fields (since v2.1.33).
How to Trigger
Enable agent teams and start a multi-agent session:
$ CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 claude
When a teammate agent finishes its current work and becomes idle, this hook fires.
Use Cases
๐
Voice: "Teammate idle"Audio notification when a teammate agent is waiting for work
๐
Auto-Assign TasksAutomatically queue the next task for the idle teammate
๐
Monitor Team UtilizationTrack idle time across agents for workload balancing
๐
Notify OrchestratorAlert the main agent that a teammate is available
๐ Sound: teammateidle.wav โ "Teammate idle"
16TaskCompletedCan Block
When It Triggers
When a background task completes in an experimental agent teams session. Requires the agent teams feature to be enabled. Includes task_id, task_subject, and task_description input fields (since v2.1.33).
How to Trigger
Enable agent teams and run background tasks:
$ CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 claude
When a background task finishes execution, this hook fires.
Use Cases
๐
Voice: "Task completed"Audio notification when a background task finishes
โ
Verify Task ResultsRun validation checks on the completed task output
๐
Trigger Follow-Up TasksAutomatically start dependent tasks in a pipeline
๐
Log Completion MetricsTrack task duration, success rate, and throughput
Prevent Unauthorized Task CreationBlock task creation from unauthorized teammates or teams
๐ Sound: taskcreated.wav โ "Task created"
Added in v2.1.84
18ConfigChangeCan Block
When It Triggers
When a configuration file changes during a session. Detects changes to user settings, project settings, local settings, policy settings, and skills. Includes optional file_path input field with the path to the modified config file (since v2.1.49).
How to Trigger
Modify any Claude Code configuration file while a session is active:
Edit .claude/settings.json while Claude is running
Change user settings via ~/.claude/settings.json
The hook fires when Claude detects the config file has been modified.
When agent worktree isolation creates worktrees, enabling custom VCS setup. This hook fires during the worktree creation process for agents that use isolation: worktree in their definitions (since v2.1.50).
How to Trigger
Use an agent configured with worktree isolation:
claude --agent my-isolated-agent (with isolation: worktree)
The hook fires when Claude creates a new git worktree for the agent's isolated workspace.
Use Cases
๐
Voice: "Worktree created"Audio notification when a worktree is set up for an agent
๐ง
Custom VCS SetupRun setup scripts (install deps, configure git hooks) in the new worktree
๐
Log Worktree ActivityTrack which agents create worktrees and when
๐
Symlink DependenciesSymlink node_modules or other large directories to save disk space
When agent worktree isolation removes worktrees, enabling custom VCS teardown. This hook fires during the worktree removal process when agents with isolation: worktree finish their work (since v2.1.50).
How to Trigger
Triggered automatically when an isolated agent's worktree is cleaned up:
Agent completes work and worktree is removed
The hook fires when Claude removes a git worktree that was created for an agent's isolated workspace.
Use Cases
๐
Voice: "Worktree removed"Audio notification when a worktree is cleaned up
๐งน
Custom VCS TeardownClean up temporary files, remove symlinks, or archive logs
๐
Log Cleanup EventsTrack when worktrees are removed for auditing
๐พ
Reclaim Disk SpaceTrigger garbage collection or cache cleanup after worktree removal
When CLAUDE.md or .claude/rules/*.md files are loaded into context. This fires whenever instructions are read, including at session start and after instruction reloads (since v2.1.69).
How to Trigger
Triggered automatically when Claude Code loads instruction files:
Start a session with CLAUDE.md or .claude/rules/*.md present
The hook fires each time instructions are loaded or reloaded into context.
Use Cases
๐
Voice: "Instructions loaded"Audio notification when project instructions are loaded
๐
Log Instruction LoadsTrack when and which instruction files are loaded for auditing
๐
Validate InstructionsCheck that loaded instructions meet organizational standards
๐
Monitor Instruction ChangesDetect when instructions change between sessions or reloads
After a user responds to an MCP elicitation, before the response is sent back to the server. Allows you to intercept, modify, or block the user's response.
How to Trigger
User responds to an MCP elicitation dialog (e.g. the pizza question above):
User clicks Yes/No โ ElicitationResult hook fires โ Response sent to server
Matcher:MCP server name
Use Cases
๐
Voice: "Response submitted"Audio confirmation when user responds to an MCP elicitation
๐
Sanitize ResponsesStrip sensitive data before it's sent to the MCP server
๐
Track User DecisionsLog accept/decline/cancel actions for analytics
When the turn ends due to an API error (rate limit, auth failure, etc.). Unlike Stop, this fires on error conditions rather than successful completion. Introduced in v2.1.78 to prevent infinite loops when stop hooks re-feed blocking errors to the model.
How to Trigger
API error occurs during Claude's response (rate limit exceeded, authentication failure, network error):
Claude processing โ API error โ StopFailure hook fires
Use Cases
๐
Voice: "Stop failure"Audio alert when a turn ends due to an API error
๐
Error TrackingLog API failures for monitoring rate limits and auth issues
๐
Alert on FailuresSend desktop notification when API errors interrupt work
๐ Sound: stopfailure.wav โ "Stop failure"
25CwdChangedCannot Block
When It Triggers
When the working directory changes during a session. Designed for reactive environment management โ for example, automatically loading environment variables via direnv when Claude navigates to a different project directory. Introduced in v2.1.83.
How to Trigger
Claude changes the current working directory during a session:
Claude navigates to new directory โ CwdChanged hook fires
Use Cases
๐
Voice: "Directory changed"Audio alert when Claude moves to a different directory
๐
Environment ReloadAutomatically reload .env files or direnv when changing directories
๐
Context AwarenessLoad project-specific rules or configurations based on current directory
When files change during a session. Designed for reactive environment management โ for example, automatically reloading configuration when a .env file is modified by an external process. Introduced in v2.1.83 alongside CwdChanged.
How to Trigger
A watched file changes during a Claude Code session:
Voice: "File changed"Audio alert when a watched file is modified
๐
Hot ReloadAutomatically reload environment variables or config when files change
๐
Change LoggingTrack file modifications for audit or debugging purposes
๐ Sound: filechanged.wav โ "File changed"
27PermissionDeniedCannot Block
When It Triggers
Fires after the auto mode classifier denies a tool call. Your hook can return {retry: true} to tell the model it can retry the operation. Introduced in v2.1.88.
How to Trigger
A tool call is denied by the auto mode classifier:
Auto mode denies tool โ PermissionDenied hook fires
Use Cases
๐
Voice: "Permission denied"Audio alert when auto mode blocks a tool call
๐
Auto-Retry LogicReturn {retry: true} to let the model retry with a different approach
๐
Denial TrackingLog denied tool calls for security auditing and permission tuning