Automate actions with hooks changedhooks-guide
Nearest release: v2.1.332, published 7 hours before upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Upstream edited this page at 25 Nov 2026 05:58 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 25 Nov 2026 06:07 UTC.
Upstream edited
Recorded here
Lines+5added
Lines−1removed
From line
471
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits62to this page, all time
The whole hunk
from line 471, old and new numbered
/
from line 471
471471| `Setup` | When you start Claude Code with `--init-only`, or with `--init` or `--maintenance` in `-p` mode. For one-time preparation in CI or scripts |
472472| `UserPromptSubmit` | When a prompt is submitted, before Claude processes it. Also fires on [turns Claude Code starts on its own](https://code.claude.com/docs/en/hooks.md#userpromptsubmit) |
473473| `UserPromptExpansion` | When a user-typed command expands into a prompt, before it reaches Claude. Can block the expansion |
474| `PreSkillShellCommand` | Before a skill's [injected shell command](https://code.claude.com/docs/en/skills.md#inject-dynamic-context) runs. Can block the command |
474475| `PreToolUse` | Before a tool call executes. Can block it |
475476| `PermissionRequest` | When a tool call needs a permission decision |
476477| `PermissionDenied` | When auto mode denies a tool call, including denials without a classifier verdict. Use JSON `hookSpecificOutput.retry: true` to tell the model it may retry the denied tool call. Claude Code ignores `retry` when the classifier produced no verdict |
from line 691
690691| `ElicitationResult` | MCP server name | same values as `Elicitation` |
691692| `FileChanged` | literal filenames to watch (see [FileChanged](https://code.claude.com/docs/en/hooks.md#filechanged)) | `.envrc\|.env` |
692693| `UserPromptExpansion` | command name | your skill or command names |
694| `PreSkillShellCommand` | tool that runs the command | `Bash`, `PowerShell` |
693695| `UserPromptSubmit`, `PostToolBatch`, `Stop`, `TeammateIdle`, `TaskCreated`, `TaskCompleted`, `WorktreeCreate`, `WorktreeRemove`, `CwdChanged`, `MessageDisplay` | no matcher support | always fires on every occurrence |
694696
695697The tabs below show a few more matchers on different event types.
from line 803
801803
802804The `if` field accepts the same patterns as permission rules: `"Bash(git *)"`, `"Edit(*.ts)"`, and so on. To match multiple tool names, use separate handlers each with its own `if` value, or match at the `matcher` level where pipe alternation is supported.
803805
804`if` only works on tool events: `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `PermissionRequest`, and `PermissionDenied`. Adding it to any other event prevents the hook from running.
806> [!NOTE]
807>
808> `if` only works on `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `PermissionRequest`, `PermissionDenied`, and `PreSkillShellCommand`. If you add it on any other event, the hook doesn't run.
805809
806810### Configure hook location
807811
No line in this hunk matches that.