One read of Claude Code CLIclaude-code-20261201T000702Z
5 pages moved out of 221 read.
Pages moved
5
significant first
Pages read
221
in this capture
Captured
00:07 UTC
Corpus hash
d7b494ee5174
corpus-hash
What this read moved
1-5 of 5hooks Changed · +4 / -4 lines
This page is larger than the 256 KiB this site keeps, so one side of the diff below stops where the stored text does.
from line 419
419419| Field | Required | Description |
420420| :- | :- | :- |
421421| `type` | yes | `"command"`, `"http"`, `"mcp_tool"`, `"prompt"`, or `"agent"` |
422| `if` | no | [Permission rule syntax](https://code.claude.com/docs/en/permissions.md#permission-rule-syntax) to filter when this hook runs, such as `"Bash(git *)"` or `"Edit(*.ts)"`. The hook command only runs if the tool call matches the pattern. See the [Bash matching table](#bash-if-matching) for how Bash patterns evaluate against subcommands, `$()`, and backticks. Only evaluated on `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `PermissionRequest`, `PermissionDenied`, and `PreSkillShellCommand`. On other events, a hook with `if` set doesn't run |
422| `if` | no | [Permission rule syntax](https://code.claude.com/docs/en/permissions.md#permission-rule-syntax) to filter when this hook runs, such as `"Bash(git *)"` or `"Edit(*.ts)"`. See [which tools accept a pattern](https://code.claude.com/docs/en/hooks-guide.md#filter-by-tool-name-and-arguments-with-the-if-field). See the [Bash matching table](#bash-if-matching) for how Bash patterns evaluate against subcommands, `$()`, and backticks. Only evaluated on `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `PermissionRequest`, `PermissionDenied`, and `PreSkillShellCommand`. On other events, a hook with `if` set doesn't run |
423423| `timeout` | no | Seconds before canceling. Claude Code doesn't enforce it on a command hook you run with [`async: true`](#run-hooks-in-the-background). Defaults: 600 for `command`, `http`, and `mcp_tool`; 30 for `prompt`; 60 for `agent`. Claude Code lowers the `command`, `http`, and `mcp_tool` default to 30 on [`UserPromptSubmit`](#userpromptsubmit), [`PreModelSwitch`](#premodelswitch), and [`PostModelSwitch`](#postmodelswitch), and to 10 on [`MessageDisplay`](#messagedisplay). [`SessionEnd`](#sessionend) hooks share a 1.5-second budget; if your settings set a longer per-hook `timeout`, Claude Code raises the budget to match, up to 60 seconds |
424424| `statusMessage` | no | Custom spinner message displayed while the hook runs |
425425| `once` | no | If `true`, Claude Code removes the hook after its first successful run. A run that fails, blocks with exit code 2, or times out leaves the hook in place, so it runs again on the next matching event. Only honored for hooks declared in [skill frontmatter](#hooks-in-skills-and-agents); ignored in settings files and agent frontmatter |
from line 3639
36393639| `context_tokens` | number | Tokens the next request re-sends as its prompt: the input, cache read, cache creation, and output tokens of the last response in the main conversation, combined. `0` before the first response |
36403640| `prompt_cache_warm` | boolean | Whether the current model's prompt cache is likely still warm, meaning the switch forfeits it |
36413641| `cache_ttl` | string | [Prompt cache lifetime](https://code.claude.com/docs/en/prompt-caching.md#cache-lifetime) of the main conversation at the time of this switch: `"5m"` or `"1h"` |
3642| `estimated_cache_write_usd` | number | Estimated cost in US dollars of writing `context_tokens` to the prompt cache on `to_model` at the `cache_ttl` rate, excluding the next response. The se
3642| `estimated_cache_write_usd` | number | Estimated cost in US dollars of writing `context_tokens` to the prompt cache on
hooks-guide Changed · +11 / -3 lines
from line 768
768768
769769The `if` field uses [permission rule syntax](https://code.claude.com/docs/en/permissions.md) to filter hooks by tool name and arguments together.
770770
771For example, this configuration runs a hook only when Claude uses `git` commands rather than all Bash commands:
771Add a pattern in parentheses, such as `Bash(git *)`, after these tool names:
772772
773* **`Bash`, `PowerShell`, [`Monitor`](https://code.claude.com/docs/en/hooks#match-monitor-commands)**: matches the command
774* **`Read`, `Edit`, `Write`, `NotebookEdit`**: matches the file path. To cover `Edit` and `Write`, use two handlers: `"Edit(*.ts)"` and `"Write(*.ts)"`
775* **`Grep`, `Glob`**: matches the call's `pattern` argument
776
777For other tools, use the tool's full name alone and check the input in your script.
778
779The following configuration runs a hook when Claude uses `git` commands:
780
773781```json theme={null}
774782{
775783 "hooks": {
from line 809
801809
802810When Claude Code can't split the Bash input into subcommands, it runs your hook regardless of the pattern. The [Bash matching table](https://code.claude.com/docs/en/hooks.md#bash-if-matching) covers the command shapes Claude Code can and can't narrow by subcommand. Because the filter is best-effort, use the [permission system](https://code.claude.com/docs/en/permissions.md) rather than a hook to enforce a hard allow or deny.
803811
804The `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.
812To match multiple tool names, use separate handlers each with its own `if` value, or match at the `matcher` level where pipe alternation is supported.
805813
806814> [!NOTE]
807815>
from line 841
833841
834842The model's only job is to return its decision as JSON:
835843
836* `"ok": true`: the action proceeds
844* `"ok": true`: the action passes this hook
837845* `"ok": false`: what happens depends on the event:
838846 * `Stop` and `SubagentStop`: the `reason` is fed back to Claude so it keeps working, unless the response also sets `"impossible": true` to mark the condition as one that can never be satisfied, in which case Claude Code allows the stop and the turn ends
839847 * `PreToolUse`: the tool call is denied; by default the turn ends and the deny `reason` appears in the chat as a warning line. Set `continueOnBlock: true` on the hook to instead return the `reason` to Claude as the tool error, so it can adjust and continue
plugins/mods/interface Changed · +1 / -1 lines
from line 278
278278
279279While Claude works, the spinner animates as before, and `under the spinner` appears below it.
280280
281The permission prompt isn't a render site, so a mod can't change what it shows. The question dialog, `AskUserQuestion`, is one, so a mod can change that dialog when Claude asks a question. A tree for the dialog has to hold the reference exactly once, with your elements above it. Otherwise, Claude Code draws its own dialog.
281To add to the question dialog, `AskUserQuestion`, return a tree that holds the reference exactly once, with your elements above it. Otherwise, Claude Code draws its own dialog.
282282
283283### Open a pane at the right time
284284
plugins/mods/overview Changed · +0 / -2 lines
from line 76
7676
7777A mod can approve [many tool calls](https://code.claude.com/docs/en/permissions.md#precedence-among-rules-hooks-and-mods) that your `deny` or `ask` rules or your `PreToolUse` hooks would stop, unless the [built-in guard](https://code.claude.com/docs/en/plugins/mods/admin.md#know-what-happens-by-default) prevents it. With the guard loaded, by default a user's mod can't do this. In a local terminal session, `cc-plugin-sec-default` on the **Installed** tab of `/plugin` means the guard is loaded.
7878
79A mod can restyle much of Claude Code's interface, but not the permission prompt. It can't change what a prompt shows you.
80
8179### List what a mod does before you install one
8280
8381Before you install a mod, you can list which events it handles and what it asks Claude Code to do, such as read a file or make a network request, without running it. Get the plugin's files first, for example by cloning its repository. Then, in your shell, run `claude plugin validate` on the plugin's directory:
tools-reference Changed · +1 / -2 lines
from line 79
7979* in the `--allowedTools` and `--disallowedTools` [CLI flags](https://code.claude.com/docs/en/cli-reference.md)
8080* in the Agent SDK's [`allowedTools` and `disallowedTools`](https://code.claude.com/docs/en/agent-sdk/permissions#allow-and-deny-rules) options
8181* in a [skill's `allowed-tools`](https://code.claude.com/docs/en/skills#frontmatter-reference) frontmatter
82* in a hook's [`if` condition](https://code.claude.com/docs/en/hooks-guide#filter-by-tool-name-and-arguments-with-the-if-field)
8382
8483All of these accept the same rule format, `ToolName(specifier)`. The specifier depends on the tool, and several tools share a format:
8584
from line 93
9493| `WebFetch(domain:example.com)` | WebFetch | [Domain matching](https://code.claude.com/docs/en/permissions.md#webfetch) |
9594| `WebSearch` | WebSearch | No specifier; allow or deny the tool as a whole |
9695
97Tools not listed here, such as `ExitPlanMode` or `ShareOnboardingGuide`, accept only the bare tool name with no specifier.
96To [match all uses](https://code.claude.com/docs/en/permissions.md#match-all-uses-of-a-tool) of another tool, such as `ExitPlanMode` or `ShareOnboardingGuide`, write its name without parentheses. For narrower deny and ask rules, see [Match by input parameter](https://code.claude.com/docs/en/permissions.md#match-by-input-parameter). For a hook's `if` condition, see [which tools accept a pattern](https://code.claude.com/docs/en/hooks-guide.md#filter-by-tool-name-and-arguments-with-the-if-field).
9897
9998An `Edit(...)` allow rule also grants read access to the same path, so you don't need a matching `Read(...)` rule. A `Read(...)` deny rule also blocks the Edit and Write tools on the same path, including creating a new file there, because both tools change content Claude has to be able to read back. For the Write tool, the `Read` deny check requires Claude Code v2.1.228 or later.
10099