Hooks run your own code before or after agent events such as tool calls, prompts and session start. A pre-tool hook can block a command, demand extra checks, or log every action to a central system, which makes hooks a programmable layer above static rules. Deploy security hooks through managed settings so users cannot quietly remove them.
Read in this order
- OfficialClaude Code: Hooks referenceStart here: the event list and how a hook returns allow or deny.
- OfficialCursor: HooksCursor's hook events, to see how blocking semantics differ.
- VideoHooking Coding Agents with the Cedar Policy Language ([un]prompted 2026)Demonstrates a tool-action reference monitor built with hooks and Cedar. 17 min.