What are agent hooks?
Hooks in Claude Code are user-defined handlers that run at set points in its lifecycle, giving deterministic control over actions instead of relying on the model to remember them.
Also written: Claude Code hooks, hooks, lifecycle hooks
Explained
A hook is configured in a settings file and tied to an event, optionally filtered by a matcher such as a tool name. Events named in the docs include SessionStart, PreToolUse, PostToolUse, SubagentStop and Stop. Most hooks use a command handler that runs a shell command. Other handler types post event data to a URL, ask a model a single question, or start a multi-turn agent check with tool access, and the docs mark agent-based hooks as experimental.
The hook receives event data as JSON on standard input and answers through its exit code and output. Exit code 0 means no objection, so a PreToolUse call still goes through the normal permission flow. Exit code 2 blocks the action and sends the stderr text back to Claude as feedback. A hook can also exit 0 and print JSON to deny, ask or allow a tool call. When several hooks match, all of them run, and for permission decisions the most restrictive answer wins.
Typical uses in the guide are formatting a file after every edit, sending a desktop notification, blocking writes to protected files, and re-injecting context after compaction. Not every event can be blocked, so the per-event rules in the reference matter. The guide presents hooks as deterministic: configured actions happen every time their event and matcher fire. It calls the general feature hooks, and uses agent-based hooks only for the multi-turn handler type.
Primary source
Automate actions with hooks (code.claude.com), read Oct 26, 2026
This entry paraphrases the page above. Sources change; check it for the current wording.
Listings that use this
The 5 top-ranked listings tagged for Agent hooks. Rank weighs adoption, freshness, documentation and publisher identity; how we rank and grade. Money never changes the order.
- 0.670score

Commit Sage
VizzleTF
Free AI commit messages using Gemini, OpenRouter, Groq, Claude, DeepSeek, xAI, Ollama, or any OpenAI-compatible LLM
PluginAFreshness: A★ 52VS Code +3 - 0.641score

Llamit - AI Commit Messages
Crstian
Generate semantic commit messages using Ollama or any OpenAI-compatible endpoint.
PluginAFreshness: A★ 13VS Code +3 - 0.626score

GitMind: AI Commit Message Generator
ShahabBahreiniJangjoo
AI commit message generator for VS Code.
PluginAFreshness: A★ 5VS Code +3 - 0.617score

otak-committer
odangoo
VS Code extension for intelligent SCM operations - Multilingual commit message generation with AI support (25 languages supported) and future PR management…
PluginAFreshness: A★ 3VS Code +3 - 0.615score

Git Commit Genie
Lune-99
AI assisted commit message generation.
PluginAFreshness: A★ 4VS Code +3
Related
Cite this page
What are agent hooks?. Agent Mart. https://agentmart.dev/glossary/agent-hooks (last updated 2026-10-26)
Written Oct 26, 2026, updated Oct 26, 2026. All glossary terms