Answer: To set up a hook, add a `hooks` block to a settings file such as `~/.claude/settings.json`, defining an event like `Notification` with a hook of `"type": "command"` and a `command` string containing the shell command to run. You can verify it by typing `/hooks` at the Claude Code prompt. Status: Confirmed Entry: tool/claude-code/agents-and-automation/set-up-first-hook Revision: 1 Digest: sha256:b7c03fa96170d7bd (changes whenever the content changes) Timeline: Created: 2026-11-13T03:04:22Z Last changed: 2026-11-13T03:04:22Z Last verified: 2026-11-20T12:21:18Z Next check: 2026-11-21T12:21:18Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of settings file | ~/.claude/settings.json | [1] | 2026-11-20 hook type | command | [1] | 2026-11-20 verify command | /hooks | [1] | 2026-11-20 Sources: [1] Anthropic. "Automate actions with hooks". https://code.claude.com/docs/en/hooks-guide.md Role: primary. Accessed: 2026-11-20T12:21:18Z Quote: "Open `~/.claude/settings.json` and add a `Notification` hook." (Supports: settings file) Quote: ""type": "command"," (Supports: hook type) Quote: "Type `/hooks` at the Claude Code prompt to open the hooks browser." (Supports: verify command) Published: 2026-11-20T10:36:06Z Snapshot SHA-256: 2076ece854a4d4be8c0a9c7568db4e9abc0e35153c22975adf750c6f8f3166e9 (captured 2026-11-17T12:26:31Z) 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]. On this check the text of [1] was unchanged since 2026-11-17T12:26:30Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T12:21:18Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:21:18Z Last attempt: 2026-11-20T12:21:18Z Notes and limitations: Extracted automatically from a single official source (section "Set up your first hook"). Related: https://latestn.com/tool/claude-code/agents-and-automation/setting-sources-not-controlled Which settings does settingSources in the Claude Code SDK not control? https://latestn.com/tool/claude-code/agents-and-automation/single-message-input-limitations What are the limitations of single message input in the Claude Agent SDK? https://latestn.com/tool/claude-code/agents-and-automation/specify-teammates-models How do I specify teammates and models for a Claude Code agent team? https://latestn.com/tool/claude-code/agents-and-automation/set-claude-code-preset-system-prompt How do I set the claude_code preset as the system prompt in the Claude Code Agent SDK? https://latestn.com/tool/claude-code/agents-and-automation/set-effort-level How do I set the effort level for a Claude Code SDK agent? https://latestn.com/tool/claude-code/agents-and-automation/set-eval-run-limits-and-tools How do I set run limits and allowed tools for a Claude Code eval case in prompt.md? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-13T03:04:22Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/agents-and-automation/set-up-first-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/set-up-first-hook POST: https://latestn.com/dispute/tool/claude-code/agents-and-automation/set-up-first-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/set-up-first-hook?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I set up a hook in Claude Code to run a shell command automatically? Revision 1, last verified 2026-11-20T12:21:18Z. https://latestn.com/tool/claude-code/agents-and-automation/set-up-first-hook (accessed 2026-11-21T10:01:35Z). @misc{LatestN_tool_claude_code_agents_and_automation_set_up_first_hook_r1, title = {How do I set up a hook in Claude Code to run a shell command automatically?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/agents-and-automation/set-up-first-hook}}, note = {Revision 1; digest sha256:b7c03fa96170d7bd; last verified 2026-11-20T12:21:18Z; accessed 2026-11-21T10:01:35Z} } 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/set-up-first-hook