Hooks
Shell commands that run automatically before or after Claude Code actions — formatting after an edit, linting before a commit, blocking a tool call outright.
Last verified August 21, 2026 · 3 sources
A hook is a shell command Claude Code runs at a defined point in its own execution — before a tool call, after a file edit, at other documented events.
The distinction that makes hooks worth understanding: hooks are deterministic. A CLAUDE.md
instruction saying “always run the formatter after editing” is a request the model may or may not
honour. A hook that runs the formatter after every edit is not a request. It runs.
What people use them for
- Formatting after every file edit
- Running the linter or type checker before a commit
- Blocking edits to protected paths
- Logging what the agent did, for audit
- Injecting context at the start of a session
Hooks vs Skills
The two get confused constantly, and the difference is exactly the one above:
| Hooks | Skills | |
|---|---|---|
| Triggered by | An event in Claude Code | The model deciding it is relevant |
| Guaranteed to run | Yes | No |
| Written as | Shell commands | Instructions, scripts, resources |
| Good for | Enforcement | Capability |
Use a hook when the thing must happen. Use a Skill when the thing needs judgement. Full comparison.
What it does not do
- A hook is not sandboxed. It is a shell command with your privileges. A hook installed by a plugin is a shell command someone else wrote, running with your privileges.
- It is not a permission system. Hooks can block, but permissions are the mechanism designed for that.
- It does not run in the Claude apps. Hooks are Claude Code and Agent SDK.
In the Agent SDK
The Agent SDK exposes hooks as the way to intercept and control agent behaviour programmatically — the same idea, with a code interface instead of a settings file.
Plan availability
Anything left blank is not documented publicly, not a claim that it is unavailable. Compare every feature at once in the availability matrix.
- FreeNot available
- ProIncluded
- MaxIncluded
- TeamIncluded
- EnterpriseIncluded
- APIIncluded
Comparisons
Sources
- 01Automate actions with hooks — Claude Code docsOfficialcode.claude.com
- 02Hooks reference — Claude Code docsOfficialcode.claude.com
- 03Intercept and control agent behavior with hooks — Agent SDKOfficialcode.claude.com
Page changelog
- VerifiedChecked against the hooks guide, hooks reference and Agent SDK hooks documentation.