Hooks are scripts the agent harness runs at fixed points, such as before a tool call. A PreToolUse hook can inspect the exact command or file path and deny it, so written policy becomes an enforced check that does not depend on the model. Hooks are one layer, since they only see the events the harness exposes.
Read in this order
- OfficialAutomate actions with hooks (Claude Code docs)Start here: a hands-on walkthrough of writing your first blocking hook.
- OfficialHooks reference (Claude Code docs)The full event list and input and output formats for precise policies.
- Open sourceclaude-code-hooks-mastery (disler)Working hook scripts you can read, run and adapt.