Skip to content

concepts

Hooks

Knowledge captured in João Lopes' learning graph.

User-defined shell commands that execute at specific lifecycle points in Claude Code, providing deterministic enforcement outside the model’s context.

↑ Contents

Definition

Hooks are lifecycle events that fire before and after tool calls in Claude Code. Unlike instructions, hooks run as code — they enforce behavior unconditionally, outside the model’s context. Hooks are wired in settings files and point at scripts that run synchronously (PreToolUse can block a tool call) or asynchronously. They fire at the process level on every tool invocation regardless of what agent or subagent triggered it, making them a reliable enforcement mechanism where behavioral modeling is not.

↑ Contents

Source

↑ Contents

Source: OKF Markdown