Learn · Intermediate · Members
Hooks
Think of the gate at a car park. You do not ask the gate to let you in, and the gate does not ask how you feel about paying. It works the same way for every car, every time, because it is built into the entrance. A sign that says "Please pay before you leave" is a request, and some people skip it. A hook is the gate. It stands at a set point in Claude's work and does its one job each time Claude reaches it.
A hook is a small script that runs at a set moment in Claude's work, every time, without Claude choosing. This chapter teaches what a hook is, the moments it can run, and the two jobs we give hooks: stopping an action and adding a reminder. Each lesson is taught from one of our own hooks, shortened.
Lessons
Further resources
- Claude Code: Hooks reference: every hook moment, the input a hook receives, and what each exit code does.
- Pasquale Pillitteri: Claude Code hooks, a complete guide: the hook moments grouped by stage, and how exit code 2 blocks an action.
- Dometrain: Hooks: a short course page on hook events, matchers and when to use each.