Definition
Hooks
Hooks are automation triggers that fire at specific points in an agent’s workflow. In Claude Code they run before or after particular tool calls — file edits, command execution — and are defined in .claude/settings.json. They are used for linting, formatting, validation and custom logic the agent cannot skip.
Why it matters
A hook is the difference between asking an agent to behave and making a command impossible to run. Instructions in a config file are advisory; a hook is code that executes whether or not the model was paying attention.
How each tool handles it
- Cursor
- Local and cloud agent hooks.
- Claude Code
- A full hook system, pre and post tool use, in
.claude/settings.json. - Codex
- Hooks alongside approvals.
Frequently asked questions
What are hooks used for?
Linting, formatting, validation and custom logic — anything that should happen every time, without depending on the agent remembering. In Claude Code they are defined in .claude/settings.json and run before or after specific tool calls.
Do Cursor and Codex have hooks?
Both have something in the category — Cursor has local and cloud agent hooks, Codex has hooks alongside approvals — but Claude Code’s is the full pre and post tool-use system.
Can a hook stop a command from running?
That is the category it exists for. Hooks run before a tool call, so validation logic placed there executes ahead of the action rather than reporting on it afterwards — which is what separates a guardrail from an instruction the model may or may not follow.