A user-defined command or prompt that Claude Code runs automatically at a named lifecycle event, such as before or after a tool call, enabling deterministic enforcement of rules the agent cannot skip.
How it works
A hook binds a command or prompt to a named lifecycle event, and the Claude Code runtime invokes that binding when the event fires rather than leaving the decision to the agent. The hook sits outside the agent's decision loop: it sees the action the agent is about to take and either passes, modifies the inputs, or blocks the action entirely, regardless of what the agent intended.
Why it matters
Inverting the trust model is what makes a rule deterministic: the agent cannot route around a gate it does not control. The trade-offs are structural: a hook can only gate inputs and not the decision itself, latency added per triggering event compounds for frequent PreToolUse hooks, and a hook that crashes blocks the action it was meant to gate, making false-positive blocks the default failure mode.
In practice
A check bound to the event before a file write inspects the pending change and blocks it when it violates a rule; the agent that triggered the write does not see the gate as a tool it could skip, and the prohibited write never lands regardless of how the agent arrived at it.
Related standards and prior art
- Anthropic: Claude Code hooks ยท continuously updated hooks fire at named lifecycle events such as PreToolUse and PostToolUse
Defined by Ready Solutions AI