Answer: A hook is a user-defined handler that executes automatically at a specific point in Claude Code's lifecycle, such as before a tool runs, after a file edit, or at session start. Hooks are deterministic, firing at fixed lifecycle points rather than at the model's discretion. Status: Confirmed Entry: tool/claude-code/agents-and-automation/what-is-a-hook Revision: 2 Digest: sha256:f546b6b41285ed08 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:04:17Z Last changed: 2026-11-19T12:16:37Z (Hook handler: — → what runs) Last verified: 2026-11-20T12:21:03Z Next check: 2026-11-21T12:21:03Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of Definition | A user-defined handler that executes automatically at a specific point in Claude Code's lifecycle | [1] | 2026-11-20 Example lifecycle points | before a tool runs, after a file edit, or at session start | [1] | 2026-11-20 Handler types | shell command, HTTP endpoint, MCP tool, LLM prompt, or subagent | [1] | 2026-11-20 Determinism | they fire at fixed lifecycle points rather than at the model's discretion | [1] | 2026-11-20 Configuration levels | Hook event | [1] | 2026-11-20 Matcher | filters which events fire it | [1] | 2026-11-20 Hook handler | what runs | [1] | 2026-11-20 Sources: [1] Anthropic. "Glossary". https://code.claude.com/docs/en/glossary.md Role: primary. Accessed: 2026-11-20T12:21:03Z Quote: "A user-defined handler that executes automatically at a specific point in Claude Code's lifecycle" (Supports: Definition) Quote: "such as before a tool runs, after a file edit, or at session start" (Supports: Example lifecycle points) Quote: "Handlers can be a shell command, HTTP endpoint, MCP tool, LLM prompt, or subagent." (Supports: Handler types) Quote: "Hooks are deterministic: they fire at fixed lifecycle points rather than at the model's discretion." (Supports: Determinism) Quote: "**Hook event**: the lifecycle point" (Supports: Configuration levels) Quote: "**Matcher**: filters which events fire it" (Supports: Matcher) Quote: "**Hook handler**: what runs" (Supports: Hook handler) Published: 2026-11-20T10:31:29Z Snapshot SHA-256: 9710e9dd45dfbb7bc5446cae9c7e560eb798451ecdcf49756a0e31d0797a5f75 (captured 2026-11-20T12:21:02Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. Cross-check: not-available at 2026-11-20T12:21:03Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:21:03Z Last attempt: 2026-11-20T12:21:03Z Notes and limitations: Extracted automatically from a single official source (section "Hook"). Related: https://latestn.com/tool/claude-code/agents-and-automation/what-is-a-subagent What is a subagent in Claude Code? https://latestn.com/tool/claude-code/agents-and-automation/when-to-use-single-message-input When should I use single message input instead of streaming input in the Claude Agent SDK? https://latestn.com/tool/claude-code/agents-and-automation/write-eval-case How do I write an eval case for a Claude Code plugin, including prompt.md frontmatter and case.yaml fields? https://latestn.com/tool/claude-code/agents-and-automation/tool-return-images-structured-data How do I return images or structured data from a Claude Code custom tool? https://latestn.com/tool/claude-code/agents-and-automation/user-input-limitations What are the limitations of handling user input with the Claude Code Agent SDK? https://latestn.com/tool/claude-code/agents-and-automation/wait-for-subagents How do I make Claude wait for subagents to finish before continuing? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-19T12:16:37Z | changed | Hook handler: — → what runs | [1] 2026-11-19T12:16:37Z | changed | Matcher: — → filters which events fire it | [1] 2026-11-19T12:16:37Z | changed | Configuration levels: — → Hook event | [1] 2026-11-19T12:16:37Z | changed | Determinism: — → they fire at fixed lifecycle points rather than at the model's discretion | [1] 2026-11-19T12:16:37Z | changed | Handler types: — → shell command, HTTP endpoint, MCP tool, LLM prompt, or subagent | [1] 2026-11-19T12:16:37Z | changed | Example lifecycle points: — → before a tool runs, after a file edit, or at session start | [1] 2026-11-19T12:16:37Z | changed | Definition: — → A user-defined handler that executes automatically at a specific point in Claude Code's lifecycle | [1] 2026-11-19T12:16:37Z | changed | hook handler: what runs → — | [1] 2026-11-19T12:16:37Z | changed | matcher: filters which events fire it → — | [1] 2026-11-19T12:16:37Z | changed | configuration levels: Hook event → — | [1] 2026-11-19T12:16:37Z | changed | determinism: they fire at fixed lifecycle points rather than at the model's discretion → — | [1] 2026-11-19T12:16:37Z | changed | handler types: a shell command, HTTP endpoint, MCP tool, LLM prompt, or subagent → — | [1] 2026-11-19T12:16:37Z | changed | example lifecycle points: before a tool runs, after a file edit, or at session start → — | [1] 2026-11-19T12:16:37Z | changed | definition: A user-defined handler that executes automatically at a specific point in Claude Code's lifecycle → — | [1] 2026-11-13T03:04:17Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/agents-and-automation/what-is-a-hook/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/claude-code/agents-and-automation/what-is-a-hook POST: https://latestn.com/dispute/tool/claude-code/agents-and-automation/what-is-a-hook with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/agents-and-automation/what-is-a-hook?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). What is a hook in Claude Code? Revision 2, last verified 2026-11-20T12:21:03Z. https://latestn.com/tool/claude-code/agents-and-automation/what-is-a-hook (accessed 2026-11-21T10:03:37Z). @misc{LatestN_tool_claude_code_agents_and_automation_what_is_a_hook_r2, title = {What is a hook in Claude Code?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/agents-and-automation/what-is-a-hook}}, note = {Revision 2; digest sha256:f546b6b41285ed08; last verified 2026-11-20T12:21:03Z; accessed 2026-11-21T10:03:37Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/claude-code/agents-and-automation/what-is-a-hook