Vibe Coder · Unit 9: Claude Code Commands and Extensions · Lesson 7 of 10
Hooks
Engineers: hooks run your own commands at set moments, so formatting, checks and guards happen every time without relying on the model.
Read the short notes and pictures.Do everything inside a blue frame.
Deterministic behaviour
A model follows instructions most of the time. Hooks are for the things that must happen every time. They are shell commands that Claude Code runs at defined points in its loop, regardless of what the model decides.

Useful hooks
Format on edit
Run your formatter on every file the agent changes.
Guard
Refuse edits to migrations, generated code or environment files.
Verify on stop
Run type-check and tests before the agent reports back.
Notify
Tell you when a long task finishes.

Writing one safely
Start with one
Formatting is a good first hook.
Keep it fast
It runs often.
Make failure clear
Return a message the agent can act on.
Review it like code
A hook runs with your permissions.
Add a formatting hook and a guard
Add a hook that formats files after edits and one that blocks changes to your environment files. Prove both by asking the agent to do each thing.
Done when
Add a stop hook for your checks when you have tests.
Keep these
- Hooks run your commands at set moments.
- Use them for what must always happen.
- Keep them fast and reviewed.