Hooks
Deterministic TypeScript checks that run around every tool call.
Hooks are the deterministic layer. They fire on lifecycle events rather than being invoked, which makes them the right place for guardrails that must not depend on the model choosing to run them.
Overview
What hooks do and when they fire.
Architecture
The dispatcher, the entries map, and how registration works.
Lifecycle hooks
Session start, prompt submit, and stop events.
Safety hooks
Guardrails that block destructive or unsafe tool calls.
Memory hooks
Capturing and recalling context across sessions.
Writing hooks
Adding a hook, registering it, and keeping counts in sync.
Writing Agents
Create your own specialized agent with the right model, tools, skills, and directive.
219 Hooks: What Fires When
TypeScript functions that intercept every Claude Code lifecycle event -- blocking dangerous commands, injecting context, and syncing memory, all invisibly.
Last updated on