Hook Events

When each event fires, what data it receives, and what it can do.

User sends message → UserPromptSubmit → Claude thinks → PreToolUse → Tool runs → PostToolUse → ... → Claude stops → Stop
PreToolUse
Fires before every tool call. Can block or approve.
stdin fieldValue
tool_nameBash, Edit, Write, Read, Glob, Grep, Agent, Skill, ...
tool_inputTool-specific: .command (Bash), .file_path (Edit/Write/Read), .pattern (Grep)
Can doHow
Blockexit 2
Approve (skip prompt)echo '{"decision":"approve"}'
Warnecho "WARNING" >&2
Modify inputNot possible
PostToolUse
Fires after every tool call. Can validate results.
stdin fieldValue
tool_nameSame as PreToolUse
tool_inputSame as PreToolUse
tool_resultThe tool's output/result
Can doHow
Warn about resultecho "SYNTAX ERROR" >&2
Log activityWrite to log file
Block (too late)Tool already ran
Modify resultNot possible (without updatedToolOutput)
Stop
Fires when Claude finishes responding.
stdin fieldValue
stop_reasonend_turn, error, max_tokens, etc.
Can doHow
Send notificationDesktop alert, sound, webhook
Log session summaryWrite to proof-log
Clean up temp filesAny cleanup script
UserPromptSubmit
Fires when the user sends a message.
stdin fieldValue
promptThe user's message text
Can doHow
Inject remindersecho "REMINDER: check tests" >&2
Log promptsWrite to log
Block submissionexit 2
SubagentStop
Fires when a subagent finishes.
Can doHow
Track subagent completionDecrement counter
NotifySound/alert when agent done

Quick Reference: Which Event?

I want to...Event
Block a dangerous commandPreToolUse
Auto-approve safe commandsPreToolUse
Check syntax after editsPostToolUse
Detect prompt injectionPostToolUse
Monitor context usagePostToolUse
Send "task done" notificationStop
Log session summaryStop
Inject reminders per messageUserPromptSubmit
Track subagent countSubagentStop

Learn more: Production Guide · All Tools