hooks
Installation
SKILL.md
Hooks
Hooks are Claude Code's automation surface — deterministic bash (or any shell) scripts that fire on lifecycle events. Each hook receives JSON on stdin and returns JSON on stdout: {"decision": "approve"|"block", "reason"?: "..."}.
Events (matcher + input + output)
| Event | Fires | Input | Output shape |
|---|---|---|---|
PreToolUse |
Before any tool | {tool_name, tool_input} |
{decision, reason?} — block prevents the tool call |
PostToolUse |
After tool succeeds | {tool_name, tool_input, tool_output} |
{decision, reason?} |
PostToolUseFailure |
After tool fails | {tool_name, tool_input, error} |
{decision} — almost always approve |
Notification |
Claude needs input | {message} |
{decision} |
Stop |
Agent finishes turn | {stop_reason} |
{decision} |
UserPromptSubmit |
Prompt submitted | {prompt} |
{decision} + optional modified prompt |
SessionStart |
New session | {} |
{decision} — usually for context injection |