Changes on
95 changes detected
--- a/accessibility.md
+++ b/accessibility.md
@@ -36,7 +36,7 @@
[`CLAUDE_AX_SCREEN_READER`](</docs/en/env-vars#variables>)| Environment variable| Screen reader mode for sessions started from the shell where you set it.
[`axScreenReader`](</docs/en/settings-reference#axscreenreader>)| Setting| Screen reader mode for every session when `true`.
[`CLAUDE_AX_STARTUP_QUIET_MS`](</docs/en/env-vars#variables>)| Environment variable| How long Claude Code waits after the confirmation line before it draws the first prompt in screen reader mode. Requires Claude Code v2.1.217 or later.
-[`CLAUDE_AX_PREPARK_MS`](</docs/en/env-vars#variables>)| Environment variable| How long Claude Code waits, with the cursor at the start of the line, before it writes a new or changed line in screen reader mode. Requires Claude Code v2.1.233 or later.
+[`CLAUDE_AX_PREPARK_MS`](</docs/en/env-vars#variables>)| Environment variable| When you set it, how many milliseconds Claude Code holds the terminal cursor at the start of the current line before writing a new or changed line in screen reader mode. Requires Claude Code v2.1.233 or later.
[`CLAUDE_CODE_ACCESSIBILITY`](</docs/en/env-vars#variables>)| Environment variable| A terminal cursor that stays visible for screen magnifiers such as macOS Zoom when you set it to `1`. The cursor follows the input caret and, on Claude Code v2.1.218 or later, the highlighted row in menus and panels such as `/config` and `/plugin`.
[`prefersReducedMotion`](</docs/en/settings-reference#prefersreducedmotion>)| Setting| Reduced or no spinners, shimmer, and other animations when `true`.
[`theme`](</docs/en/settings-reference#theme>)| Setting| The interface colors, including the colorblind-friendly `dark-daltonized` and `light-daltonized` themes. You can also pick one with [`/theme`](</docs/en/commands#all-commands>).
@@ -54,13 +54,9 @@
* No color-only cues
* No redraws of content that hasn’t changed. Progress spinners render as static text
* Tables in Claude’s replies read as `Header: value` sentences instead of a box-character grid
+ * Diffs read as plain text, line by line with `+` and `-` marking added and removed lines, so you can hear the proposed change in a file edit approval prompt before you answer it
-Claude Code leaves everything it prints in your terminal’s scrollback, so you can re-read earlier turns with your screen reader’s review commands or your terminal’s search. Claude Code ignores the [`tui` setting](</docs/en/settings-reference#tui>) in screen reader mode. Apart from the attached background sessions listed under Known limitations, it prints scrolling text instead of [fullscreen rendering](</docs/en/fullscreen>). Claude Code also waits at two points so your screen reader can keep up:
-
- * After Claude Code prints the confirmation line, it waits 3 seconds before it draws the prompt, so your screen reader can finish the line. Press any key to end the wait. To change the length of the wait, set [`CLAUDE_AX_STARTUP_QUIET_MS`](</docs/en/env-vars#variables>).
- * Before Claude Code writes a new or changed line, such as a hint or more of Claude’s reply, it moves the cursor to the start of the line and waits 50 milliseconds. Your screen reader then reads the line from its first character. Characters you type or delete at the end of the input line appear immediately. To change the length of the wait, set [`CLAUDE_AX_PREPARK_MS`](</docs/en/env-vars#variables>).
-
-Each message in the transcript starts with a label your screen reader announces, naming what it is: your messages, Claude’s replies and thinking, tool activity, errors and warnings, and prompts. The labels are also searchable, so you can jump between sections of the transcript by searching your terminal’s scrollback:
+Claude Code leaves everything it prints in your terminal’s scrollback, so you can re-read earlier turns with your screen reader’s review commands or your terminal’s search. Claude Code ignores the [`tui` setting](</docs/en/settings-reference#tui>) in screen reader mode. Apart from the attached background sessions listed under Known limitations, it prints scrolling text instead of [fullscreen rendering](</docs/en/fullscreen>). After Claude Code prints the confirmation line at startup, it waits 3 seconds before it draws the prompt, so your screen reader can finish the line. Press any key to end the wait. To change the length of the wait, set [`CLAUDE_AX_STARTUP_QUIET_MS`](</docs/en/env-vars#variables>). Each message in the transcript starts with a label your screen reader announces, naming what it is: your messages, Claude’s replies and thinking, tool activity, errors and warnings, and prompts. The labels are also searchable, so you can jump between sections of the transcript by searching your terminal’s scrollback:
Label| Meaning
---|---
@@ -81,6 +77,14 @@
* Deleting to the end of the line with `Ctrl+K`
When you cycle [permission modes](</docs/en/permission-modes>) with `Shift+Tab`, Claude Code announces the permission mode you land on, such as `[plan mode on]` or `[accept edits on]`. Claude Code prints the announcement once and doesn’t repeat it on later redraws.
+
+###
+
+
+
+Read earlier output without losing your place
+
+If your screen reader jumps back to the prompt while you’re reading earlier output, it’s following the terminal cursor. Claude Code moves the terminal cursor back to the prompt each time it writes new text. To keep your place while you read, stop your screen reader from following the terminal cursor. In NVDA, press `NVDA+6` to stop the review cursor from following the terminal cursor. Press `NVDA+6` again to turn following back on.
###
Show diff (409 lines)
--- a/admin.md
+++ b/admin.md
@@ -0,0 +1,406 @@
+A [mod](</docs/en/plugins/mods/overview>) is a plugin that runs code inside Claude Code with the permissions of the user who installed it. Mods aren’t sandboxed. Through [managed settings](</docs/en/managed-settings>), you decide whether mods run on your users’ machines, which ones, and in what order. You can also install a mod of your own that watches or refuses what other mods do. This page is for the person who deploys managed settings for Claude Code, whether as a file, through MDM, or from the claude.ai admin console. Mods are on by default in Claude Code v2.1.287 and later. Start with the section that matches what you came to do:
+
+ * **Keep users’ own mods out, with or without mods of your own** : Stop user-installed mods from loading
+ * **See what your users get when you change nothing** : Know what happens by default
+ * **Leave mods on with other limits** : Choose how much to allow
+
+These cases are covered on other pages:
+
+ * **You haven’t deployed managed settings before** : start with [Deploy managed settings](</docs/en/managed-settings>)
+ * **You want to control which plugins users can install** : see [Manage plugins for your organization](</docs/en/plugins/org>)
+
+##
+
+
+
+Stop user-installed mods from loading
+
+To keep every mod your users bring from loading, set the `allowManagedModsOnly` option on the built-in guard, a policy mod that Claude Code loads ahead of every mod a user installs. The option goes in managed settings under `pluginConfigs`, keyed by `cc-plugin-sec-default@builtin`:
+
+managed-settings.json
+
+ {
+ "pluginConfigs": {
+ "cc-plugin-sec-default@builtin": {
+ "options": {
+ "allowManagedModsOnly": true
+ }
+ }
+ }
+ }
+
+With the option set in managed settings:
+
+ * **No mod a user brings loads** : that covers a mod in a plugin the user installed, a mod loaded with `--plugin-dir`, and a mod [Claude wrote during a session](</docs/en/plugins/mods/create#ask-claude-for-a-mod>)
+ * **Your organization’s mods still load** : a mod that counts as your organization’s isn’t checked. Every other mod counts as a user’s and doesn’t load. That includes a mod in a plugin you enable from a GitHub or other remote marketplace, and one your organization turns on for its members on claude.ai. If none counts as yours, no installed mod loads.
+ * **Users can’t undo it** : the guard reads the option from managed settings only, so the same entry in a user, project, or local settings file, or in a file passed with `--settings`, changes nothing
+ * **A file or MDM policy covers every provider** : when you deliver the option as a file or through MDM, it works the same way on Amazon Bedrock, Google Cloud’s Agent Platform, and Microsoft Foundry. For delivery from the claude.ai admin console, see [Platform availability](</docs/en/server-managed-settings#platform-availability>)
+ * **Users’ other customizations keep working** : their [hooks in settings files](</docs/en/hooks>), status lines, and `/goal` aren’t affected
+ * **Built-in mods keep running** : mods built into Claude Code, such as `AGENTS.md` support, each have [their own switch](</docs/en/plugins/mods/overview#mods-built-into-claude-code>)
+
+To confirm the option on a user’s machine, start Claude Code there with `--plugin-dir` and the path of a directory that holds a mod, such as `claude --plugin-dir ./first-mod`. The mod’s hooks don’t run, and the transcript and the debug log have the [guard’s message](</docs/en/plugins/mods/troubleshoot#messages-from-the-built-in-guard>), which names the mod and `allowManagedModsOnly`. If the mod loads, see [Check that a policy is in force](</docs/en/managed-settings#check-that-a-policy-is-in-force>) and the rules that decide whether an option takes effect. If you set `CLAUDE_CODE_ENABLE_FUNCTION_HOOKS` to `0` during early access, replace it with this option. Claude Code v2.1.287 and later ignores the variable at any value, so a `0` there leaves mods on.
+
+##
+
+
+
+Know what happens by default
+
+With no mod settings of your own, this is what your users get:
+
+ * **Mods are on.** A user can install a plugin that contains a mod from any marketplace your plugin settings allow, or load one from a directory with `--plugin-dir`.
+ * **A built-in guard runs first.** Claude Code loads a built-in mod named `sec-default@builtin` ahead of every mod a user installs. Users can’t turn it off. `/plugin` and the debug log list it as `cc-plugin-sec-default`. The guard loads when either of these is true:
+ * The machine has managed settings
+ * The user is signed in to Claude Code with a Team or Enterprise plan
+A user who authenticates with an API key, or through Amazon Bedrock, Google Cloud’s Agent Platform, or Microsoft Foundry, gets the guard only on a machine that has managed settings.
+ * **The guard protects what you manage.** A user’s mod can’t change what your managed hooks receive or decide, the system prompt, your managed `CLAUDE.md` and other managed instructions, what any mod reads as settings, or the tools and descriptions of your managed MCP servers.
+ * **Everything else is allowed.** The guard adds no other restrictions. A user’s mod can still read and write files, start processes, make network requests, rewrite tool calls and prompts, deny a tool call, approve one that would otherwise prompt, and draw in the interface, all with that user’s permissions.
+ * **Deny rules and your managed hooks take precedence.** Where the guard loads, a user’s mod can’t approve a call that a `deny` rule refuses, whichever settings file holds the rule. A block from a `PreToolUse` hook in managed settings is final too. Both apply to Claude’s tool calls. Neither applies to a mod’s own [`$.fs` and `$.process` calls](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>): with `Read(.env)` denied, a mod can still read that file with `$.fs.read` or start a program that does. To limit those calls, keep the mod from loading or handle the call in a policy mod.
+ * **Other permission checks can be overridden.** A user’s mod that approves tool calls can approve a call that an `ask` rule would prompt for, or that a `PreToolUse` hook outside managed settings blocked. In auto mode, a call the mod approves runs without a classifier check.
+
+The guard’s source is public in the [`mods/sec-default` directory of the Claude Code repository](<https://github.com/anthropics/claude-code/tree/main/mods/sec-default>).
+
+###
+
+
+
+Know which controls still apply
+
+Mods don’t replace the controls you already have:
+
+ * **Settings hooks keep working.** Command, HTTP, prompt, and agent hooks in settings files and in plugins’ `hooks/hooks.json` run as before, alongside mods. Nothing about them is deprecated.
+ * **Deny rules take precedence where the guard loads.** A user’s mod can’t approve a call that a `deny` rule refuses, unless you set `allowModsToOverrideDenyRules`.
+ * **Managed hooks run first.** A `PreToolUse` hook in managed settings runs before any mod sees the tool call, and its block is final. If a mod then rewrites the call, your managed hooks run again on the rewritten call, so a block still applies. `PreToolUse` hooks from other settings files and from plugins run after the last mod, so a mod that returns its own result in place of running the tool keeps those from running. See [The order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>).
+ * **Network policy covers`$.http.fetch`.** If your organization turns off web fetching, or nonessential network traffic is turned off for the session, Claude Code refuses a network request that a mod makes with `$.http.fetch`. The policy doesn’t cover a program the mod starts with `$.process.run`. That program reaches the network with the user’s own access.
+ * **Plugin controls cover mods.** A mod is a plugin, so the [settings that restrict what users can install](</docs/en/plugins/org#restrict-what-users-can-install>), such as `strictKnownMarketplaces`, decide whether it can be installed at all.
+ * **Mods can’t change the permission prompt.** A mod can restyle much of Claude Code’s interface, but not the permission prompt, so it can’t change what a prompt shows. A mod can still approve or deny a tool call before the prompt appears, as Know what happens by default describes.
+ * **Trust prompts come first.** In an interactive session in a directory the user hasn’t trusted yet, no mod loads until they answer the trust prompt.
+ * **`--safe-mode` turns installed mods off, yours included.** Start a session with `claude --safe-mode` to check whether a mod caused a problem.
+
+None of these controls sandboxes a mod. A mod you allow runs as the user, with the user’s access to files, processes, and the network.
+
+##
+
+
+
+Decide whether to leave mods on
+
+A mod can do more than the other parts of a plugin because it runs inside Claude Code. It sees every prompt and tool call, can change them, and can allow or deny a tool call before a permission prompt appears. What a user can load as a mod depends on the plugin controls you already have:
+
+Your plugin controls today| What a user can load as a mod
+---|---
+None| A mod from any marketplace, from any directory with `--plugin-dir`, or that Claude writes during a session
+A marketplace allowlist| A mod from the marketplaces you allow, or from any directory with `--plugin-dir`. A mod Claude writes during a session loads only when the allowlist [includes `skills-dir`](</docs/en/plugins/org#keep-skills-directory-plugins-loading>).
+A marketplace allowlist and `disableSideloadFlags`| A mod from the marketplaces you allow
+
+[Manage plugins for your organization](</docs/en/plugins/org>) lists the ways a plugin loads and the setting that controls each. To check the mods in a marketplace before your users install them, see Review what a mod can do. To keep users’ mods out until you’ve done that, see Stop user-installed mods from loading.
+
+###
+
+
+
+Review what a mod can do
+
+You can see what a mod is able to do without running it. In your shell, run `claude plugin validate` on the plugin’s directory:
+
+ claude plugin validate ./some-mod
+
+Two lines in the output describe the mod’s code:
+
+ ❯ ./register.js hooks: session.start, tool.call, ui.render{component=Pane}
+ ❯ ./register.js calls: $.fs.read, $.http.fetch, $.store.set, $.ui.open
+
+The `hooks:` line lists the events the mod receives. The `calls:` line lists the mods API methods its code calls. The [mods API](</docs/en/plugins/mods/api>), written `$` in a mod’s code, is how a mod reaches files, processes, and the network. Claude Code refuses to load a mod that uses the mods API in a way this command can’t read. Look at the `calls:` line for these:
+
+Call| What it means
+---|---
+`$.fs.read`, `$.fs.write`| Reads or writes files anywhere the user can
+`$.process.run`, `$.process.spawn`| Starts programs as the user
+`$.http.fetch`| Makes network requests
+`$.env.get`, `$.settings.read`| Reads environment variables and settings, which can hold API keys. An `env reads:` line in the output names each variable.
+`$.env.set`| Sets an environment variable for Claude Code and for every command and MCP server it starts afterward, which can change what those programs run. An `env writes:` line names each variable.
+`$.mcp.call`| Calls a tool on a connected MCP server, under the session’s permission rules
+`$.model.complete`| Uses the user’s plan or API key for model calls
+`$.prompt.submit`| Submits a prompt, and can send it as the user’s own words
+`$.session.send`| Sends a message that another session’s or subagent’s Claude reads
+
+In the `hooks:` line, [`tool.call`](</docs/en/plugins/mods/reference#tools>) and [`prompt.submit`](</docs/en/plugins/mods/reference#prompts-and-what-claude-reads>) mean the mod sees every tool call and every prompt, and can change them. [`session.append`](</docs/en/plugins/mods/reference#session>) means the mod can rewrite each row of the conversation before it’s stored. [`ui.render{component=AskUserQuestion}`](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>) means the mod can redraw the dialog Claude uses to ask the user a question. `tool.check` means the mod can approve or deny a tool call before a permission prompt appears. Know what happens by default lists which of your rules and hooks take precedence over its answer.
+
+##
+
+
+
+Choose how much to allow
+
+Mod policies range from no installed mods at all to any mod a user chooses, with your own mod checking the others, and each one is a few managed settings. Find the policy you want in the first column and set what the second column names. [Deploy managed settings](</docs/en/managed-settings>) covers where managed settings live.
+
+What you want| Settings
+---|---
+No installed mods, with hooks untouched| Set `allowManagedModsOnly` and deploy no mods of your own
+No installed mods and no hooks at all, your managed hooks included| Set `disableAllHooks` to `true`
+Only your organization’s mods| Set the guard’s `allowManagedModsOnly` option, and install your mods so that they count as yours
+Any mod from marketplaces you approve| Keep your [marketplace restrictions](</docs/en/plugins/org#restrict-what-users-can-install>), and set `disableSideloadFlags` to `true`
+Any mod, with your own mod checking the others| Install your mod, and list it with `sec-default@builtin` in `prependPlugins`
+
+What each setting does:
+
+ * **`allowManagedModsOnly`** : an option on the built-in guard. Users’ own mods don’t load, and their settings hooks, status lines, and `/goal` keep working. Stop user-installed mods from loading lists what it covers.
+ * **`allowManagedHooksOnly`** : a wider setting. Only your organization’s mods and the mods built into Claude Code load. A mod a user installed themselves doesn’t. The setting also blocks hooks in users’ own settings files. Read [What runs under `allowManagedHooksOnly`](</docs/en/settings-reference#what-runs-under-allowmanagedhooksonly>) before you set it.
+ * **`disableAllHooks`** : the widest setting. In managed settings, it stops the mods in every installed plugin, yours included, and turns off every hook in settings files, so a `PreToolUse` hook in your managed settings no longer blocks anything. Custom status lines and `/goal` stop working too. Read [`disableAllHooks`](</docs/en/settings-reference#disableallhooks>) before you set it.
+ * **`disableSideloadFlags`** : rejects `--plugin-dir` and `--plugin-url` at startup, and keeps mods Claude writes during a session from loading. The setting also rejects `--agents` and `--mcp-config`. Read [`disableSideloadFlags`](</docs/en/settings-reference#disablesideloadflags>) before you set it.
+
+Mods built into Claude Code, such as `AGENTS.md` support, aren’t affected by these settings. Each has [its own switch](</docs/en/plugins/mods/overview#mods-built-into-claude-code>). A user whose mod didn’t load finds the reason in their debug log. [Refusal messages](</docs/en/plugins/mods/troubleshoot#refusal-messages>) lists the lines for `allowManagedHooksOnly` and `disableAllHooks`, and [Messages from the built-in guard](</docs/en/plugins/mods/troubleshoot#messages-from-the-built-in-guard>) has the line for `allowManagedModsOnly`.
+
+###
+
+
+
+Allow only your organization’s mods
+
+To run your organization’s mods and block the ones users bring, deploy the settings from the **Only your organization’s mods** row of the policy table, plus `disableSideloadFlags`. With this complete `managed-settings.json`, Claude Code refuses users’ own mods, so none of their hooks run, and your policy mod runs ahead of other mods:
+
+managed-settings.json
+
+ {
+ "extraKnownMarketplaces": {
+ "acme-tools": {
+ "source": { "source": "directory", "path": "/opt/acme/claude-plugins" }
+ }
+ },
+ "enabledPlugins": { "acme-guard@acme-tools": true },
+ "prependPlugins": ["acme-guard@acme-tools", "sec-default@builtin"],
+ "pluginConfigs": {
+ "cc-plugin-sec-default@builtin": {
+ "options": { "allowManagedModsOnly": true }
+ }
+ },
+ "disableSideloadFlags": true
+ }
+
+Each group of keys does one job:
+
+ * **`extraKnownMarketplaces`, `enabledPlugins`, and `prependPlugins`**: install your mod so that it counts as yours, and run it first with the guard after it. Install your organization’s mods and set the order covers the directory these keys point at.
+ * **`pluginConfigs`** : sets the guard’s `allowManagedModsOnly` option, so Claude Code refuses users’ own mods. Their settings hooks, status lines, and `/goal` keep working.
+ * **`disableSideloadFlags`** : see [`disableSideloadFlags`](</docs/en/settings-reference#disablesideloadflags>) for the flags it rejects at startup
+
+To confirm the policy on a test machine, in your shell start a session with `claude --debug` and read the debug log:
+
+ * **Your mod** : its `hooks module` line has `tier prepend`
+ * **A mod the user installed** : a line reads `refused by cc-plugin-sec-default: mods are limited to your organization's by policy (allowManagedModsOnly)`. An earlier line says that mod’s hooks module `loaded`, so look for the refusal.
+ * **A plugin directory** : `claude --plugin-dir ./any-mod` exits with a message that starts `--plugin-dir is disabled by your organization's managed settings (disableSideloadFlags)`
+
+To also limit which marketplaces users can add, combine this file with your [marketplace restrictions](</docs/en/plugins/org#restrict-what-users-can-install>).
+
+###
+
+
+
+Apply your plugin controls to mods
+
+A mod is a plugin, so the ways you [manage plugins for your organization](</docs/en/plugins/org>) also apply to a plugin that holds a mod:
+
+ * **See which plugins load across your fleet** : [Audit and review](</docs/en/plugins/org#audit-and-review>)
+ * **Decide when a plugin you reviewed can update** : [Set update policy](</docs/en/plugins/org#set-update-policy>)
+ * **Give one group a different policy, such as a pilot** : [Plan for what managed settings can’t enforce](</docs/en/plugins/org#plan-for-what-managed-settings-can%E2%80%99t-enforce>)
+ * **Check which apps and session kinds apply the plugin keys** : [When each surface applies the plugin keys](</docs/en/plugins/org#when-each-surface-applies-the-plugin-keys>)
+ * **Set up CI and containers** : [Seed containers and CI](</docs/en/plugins/org#seed-containers-and-ci>)
+ * **Offer mods your users may install** : [Host a marketplace](</docs/en/plugins/host-marketplace>). A mod that Claude Code copies from a GitHub, git, URL, or npm source counts as a user’s, not as your organization’s.
+
+###
+
+
+
+Set options on the built-in guard
+
+The built-in guard takes options. Set them in managed settings under `pluginConfigs`, keyed by `cc-plugin-sec-default@builtin`, as the example in Stop user-installed mods from loading does. The table gives what your users get with each option unset and with it set to `true`:
+
+Option| Unset| `true`
+---|---|---
+`allowManagedModsOnly`| Users’ own mods load| Only your organization’s mods, and mods built into Claude Code, load. Claude Code refuses every other mod, including one a user installed or named with `--plugin-dir`.
+`allowModsToOverrideDenyRules`| Deny rules take precedence over users’ mods| A user’s mod that approves tool calls can approve a call that a `deny` rule refuses
+
+These rules decide whether an option takes effect:
+
+ * **The id has one form here** : Claude Code reads the options only under `cc-plugin-sec-default@builtin`. `prependPlugins` accepts `sec-default@builtin` as well, and `pluginConfigs` doesn’t.
+ * **Only managed settings count** : the same entry in a user, project, or local settings file, or in a file passed with `--settings`, neither sets an option nor loosens one
+ * **The guard has to load** : if you set `prependPlugins`, name the guard in the list. Where the guard doesn’t load, neither option applies.
+ * **The guard fails closed** : if the guard can’t read managed settings, it refuses every user’s mod at load. If it can’t check the deny rules for a call that a user’s mod approved, it refuses the call.
+
+The [messages from the built-in guard](</docs/en/plugins/mods/troubleshoot#messages-from-the-built-in-guard>) are what your users see when either option applies.
+
+##
+
+
+
+Run your organization’s own mods
+
+You can deploy mods of your own to every user, choose where they run relative to users’ mods, and use one to enforce a policy.
+
+###
+
+
+
+Install your organization’s mods and set the order
+
+Your organization’s mods load where users’ mods don’t and can run ahead of them, so Claude Code has to be able to tell that a mod came from you. It treats a mod as your organization’s only when all of these are true:
+
+ * Managed `enabledPlugins` sets the mod’s plugin to `true`
+ * Managed settings name the plugin’s [marketplace](</docs/en/plugins/create-marketplace>) as a directory on the user’s machine, by absolute path. An `extraKnownMarketplaces` entry does that and registers the marketplace for the user too.
+ * The marketplace lists the plugin by a relative path, so Claude Code [loads it in place](</docs/en/plugins/loading#in-place-and-copied-plugins>) from that directory
+
+To meet them, have your device management copy the marketplace directory to the same path on every machine. Make the directory and every directory above it writable only by an administrator, as the managed settings file is. Anyone who can write there can rewrite your mod. Managed settings you deliver from the claude.ai admin console can carry the keys, but they can’t put the directory on a machine. The directory holds the marketplace’s manifest and the plugin:
+
+ /opt/acme/claude-plugins/
+ ├── .claude-plugin/
+ │ └── marketplace.json
+ └── plugins/
+ └── acme-guard/
+ ├── .claude-plugin/
+ │ └── plugin.json
+ └── hooks/
+ ├── hooks.json
+ └── register.js
+
+The manifest lists the plugin by its path relative to that directory:
+
+/opt/acme/claude-plugins/.claude-plugin/marketplace.json
+
+ {
+ "name": "acme-tools",
+ "owner": { "name": "Acme" },
+ "plugins": [
+ { "name": "acme-guard", "source": "./plugins/acme-guard", "description": "Acme policy mod" }
+ ]
+ }
+
+A plugin that Claude Code copies into its cache counts as a user’s, even when managed `enabledPlugins` enables it. That covers every plugin from a GitHub, git, URL, or npm source. Its mod runs among users’ mods, `prependPlugins` and `appendPlugins` skip it, and it doesn’t load under `allowManagedModsOnly` or `allowManagedHooksOnly`. The user’s debug log has a line that starts with the plugin’s id and `is enabled by managed settings, but`. Claude Code fires an event each time it’s about to act, such as run a tool, and passes it to each mod in turn. A mod that counts as yours [runs before users’ mods](</docs/en/plugins/mods/events#the-order-mods-run-in>) even when you list it nowhere. To set its place, list its id in one of two settings. The id is the plugin’s name, `@`, and the marketplace’s name, such as `acme-guard@acme-tools`.
+
+ * **`prependPlugins`** : your mod sees every event before any user’s mod and every result after. It can change the event, refuse it, or skip the users’ mods.
+ * **`appendPlugins`** : your mod runs after every user’s mod, so it sees only the events those mods pass on, in the form they pass them
+
+This example declares the `acme-tools` marketplace at `/opt/acme/claude-plugins`, enables `acme-guard` from it, and runs that mod first, with the built-in guard after it:
+
+managed-settings.json
+
+ {
+ "extraKnownMarketplaces": {
+ "acme-tools": {
+ "source": { "source": "directory", "path": "/opt/acme/claude-plugins" }
+ }
+ },
+ "enabledPlugins": { "acme-guard@acme-tools": true },
+ "prependPlugins": ["acme-guard@acme-tools", "sec-default@builtin"]
+ }
+
+Each key does one job:
+
+ * **`extraKnownMarketplaces`** : names the directory that holds the `acme-tools` marketplace. `path` is the absolute path of the directory that contains `.claude-plugin/marketplace.json`.
+ * **`enabledPlugins`** : turns `acme-guard` on for every user who receives these managed settings
+ * **`prependPlugins`** : puts `acme-guard` first and the built-in guard second, both ahead of any mod a user installs. Claude Code follows the order you list.
+
+To confirm that a user’s machine received the settings, see [Check that a policy is in force](</docs/en/managed-settings#check-that-a-policy-is-in-force>). To confirm where the mod runs, start a session on that machine with `claude --debug` and search the [debug log](</docs/en/plugins/mods/troubleshoot#read-the-debug-log>) for the mod’s id:
+
+ * **`hooks module acme-guard@acme-tools loaded`, with `tier prepend`**: the mod counts as your organization’s and runs first
+ * **The same line with`tier user`**: Claude Code treats it as a user’s mod. A second line, `prependPlugins names acme-guard@acme-tools, which is not an enabled managed plugin with a hooks module; skipped`, says the list skipped it.
+
+These rules decide which ids in the two lists take effect:
+
+ * **The list replaces the default** : when you set `prependPlugins` in managed settings, name `sec-default@builtin` in it to keep the built-in guard. The guard is built in and needs no `enabledPlugins` entry.
+ * **Your own ids must count as yours** : in managed settings, Claude Code skips an id whose plugin doesn’t meet the conditions for an organization’s mod
+ * **Repositories can’t set them** : Claude Code reads both settings from managed settings and never from a repository’s settings file. A user can set them in `~/.claude/settings.json` to order their own mods only on a machine with no managed settings, and only when they aren’t signed in with a Team or Enterprise plan. Anywhere else, Claude Code ignores both keys in user settings. A list there neither adds nor removes the built-in guard.
+
+###
+
+
+
+Enforce a policy with a mod of your own
+
+To keep every user’s mod out, you don’t need a mod of your own. Set `allowManagedModsOnly`. Write a policy mod when you want to allow some users’ mods and refuse others, or to record what mods do. Each time another mod is about to load, your mod receives the list that `claude plugin validate` prints, in an event named [`plugin.register`](</docs/en/plugins/mods/reference#other-mods>). A mod in `prependPlugins` can read that list and refuse the mod. It can also [handle any mods API call by name](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>) to record or refuse that call for every other mod. The name is the method without the `$.`, so a hook on `fs.write` sees every `$.fs.write` call. This policy mod refuses any user’s mod whose own code calls `$.process.run` or `$.process.spawn`. It also keeps an audit log, writing each tool call and each file a mod writes to the debug log. Because it runs first, the log records what was requested, before any user’s mod changes it. Save it as `acme-guard/hooks/register.js`:
+
+acme-guard/hooks/register.js
+
+ // The methods no user's mod may call, each spelled namespace.method
+ const BLOCKED_CALLS = ['process.run', 'process.spawn']
+
+ export function register(on) {
+ // Runs each time another mod is about to load
+ on('plugin.register', async ($, e, next) => {
+ // Keep the calls in that mod's code that are on the blocked list
+ const blocked = e.uses.calls.filter((call) => BLOCKED_CALLS.includes(call))
+ if (e.tier === 'user' && blocked.length > 0) {
+ // Returning refuse keeps the mod from loading, and the text is the reason
+ return { refuse: 'Acme policy: mods may not call ' + blocked.join(', ') }
+ }
+ // Let every other mod load
+ return next(e)
+ })
+
+ // Record each tool call, then let it go ahead unchanged
+ on('tool.call', async ($, e, next) => {
+ $.ui.log('audit tool.call ' + e.tool, { to: 'debug' })
+ return next(e)
+ })
+
+ // Record which mod wrote a file, then the path, quoted because the mod chose it
+ on('fs.write', async ($, e, next) => {
+ $.ui.log('audit fs.write by ' + next.origin.plugin + ' ' + JSON.stringify(e.path), { to: 'debug' })
+ return next(e)
+ })
+ }
+
+The file registers three hooks:
+
+ * **`plugin.register`** : decides whether another mod loads. It refuses a user’s mod that calls a blocked method and passes every other mod on.
+ * **`tool.call`** : writes a line such as `audit tool.call Bash` to the debug log for each tool call, and changes nothing
+ * **`fs.write`** : writes a line such as `audit fs.write by reader "/tmp/notes.md"` for each `$.fs.write` call another mod makes, and changes nothing. The mod’s name comes first and the path is quoted, so a path that a mod picks can’t pass for another field of the line.
+
+The `plugin.register` hook reads two fields of the event:
+
+ * **`e.tier`** : where the mod would run, one of `prepend`, `user`, `append`, or `builtin`. Every mod a person installs is `user`.
+ * **`e.uses.calls`** : the mods API methods the mod calls, each written `namespace.method` such as `process.run`, without the `$.` that `claude plugin validate` prints
+
+When a user installs a mod that calls `$.process.run`, the mod doesn’t load, and their debug log has a line that ends with `refused by acme-guard:` and your reason. The refusal also reaches the transcript in a [session that hot-reloads a plugin directory](</docs/en/plugins/mods/troubleshoot#find-out-why-a-mod-does-nothing>). To block a call without refusing the whole mod, return `{ deny: 'your reason' }` from a hook on that call’s name. To send the audit lines somewhere other than the debug log, call `$.http.fetch` from the same hooks. A session can run without your mod. If the worker thread that runs installed mods [crashes three times](</docs/en/plugins/mods/troubleshoot#mods-that-run-in-the-hooks-worker-are-off-for-this-session>), Claude Code unloads every mod that isn’t built in, including yours, until the user runs `/reload-plugins` or starts a new session. And a user who starts Claude Code with `--safe-mode` runs without installed mods, yours included. [Create a mod](</docs/en/plugins/mods/create>) covers the files a mod needs. [Test a policy mod](</docs/en/plugins/mods/test#test-a-mod-that-judges-other-mods>) has a test file for this policy mod.
+
+####
+
+
+
+Refuse mods when your check fails
+
+If your `plugin.register` hook throws or exceeds its time limit, Claude Code skips the hook, so the check fails open and the mod it was checking loads. To fail closed and refuse users’ mods, move the check into a named function and add a `.catch` handler that returns the refusal. This version of the file shows the `plugin.register` hook only, so keep the two audit hooks from the first version in `register`:
+
+acme-guard/hooks/register.js
+
+ const BLOCKED_CALLS = ['process.run', 'process.spawn']
+
+ // The same check as before, moved into a function of its own
+ async function checkMod($, e, next) {
+ const blocked = e.uses.calls.filter((call) => BLOCKED_CALLS.includes(call))
+ if (e.tier === 'user' && blocked.length > 0) {
+ return { refuse: 'Acme policy: mods may not call ' + blocked.join(', ') }
+ }
+ return next(e)
+ }
+
+ export function register(on) {
+ // The handler runs only when checkMod throws or exceeds its time limit
+ on('plugin.register', checkMod).catch(async ($, e, next) => {
+ // Let your organization's mods and built-in mods load
+ if (e.tier !== 'user') return next(e)
+ // Refuse the user's mod that couldn't be checked
+ return { refuse: 'Acme policy check failed, so this mod was not loaded' }
+ })
+ }
+
+With the handler in place, a mod that was being checked when the check threw or timed out doesn’t load, and the refusal line carries the second reason, as in `refused by acme-guard: Acme policy check failed, so this mod was not loaded`. The handler passes every mod outside the `user` tier to `next(e)`, so a failed check doesn’t stop the mods your organization lists. [Handle a hook that fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>) covers `.catch` for other events.
+
+##
+
+
+
+Next steps
+
+ * [Plugin security](</docs/en/plugins/security>): what any plugin can do on a user’s machine, and how to review one before it’s installed
+ * [Mods overview](</docs/en/plugins/mods/overview>): what a mod is and how it compares to hooks, skills, and MCP servers
+ * [The order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>): how `prependPlugins` and `appendPlugins` fit with users’ mods
+ * [Settings and environment variables](</docs/en/plugins/mods/reference#settings-and-environment-variables>): every setting named on this page in one table
--- a/admin-setup.md
+++ b/admin-setup.md
@@ -99,10 +99,29 @@
If your members sign in through claude.ai or the Anthropic API and you’re on a Claude Enterprise plan, you can also govern models from your organization’s admin settings without deploying anything:
* [Organization model restrictions](</docs/en/model-config#organization-model-restrictions>): disable individual models. Enforced server-side.
- * [Organization default model](</docs/en/model-config#organization-default-model>): set which model new sessions start on. Users can change it unless your organization enforces the default, which is available to a limited set of organizations; ask your Anthropic account team.
+ * [Organization default model](</docs/en/model-config#organization-default-model>): set which model new sessions start on. Members can still switch models. To return them to your default at launch, turn on the override that section describes. To limit which models they can pick, use [organization model restrictions](</docs/en/model-config#organization-model-restrictions>).
* [Organization effort limits](</docs/en/model-config#organization-effort-limits>): cap effort levels per role. Enforced server-side.
-None of these controls reach sessions on Amazon Bedrock, Google Cloud’s Agent Platform, Microsoft Foundry, or [Claude Platform on AWS](</docs/en/claude-platform-on-aws>). On those providers, use managed settings instead: `availableModels` for restrictions, `model` for a default, and [`maxEffortLevel`](</docs/en/settings-reference#maxeffortlevel>) for an effort cap. [Cloud sessions](</docs/en/claude-code-on-the-web>) have their own admin surface: on the Cloud environments page in admin settings, Owners create [organization-shared environments](</docs/en/cloud-environments#organization-shared-environments>) that set the [network access level](</docs/en/cloud-environments#network-access>), environment variables, and setup script for members’ cloud sessions. Owners choose the organization’s default environment separately, at [claude.ai/admin-settings/claude-code](<https://claude.ai/admin-settings/claude-code>). Permission rules and sandboxing cover different layers. Denying WebFetch blocks Claude’s fetch tool, but if Bash is allowed, `curl` and `wget` can still reach any URL. Sandboxing closes that gap with a network domain allowlist enforced at the OS level. For the threat model these controls defend against, see [Security](</docs/en/security>).
+None of these controls reach sessions on Amazon Bedrock, Google Cloud’s Agent Platform, Microsoft Foundry, or [Claude Platform on AWS](</docs/en/claude-platform-on-aws>). On those providers, use managed settings instead: `availableModels` for restrictions, `model` for a default, and [`maxEffortLevel`](</docs/en/settings-reference#maxeffortlevel>) for an effort cap. [Cloud sessions](</docs/en/claude-code-on-the-web>) have their own admin surfaces on claude.ai:
+
+ * **Cloud environments page** : Owners create [organization-shared environments](</docs/en/cloud-environments#organization-shared-environments>) that set the [network access level](</docs/en/cloud-environments#network-access>), environment variables, and setup script for members’ cloud sessions.
+ * **Default environment** : Owners choose the organization’s default environment separately, at [claude.ai/admin-settings/claude-code](<https://claude.ai/admin-settings/claude-code>).
+ * **GitHub page** : see Connected GitHub accounts for the GitHub accounts linked to your organization.
+
+Permission rules and sandboxing cover different layers. Denying WebFetch blocks Claude’s fetch tool, but if Bash is allowed, `curl` and `wget` can still reach any URL. Sandboxing closes that gap with a network domain allowlist enforced at the OS level. For the threat model these controls defend against, see [Security](</docs/en/security>).
+
+###
+
+
+
+Connected GitHub accounts
+
+On Team and Enterprise plans, [**Admin settings > GitHub**](<https://claude.ai/admin-settings/github>) lists the GitHub organizations and personal accounts linked to your Claude organization through the [Claude GitHub App](<https://github.com/apps/claude>). Claude Code, [Claude Tag](<https://claude.com/docs/claude-tag/admins/configure-github>), and Claude Security share the list. Opening it requires an admin role in your Claude organization. An admin or a member can link an account:
+
+ * **Admin connection** : an admin clicks **Connect** on that page and installs the Claude GitHub App on a GitHub organization. Linking an organization this way requires someone who is both an owner of the GitHub organization and an admin of your Claude organization.
+ * **Member connection** : when a member connects their GitHub account to Claude, for example while [setting up cloud sessions](</docs/en/web-quickstart#connect-github>), Claude links the GitHub accounts that member owns where the Claude GitHub App is already installed. That can include their personal account and GitHub organizations they own.
+
+A row marked **Not linked** comes from your own GitHub sign-in. It’s an account you can see on GitHub where the Claude GitHub App is installed. To unlink an account from your Claude organization, open its row’s menu and select **Unlink from this workspace**. Unlinking leaves the Claude GitHub App installed on GitHub, and the account is linked again the next time one of its owners connects GitHub to Claude. To keep it from being linked again, uninstall the Claude GitHub App from that account on GitHub. On Enterprise plans, the [Compliance API](<https://platform.claude.com/docs/en/api/compliance/activities/list>) activity types for linking and unlinking are `github_app_installation_linked` and `github_app_installation_unlinked`.
##
--- a/advisor.md
+++ b/advisor.md
@@ -71,7 +71,7 @@
* Your organization’s [`availableModels`](</docs/en/model-config#restrict-model-selection>) allowlist excludes the requested model
* You requested Fable and your account still requires the usage-credits consent
-If you start a [background session](</docs/en/agent-view>) with `--advisor` and one of these applies, Claude Code starts the session without the advisor instead of exiting.
+If you start a [background session](</docs/en/agent-view>) with `--advisor` and one of these applies, Claude Code starts the session without the advisor instead of exiting. If the requested model can act as an advisor but ranks below the session’s main model, Claude Code starts the session anyway. Outside background sessions, it also warns at launch that the model `cannot advise` the main model.
##
@@ -79,24 +79,24 @@
Choose an advisor model
-Both Claude Code and the API require an advisor at least as capable as the main model, and the two rank some models differently. The accepted advisors for each main model are:
-
-Main model| Accepted advisors| Notes
----|---|---
-Haiku 4.5| Fable, Opus, Sonnet| Haiku can call the advisor but cannot act as one
-Sonnet 4.6| Fable, Opus, Sonnet|
-Sonnet 5| Fable, Opus 4.7 or later, Sonnet 5 or later| A Sonnet 4.6 advisor is rejected, and the API refuses an Opus 4.6 advisor
-Sonnet 5.5| Fable, Opus 5 or later, Sonnet 5.5| A Sonnet 4.6 advisor is rejected, and the API refuses a Sonnet 5, Opus 4.6, Opus 4.7, or Opus 4.8 advisor
-Opus 4.6| Fable, Opus, Sonnet 5 or later| A Sonnet 4.6 advisor is rejected
-Opus 4.7 or Opus 4.8| Fable, and Opus 4.7 or later| An Opus 4.6 or Sonnet advisor is rejected
-Opus 5.5 or Opus 5| Fable, and Opus 5 or later| An Opus 4.6 or Sonnet advisor is rejected, and the API refuses an Opus 4.7 or Opus 4.8 advisor
-Fable 5| Fable 5.1 or Fable 5| An Opus or Sonnet advisor is rejected
-Fable 5.1| Fable 5.1| An Opus or Sonnet advisor is rejected, and the API refuses a Fable 5 advisor
-
-Fable 5.1 requires Claude Code v2.1.257 or later. Both Fable models require [Fable access](</docs/en/model-config#work-with-fable>). Set the advisor as `fable`, `opus`, or `sonnet`. These aliases resolve to Claude Code’s built-in default version for each model family, which advances with new Claude Code releases. You can also pass a full model ID such as `claude-opus-5-5`. Subagents inherit the configured advisor and apply the same pairing check against their own model. Claude Code validates the pairing before sending a request, and the API validates it again:
-
- * For an advisor the table lists as rejected, Claude Code doesn’t attach it to the main model’s requests. The `/advisor` command output and a notification show this. Subagents whose own model satisfies the pairing may still use the advisor.
- * For an advisor the table lists as refused by the API, Claude Code attaches it and the API refuses it. Claude Code then resends that request without the advisor, and the rest of the conversation runs without one, so you see no error and get no advisor calls. Pick an accepted advisor with `/advisor`; the change takes effect after `/clear` or `/compact` and in new sessions.
+Claude Code ranks models by capability for the advisor role, and an advisor must rank at or above your session’s main model. Rows run from the lowest-ranked main model to the highest:
+
+Main model| Accepted advisors
+---|---
+Haiku 4.5| Fable, Opus, Sonnet
+Sonnet 4.6| Fable, Opus, Sonnet
+Opus 4.6| Fable, Opus, Sonnet 5 or later
+Sonnet 5| Fable, Opus 4.7 or later, Sonnet 5 or later
+Opus 4.7 or Opus 4.8| Fable, Opus 4.7 or later, Sonnet 5.5
+Sonnet 5.5| Fable, Opus 5 or later, Sonnet 5.5
+Opus 5 or Opus 5.5| Fable, Opus 5 or later
+Fable 5| Fable 5.1 or Fable 5
+Fable 5.1| Fable 5.1
+
+Fable 5.1 requires Claude Code v2.1.257 or later. Fable models require [Fable access](</docs/en/model-config#work-with-fable>). Sonnet 5.5 as the advisor for an Opus 4.7 or Opus 4.8 main model requires Claude Code v2.1.287 or later. Set the advisor as `fable`, `opus`, or `sonnet`. These aliases resolve to Claude Code’s [built-in default version](</docs/en/model-config#model-aliases>) for each model family, which advances with new Claude Code releases. You can also pass a full model ID such as `claude-opus-5-5`. Haiku can call the advisor but can’t act as one. Subagents inherit the configured advisor and apply the same pairing check against their own model. Claude Code validates the pairing before sending a request, and the API validates it again:
+
+ * For an advisor that ranks below the main model, Claude Code doesn’t attach it to the main model’s requests. The `/advisor` command output and a notification show this; see [Advisor is less capable than the current main model](</docs/en/errors#advisor-is-less-capable-than-the-current-main-model>). Subagents whose own model satisfies the pairing may still use the advisor.
+ * If the API refuses the pairing of an advisor that Claude Code attached, Claude Code resends that request without the advisor. The conversation continues without one, so you see no error and get no advisor calls. If you then pick a different advisor with `/advisor`, it takes effect after `/clear` or `/compact` and in new sessions.
* If the main model or the advisor is a model Claude Code does not recognize, the advisor is not attached.
###
--- a/agent-loop.md
+++ b/agent-loop.md
@@ -313,7 +313,7 @@
A few strategies for long-running agents:
- * **Use subagents for subtasks.** Each subagent starts with a fresh conversation (no prior message history, though it does load its own system prompt and project-level context like CLAUDE.md). It does not see the parent’s turns, and only its final response returns to the parent as a tool result. The main agent’s context grows by that summary, not by the full subtask transcript. See [What subagents inherit](</docs/en/agent-sdk/subagents#what-subagents-inherit>) for details.
+ * **Use subagents for subtasks.** Each subagent starts with a fresh conversation (no prior message history, though it does load its own system prompt and project-level context like CLAUDE.md). It does not see the parent’s turns, and only its final response returns to the parent. The main agent’s context grows by that summary, not by the full subtask transcript. See [What subagents inherit](</docs/en/agent-sdk/subagents#what-subagents-inherit>) for details.
* **Be selective with tools.** Every tool definition takes context space. Use the `tools` field on [`AgentDefinition`](</docs/en/agent-sdk/subagents#agentdefinition-configuration>) to scope subagents to the minimum set they need.
* **Watch MCP server costs.** [MCP tool search](</docs/en/agent-sdk/mcp#mcp-tool-search>) defers MCP tool schemas by default and loads them on demand. When tool search is off or has fallen back to upfront loading, each MCP server adds all its tool schemas to every request, so a few servers with many tools can consume significant context before the agent does any work. See [Configure tool search](</docs/en/agent-sdk/tool-search#configure-tool-search>) for the configurations where the fallback applies.
* **Use lower effort for routine tasks.** Set effort to `"low"` for agents that only need to read files or list directories. This reduces token usage and cost.
--- a/agent-teams.md
+++ b/agent-teams.md
@@ -163,7 +163,12 @@
* **In-process mode** : use the up and down arrow keys in the agent panel to select a teammate, then press Enter to view its session and type to send it a message. Press `x` on a selected teammate to stop it. Press Ctrl+T to toggle the task list.
* **Split-pane mode** : click into a teammate’s pane to interact with their session directly. Each teammate has a full view of their own terminal.
-While you’re viewing an in-process teammate, plain text and [skills](</docs/en/skills>) go to that teammate, but built-in commands still run in the lead’s session. A teammate’s model and fast mode are fixed when it spawns, so `/model` and `/fast` only change the lead’s settings. As of v2.1.199, typing either command while viewing a teammate shows a notice that the change applies to the lead; earlier versions applied it to the lead with no indication. `/effort` still applies to the viewed teammate’s later turns, because teammates follow the lead’s [effort level](</docs/en/model-config#adjust-effort-level>).
+While you’re viewing an in-process teammate, plain text and [skills](</docs/en/skills>) go to that teammate, and built-in commands go to the lead’s session, with these safeguards:
+
+ * `/compact`, `/clear`, and `/rewind` act on the lead’s conversation, so Claude Code asks you to confirm before running one of them from this view.
+ * `/model` and `/fast` set the lead’s model and fast mode, not the teammate’s, so they don’t run from this view. A notice tells you why.
+
+A teammate’s model and fast mode are fixed when it spawns. `/effort` still applies to the viewed teammate’s later turns, because teammates follow the lead’s [effort level](</docs/en/model-config#adjust-effort-level>).
###
--- a/agent-view.md
+++ b/agent-view.md
@@ -180,7 +180,19 @@
* A finished session: its result
* A working session: its full status sentence
-Any pull requests linked to the session are listed next. For a session that’s waiting on you, a line such as `waiting 3m` below them shows how long it has been waiting, and it’s the only time shown in the panel. The age at the right edge of the row is a different number: it counts from when the session started. Most of the time the peek panel is enough and you don’t need to open the full transcript. Type a reply in the peek panel and press `Enter` to send it to that session. When the session asks a question with predefined choices, the peek panel shows them as a numbered list and you can press a number key to pick one. A permission prompt shows as text describing what the session wants to run, without numbered options. Type a reply to answer it, or attach to answer with the standard prompt. For other blocked sessions, press `Tab` to fill the input with a suggested reply you can edit before sending. Prefix a reply with `!` to send a Bash command instead. When a [`PermissionRequest`](</docs/en/hooks#permissionrequest>) or [`PreToolUse`](</docs/en/hooks#pretooluse>) hook returns output Claude Code can’t validate for the call the session is asking about, the row shows the hook event and `hook output invalid:` with the validation error before the pending request’s text. For a hook that fails another way, the row says the hook failed. The session still waits on the same request. A reply that can’t be delivered, because the background service is unreachable or the send fails, is saved and sent to the session as its next prompt when its process starts again, and the error message says the reply was saved. A reply prefixed with `!` isn’t saved, because the saved text would reach the session as a plain prompt rather than run as a Bash command. With [voice dictation](</docs/en/voice-dictation>) enabled, hold or tap your push-to-talk key while the reply input is focused to dictate a reply instead of typing it. The same works in the dispatch input at the bottom of agent view. Use `↑` and `↓` to peek at adjacent sessions without closing the panel, or `→` to attach.
+Any pull requests linked to the session are listed next. For a session that’s waiting on you, a line such as `waiting 3m` below them shows how long it has been waiting, and it’s the only time shown in the panel. The age at the right edge of the row is a different number: it counts from when the session started. Most of the time the peek panel is enough and you don’t need to open the full transcript. Type a reply in the peek panel and press `Enter` to send it to that session. Prefix a reply with `!` to send a Bash command instead. What happens to the reply depends on the session and on what you send:
+
+ * A session that’s working: the reply joins the session’s [message queue](</docs/en/interactive-mode#queue-messages-while-claude-works>) instead of interrupting the response, and takes effect [when queued input does](</docs/en/interactive-mode#when-claude-code-sends-what-you-queued>). A [command](</docs/en/commands>) waits for the turn to end, even one that runs as soon as you type it at a session’s own prompt
+ * A reply that is exactly `/stop`: stops the session at once instead of being delivered to it, whether the session is working or waiting on you
+ * A shell job: the reply, `/stop` included, goes to the command’s terminal as typed input
+
+When the session is waiting on you, how you answer from the peek panel depends on what it’s waiting for:
+
+ * A question with predefined choices: the panel lists the choices by number. With the reply input empty, press a choice’s number to fill it in, then `Enter` to send it, or type your own answer instead
+ * A question without predefined choices: type your answer. When the empty input shows a suggested reply, press `Tab` to fill it in and edit it before sending
+ * A permission prompt or another dialog, such as a [sandbox](</docs/en/sandboxing>) prompt or an MCP server’s [request for input](</docs/en/mcp#respond-to-mcp-elicitation-requests>): replying doesn’t answer it. Your reply waits in the queue. To answer the dialog, attach with `→`
+
+When a [`PermissionRequest`](</docs/en/hooks#permissionrequest>) or [`PreToolUse`](</docs/en/hooks#pretooluse>) hook returns output Claude Code can’t validate for the call the session is asking about, the row shows the hook event and `hook output invalid:` with the validation error before the pending request’s text. For a hook that fails another way, the row says the hook failed. The session still waits on the same request. A reply that can’t be delivered, because the background service is unreachable or the send fails, is saved and sent to the session as its next prompt when its process starts again, and the error message says the reply was saved. A reply prefixed with `!` isn’t saved, because the saved text would reach the session as a plain prompt rather than run as a Bash command. With [voice dictation](</docs/en/voice-dictation>) enabled, hold or tap your push-to-talk key while the reply input is focused to dictate a reply instead of typing it. The same works in the dispatch input at the bottom of agent view. Use `↑` and `↓` to peek at adjacent sessions without closing the panel, or `→` to attach.
###
@@ -215,7 +227,7 @@
* Press `Ctrl+T` to pin a session to the top and keep its process running while idle
* Press `Shift+↑` or `Shift+↓` to reorder sessions
* Press `Ctrl+R` to rename a session
- * Press `Enter` on a group header to collapse it
+ * Press `Enter` on a group header to collapse it, except while a filter is active, when every group stays expanded
To remove a session from the list, press `Ctrl+X` to stop it and `Ctrl+X` again within two seconds to delete it. Pressing `Ctrl+X` on a group header deletes every session in that group after confirmation. The second press deletes the session even when the stop attempt fails, for example because the background service isn’t responding: the confirmation stays active for another two seconds, and the delete ends the session’s process itself. Press `Esc` to dismiss the confirmation without deleting. Except in the kept cases covered in What deleting a session removes, deleting removes the session from the list, and a worktree Claude created for it is removed, kept, or left in place depending on how you delete and what the worktree holds. The conversation transcript always stays on your local machine, available through `claude --resume`. To bring a session back on Claude Code v2.1.212 or later, type `/resume` in the dispatch input. A picker opens with past sessions of the repository you opened agent view from, newest first, including sessions you deleted from the list; sessions that already have a row aren’t listed. `↑`/`↓` move the selection, `Enter` resumes the selected session as a background session so it rejoins the list as a row, and `Esc` closes the picker. The picker opens only for a bare `/resume`. A targeted, scoped, or restricted resume can’t be served by the picker, so agent view shows the `attach to a session to run it` hint instead when:
@@ -232,14 +244,18 @@
Filter sessions
-Type in the dispatch input to filter instead of dispatching:
+Start the dispatch input with one of these filters to narrow the list as you type:
Filter| Shows
---|---
`a:<name>`| Sessions running the named agent
-`s:<state>`| Sessions in the given state, such as `s:working`. Also accepts `s:blocked` for everything waiting on you
-`#<number>` or a pull or merge request URL| The session working on that pull request or merge request
+`s:<state>`| Sessions in the given state, such as `s:working`, or under the given group header, such as `s:ready` for `Ready for review`. `s:blocked` lists everything waiting on you
+`n:<text>`| Sessions whose name or first prompt contains the text, such as `n:login`. Requires Claude Code v2.1.287 or later
+`o:<text>`| Sessions whose result contains the text, such as `o:merged`. A bare `o:` lists every session that has reported a result
+A pull or merge request number, such as `#1234`, or its URL| The session working on that pull request or merge request
Any other URL| The session whose first prompt contained that URL
+
+To combine filters, start with `a:`, `s:`, `n:`, or `o:` and add more, separated by spaces. The list shows the sessions that match all of them. For example, `s:blocked a:reviewer` lists the `reviewer` sessions that are waiting on you. While a filter is active, groups you collapsed expand to show their matches and the first match is selected, so pressing `Enter` opens it. Clear the input to remove the filter, and those groups collapse again.
###
@@ -252,7 +268,9 @@
Shortcut| Action
---|---
`↑` / `↓`| Move between rows
-`Enter`| Attach to the selected session, or dispatch if there’s text in the input
+`PgUp` / `PgDn`| Move up or down by a screenful of rows
+`Home` / `End`| Jump to the first or last row
+`Enter`| Attach to the selected session, or submit the input’s text if it isn’t a filter
`Space`| Open or close the peek panel for the selected session
`Shift+Enter`| Insert a newline in the dispatch input, [as in the main prompt](</docs/en/terminal-config#enter-multiline-prompts>)
`Ctrl+Enter`| Dispatch and attach immediately, in terminals where the `?` overlay lists `ctrl+enter to start and open`
@@ -883,6 +901,8 @@
Version| Change
---|---
+v2.1.287| The `n:<text>` filter finds sessions by name or first prompt. While any filter is active, groups you collapsed expand to show their matches and the first match is selected, so `Enter` opens it.
+v2.1.287| A command sent as a peek reply runs when the session’s current turn ends, including the commands that run as soon as you type them at a session’s own prompt. A reply that is exactly `/stop` stops the session at once.
v2.1.281| A [`--setting-sources`](</docs/en/cli-reference#cli-flags>) restriction carries over to a session you background with `←` or `/bg` and to the sessions you dispatch from agent view. Before this release, the spawned session loaded every settings source.
v2.1.281| `claude --bg`, and the commands that restart a session, check workspace trust for the session’s directory first. From a terminal in that directory, the trust dialog appears if you haven’t accepted it; where no dialog can appear, such as in a script, the command exits with a [`Workspace not trusted`](</docs/en/errors#workspace-not-trusted-when-dispatching-a-background-session>) error.
v2.1.274| After an auto-update, an agent view you’ve been away from for about an hour can relaunch itself onto the new build. When it does, it keeps the dispatch defaults you opened it with: `--model`, `--effort`, `--permission-mode`, `--allow-dangerously-skip-permissions`, and `--agent`. Before this release, the relaunched view kept only `--cwd` and configuration flags such as `--settings` and `--mcp-config`, so sessions you dispatched afterward started without those defaults.
--- a/agents.md
+++ b/agents.md
@@ -47,7 +47,7 @@
The command for checking on running work depends on which approach you used:
* For background sessions, `claude agents` opens [agent view](</docs/en/agent-view>): one screen showing every session, its state, and which ones need your input.
- * For subagents in the current session, named background subagents appear in the @-mention typeahead with their status. As of v2.1.198, `/agents` no longer opens a panel; it prints a notice pointing to the subagent file locations. To [create and edit custom subagents](</docs/en/sub-agents#configure-subagents>), ask Claude or edit the files directly. Despite the similar name, `/agents` is separate from `claude agents`.
+ * For subagents in the current session, named background subagents appear in the @-mention typeahead with their status. The `/agents` command prints a notice pointing to the subagent file locations. To [create and edit custom subagents](</docs/en/sub-agents#configure-subagents>), ask Claude or edit the files directly. Despite the similar name, `/agents` is separate from `claude agents`.
* For anything running in the background of the current session, `/tasks` lists each item and lets you check on, attach to, or stop it. The list also includes subagents that have finished.
* For dynamic workflows, `/workflows` lists running and completed runs, the phase each is in, and how many agents have finished.
--- a/amazon-bedrock.md
+++ b/amazon-bedrock.md
@@ -378,7 +378,7 @@
}
}
-If your organization delivers the guardrail headers through a [Claude apps gateway](</docs/en/claude-apps-gateway>) policy instead, they count as [settings that need approval](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>).
+If your organization delivers the guardrail headers through a [Claude apps gateway](</docs/en/claude-apps-gateway>) policy instead, they count as [settings that need approval](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>). When the guardrail blocks a response partway through, the text streamed so far stays and the reply ends with the message configured on the guardrail for blocked responses.
##
--- a/anthropic-marketplaces.md
+++ b/anthropic-marketplaces.md
@@ -33,7 +33,7 @@
The demo marketplace in `anthropics/claude-code`
-If a tutorial or an older set of instructions tells you to run `/plugin marketplace add anthropics/claude-code`, that adds the demo marketplace, named `claude-code-plugins`. It isn’t the official marketplace, which Claude Code already added for you. Most of the demo marketplace’s plugins are also in the official marketplace under the same names. For example, `code-review`, `feature-dev`, `commit-commands`, and `security-guidance` are in both. Install those from `claude-plugins-official` so you don’t have two copies installed.
+If a tutorial or an older set of instructions tells you to run `/plugin marketplace add anthropics/claude-code`, that adds the demo marketplace, named `claude-code-plugins`. It isn’t the official marketplace. Most of the demo marketplace’s plugins are also in the official marketplace under the same names. For example, `code-review`, `feature-dev`, `commit-commands`, and `security-guidance` are in both. Install those from `claude-plugins-official` so you don’t have two copies installed.
##
@@ -41,7 +41,7 @@
Find plugins in the official marketplace
-The official marketplace, `claude-plugins-official`, is the one Claude Code adds for you. Most of what it lists comes from partners and other authors rather than from Anthropic: tool vendors publish plugins that connect Claude Code to their services, and Anthropic maintains a smaller set of its own, such as `commit-commands`, `code-review`, `feature-dev`, and the [language server plugins](</docs/en/plugins/code-intelligence>). The catalog changes often, so this page doesn’t list it. To see what’s in it, use the **Discover** tab of `/plugin` in a Claude Code session, which you can search, or browse [Claude Marketplace](<https://claude.com/marketplace/plugins>) on the web.
+By default, Claude Code adds the official marketplace, `claude-plugins-official`, for you. Most of what it lists comes from partners and other authors rather than from Anthropic: tool vendors publish plugins that connect Claude Code to their services, and Anthropic maintains a smaller set of its own, such as `commit-commands`, `code-review`, `feature-dev`, and the [language server plugins](</docs/en/plugins/code-intelligence>). The catalog changes often, so this page doesn’t list it. To see what’s in it, use the **Discover** tab of `/plugin` in a Claude Code session, which you can search, or browse [Claude Marketplace](<https://claude.com/marketplace/plugins>) on the web.
##
@@ -51,12 +51,12 @@
You can search Anthropic’s marketplaces for a plugin in Claude Code, on the web, or on GitHub:
- * **In Claude Code, by browsing** : run `/plugin` in an interactive session. Its **Discover** tab lists the plugins from the marketplaces you’ve added.
- * **In Claude Code, by name** : run `/plugin install <name>` in a session, which looks the name up in the marketplaces you’ve added. If the plugin is in one of them, its details open in the `/plugin` panel, and nothing installs until you choose an [installation scope](</docs/en/plugins/install#install-a-plugin>) and confirm there. If it isn’t, you see `Plugin "<name>" not found in any marketplace`.
+ * **In Claude Code, by browsing** : run `/plugin` in an interactive session. Its **Discover** tab lists the plugins from your marketplaces.
+ * **In Claude Code, by name** : run `/plugin install <name>` in a session, which looks the name up in your marketplaces. If the plugin is in one of them, its details open in the `/plugin` panel, and nothing installs until you choose an [installation scope](</docs/en/plugins/install#install-a-plugin>) and confirm there. If it isn’t, you see `Plugin "<name>" not found in any marketplace`.
* **On the web** : search the full catalog on [Claude Marketplace](<https://claude.com/marketplace/plugins>), which shows install counts and marks some plugins **Anthropic verified**.
* **On GitHub** : open `.claude-plugin/marketplace.json` in the marketplace’s repository, such as [`anthropics/claude-plugins-official`](<https://github.com/anthropics/claude-plugins-official>). That file is the catalog itself.
-Anthropic’s directory is separate from these marketplaces. The directory is the catalog on claude.ai, and `/plugin` doesn’t list it. A plugin you add from the directory on claude.ai reaches Claude Code through [account sync](</docs/en/plugins/loading#synced-plugins>). To list your own plugin there, see [Submit to Anthropic’s directory](</docs/en/plugins/publish#submit-to-anthropics-directory>). To install from the desktop app or from a script, or to see what a cloud session loads, see [Install plugins](</docs/en/plugins/install>).
+Anthropic’s directory is separate from these marketplaces. The directory is the catalog on claude.ai. A plugin you add from the directory on claude.ai reaches Claude Code through [account sync](</docs/en/plugins/loading#synced-plugins>). To list your own plugin there, see [Submit to Anthropic’s directory](</docs/en/plugins/publish#submit-to-anthropics-directory>). To install from the desktop app or from a script, or to see what a cloud session loads, see [Install plugins](</docs/en/plugins/install>).
###
Show diff (203 lines)
--- a/api.md
+++ b/api.md
@@ -0,0 +1,200 @@
+The mods API is the set of methods a mod calls to act: add commands and tools, call a model, run work between events, and reach the file system, processes, and the network. Every hook receives it as its first argument, `$`, with the methods grouped in namespaces such as `$.ui` and `$.fs`. [Events](</docs/en/plugins/mods/events>) decide when a hook runs, and the mods API is what the hook calls once it does. Build your [first mod](</docs/en/plugins/mods/create>) before you start here. For every method, see [mods API methods](</docs/en/plugins/mods/reference#mods-api-methods>) or read [the types for your build](</docs/en/plugins/mods/create#get-the-types-for-your-build>).
+
+##
+
+
+
+Add a command or a tool
+
+A mod can add a command for the user to run and a tool for Claude to call. Register both in a [`session.start`](</docs/en/plugins/mods/reference#session>) hook. Claude Code waits for that hook before the first prompt, so what you register is available from the first turn.
+
+###
+
+
+
+Add a command
+
+A command is for the user. Register it, then handle [`command.run`](</docs/en/plugins/mods/reference#commands-and-configuration>) for its name. This example adds a `/standup` command that takes an optional number of days:
+
+ on('session.start', async ($, e, next) => {
+ // Add /standup to the command list, with the description the user sees there
+ await $.command.register({ name: 'standup', description: 'Summarize what changed today', argumentHint: '[days]' })
+ return next(e)
+ })
+
+ // The matcher limits the hook to /standup, so other commands don't reach it
+ on('command.run', { command: 'standup' }, async ($, e) => {
+ // e.args is the text typed after the command name, or an empty string
+ return { text: 'Summary for the last ' + (e.args || '1') + ' day(s): ...' }
+ })
+
+After the session starts, `/standup` appears with its description in the list you see when you type `/`. The `argumentHint` shows in the prompt after you type the command and a space, as in `/standup [days]`. When you run `/standup 3`, the second hook returns `Summary for the last 3 day(s): ...`, and the transcript shows that text after the plugin’s name. The hook never calls `next`, because the command has no behavior other than yours. The `text` you return prints in the transcript and Claude reads it. To print nothing, as a command that only opens a [pane](</docs/en/plugins/mods/interface#pick-where-to-draw>) does, return `{}`. To let the command run while Claude is working, add `immediate: true` to the registration. Pick a name that no built-in command uses. Type `/` in a session to see them. `$.command.register` throws for a taken name, with a message such as `"/focus" refused: it is the built-in /focus`. A hook that throws is skipped, so the rest of your `session.start` hook doesn’t run either. Register commands last in that hook, or wrap the call in `try` and `catch`.
+
+###
+
+
+
+Add a tool
+
+A tool is for Claude. Register it with a name, a description Claude reads, and a JSON Schema for its input. Claude sees it under a longer name made of `mcp__`, your plugin’s name, two underscores, and the name you registered. You handle its calls in a [`tool.call`](</docs/en/plugins/mods/events#guard-or-change-a-tool-call>) hook filtered to that full name. This example, from a plugin named `my-mod`, registers `ticket`, so the full name is `mcp__my-mod__ticket`. It gives Claude a tool that looks up a ticket in an issue tracker:
+
+ on('session.start', async ($, e, next) => {
+ await $.tool.register({
+ name: 'ticket',
+ // Claude decides when to call the tool from this description
+ description: 'Look up a ticket by its id and return its title and status',
+ // The arguments Claude has to send: one required string named id
+ inputSchema: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'] },
+ })
+ return next(e)
+ })
+
+ // The full tool name is mcp__, the plugin's name, and the registered name
+ on('tool.call', { tool: 'mcp__my-mod__ticket' }, async ($, e) => {
+ // The tool's arguments are fields of e, so the id is e.id
+ const response = await $.http.fetch('https://tickets.example.com/api/' + encodeURIComponent(e.id))
+ // Return a result either way, so Claude learns when the lookup failed
+ return { result: response.ok ? response.text : 'Lookup failed with status ' + response.status }
+ })
+
+When you ask about a ticket, Claude can call `mcp__my-mod__ticket` with its id. The second hook fetches the ticket and returns the response body, which Claude reads as the tool’s result. When the server answers with an error status, Claude reads `Lookup failed with status` and the number.
+
+##
+
+
+
+Call a model
+
+A mod can ask a model a question of its own, outside the conversation, for a small job such as sorting or summarizing a piece of text. `$.model.complete` sends one prompt to a model with your session’s credentials and resolves to the reply. It has no conversation history. This hook answers a `/triage` command, registered as a command, by asking a small model to label the text typed after it:
+
+ on('command.run', { command: 'triage' }, async ($, e) => {
+ const r = await $.model.complete({
+ model: 'haiku',
+ // The system prompt sets the job, and the prompt carries the text to label
+ system: 'Reply with one word: bug, feature, or question.',
+ prompt: e.args,
+ // One word needs few tokens, and the call gives up after 15 seconds
+ maxTokens: 20,
+ timeoutMs: 15000,
+ })
+ // r.text exists only when the model answered, so check r.isAnswered first
+ const label = r.isAnswered ? r.text.trim() : 'unknown'
+ return { text: 'Label: ' + label }
+ })
+
+When you run `/triage the export button does nothing`, the mod sends that text to the model and prints its answer, such as `Label: bug`. Claude’s conversation isn’t part of the request. When the model doesn’t answer, the label is `unknown`. A Claude API failure doesn’t reject the call, so check `r.isAnswered`, and read `r.reason` when it’s `false`. The call rejects for a request Claude Code won’t send, such as a model your organization blocks. [The types for your build](</docs/en/plugins/mods/create#get-the-types-for-your-build>) list the other options, such as `effort`, and the [limits](</docs/en/plugins/mods/reference#limits>) give the `maxTokens` default. `$.model.fork({ prompt })` asks one question over the current conversation instead, with the same model and system prompt, so the Claude API serves most of it from the prompt cache. These calls use the user’s plan or API key.
+
+##
+
+
+
+Run work in the background
+
+Work that outlives one event, such as checking on something once a minute, runs on a timer you start from `session.start`. A hook itself runs for one event and has a [time limit](</docs/en/plugins/mods/reference#limits>) on its own execution time. Time spent waiting on `next` or on a mods API call doesn’t count, except a `$.clock.sleep`. `$.clock.every` and `$.clock.after` take the place of `setInterval` and `setTimeout`, with the delay in milliseconds first: `$.clock.after(5000, fn)` calls `fn` once, five seconds from now. Each returns a timer with a `cancel()` method, and `await $.clock.now()` gives the time in milliseconds. This hook looks up a pull request’s checks once a minute and shows the result under the prompt. `summarize` is a function of your own that turns the command’s JSON output into a few words:
+
+ on('session.start', async ($, e, next) => {
+ // Call the function every 60,000 milliseconds, starting one minute from now
+ $.clock.every(60_000, async () => {
+ const status = await $.process.run(['gh', 'pr', 'checks', '--json', 'state'])
+ // Replace the line under the prompt with the latest summary
+ $.ui.status('checks: ' + summarize(status.stdout))
+ })
+ // Return without waiting for the timer, so the session starts right away
+ return next(e)
+ })
+
+The session starts as usual. A minute later, a line appears under the prompt with a `⚠`, the mod’s name, and then `checks:` and your summary. It’s replaced once a minute after that. The timer’s callback runs outside any event, so it keeps running between turns and doesn’t start one. If the callback throws, the error goes to the [debug log](</docs/en/plugins/mods/troubleshoot#read-the-debug-log>) and the timer runs again at the next interval.
+
+###
+
+
+
+Show something without starting a turn
+
+A background job can show the user something without starting a turn. Each of these calls puts text in a different place:
+
+Call| What the user sees
+---|---
+`$.ui.status(text)`| One line under the prompt that stays until you change it. It starts with `⚠` and the mod’s name, as in `⚠ my-mod: checks: 3 passing`.
+`$.ui.toast(text)`| A toast notification at the top right, with the mod’s name above the text, that disappears after a few seconds
+`$.ui.log(text)`| A dim line in the transcript that Claude doesn’t read. It starts with `●` and the mod’s name, as in `● my-mod: build finished`.
+
+###
+
+
+
+Start a turn from a background job
+
+When a background job finds something that needs Claude’s attention, it can start a turn by submitting a prompt with `$.prompt.submit({ text })`. Claude reads the text after a sentence that names your mod as the sender. To send it as the user’s own words, without that sentence, add `asUser: true`. The call waits until the session is idle and then starts a new turn. It resolves when that turn starts, so don’t `await` it in a handler that runs while Claude is working.
+
+###
+
+
+
+Stop background work
+
+Timers stop when the module reloads. For long-running work inside a hook, [`next.signal`](</docs/en/plugins/mods/reference#the-hook-function>) is an `AbortSignal` that aborts when the event your hook is handling is abandoned, for example when the user interrupts, so pass it to anything long-running.
+
+##
+
+
+
+Send and receive messages between sessions
+
+A mod can send a plain-text message to another of your sessions or to one of this session’s subagents, and observe the messages that arrive and leave. `$.session.send({ to, text })` sends one, the same delivery the SendMessage tool makes. `to` is `{ sessionId }` for a session, `{ agentId }` for a subagent from `$.agent.list()`, or the string address a received message came from. The call resolves once the message is queued, with `{ isDelivered: true }`. When nothing was delivered it resolves with `{ isDelivered: false, reason }`, and `reason` says why. This hook answers a `/ping` command, registered as a command, by asking the session whose id you type after it for a status:
+
+ on('command.run', { command: 'ping' }, async ($, e) => {
+ // e.args is the session id typed after /ping
+ const sent = await $.session.send({ to: { sessionId: e.args }, text: 'Status? One line.' })
+ // The call resolves either way, so check isDelivered to learn what happened
+ if (!sent.isDelivered) $.ui.toast('Not delivered: ' + sent.reason)
+ // An empty result prints nothing in this session's transcript
+ return {}
+ })
+
+When the message is queued, nothing appears in your session, and the other session’s Claude reads `Status? One line.` When nothing was delivered, a toast notification gives the reason. `session.receive` and `session.send` let a mod observe the messages. Return `next(e)` from both to pass each message through unchanged:
+
+Event| Fires when| Useful fields
+---|---|---
+`session.receive`| A message arrives for this session, before Claude reads it| `e.text`, and `e.origin.kind`, such as `peer` or `peer-send-message` for another session or agent, `task-notification`, or `scheduled-trigger`. Return `{ consumed: reason }` to keep it from Claude.
+`session.send`| A message is about to leave, from the SendMessage tool or a mod| `e.to`, `e.text`, and `e.origin.kind`, which is `model` or `plugin`
+
+A session set to [refuse inbound messages](</docs/en/cross-session-messaging#control-inbound-messages>) refuses a message before `session.receive` fires, so a hook never sees it. A message that’s held for your approval reaches the hook first, so a mod can read a message you haven’t approved yet. The hook’s `next(e)` rejects when the message isn’t delivered. The sender’s name on a received message is whatever the sender wrote, so don’t base a decision on it.
+
+##
+
+
+
+Reach files, processes, and the network
+
+A mod reaches the file system, processes, and the network through the mods API, with the same permissions as the user running Claude Code. The hooks module itself has no Node.js APIs, no timer globals such as `setTimeout`, and no network or file access of its own. Standard JavaScript and web APIs such as `URL`, `TextEncoder`, `AbortController`, and `crypto.subtle` are available. Each namespace below covers one kind of access:
+
+Namespace| What it does
+---|---
+`$.fs`| `read(path)`, `write(path, text)`, `exists(path)`, `stat(path)`, and `list(path)` work on files and directories
+`$.process`| `run(['git', 'status'])` starts a command and resolves when it exits. `spawn` streams a long-running command’s output.
+`$.http`| `fetch(url, init)` over `http` or `https`. It resolves to `{ status, ok, headers, text }` once the body is read.
+`$.store`| A JSON key-value store of your plugin’s own, kept between sessions
+`$.env`| `get` and `set` environment variables. Write the name as a string literal.
+`$.settings`| `read` what the settings files and managed policy hold
+`$.session`| `messages()` returns the transcript as a list of `{ role, text, toolUses }`. Also the working directory, model, and more. [`usage()`](</docs/en/plugins/mods/reference#mods-api-methods>) returns context window use and plan limits.
+`$.mcp`| `call` a tool on a connected MCP server
+
+Files and processes have a few rules of their own:
+
+ * **Paths** : a relative path resolves against the session’s working directory
+ * **`$.fs.list`** : returns one directory’s entries as `{ name, kind, size, isLink }` and isn’t recursive
+ * **`$.process.run`** : takes an argument list and uses no shell. It resolves to `{ exitCode, stdout, stderr }` whatever the exit code. It rejects if the program can’t start or is still running at the timeout, which is 30 seconds by default, so wrap it in `try` and `catch`.
+
+Every one of these calls is itself an event, named for its namespace and method without the `$.`, such as `fs.read` for `$.fs.read`. A mod [earlier in the chain](</docs/en/plugins/mods/events#the-order-mods-run-in>) can observe, rewrite, or refuse your call, which is how an organization restricts what mods reach.
+
+##
+
+
+
+Next steps
+
+ * [React to events](</docs/en/plugins/mods/events>): hook tool calls, prompts, and turns
+ * [Draw in the interface](</docs/en/plugins/mods/interface>): show what your mod collects in a pane or above the prompt
+ * [Test a mod](</docs/en/plugins/mods/test>): stub any of these calls in a test
+ * [Mods reference](</docs/en/plugins/mods/reference>): events, mods API methods, and limits
--- a/artifacts.md
+++ b/artifacts.md
@@ -88,7 +88,14 @@
Read an artifact shared with you
-When someone shares an artifact with you, you can have Claude read it: give Claude its URL, or attach it from `/artifacts`. Claude reads a page someone else wrote the way it reads a web page with [WebFetch](</docs/en/tools-reference#webfetch-tool-behavior>): it gets a summary of what it asked about rather than the raw page, and the summary reports instructions written into the page instead of relaying them. Claude Code also saves the page’s full source to a local file, which Claude can open when it needs the exact content, such as to republish the artifact as an editor.
+When someone shares an artifact with you, you can have Claude read it: give Claude its URL, or attach it from `/artifacts`. Claude reads a page someone else wrote the way it reads a web page with [WebFetch](</docs/en/tools-reference#webfetch-tool-behavior>): it gets a summary of what it asked about rather than the raw page, and the summary reports instructions written into the page instead of relaying them. Claude Code also saves the page’s full source to a local file, which Claude can open when it needs the exact content, such as to republish the artifact as an editor. Claude Code asks for your approval before Claude reads the artifact in these cases, in addition to any prompt your permission mode or rules call for:
+
+ * **Cloud session without network access** : for a [cloud environment](</docs/en/cloud-environments#access-levels>), that’s the **None** level. In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), the classifier can approve instead; in a [Cowork](<https://claude.com/product/cowork>) session, the approval is yours alone.
+ * **Another organization’s public artifact** : Claude Code asks you first, even in auto mode. Where Claude Code can’t ask you, such as in `bypassPermissions` mode, Claude can’t read the artifact. Claude can read these artifacts only while [feature-flag fetching](</docs/en/env-vars#features-that-need-feature-flag-fetching>) is on.
+ * **Unconfirmed owner or network setting** : when Claude Code can’t confirm who made the artifact, or can’t confirm a cloud session’s network setting, it asks, and your approval covers that one request.
+ * **Plan mode, or feature-flag fetching turned off** : in [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), or if you turned [feature-flag fetching](</docs/en/env-vars#features-that-need-feature-flag-fetching>) off, Claude Code asks before the Artifact tool reads an artifact someone else in your organization made.
+
+When Claude reads the artifact with WebFetch, WebFetch’s own [prompting rules](</docs/en/tools-reference#webfetch-tool-behavior>) still apply.
##
@@ -313,6 +320,7 @@
Downloads| The page can’t start a download itself. To let viewers save a file the page generates, Claude declares the downloads capability. See Offer a file download.
Single page| Relative links do not resolve, because nothing is deployed alongside the page. For multi-section content, Claude uses in-page anchors rather than separate files.
Source file types| The published file must be `.html`, `.htm`, or `.md`, and must decode as UTF-8, or as little-endian UTF-16 by its byte-order mark. Markdown files render as styled document pages with syntax-highlighted code. A file that doesn’t decode, or that contains the replacement character `U+FFFD`, is [refused with the line and column to fix](</docs/en/errors#the-source-file-is-not-valid-utf-8-text>).
+Source location| A file at a path that names a network host is refused without being read. See [Not published: that file is on a network share](</docs/en/errors#not-published-that-file-is-on-a-network-share>) for which paths are refused and the mapped-drive exception on Windows.
Rendered size| The rendered page must be 16 MiB or smaller. Large embedded images are the usual cause when a publish fails for size.
Generating an artifact uses output tokens like any other response, and a styled page is more token-intensive than the same content as terminal text. Inline CSS, JavaScript for interactive controls, and especially images embedded as data URIs are the main contributors. To reduce an artifact’s token cost:
--- a/best-practices.md
+++ b/best-practices.md
@@ -124,7 +124,7 @@
* **Reference files with`@`** instead of describing where code lives. Claude reads the file before responding.
* **Paste images directly**. Copy/paste or drag and drop images into the prompt.
* **Give URLs** for documentation and API references. Use `/permissions` to allowlist frequently-used domains.
- * **Pipe in data** by running `cat error.log | claude` to send file contents directly.
+ * **Pipe in data** by running `cat error.log | claude -p "explain this error"` to send file contents directly.
* **Let Claude fetch what it needs**. Tell Claude to pull context itself using Bash commands, MCP tools, or by reading files.
* * *
Show diff (120 lines)
--- a/changelog.md
+++ b/changelog.md
@@ -1,4 +1,117 @@
This page is generated from the [CHANGELOG.md on GitHub](<https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md>). Run `claude --version` to check your installed version.
+
+
+
+2.1.287
+
+October 1, 2026
+
+ * Added Claude Mods: plugins may now modify deeper behavior
+ * Added You should know, a built-in mod where a side agent watches your back and flags things you or Claude might miss. Turn it on with `/plugin enable cc-plugin-you-should-know@builtin` (for first-party sessions with telemetry on)
+ * Added an `n:<text>` filter to the agents view that matches session names and tasks; a filter now shows matches in collapsed sections and Enter opens the first match
+ * Added `prompt_text` to the OpenTelemetry `user_prompt` event, a copy of `prompt` for backends that nest dotted keys; drop or mask it wherever you drop or mask `prompt` (anthropics/claude-code#70763)
+ * Added URL prompts from MCP servers on the 2025-11-25 protocol, for example to sign in. If a server no longer connects after this update, add “bareElicitationCapability”: true to its MCP config entry
+ * Windows: Added a startup warning when denying the Bash tool also turns off the PowerShell tool, so Claude has no shell tool
+ * Self-hosted runner: Added a built-in `gh api` (REST only) for sessions that use Anthropic-managed git on macOS and Linux machines where the GitHub CLI is not installed
+ * Fixed fast mode staying off in remote sessions owned by an agent with no user account, even when the organization allows it
+ * Fixed Remote Control not receiving messages for minutes at a time when a reconnect request got no response; it now gives up after 30 seconds and retries
+ * Fixed hooks configured with `asyncRewake` waking Claude over and over with “found issues” notifications when the hook’s script file is missing; the broken hook is now reported once
+ * Fixed tool heartbeats not reaching SDK hosts while the model’s response stream was stalled with no data arriving
+ * Fixed Bedrock and Vertex startup model checks ignoring an enforced `availableModels` list, which could collapse `/model` to one Opus row
+ * Fixed the Claude in Chrome browser picker showing a JSON parse error when Chrome could not be reached
+ * Fixed picking Fable in `/model` on a claude.ai login saving the current version’s id, so your saved default now follows the newest Fable like Opus and Sonnet do
+ * Fixed switching between Opus 5.5 and Sonnet 5.5 (`/model`, `opusplan`) rewriting earlier MCP tool announcements, which could drop earlier extended thinking
+ * Fixed Amazon Bedrock Guardrails blocks that arrive mid-response ending the turn with an API error instead of the guardrail’s message when the reply began with thinking
+ * Fixed a dangerous `rm` (such as one on `/` or the home directory) losing its always-ask safeguard when the same command also redirected output to a `~` or wildcard path
+ * Fixed `claude -p` and SDK sessions repeating a model fallback on every later message after the model was switched while a reply was running
+ * Fixed a folder’s CLAUDE.md being attached a second time after resuming a session or after a compaction
+ * Fixed background sessions that could not be reopened from `claude agents` after the agent exited and removed the worktree the session was started in
+ * Fixed `/advisor` pairing checks: Sonnet 5.5 can now advise Opus 4.7 and 4.8, and advisors the API would refuse are flagged up front instead of being silently dropped
+ * Fixed Bash permission prompts showing internal parser names such as “Contains simple_expansion” instead of a plain explanation
+ * Fixed a cause of fullscreen sessions on slow or busy machines exiting with “Claude Code exited after an unrecoverable interface error” while a scroll key was held in a long conversation
+ * Fixed organization per-tool permission ceilings being silently dropped for an MCP tool named `__proto__`
+ * Fixed Claude being told to page large MCP results saved as JSON with Read’s offset and limit, which cannot split one long line
+ * Fixed the commit attribution reminder being delivered inside a tool result after a compaction
+ * Fixed screen reader mode leaving the cursor away from the typed text in search boxes (such as /resume and /permissions) and sign-in code fields
+ * Fixed screen reader mode refusing Enter with nothing typed on /rewind’s summarize options, whose added context is optional
+ * Fixed screen reader mode showing a “Tab to amend” hint on approval prompts, where Tab does nothing
+ * Fixed screen reader mode listing arrow keys that do nothing in /permissions and /mcp, and saying “Select with numbers” in empty menus or while a search box has the keys
+ * Fixed screen reader mode leaving out the changed lines in file edit approval prompts and other diffs
+ * Fixed screen reader mode sending the `claude --teleport` progress screen, and an MCP form field while it is being checked, to the screen reader again on every spinner frame
+ * Fixed `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` not removing the structured-output format from session-title and prompt-hook requests, which Bedrock-backed gateways reject
+ * Fixed screen reader mode leaving out the top lines of a second approval prompt, a changed /config row or the rejected-plan line when the previous screen was taller than the terminal window
+ * Fixed `--include-partial-messages` sending a cut-short reply’s `message_stop` late or never, so apps could show the reply as still in progress
+ * Fixed `claude agents` sometimes not showing the permission prompt a background session is waiting on
+ * Fixed `/ultrareview` giving advice about `.git/info/attributes` when the upload stops on a committed `.gitattributes` it cannot read, such as one saved as UTF-16
+ * Fixed `claude remote-control` failing to register behind an HTTP proxy with a misleading “Check your organization permissions” error (anthropics/claude-code#97352)
+ * Fixed sandboxed Bash commands on Linux inheriting an open handle on the Claude Code executable
+ * Fixed the running-tool dot and three spinners still moving with the “Reduce motion” setting on, and /rewind’s confirm screen updating its “ago” time while you type a note
+ * Fixed times in `claude agents` changing every second in screen reader mode; they now change at most every 10 seconds
+ * Fixed a revoked claude.ai login showing a generic `API Error: 401` instead of “OAuth token revoked”; in `-p` mode the error now starts with “Failed to authenticate”
+ * Fixed `/ultrareview` upload refusals advising you to copy a variable named by a repository’s settings file into your own user settings
+ * Fixed `--output-format stream-json` and the SDK not streaming the turns of a `context: fork` skill run by typing `/<skill>` as the prompt, as they do for the Skill tool’s fork
+ * Fixed /feedback and /bug: the pre-filled GitHub issue no longer includes your recent error messages, and the confirmation screen now lists them as part of the report
+ * Fixed `claude plugin marketplace add --sparse` and `git-subdir` plugin installs failing with “transport ‘http’ not allowed” when the repository is served over plain http
+ * Fixed cloud sessions sometimes losing the earlier conversation when the session restarted while it was being compacted
+ * Fixed a plugin reload that overlapped the startup `--plugin-url` download corrupting the session’s cached copy of the plugin archive
+ * Fixed `/desktop` quoting partial output when opening Claude Desktop timed out or printed too much output; the error now names the cause
+ * Fixed an MCP connector tool call occasionally running twice, or the connector’s calls failing until restart, when its server changed which MCP protocol version it supports
+ * Fixed SessionStart hooks from synced plugins not running in new cloud sessions
+ * Fixed the transcript’s “N hooks ran” summary and the verbose debug log’s matched-hooks count including Claude Code’s internal callbacks, so one configured hook no longer shows as two
+ * Fixed files Claude sends from cloud and Remote Control sessions failing when the upload finished just after the 30-second timeout; it now waits 35 seconds
+ * Fixed repositories added mid-session in cloud and SDK sessions not loading their skills and plugins, and loading CLAUDE.md late, after Claude changed directory
+ * Fixed PNG, JPEG and WebP images over 8,000 pixels on a side failing to send from a remote session; Claude now sends a scaled-down copy
+ * Fixed messages sent from the Claude apps with 17 to 20 attached files delivering only the first 16
+ * Fixed headless sessions reporting an MCP server as needing authentication after one refused call, even though later calls succeed
+ * macOS: Fixed Remote Control sessions started with `claude remote-control` stopping mid-turn when the Mac went to idle sleep
+ * Windows: Fixed interactive `claude` hanging or crashing with “Raw mode is not supported” when its input is piped or redirected; it now says why and exits (use `-p` for piped input)
+ * Bedrock, Vertex, Mantle: Fixed model availability checks under `CLAUDE_CODE_SKIP_*_AUTH` sending a different `Authorization` header than real requests when `ANTHROPIC_CUSTOM_HEADERS` repeats it
+ * Improved `/config`: settings that cycle show ‹ › and step both ways with ←/→, narrow terminals stack each value under its label, and PgUp/PgDn page the list
+ * Improved plugin marketplace errors to say in plain words why a marketplace was ignored or refused, and what to do
+ * Improved plugin listings to note when a plugin’s dependencies were not installed, and updating a plugin now retries an install that did not finish
+ * Improved the Claude apps gateway’s error when Amazon Bedrock rejects a model ID: developers now see which model is unavailable, and the gateway log names the ID that was sent
+ * Improved SDK sessions so a message sent with priority “now” no longer cancels a running web fetch or web search; it keeps loading in the background
+ * Improved `/memory`: the left and right arrow keys now flip its on/off settings, such as Auto-memory
+ * Improved `/skill` names typed mid-message: Claude is now told they are skills, including `disable-model-invocation` ones
+ * Improved the contrast of the prompt input border in light themes and of the ❯ before your earlier messages
+ * Improved delivery of files Claude sends from cloud sessions and Remote Control: an upload that fails on a timeout, a network error or a 502, 503 or 504 is now retried once
+ * Improved what Claude says when a file cannot be sent for a reason that may be temporary: it now mentions that you can ask for the file again in a few minutes
+ * Improved the prompt for a held message from another session to show the message between dashed lines, matching other permission prompts
+ * Improved MCP and other tool permission prompts to show the tool call between dashed lines, matching file edit prompts
+ * Improved MCP startup in headless mode: a remote server whose first connect fails transiently is now retried without waiting for the slowest server to finish connecting
+ * Improved files Claude sends from a remote session: large files now stream from disk instead of being read into memory, and a file over the size limit is refused with the server’s limit named
+ * Improved the explanation Claude gives when the server refuses a file it sends from a Remote Control or cloud session, such as an oversized image
+ * Improved handling of large MCP tool results: less memory, smaller session files, and no extra upload to count tokens for results far over the limit
+ * Windows: Improved Bash tool speed by removing a subshell that ran before every command
+ * Changed a shell write through a repo-committed symlink onto a sensitive file or out of the working tree to name where it lands and wait for a person, on lines with a `~` target too
+ * Changed Opus 4.7+ and Fable to use a 1M context window by default on Bedrock, Vertex, Foundry and the Claude apps gateway, with no `[1m]` suffix (`CLAUDE_CODE_DISABLE_1M_CONTEXT=1` keeps 200K)
+ * Changed replies from `claude agents` to arrive as queued messages; slash commands other than `/stop` sent while a turn is running now run when it ends
+ * Changed whole-tool `Bash` allow rules and allowing hooks to prompt for, not run, shell writes to files Claude Code’s file tools refuse outright (the Anthropic profile store, the host credentials file)
+ * Changed right-click paste on Windows and Linux, and middle-click paste on Linux, to happen when the button is released; moving the pointer away before releasing cancels it
+ * Changed MCP server `alwaysLoad: false` to defer all of that server’s tools behind tool search
+ * Changed screen reader mode to write new or changed lines without first pausing with the cursor at the start of the line; set `CLAUDE_AX_PREPARK_MS=50` to restore the pause
+ * Changed automatic model switches after a flagged message to keep your current effort level instead of the new model’s default
+ * Changed waiting permission prompts to show oldest first, so a new prompt no longer covers the one you’re reading (prompts with a countdown still open on top)
+ * [VSCode] Added “Run in background” to a running command or sub-agent, to move it to the background and keep working
+ * [VSCode] Added the output of background shells and Monitors to their cards in the agent map
+ * [VSCode] Fixed settings dialogs blaming a timeout when Claude Code’s reply was too large to confirm a save
+ * [VSCode] Fixed reopening a cloud session that the side bar already brought to this machine opening it again in a new tab; the side bar is shown instead
+ * [VSCode] Fixed the side bar’s Web tab not listing cloud sessions started after the window loaded; a failed load now says “Remote server is not connected” instead of “No web sessions yet”
+ * [VSCode] Fixed a tab restored after a reload starting a second Claude process on a conversation the side bar already has open; it now shows the “still open somewhere else” notice
+ * [VSCode] Fixed tool-row file links, session-list links and two hints showing in plain text
+ * [VSCode] Fixed a background agent’s still-running command showing as failed once the main turn ended
+ * [VSCode] Fixed a user’s own `/usage` or `/context` command opening the extension’s dialog instead of running when picked from the command menu
+ * [VSCode] Fixed file links in the plan preview tab doing nothing when clicked; they now open the file like links in chat replies
+ * [VSCode] Fixed opening a tool’s input or output in an editor tab failing with “Timeout waiting after 1000ms” on remote hosts such as WSL when the tab is slow to appear
+ * [VSCode] Improved the Manage plugins dialog: a failed marketplace add, remove or refresh now says what went wrong
+ * [VSCode] Changed the Claude in Chrome “Enabled by default” switch to also connect the editor’s own sessions, which still ask before browser actions
+ * [Cloud sessions] Fixed occasional failures to fetch from or push to GitHub when GitHub briefly refused a newly issued access token
+ * [Claude Tag] Fixed Claude posting a failure warning, such as a spend limit notice, in a Slack thread when a background event like GitHub activity woke it and nobody was waiting on a reply
+ * [Claude Tag] Fixed Claude Tag’s spend limits page in admin settings leaving out recently created and private channels in organizations with many channels
+ * [Claude Tag] Improved Claude’s task list in long Slack threads: background work no longer reposts it as a new message on its own, so people following the thread aren’t notified
+ * [Code Review] Fixed finding comments and their “Why this was flagged” text stopping mid-sentence; they now end on a complete sentence
+ * [Code Review] Fixed Code Review skipping a pull request after a new push when its review had failed twice on the previous commit; it now reviews the latest commit
+ * [Code Review] Improved the failed-review card on a pull request whose conversation is locked: it now says the lock blocked the review and that nothing was posted or charged
--- a/channels.md
+++ b/channels.md
@@ -28,7 +28,7 @@
Install the plugin
-In Claude Code, run:
+Start Claude Code by running `claude` in your terminal, then enter this at its prompt:
/plugin install telegram@claude-plugins-official
@@ -106,7 +106,7 @@
Install the plugin
-In Claude Code, run:
+Start Claude Code by running `claude` in your terminal, then enter this at its prompt:
/plugin install discord@claude-plugins-official
@@ -163,7 +163,7 @@
Install the plugin
-In Claude Code, run:
+Start Claude Code by running `claude` in your terminal, then enter this at its prompt:
/plugin install imessage@claude-plugins-official
@@ -216,7 +216,7 @@
Install the fakechat channel plugin
-Start a Claude Code session and run the install command:
+Start Claude Code by running `claude` in your terminal, then enter the install command at its prompt:
/plugin install fakechat@claude-plugins-official
--- a/chrome.md
+++ b/chrome.md
@@ -91,9 +91,9 @@
Enable Chrome by default
-To avoid passing `--chrome` each session, run `/chrome` and select “Enabled by default”. Claude Code starts normally when Chrome isn’t running. Before v2.1.211, startup could hang when Chrome integration was enabled but Chrome wasn’t running. In the [VS Code extension](</docs/en/vs-code#automate-browser-tasks-with-chrome>), Chrome is available whenever the Chrome extension is installed. No additional flag is needed.
-
-Enabling Chrome by default in the CLI increases context usage since browser tools are always loaded. If you notice increased context consumption, disable this setting and use `--chrome` only when needed.
+To connect Chrome without passing `--chrome` each time, run `/chrome` in a CLI session and select **Enabled by default**. In the [VS Code extension](</docs/en/vs-code#automate-browser-tasks-with-chrome>), type `/chrome` in the prompt box and turn on the **Enabled by default** switch. The two share one setting, so turning it on in either place turns it on for both the CLI and VS Code. With the setting on and Claude Code v2.1.287 or later, each VS Code session connects to your browser as it starts, so Claude can use it before you type `@browser`. On earlier versions, or with the setting off, a VS Code session connects when you type `@browser`. Claude Code starts normally when Chrome isn’t running. Before v2.1.211, startup could hang when Chrome integration was enabled but Chrome wasn’t running.
+
+Enabling Chrome by default increases context usage since the browser tools and their instructions are always loaded. If you notice increased context consumption, turn the setting off and connect only when needed, with `--chrome` in the CLI or by typing [`@browser`](</docs/en/vs-code#automate-browser-tasks-with-chrome>) in the VS Code prompt box.
###
@@ -107,9 +107,20 @@
+Permission prompts in VS Code sessions
+
+In a VS Code session, whether Claude Code asks you before a browser action depends on how the session connected to your browser:
+
+ * **You typed`@browser`**: the extension approves each browser action that Claude Code would otherwise ask you about.
+ * **TheEnabled by default setting connected it at start**: Claude Code asks you before browser actions in Manual, Edit automatically, Auto, and Bypass permissions modes, until you type `@browser` in that session.
+
+###
+
+
+
Browser tools in plan mode
-In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), a permission prompt appears before Claude records a GIF, opens a new tab, or runs a shortcut. If [bypass permissions mode is available](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) in your session and [feature-flag fetching](</docs/en/env-vars#features-that-need-feature-flag-fetching>) is off, these calls run without a prompt. A `tabs_context_mcp` call also prompts when it sets `createIfEmpty`, and so does a `browser_batch` call that includes any of these actions.
+In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), a permission prompt appears before Claude records a GIF, opens a new tab, or runs a shortcut, except in a VS Code session where you typed `@browser`. In an interactive CLI session, if [bypass permissions mode is available](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) and [feature-flag fetching](</docs/en/env-vars#features-that-need-feature-flag-fetching>) is off, these calls run without a prompt. A `tabs_context_mcp` call also prompts when it sets `createIfEmpty`, and so does a `browser_batch` call that includes any of these actions.
##
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -785,6 +785,23 @@
+Context window in terminal sessions
+
+Terminal sessions signed in through `/login` use the 1M context window for Opus 4.7 and later, Sonnet 5 and later, and the Fable models. The model ID needs no `[1m]` suffix, and sessions compact at about 967K tokens. Before Claude Code v2.1.287 on the developer’s machine, Claude Code treated the Opus and Fable models as having a 200K window unless the model ID ended in `[1m]`. To have terminal sessions compact at the 200K boundary instead, set the [auto-compact window](</docs/en/model-config#set-the-auto-compact-window>) in the policy’s `env`:
+
+ managed:
+ policies:
+ - match: {}
+ cli:
+ env:
+ CLAUDE_CODE_AUTO_COMPACT_WINDOW: "200000"
+
+Claude Code applies this variable without showing the developer the approval dialog. The variable applies to every model, including model IDs that end in `[1m]`. To turn off 1M context instead, set [`CLAUDE_CODE_DISABLE_1M_CONTEXT: "1"`](</docs/en/model-config#extended-context>) in the same `env` block. Claude Code then treats every model as having a 200K window. In interactive sessions, each developer approves this variable in the approval dialog before it takes effect.
+
+####
+
+
+
MCP servers in a policy
To provide MCP servers to the Claude Code clients a policy matches, set [`managedMcpServers`](</docs/en/managed-mcp#provide-servers-through-managed-settings>) in that policy’s `cli` block. You need Claude Code v2.1.259 or later on the gateway server and on clients. The gateway checks each entry at boot with [the same rules Claude Code applies on the client](</docs/en/managed-mcp#what-an-entry-can-contain>), and if an entry fails a check, the gateway refuses to start and names the entry. If you write a `${VAR}` reference in `gateway.yaml`, the gateway resolves it from its environment at boot through secret expansion before it runs the entry checks, so every matching client receives the literal value and can read it. The [header guidance for provided servers](</docs/en/managed-mcp#provide-servers-through-managed-settings>) applies to the expanded value. The gateway rejects the `.mcp.json` spelling `mcpServers` in a `cli` block, and its boot error names `managedMcpServers` as the key to use. Before v2.1.259, the gateway rejected any MCP server definition in a `cli` block.
@@ -801,7 +818,7 @@
The gateway derives much of the response from the matched policy’s `cli` block and from top-level gateway config:
- * The model list, from `availableModels`
+ * The model list, from `availableModels`. Extended context in Claude Desktop covers each model’s 1M context option
* Disabled tools, from bare tool-name `permissions.deny` entries. If you set `disabledBuiltinTools` in the policy’s `desktop` block, the gateway serves the union of your value and the derived list, so you can disable more tools this way but can’t re-enable one you disabled through `permissions.deny`
* The egress allowlist, from `sandbox.network.allowedDomains`. If you set `coworkEgressAllowedHosts` in the policy’s `desktop` block, the gateway uses that value instead of the derived list
* An OTLP endpoint that points at the gateway itself, and the signed-in user’s identity attributes. The gateway relays the exports it receives at that endpoint to your `forward_to` destinations. It includes the endpoint and the attributes when you set both `telemetry.forward_to` and `listen.public_url`. Claude Desktop exports every signal with one encoding: `http/protobuf`, or `http/json` when you set `OTEL_EXPORTER_OTLP_PROTOCOL` or one of its per-signal variants to `http/json` in the policy’s `env`. Before Claude Code v2.1.261 on the gateway server, the response set `http/json` regardless, so a collector that accepts only protobuf rejected Claude Desktop’s exports
@@ -831,6 +848,42 @@
* `builtinToolPolicy`: if you set a tool to a value other than `allow` in the base, the gateway keeps that value even if you set `allow` for the same tool in a role policy
For every other key, if you set it in the role policy, the gateway uses the role policy’s value. The gateway replaces an array or a nested object such as `banner` whole, so if you set `banner.text` in a role policy, the gateway drops the base’s `banner.backgroundColor`. If you don’t deploy Claude Desktop, leave `desktop` out of your policies entirely; the gateway then returns 404 from `/user/bootstrap` for every user.
+
+####
+
+
+
+Extended context in Claude Desktop
+
+If you serve Claude Desktop from the gateway, its model picker offers a 1M context option for each listed model that can run with a 1M context window. These include Claude Opus 4.6 and later, Claude Sonnet 4.6 and later, and the Fable models. The option is the model’s `[1m]` variant, which [Extended context](</docs/en/model-config#extended-context>) describes. You need Claude Code v2.1.284 or later on the gateway server. A `models` entry gets no 1M option when:
+
+ * An upstream that can serve the entry maps it to a model without 1M support, including an upstream the gateway reaches only on failover
+ * Neither its `id` nor any of its `upstream_model` values names a Claude model, such as a custom alias routed to an application inference profile ARN
+
+To change what the picker offers, use one of these:
+
+ * **Start users on the 1M option** : set `modelPrefer1mContext: true` in the policy’s `desktop` block. Users who haven’t yet chosen a model start on the 1M option when the first listed model has one. Users who already chose a model keep their choice.
+ * **Offer the option by hand** : do this if your gateway server runs a version older than v2.1.284, or an entry names no Claude model. List the model twice in `models`, once with its plain ID and once with `[1m]` appended, both with the same `upstream_model` map. Claude Desktop shows the pair as one model with a 1M option. The gateway serves a `[1m]` entry without checking it, so add one only for a model your upstreams serve at 1M.
+
+This example offers the option by hand for a custom alias routed to an application inference profile, and starts new users on it:
+
+ models:
+ - id: corp-sonnet
+ upstream_model:
+ bedrock: arn:aws:bedrock:us-east-2:123456789012:application-inference-profile/sonnet-5-prod
+ - id: corp-sonnet[1m]
+ upstream_model:
+ bedrock: arn:aws:bedrock:us-east-2:123456789012:application-inference-profile/sonnet-5-prod
+
+ managed:
+ policies:
+ - match: {}
+ desktop:
+ modelPrefer1mContext: true
+
+##### Remove the 1M option
+
+To remove the option from the picker, set `CLAUDE_CODE_DISABLE_1M_CONTEXT: "1"` in the `env` block under the policy’s `cli` key. If you also listed an entry whose `id` ends in `[1m]`, the gateway still serves it, so delete that entry too. The variable also reaches the terminal sessions of developers the policy matches. For what it changes there, see [Extended context](</docs/en/model-config#extended-context>).
####
--- a/claude-apps-gateway-deploy.md
+++ b/claude-apps-gateway-deploy.md
@@ -303,12 +303,25 @@
* **Host-process traffic** : the host process is the Claude Code CLI. `claude gateway` runs under the same third-party rules as Amazon Bedrock and Google Cloud’s Agent Platform deployments and sends nothing to Anthropic. Before v2.1.227, the host process sent startup telemetry such as product version and platform, which setting `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1` in the container environment turned off. Those releases also sent one `HEAD` request at boot, with no body or credentials, to `/api/hello` on `https://api.anthropic.com`, or on `ANTHROPIC_BASE_URL` when the environment set it, unless the environment also set a proxy variable such as `HTTPS_PROXY` or an mTLS client certificate. They ignored the response, so blocking that request at the egress firewall didn’t affect the gateway.
* **Client analytics** : the CLI disables its own usage analytics and error reporting while signed in to a gateway. Before the first sign-in, the CLI still sends startup events to Anthropic, including on machines whose managed settings force gateway sign-in. To keep those off too, deliver [`DISABLE_TELEMETRY`](</docs/en/managed-settings#turn-telemetry-off-for-your-organization>) in the same [client-side managed settings](</docs/en/claude-apps-gateway-config#client-side-managed-settings>) that force gateway sign-in.
* **Error reporting** : the CLI turns error reporting off whenever its model requests go to any endpoint other than Anthropic’s first-party API, such as Amazon Bedrock or a custom `ANTHROPIC_BASE_URL`.
- * **Client machines** : developers’ CLIs still send WebFetch hostname checks and version checks to Anthropic unless `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1` and `skipWebFetchPreflight: true` are set. See [data usage](</docs/en/data-usage>).
+ * **Client machines** : developers’ CLIs still send WebFetch hostname checks and version checks to Anthropic unless `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1` and `skipWebFetchPreflight: true` are set. Plugin marketplace requests have their own off switches. See [data usage](</docs/en/data-usage>).
* **Survey ratings** : while signed in to a gateway, the CLI disables the Anthropic-bound rating upload together with the analytics streams, so it doesn’t send ratings to Anthropic.
* **Transcript sharing** : choosing Yes on a survey’s transcript-share prompt writes a local file under `~/.claude/feedback-bundles/` instead of uploading to Anthropic.
* **Client updates** : update checks are separate from gateway traffic. Pin versions through your own distribution and set `DISABLE_UPDATES` if laptops must not fetch releases. `DISABLE_AUTOUPDATER` stops only background updates while `claude update` still works.
* **TLS** : serve `public_url` over HTTPS in production, either from the gateway’s own listener via `listen.tls` or from a TLS-terminating ingress in front of plain-HTTP replicas, with `listen.public_url` set in both cases. The gateway doesn’t refuse plain HTTP. The IdP must serve HTTPS in production, and Postgres supports `?sslmode=require`. Set `Strict-Transport-Security` at your ingress.
* **Vulnerability disclosure** : follow [Reporting security issues](</docs/en/security#reporting-security-issues>)
+
+###
+
+
+
+Plugin marketplace requests
+
+Claude Code fetches plugin marketplaces directly from each developer’s machine, not through the gateway. [Network access requirements](</docs/en/network-config#network-access-requirements>) lists the hosts. The first time a developer starts an interactive terminal session, Claude Code registers the official marketplace, `claude-plugins-official`. It downloads the catalog from `downloads.claude.ai` and, if that fails, clones it from `github.com`. [Which marketplaces and plugins auto-update](</docs/en/plugins/loading#which-marketplaces-and-plugins-auto-update>) covers later refreshes. `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1` doesn’t stop the first registration. Either of these managed settings does:
+
+ * **A marketplace list** : a [`strictKnownMarketplaces`](</docs/en/plugins/org#allowlist-with-strictknownmarketplaces>) allowlist that leaves the marketplace out, or a [`blockedMarketplaces`](</docs/en/plugins/org#blocklist-with-blockedmarketplaces>) entry that names it
+ * **An environment variable** : `CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL` set to `"1"` in the managed [`env` block](</docs/en/plugins/org#turn-updates-off-for-the-whole-fleet>)
+
+The first registration can run before the developer signs in to the gateway, when no gateway policy has arrived. To cover that first start, deliver your choice in [client-side managed settings](</docs/en/claude-apps-gateway-config#client-side-managed-settings>) as well as in the gateway policy’s [`cli` block](</docs/en/claude-apps-gateway-config#what-goes-in-cli>).
##
--- a/claude-apps-gateway-spend-limits.md
+++ b/claude-apps-gateway-spend-limits.md
@@ -76,12 +76,15 @@
Usage warnings in Claude Code
-Claude Code warns a developer as they approach their cap: once utilization passes 75%, and again past 95% of their most-consumed cap. When the gateway blocks a request, Claude Code shows the gateway’s `429` message as is, including your `admin.blocked_message`. The warning works off response headers:
+Claude Code warns a developer as they approach their cap: once utilization passes 75%, and again past 95% of their most-consumed cap. When the gateway blocks a request, Claude Code shows the gateway’s `429` message as is, including your `admin.blocked_message`. It also shows the cap in `/usage` and passes it to the developer’s [status line](</docs/en/statusline#spend-limit-fields>) script. Each display needs a minimum Claude Code version on the developer’s machine and on the gateway server:
- * With v2.1.225 or later on the gateway server, each successful `/v1/messages` response for a developer who has a cap carries their own cap utilization and reset time in the `anthropic-ratelimit-unified-*` headers.
- * With v2.1.225 or later on the developer’s machine as well, Claude Code reads the headers and shows the warning.
+What the developer sees| Developer’s machine| Gateway server
+---|---|---
+Usage warnings at 75% and 95%| v2.1.225 or later| v2.1.225 or later
+A **Spend limit** bar in `/usage` with the percentage of their cap used and when it resets, and a `rate_limits.spend_limit` object in the status line input| v2.1.251 or later| v2.1.225 or later
+Their estimated spend and the cap in US dollars in the **Spend limit** bar, such as “$271.40 / $500.00 spent this month”, and the same amounts plus the cap’s period in the status line input| v2.1.284 or later| v2.1.284 or later
-The headers always describe the developer’s own cap: the gateway strips the upstream provider’s rate-limit headers, which describe your shared quota, and never forwards them. With v2.1.251 or later on the developer’s machine, Claude Code also reads the same headers to show a **Spend limit** bar in `/usage`, with the percentage of their cap used and when it resets, and to add a `rate_limits.spend_limit` object to the [status line](</docs/en/statusline#rate-limit-usage>) input. Claude Code shows both as a percentage rather than a dollar amount, and needs nothing newer than v2.1.225 on the gateway server.
+The warnings and the percentage come from the `anthropic-ratelimit-unified-*` headers, which the gateway adds to each successful `/v1/messages` response for a developer who has a cap. The headers always describe the developer’s own cap: the gateway strips the upstream provider’s rate-limit headers, which describe your shared quota, and never forwards them. The spend a developer sees is the gateway’s own estimate, the same figure it enforces the cap with, and not an amount from your provider’s bill. Claude Code reads the dollar amounts with a separate request to the gateway. If you set `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` on developers’ machines, as [Compliance posture](</docs/en/claude-apps-gateway-deploy#compliance-posture>) suggests, Claude Code skips that request. With that variable set, or with a gateway server older than v2.1.284, the bar and the status line stay percentage-only.
##
--- a/claude-code-on-the-web.md
+++ b/claude-code-on-the-web.md
@@ -101,7 +101,12 @@
Send local repositories without GitHub
-When you run `claude --cloud` from a repository that has no git remote, or from a github.com repository that the Claude GitHub App isn’t installed on, Claude Code bundles your local repository and uploads it directly to the cloud session. This applies even if you connected GitHub with `/web-setup`. The bundle includes your full repository history across all branches, plus uncommitted changes to tracked files. On macOS, Linux, and WSL, Claude Code leaves uncommitted changes to files named like credentials or keys out of the upload and names the files it left out. This covers `.env` files, Terraform `*.tfvars` files, and key files such as `id_rsa` and `*.pem`. The session starts with the committed version of each, or without the file if none is committed. To upload a bundle even when Claude Code would otherwise clone from the remote, set `CCR_FORCE_BUNDLE=1`:
+When you run `claude --cloud` from a repository that has no git remote, or from a github.com repository that the Claude GitHub App isn’t installed on, Claude Code bundles your local repository and uploads it directly to the cloud session. This applies even if you connected GitHub with `/web-setup`. For a full clone, the bundle includes your repository history across all branches, plus uncommitted changes to tracked files. What happens to uncommitted changes in sensitive files depends on your platform:
+
+ * **macOS, Linux, and WSL** : Claude Code leaves uncommitted changes to files named like credentials or keys out of the upload. This includes `.env` files, Terraform `*.tfvars` files, and key files such as `id_rsa` and `*.pem`. It also leaves out uncommitted changes to files that a git filter such as Git LFS manages. A `Left on this machine:` notice names the files left out, and the session starts with the committed version of each, or without the file if none is committed.
+ * **Native Windows** : uncommitted changes to tracked files upload as they are, whatever the file’s name. Stash or revert an edit you don’t want in the cloud session before you start it.
+
+To upload a bundle even when Claude Code would otherwise clone from the remote, set `CCR_FORCE_BUNDLE=1`:
CCR_FORCE_BUNDLE=1 claude --cloud "Run the test suite and fix any failures"
@@ -112,6 +117,15 @@
* Untracked files are not included; run `git add` on files you want the cloud session to see
* On macOS, Linux, and WSL, Claude Code refuses the upload when it can’t follow a git setting that affects which attribute rules apply to your files, such as `core.attributesFile` set in an included config file. The [refusal message](</docs/en/errors#the-repository-upload-cant-follow-a-git-setting>) names the setting and the fix
* Sessions created from a bundle can push back to a GitHub remote only when your GitHub connection has push access to that repository
+
+On macOS, Linux, and WSL, the upload also needs git 2.31 or later and a checkout layout it supports, while on native Windows Claude Code uploads without either check. When a checkout doesn’t meet those requirements, Claude Code doesn’t start the session. It prints an error that contains `Not uploading this working tree:`, names the cause, and says what to change. These are the common causes:
+
+ * **Older git** : the installed git is older than 2.31. Update git, then retry.
+ * **A checkout layout the upload doesn’t support** : you started inside a submodule, in a clone made with `git clone --separate-git-dir`, `--shared`, or `--reference`, in a checkout with `core.worktree` set, or in a repository that keeps its refs in the reftable format. Start from the main checkout of a clone made with a plain `git clone` instead.
+ * **A linked worktree with a sparse checkout** : `git sparse-checkout` writes settings to the worktree’s own `config.worktree` file, which the upload doesn’t accept, so a worktree that has those settings isn’t uploaded, and neither is one Claude Code created with [`worktree.sparsePaths`](</docs/en/settings-reference#worktree-sparsepaths>). Start from the repository’s main checkout instead.
+ * **Git configuration kept inside the working tree** : your git configuration includes a file that sits inside the checkout, for example an `include.path` entry that points into the repository. Move that file outside the working tree or remove the include, then retry.
+
+On macOS, Linux, and WSL, a partial clone made with `git clone --filter` uploads as a snapshot of its working tree without history, as long as the clone holds every tracked file locally. For `claude --cloud`, if the repository is on GitHub, you can avoid the upload and its requirements: push your branch, install the Claude GitHub App on the repository, and start the session again so that it clones from GitHub.
###
@@ -180,6 +194,8 @@
Correct repository| You must run `--teleport` from a checkout of the same repository, not a fork. If you run it from a checkout of a different repository, Claude Code shows an error that names both the session’s repository and your checkout’s. Before v2.1.219, the error didn’t name your checkout’s repository. If Claude Code can’t parse your remote into a hostname, for example an SSH host alias like `git@work:owner/repo.git`, it asks you to confirm, and accepts the checkout when the remote’s owner and repository name match the session’s repository.
Branch available| The branch from the cloud session must have been pushed to the remote. Teleport automatically fetches and checks it out.
Same account| You must be authenticated to the same claude.ai account used in the cloud session.
+
+When teleport fetches the session’s branch, the fetch never waits for input in your terminal. If git or ssh would ask for a password, a key passphrase, or confirmation of a new SSH host, the fetch fails, and the checkout then works only if your local clone already has the branch. For the two SSH cases, load your key into `ssh-agent` and run `git fetch` once by hand first to record the host.
####
--- a/claude-directory.md
+++ b/claude-directory.md
@@ -137,6 +137,7 @@
`paste-cache/`| Contents of large pastes
`image-cache/<session>/`| Attached images saved by Claude Code v2.1.274 and earlier. Later versions save pasted and attached images outside `~/.claude`, in an `images/` directory for each session under the temp directory that [`CLAUDE_CODE_TMPDIR`](</docs/en/env-vars>) controls. The sweep removes other sessions’ leftover directories here, whatever their age.
`uploads/<session>/`| Files you attach from the web or mobile app, and photos you attach from the mobile app, when messaging a [Remote Control](</docs/en/remote-control>) session. An attachment to a [cloud session](</docs/en/claude-code-on-the-web>) is saved in that session’s own cloud environment instead, not on your machine.
+`dev-mods/<session>/`| [Mods that Claude wrote](</docs/en/plugins/mods/create#ask-claude-for-a-mod>) during the session
`session-env/`| Per-session environment metadata
`tasks/`| Task lists written by the task tools, one directory per list
`shell-snapshots/`| Aliases, functions, and shell options captured at startup and applied by the [Bash tool](</docs/en/tools-reference#bash-tool-behavior>) to each command. Removed on clean exit. The sweep clears any left after a crash.
@@ -193,7 +194,13 @@
`cache/changelog.md`| Cached copy of the Claude Code changelog, shown by `/release-notes`. Refreshed in the background.
`policy-limits.json`| Cached feature policy settings for your organization. Only present for some account types. Refreshed automatically. A `policy-limits.json.stamp.json` sidecar records which account or API key the cache belongs to. Claude Code deletes both files when you log out.
-Other files appear depending on which features you use. Caches and lock files are safe to delete. Keep these state files:
+####
+
+
+
+State files to keep
+
+Depending on which features you use, `~/.claude/` also holds files that the tables under Application data don’t list. Of those, caches and lock files are safe to delete. Keep these state files:
* `.credentials.json`: your [login credentials](</docs/en/authentication#credential-management>)
* `agent-memory/`: [subagent memory](</docs/en/sub-agents#enable-persistent-memory>)
--- a/claude-platform-on-aws.md
+++ b/claude-platform-on-aws.md
@@ -32,7 +32,7 @@
aws sso login --profile my-profile
export AWS_PROFILE=my-profile
-For CI and automation, give the runner an IAM role with permission to invoke the Anthropic service and set `AWS_REGION`. The credential chain picks the role up automatically. If your SSO credentials expire mid-session, configure [`awsAuthRefresh`](</docs/en/amazon-bedrock#advanced-credential-configuration>) so Claude Code re-runs your login command and retries instead of failing. Automatic refresh on Claude Platform on AWS requires Claude Code v2.1.198 or later; earlier versions stop with a prompt to run `/login`, which can’t refresh AWS credentials. Add the command to your [settings file](</docs/en/settings>), such as `~/.claude/settings.json`:
+For CI and automation, give the runner an IAM role with permission to invoke the Anthropic service and set `AWS_REGION`. The credential chain picks the role up automatically. If your SSO credentials expire mid-session, configure [`awsAuthRefresh`](</docs/en/amazon-bedrock#advanced-credential-configuration>) so Claude Code re-runs your login command and retries instead of failing. Add the command to your [settings file](</docs/en/settings>), such as `~/.claude/settings.json`:
{
"awsAuthRefresh": "aws sso login --profile my-profile"
--- a/claude-security.md
+++ b/claude-security.md
@@ -32,7 +32,7 @@
Install the plugin
-In a Claude Code session, install from the [official Anthropic marketplace](</docs/en/plugins/anthropic-marketplaces>):
+In the VS Code extension or the desktop app, install it by following [Install a plugin](</docs/en/plugins/install#install-a-plugin>). In a terminal, start Claude Code by running `claude`, then enter this at its prompt to install from the [official Anthropic marketplace](</docs/en/plugins/anthropic-marketplaces>):
/plugin install claude-security@claude-plugins-official
--- a/claude-tag.md
+++ b/claude-tag.md
@@ -55,7 +55,7 @@
[For administratorsSet up Claude Tag](</docs/claude-tag/admins/setup-overview>)
-[Where do I start?Pair your Slack workspace, connect the services Claude will work in, launch, and test that it works](</docs/claude-tag/admins/setup-overview>)[What can Claude Tag access?How admins set access per channel, and where credentials are stored](</docs/claude-tag/concepts/agent-identity>)[How do I connect each service?Credential types, allowed hosts, and what each connection lets Claude reach](</docs/claude-tag/admins/add-connections>)
+[Where do I start?Pair your Slack workspace, launch, and test that it works](</docs/claude-tag/admins/setup-overview>)[What can Claude Tag access?How admins set access per channel, and where credentials are stored](</docs/claude-tag/concepts/agent-identity>)[How do I connect each service?Credential types, allowed hosts, and what each connection lets Claude reach](</docs/claude-tag/admins/add-connections>)
For end usersPut Claude Tag to work
@@ -85,7 +85,7 @@
Common uses
-The list below covers common ways teams use Claude Tag. Each link opens a guide with the prompts to paste and the connections the task needs.
+Each link opens a guide with the prompts to paste and the connections the task needs.
* [Watch monitors and alerts](</docs/claude-tag/users/use-cases/watch-monitors>): scheduled dashboard checks, and alerts investigated as they arrive. Needs a monitoring connection like Datadog, Sentry, or PagerDuty.
* [Triage requests](</docs/claude-tag/users/use-cases/triage-requests>): an intake channel where Claude answers what it can, flags duplicates, and routes the rest. Works on Slack content alone.
@@ -109,11 +109,9 @@
You set up Claude Tag once, at [`claude.ai/admin-settings/claude-tag`](<https://claude.ai/admin-settings/claude-tag>), and you must be an Owner in your Claude organization to do it. The setup page at that URL walks you through it:
* **Pair your Slack workspace** : send `@Claude connect` in Slack to get a pairing code, then enter it on the setup page.
- * **Connect the services Claude will work in** : for each one, such as your issue tracker or data warehouse, create an account for Claude and enter its credential.
- * **Grant repositories** : choose which repositories the Claude GitHub App can reach.
- * **Set a monthly spend limit and launch**.
+ * **Set a monthly spend limit, add Claude to channels, and launch**.
-Claude Tag starts with no access to your external systems. The services you connect during setup form an [Access bundle](</docs/claude-tag/concepts/glossary#access-bundle>), the set of tools Claude can reach, attached to the workspace or channels you paired. Once you launch, everyone in a channel Claude is in can use Claude Tag immediately, with no per-user setup. [Set up Claude Tag](</docs/claude-tag/admins/setup-overview>) walks through those steps with what to have ready, what each choice means, and how to verify Claude Tag works once you launch.
+Once you launch, everyone in a channel Claude is in can use Claude Tag immediately, with no per-user setup. Claude Tag starts with no access of its own to your external systems. After you launch, you connect the services Claude will work in, such as your issue tracker or data warehouse, and grant repositories to the Claude GitHub App. The services you connect form an [Access bundle](</docs/claude-tag/concepts/glossary#access-bundle>), the set of tools Claude can reach. You attach the bundle to a workspace or to channels. Members can also let Claude use their own [personal connectors](</docs/claude-tag/concepts/personal-connectors>) for their requests. [Set up Claude Tag](</docs/claude-tag/admins/setup-overview>) walks through setup and connecting tools, with what to have ready, what each choice means, and how to verify Claude Tag works once you launch.
Security review
@@ -129,7 +127,7 @@
## Set up Claude Tag
-Admins: pair your Slack workspace, connect the services Claude will work in, and launch
+Admins: pair your Slack workspace and launch
## Hand Claude Tag your first task
--- a/cli-reference.md
+++ b/cli-reference.md
@@ -20,7 +20,7 @@
`claude install [version]`| Install or reinstall the native binary. Accepts a version like `2.1.118`, or `stable` or `latest`. See [Install a specific version](</docs/en/setup#install-a-specific-version>)| `claude install stable`
`claude auth login`| Sign in to your Anthropic account. Use `--email` to pre-fill your email address, `--sso` to force SSO authentication, and `--console` to sign in with Anthropic Console for API usage billing instead of a Claude subscription| `claude auth login --console`
`claude auth logout`| Log out from your Anthropic account| `claude auth logout`
-`claude auth status`| Show authentication status as JSON. Use `--text` for human-readable output. Exits with code 0 if logged in, 1 if not. The JSON includes a `configDirectory` field naming the [configuration directory](</docs/en/claude-directory>) the CLI uses. The field requires Claude Code v2.1.268 or later| `claude auth status`
+`claude auth status`| Show authentication status as JSON. Use `--text` for human-readable output. Exits with code 0 if logged in, 1 if not. The JSON includes a `configDirectory` field naming the [configuration directory](</docs/en/claude-directory>) the CLI uses. The field requires Claude Code v2.1.268 or later. The JSON’s `authMethod` field is one of `none`, `claude.ai`, `oauth_token`, `api_key`, `api_key_helper`, or `third_party`| `claude auth status`
`claude agents`| Open [agent view](</docs/en/agent-view>) to monitor and dispatch parallel background sessions. Use `--cwd <path>` to show only sessions started under that directory, or `--json` to print active sessions as a JSON array for scripting (`--json --all` also includes completed background sessions). Pass `--permission-mode`, `--model`, `--effort`, or `--agent` to set [defaults for dispatched sessions](</docs/en/agent-view#permission-mode-model-and-effort>). Accepts `--settings`, `--add-dir`, `--plugin-dir`, and `--mcp-config` like the top-level `claude` command. Opening agent view requires an interactive terminal| `claude agents --json`
`claude attach <id>`| Attach to a [background session](</docs/en/agent-view#manage-sessions-from-the-shell>) in this terminal| `claude attach 7c5dcf5d`
`claude auto-mode defaults`| Print the built-in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) classifier rules as JSON. Use `claude auto-mode config` to see your effective config with settings applied. `--label <prefix>` prints only the rules whose label starts with that prefix, matched case-insensitively. Requires Claude Code v2.1.208 or later| `claude auto-mode defaults --label 'Git Destructive'`
@@ -115,7 +115,7 @@
`--permission-prompts`| Set who answers permission prompts in print mode. With the default `host`, Claude Code sends them to the Agent SDK host or the `--permission-prompt-tool` tool. Pass `none` when nobody can answer, and Claude Code denies them instead. See [Turn off permission prompts in unattended runs](</docs/en/headless#turn-off-permission-prompts-in-unattended-runs>). Requires Claude Code v2.1.259 or later| `claude -p --permission-prompts none "query"`
`--plugin-dir`| Load a plugin from a directory or `.zip` archive, or several from a [folder of plugins](</docs/en/plugins/create#load-a-directory-or-archive-for-one-session>), for this session only. Each flag takes one path. Repeat the flag for more paths: `--plugin-dir A --plugin-dir B.zip`. Passing a folder of plugins requires Claude Code v2.1.265 or later| `claude --plugin-dir ./my-plugin`
`--plugin-url`| Fetch a plugin `.zip` archive from a URL for this session only. Repeat the flag for multiple plugins, or pass space-separated URLs in a single quoted value| `claude --plugin-url https://example.com/plugin.zip`
-`--print`, `-p`| Print response without interactive mode (see [Agent SDK documentation](</docs/en/agent-sdk/overview>) for programmatic usage details). For `--resume` on a background session that is still running, see [Resume a session](</docs/en/sessions#resume-a-running-background-session>)| `claude -p "query"`
+`--print`, `-p`| Print response without interactive mode (see [Agent SDK documentation](</docs/en/agent-sdk/overview>) for programmatic usage details). For `--resume` on a background session that is still running, see [Resume a running background session](</docs/en/sessions#resume-a-running-background-session>)| `claude -p "query"`
`--prompt-suggestions`| Emit a `prompt_suggestion` message with a predicted next user prompt after each turn that generates one; very short conversations can produce none. Requires `--print`, `--output-format stream-json`, and `--verbose`. See [Prompt suggestions](</docs/en/interactive-mode#prompt-suggestions>)| `claude -p --prompt-suggestions --output-format stream-json --verbose "query"`
`--ref <branch>`| With `--environment`, base the new session’s checkout on a named ref instead of local `HEAD`| `claude -p "Run the smoke test" --environment ccpool_abc123 --ref main`
`--remote`| Deprecated alias for `--cloud`, including the existing-session form| `claude --remote "Fix the login bug"`
@@ -156,7 +156,11 @@
`--append-system-prompt-file`| Appends file contents to the default prompt| `claude --append-system-prompt-file ./style-rules.txt`
`--system-prompt-snapshot`| With `off`, rebuilds the prompt on every request. With `on`, the default, reuses a recorded prompt where recording applies| `claude --append-system-prompt "Draft rules" --system-prompt-snapshot off`
-`--system-prompt` and `--system-prompt-file` are mutually exclusive. The append flags can be combined with either replacement flag. When the replacement text combines instructions that are the same on every run with context that changes per run, add a line containing only `__SYSTEM_PROMPT_DYNAMIC_BOUNDARY__` between the instructions and the context. Claude Code splits the prompt at the first such line and removes that line, so the part above it stays cached while the part below changes. Requires Claude Code v2.1.275 or later. [Cache the static part of a custom prompt](</docs/en/agent-sdk/modifying-system-prompts#cache-the-static-part-of-a-custom-prompt>) lists the configurations where the split applies. Choose based on whether Claude Code’s default identity still fits your task. Use an append flag when Claude should remain a coding assistant that also follows your extra rules: per-invocation instructions, output formatting, or domain context for a `-p` script. Appending preserves the default tool guidance, safety instructions, and coding conventions, so you only supply what differs. Use a replacement flag when the surface, identity, or permission model differs from Claude Code’s, like a non-coding agent in a pipeline that no human watches. Replacing drops all of the default prompt, including tool guidance and safety instructions, so you take responsibility for whatever your task still needs. For persistent personas you can switch between and share across a project, use [output styles](</docs/en/output-styles>). For project conventions Claude should always follow, use [CLAUDE.md](</docs/en/memory>). The [Agent SDK guide on system prompts](</docs/en/agent-sdk/modifying-system-prompts#decide-on-a-starting-point>) covers the same decision in more depth.
+You can combine these flags. To replace the default prompt and still append your own text, pass `--append-system-prompt` or `--append-system-prompt-file` together with `--system-prompt` or `--system-prompt-file`. With Claude Code v2.1.283 or later, you can also pass a flag together with its own file form, such as `--append-system-prompt` with `--append-system-prompt-file`, and Claude Code uses both. For example, run the following in your shell to append both a style guide from a file and one extra instruction:
+
+ claude -p --append-system-prompt-file ./style.md --append-system-prompt "Always reply in French" "Summarize README.md"
+
+Claude receives the default system prompt followed by the contents of `style.md`, a blank line, and then `Always reply in French`. The file’s contents come first even if you pass `--append-system-prompt` before `--append-system-prompt-file`. When the replacement text combines instructions that are the same on every run with context that changes per run, add a line containing only `__SYSTEM_PROMPT_DYNAMIC_BOUNDARY__` between the instructions and the context. Claude Code splits the prompt at the first such line and removes that line, so the part above it stays cached while the part below changes. Requires Claude Code v2.1.275 or later. [Cache the static part of a custom prompt](</docs/en/agent-sdk/modifying-system-prompts#cache-the-static-part-of-a-custom-prompt>) lists the configurations where the split applies. Choose based on whether Claude Code’s default identity still fits your task. Use an append flag when Claude should remain a coding assistant that also follows your extra rules: per-invocation instructions, output formatting, or domain context for a `-p` script. Appending preserves the default tool guidance, safety instructions, and coding conventions, so you only supply what differs. Use a replacement flag when the surface, identity, or permission model differs from Claude Code’s, like a non-coding agent in a pipeline that no human watches. Replacing drops all of the default prompt, including tool guidance and safety instructions, so you take responsibility for whatever your task still needs. For persistent personas you can switch between and share across a project, use [output styles](</docs/en/output-styles>). For project conventions Claude should always follow, use [CLAUDE.md](</docs/en/memory>). The [Agent SDK guide on system prompts](</docs/en/agent-sdk/modifying-system-prompts#decide-on-a-starting-point>) covers the same decision in more depth.
####
--- a/cloud-environments.md
+++ b/cloud-environments.md
@@ -46,7 +46,7 @@
Add or edit an environment
-Select **Add cloud environment** , or hover over an existing environment and select the settings icon that appears on the right. The dialog includes the name, network access level, environment variables, and setup script. When you edit an existing cloud environment on a Pro or Max plan, the dialog also includes API credentials.
+Select **Cloud** to list your environments. Then select **Add cloud environment** , or hover over an existing environment and select the settings icon that appears on the right.The dialog includes the name, network access level, environment variables, and setup script. When you edit an existing cloud environment on a Pro or Max plan, the dialog also includes API credentials.
###
@@ -86,7 +86,6 @@
* **Role** : an organization admin role in your claude.ai organization
* On Team and Enterprise, Owners hold it and Admins don’t
* On Pro and Max, you hold it in your own organization
- * Without it, you see a note instead of the credential list, on your own environments too. Ask an Owner to add the credential to a shared environment and run your sessions there
* **Environment type** : an Anthropic-hosted cloud environment that already exists. A [self-hosted environment](</docs/en/self-hosted-environments>) doesn’t have API credentials
* **API reachability** : the API accepts connections from the internet, because requests leave from Anthropic’s network
* **Encryption keys** : if your organization uses customer-managed encryption keys, you can’t save credentials
@@ -103,7 +102,7 @@
Open the environment's API credentials
-Open the environment for editing at [claude.ai/code](<https://claude.ai/code>). In the **Update cloud environment** dialog, find **API credentials** below **Environment variables**. You see the credentials already on the environment, each with the hosts it applies to.
+Open the environment for editing at [claude.ai/code](<https://claude.ai/code>). In the **Edit cloud environment** dialog, find **API credentials** below **Environment variables**. You see the credentials already on the environment, each with the hosts it applies to.
2
@@ -252,7 +251,7 @@
* **Git credentials** : the git client inside the VM uses a scoped credential, which the proxy verifies and swaps for your actual GitHub token.
* **API requests** : requests from the built-in GitHub tools, and from `gh` under the `proxy-injected` placeholder, go out with your real credentials substituted.
- * **Push protection** : `git push` works only against the session’s current working branch; cloning, fetching, and PR operations work normally.
+ * **Push restrictions** : the proxy rejects branch deletions and pushes of anything other than a branch, such as a tag. It doesn’t limit which branches a push can update. To do that, use branch protection rules or rulesets on GitHub.
* **Repository scope** : GitHub API and release-asset requests reach only repositories attached to the session, so a setup script that downloads release assets from an unattached repository gets a 403.
* **GraphQL restrictions** : the proxy serves only a pinned set of GraphQL operations for pull-request workflows. The proxy rejects everything else on the GraphQL endpoint with a 403 that says `This GraphQL query is not enabled for this session` and names the REST fallback, `gh api repos/{owner}/{repo}/...`. The restriction applies to every request through the proxy regardless of the credentials you supply, so a `GH_TOKEN` you set gets the same 403. Claude can’t reach GitHub APIs that exist only in GraphQL, such as Projects v2, through the proxy.
--- a/code-intelligence.md
+++ b/code-intelligence.md
@@ -40,7 +40,7 @@
Install the plugin
-To install the plugin listed for your language in the step 1 table, run `/plugin install` in a Claude Code session, replacing `typescript-lsp` with that plugin’s name:
+In the VS Code extension or the desktop app, follow [Install a plugin](</docs/en/plugins/install#install-a-plugin>) instead of this step. In a terminal, start Claude Code by running `claude`, then enter this at its prompt, replacing `typescript-lsp` with the plugin the step 1 table lists for your language:
/plugin install typescript-lsp@claude-plugins-official
--- a/code-review.md
+++ b/code-review.md
@@ -372,7 +372,7 @@
The review runs in the background by default; before v2.1.218, it ran inside your conversation. It runs in the foreground instead in cases like these:
* You run `/code-review` again while an earlier review is still in progress
- * You run it in non-interactive mode, with the `-p` flag or the Agent SDK; Claude Code waits for the review and includes the findings in the response, except for `ultra`, which launches the cloud review without waiting
+ * You run it in non-interactive mode, with the `-p` flag or the Agent SDK; Claude Code waits for the review and includes the findings in the response, except for `ultra`, which [doesn’t wait for the cloud review](</docs/en/ultrareview#run-ultrareview-non-interactively>)
* You set [`CLAUDE_CODE_DISABLE_BACKGROUND_TASKS`](</docs/en/env-vars>) to `1`, which also turns off every other background task feature
###
@@ -401,7 +401,7 @@
Ultrareview requires authentication with a claude.ai account and is not available on Amazon Bedrock, Google Cloud’s Agent Platform, or Microsoft Foundry, or to organizations with Zero Data Retention enabled. When ultrareview is not available, `/code-review ultra` runs a local review in your session instead.
-To start a cloud review from a script or CI, run `claude -p '/code-review ultra'`. Claude Code launches the review and prints a link for tracking it. Requires Claude Code v2.1.218 or later. When the review would bill [usage credits](<https://support.claude.com/en/articles/12429409-extra-usage-for-paid-claude-plans>), Claude Code stops before launching, because the billing confirmation needs an interactive session. Run the [`claude ultrareview` subcommand](</docs/en/ultrareview#run-ultrareview-non-interactively>) instead; by running it, you consent to the charge. The command was named `/simplify` before v2.1.147, when it applied fixes by default. `/simplify` runs a separate cleanup-only review that applies fixes without hunting for bugs. If you scripted `/simplify` for bug-finding, switch to `/code-review --fix`.
+To run a cloud review from a script or CI job, use the [`claude ultrareview` subcommand](</docs/en/ultrareview#run-ultrareview-non-interactively>), which waits for the findings and prints them to stdout. The command was named `/simplify` before v2.1.147, when it applied fixes by default. `/simplify` runs a separate cleanup-only review that applies fixes without hunting for bugs. If you scripted `/simplify` for bug-finding, switch to `/code-review --fix`.
##
--- a/commands.md
+++ b/commands.md
@@ -29,7 +29,7 @@
---|---
`/add-dir <path>`| Add a working directory for file access during the current session. Type a partial path to see matching directory suggestions; press `Tab` to accept one. Most `.claude/` configuration [isn’t discovered](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) from the added directory. You can’t add most [network paths](</docs/en/errors#working-directory-is-a-network-path>), such as `\\server\share`. After a successful add, your [`DirectoryAdded` hooks](</docs/en/hooks#directoryadded>) run. When you run it while Claude is responding, Claude Code asks you to confirm the directory right away, and once you confirm, Claude’s next tool call in the same turn can access it. Before v2.1.234, Claude Code queued the command until the turn finished
`/advisor [model|off]`| Enable or disable the [advisor tool](</docs/en/advisor>), which consults a second model for guidance at key moments during a task. Accepts `fable`, `opus`, `sonnet`, or a full model ID. `fable` requires [Fable access](</docs/en/advisor#choose-an-advisor-model>). Without an argument, opens a picker. In a session without an interactive terminal, or over [Remote Control](</docs/en/remote-control#limitations>), pass the model or `off` as an argument; with no argument there, the command prints the current advisor as text. These forms require Claude Code v2.1.260 or later
-`/agents`| As of v2.1.198, running `/agents` prints a reminder to ask Claude to create or manage [subagents](</docs/en/sub-agents>), or to edit `.claude/agents/` or `~/.claude/agents/` directly. On v2.1.197 and earlier, opens an interactive interface for creating and managing subagent configurations
+`/agents`| Print a reminder to ask Claude to create or manage [subagents](</docs/en/sub-agents>), or to edit `.claude/agents/` or `~/.claude/agents/` directly. On v2.1.197 and earlier, opens an interactive interface for creating and managing subagent configurations
`/artifact-capabilities`| **[Skill](</docs/en/skills#bundled-skills>).** Load the reference for the runtime capabilities a published [artifact](</docs/en/artifacts>) can use, such as [calling your connectors](</docs/en/artifacts#pull-live-data-with-mcp-connectors>) or [offering a file download](</docs/en/artifacts#offer-a-file-download>), including which ones your account has. Claude normally loads it on its own before building a page that uses one. Available where [artifacts](</docs/en/artifacts#availability>) are
`/artifact-diagramming`| **[Skill](</docs/en/skills#bundled-skills>).** Load diagramming guidance for Claude to follow in [artifacts](</docs/en/artifacts>): when a diagram helps, what to draw, and how to write inline SVG that stays legible in light and dark themes. Requires Claude Code v2.1.221 or later
`/artifacts`| List the [artifacts](</docs/en/artifacts#find-an-artifact-again>) you own or that are shared with you, then attach one to the session, open it in your browser, or copy its link. Available where [artifacts](</docs/en/artifacts#availability>) are. Requires Claude Code v2.1.208 or later; attaching with `Enter` requires v2.1.216
@@ -53,7 +53,7 @@
`/context [all]`| Visualize current context usage as a colored grid. Shows optimization suggestions for context-heavy tools, memory bloat, and capacity warnings. When the conversation exceeds the context window, the output includes a [warning](</docs/en/errors#context-exceeds-the-token-limit>) showing how far over the limit you are and which command frees space. In [fullscreen mode](</docs/en/fullscreen>), `/context` collapses the per-item breakdown to keep the grid visible. Pass `all` to expand it
`/copy [N]`| Copy the last assistant response to clipboard. Pass a number `N` to copy the Nth-latest response: `/copy 2` copies the second-to-last. When code blocks are present, shows an interactive picker to select individual blocks or the full response. Press `w` in the picker to write the selection to a file instead of the clipboard, which is useful over SSH
`/cost`| Alias for `/usage`
-`/dataviz [request]`| **[Skill](</docs/en/skills#bundled-skills>).** Design guidance for charts, graphs, and dashboards. Claude picks the chart form for the data, assigns color by role, validates the palette for colorblind safety and contrast with a bundled script, and applies mark, interaction, and accessibility rules. Uses a brand-neutral placeholder palette that you replace with your own. Requires Claude Code v2.1.198 or later
+`/dataviz [request]`| **[Skill](</docs/en/skills#bundled-skills>).** Design guidance for charts, graphs, and dashboards. Claude picks the chart form for the data, assigns color by role, validates the palette for colorblind safety and contrast with a bundled script, and applies mark, interaction, and accessibility rules. Uses a brand-neutral placeholder palette that you replace with your own
`/debug [description]`| **[Skill](</docs/en/skills#bundled-skills>).** Enable debug logging for the current session and troubleshoot issues by reading the session debug log. Debug logging is off by default unless you started with `claude --debug`, so running `/debug` mid-session starts capturing logs from that point forward. Optionally describe the issue to focus the analysis
`/deep-research <question>`| **[Workflow](</docs/en/workflows#bundled-workflows>).** Fan out web searches on a question, fetch and cross-check sources, and synthesize a cited report
`/design [brief]`| **[Skill](</docs/en/skills#bundled-skills>).** Draft UI mockups, screen flows, landing pages, or posters as artboards on one canvas, published as a Claude Design [artifact](</docs/en/artifacts#draft-a-design-canvas>), for example `/design a settings screen for a mobile banking app`. You edit the artboards in a desktop browser, and your edits save automatically. You can export each artboard as PNG or PDF. Requires Claude Code v2.1.265 or later, a session where [artifacts are available](</docs/en/artifacts#availability>), and an account where the [Design template is available](</docs/en/artifacts#start-from-a-slides-design-or-docs-template>); if your organization has turned that template off, `/design` doesn’t draft designs. Available on the Anthropic API. On Amazon Bedrock, Google Cloud’s Agent Platform, Microsoft Foundry, and Claude Platform on AWS, artifacts aren’t available, so the command is unavailable there
@@ -73,7 +73,7 @@
`/goal [condition|clear]`| Set a [goal](</docs/en/goal>): Claude keeps working across turns until the condition is met or the goal [clears for another reason](</docs/en/goal#how-evaluation-works>). With no argument, shows the current or most recently achieved goal. `clear`, `stop`, `off`, `reset`, `none`, or `cancel` removes an active goal early
`/heapdump`| Write a JavaScript heap snapshot and a memory breakdown to `~/Desktop`, or your home directory on Linux without a Desktop folder, for diagnosing high memory usage. Attach only the `-diagnostics.json` file when reporting a memory issue; the `.heapsnapshot` contains your full conversation and credentials, so don’t share it. Hidden from the command menu; type it in full. See [what to do with the output](</docs/en/troubleshooting#high-cpu-or-memory-usage>)
`/help`| Show help and available commands
-`/hooks`| View [hook](</docs/en/hooks>) configurations for tool events
+`/hooks`| View [hook](</docs/en/hooks#the-%2Fhooks-menu>) configurations
`/ide`| Manage IDE integrations and show status
`/import [codex|gemini|cursor] [--dry-run] [--yes]`| Bring configuration from OpenAI Codex, Google Gemini CLI, or Cursor on your machine into Claude Code, including instruction files, MCP servers, commands, subagents, and skills. In [non-interactive mode](</docs/en/headless>) with `-p`, `/import` lists what it found and gives you the command that confirms the import. Add `--dry-run` to preview without writing anything, or `--yes` to skip the interactive picker. Not available on Amazon Bedrock, Google Cloud’s Agent Platform, Microsoft Foundry, or Claude Platform on AWS, or through a [Claude apps gateway](</docs/en/claude-apps-gateway#availability-and-limitations>). Also unavailable when you turn off [feature-flag fetching](</docs/en/env-vars#features-that-need-feature-flag-fetching>). Requires Claude Code v2.1.213 or later. Importing from Cursor requires v2.1.265 or later
`/init`| Initialize project with a `CLAUDE.md` guide. Set `CLAUDE_CODE_NEW_INIT=1` for an interactive flow that also walks through skills, hooks, and personal memory files. If `/init` finds OpenAI Codex or Google Gemini CLI configuration, it offers to carry it over with `/import`
@@ -85,7 +85,7 @@
`/login`| Sign in to your Anthropic account
`/logout`| Sign out from your Anthropic account
`/loop [interval] [prompt]`| **[Skill](</docs/en/skills#bundled-skills>).** Run a prompt repeatedly while the session stays open. Omit the interval and Claude [self-paces between iterations](</docs/en/scheduled-tasks#let-claude-choose-the-interval>). Omit the prompt and Claude runs the [built-in maintenance prompt](</docs/en/scheduled-tasks#run-the-built-in-maintenance-prompt>) or your [`loop.md`](</docs/en/scheduled-tasks#customize-the-default-prompt-with-loop-md>). Example: `/loop 5m check if the deploy finished`. See [Run prompts on a schedule](</docs/en/scheduled-tasks>). Alias: `/proactive`
-`/mcp [reconnect <server>|enable|disable [<server>|all]]`| Manage MCP server connections and OAuth authentication. Run with no argument to open the interactive list, pass `reconnect <server>` to reconnect one disconnected server, or pass `enable`/`disable` with a server name or `all` to change connection state without opening the dialog. Also available in non-interactive mode (`-p`), where running it with no argument prints a text summary of server status instead of opening the list; requires Claude Code v2.1.205 or later
+`/mcp [reconnect (<server>|all)|enable|disable [<server>|all]]`| Manage MCP server connections and OAuth authentication. Run with no argument to open the interactive list, or pass `reconnect`, `enable`, or `disable` with a server name or `all` to change connection state without opening it. `reconnect all` [retries every server that failed or needs authentication](</docs/en/mcp#retry-failed-servers-yourself>). Also available in non-interactive mode (`-p`), where running it with no argument prints a text summary of server status instead of opening the list; requires Claude Code v2.1.205 or later
`/memory`| Edit `CLAUDE.md` files, enable or disable [auto memory](</docs/en/memory#auto-memory>), and view auto memory entries
`/mobile`| Show QR code to download the Claude mobile app. Aliases: `/ios`, `/android`
`/model [model]`| Switch the AI model and save it as your default for new sessions. For models that support it, use left/right arrows to [adjust effort level](</docs/en/model-config#adjust-effort-level>). With no argument, opens a picker; press `s` on a row to switch for the current session only. See [when Claude Code asks you to confirm the switch](</docs/en/prompt-caching#switching-models>). Once you confirm the switch, if Claude Code asks, Claude Code applies the change without waiting for the current response to finish. Before v2.1.242, Claude Code decided from a feature flag it fetched from Anthropic whether to run the command mid-turn or queue it until the turn finished, and always queued it in a session that doesn’t [fetch feature flags](</docs/en/env-vars#features-that-need-feature-flag-fetching>), such as on a [third-party provider](</docs/en/third-party-integrations>). Also available in non-interactive mode (`-p`) with a model argument instead of the picker, where it applies to the current session only and isn’t saved as your default; requires Claude Code v2.1.205 or later
@@ -94,6 +94,7 @@
`/permissions`| Manage allow, ask, and deny rules for tool permissions. Opens an interactive dialog where you can view rules by scope, add or remove rules, manage working directories, and review [recent auto mode denials](</docs/en/auto-mode-config#review-denials>). You can also view and edit [auto mode classifier rules](</docs/en/auto-mode-config#edit-rules-from-permissions>) from the dialog’s **Auto mode** tab. When you run it while Claude is responding, Claude Code opens the dialog immediately and applies your changes starting with Claude’s next tool call in the same turn. Before v2.1.234, Claude Code queued the command until the turn finished. Alias: `/allowed-tools`
`/plan [description]`| Enter plan mode directly from the prompt. Pass an optional description to enter plan mode and immediately start with that task, for example `/plan fix the auth bug`
`/plugin [subcommand]`| Manage Claude Code [plugins](</docs/en/plugins/overview>). Run with no argument to open the plugin menu, or pass a subcommand such as `list`, `install`, `enable`, or `disable` to act directly. Claude Code can activate a plugin during the install; the [install summary](</docs/en/plugins/install#install-a-plugin>) tells you whether it did or whether to run `/reload-plugins`
+`/plugin-authoring`| Load the reference Claude works from to [write a mod](</docs/en/plugins/mods/create#ask-claude-for-a-mod>). Claude can load it on its own when you ask for a mod. This is a skill from a [built-in plugin](</docs/en/plugins/mods/overview#mods-built-into-claude-code>), which you can turn off in `/plugin`. Requires Claude Code v2.1.287 or later
`/powerup`| Discover Claude Code features through quick interactive lessons with animated demos
`/pr-comments [PR]`| Removed in v2.1.91. Ask Claude directly to view pull request comments instead. On earlier versions, fetches and displays comments from a GitHub pull request; automatically detects the PR for the current branch, or pass a PR URL or number. Requires the `gh` CLI
`/privacy-settings`| View and update your privacy settings. Only available for Pro and Max plan subscribers
@@ -125,7 +126,7 @@
`/status`| Open the Settings interface on the Status tab, showing version, model, account, and connectivity. A `Session kind` row reads `background job · attached` or `background job · unattended` in a [background session](</docs/en/agent-view>), depending on whether a terminal is attached, and `interactive` in any other session. Before v2.1.221, `/status` didn’t show this row. Works while Claude is responding
`/statusline`| Configure Claude Code’s [status line](</docs/en/statusline>). Describe what you want, or run without arguments to auto-configure from your shell prompt
`/stickers`| Order Claude Code stickers
-`/stop`| Stop the current [background session](</docs/en/agent-view>). Only available while attached to a background session; the transcript and any worktree are kept. To detach without stopping, use `/exit` or press `←`
+`/stop`| Stop the [background session](</docs/en/agent-view>) you’re attached to, or the one you send it to as a [peek reply](</docs/en/agent-view#peek-and-reply>); the transcript and any worktree are kept. To detach without stopping, use `/exit` or press `←`
`/subtask <task>`| Spawn a [forked subagent](</docs/en/sub-agents#fork-the-current-conversation>): a background subagent that inherits the full conversation and works on the task while you keep working. Its result returns to this conversation when it finishes. To copy the conversation into a separate background session instead, use `/fork`. Requires Claude Code v2.1.212 or later; on v2.1.161 through v2.1.211 this command is `/fork`. When [agent view is turned off](</docs/en/agent-view#turn-off-agent-view>), `/subtask` isn’t available and `/fork` keeps the forked-subagent behavior
`/tasks`| View and manage background work in the current session, including subagents that have finished. Also available as `/bashes`
`/team-onboarding`| Generate a team onboarding guide from your Claude Code usage history. Claude analyzes your sessions, commands, and MCP server usage from the past 30 days and produces a markdown guide a teammate can paste as a first message to get set up quickly. For claude.ai subscribers on Pro, Max, Team, and Enterprise plans, also returns a share link teammates can open directly in Claude Code
--- a/components.md
+++ b/components.md
@@ -176,7 +176,7 @@
}
}
-Save the script at `scripts/format.sh` and make it executable. Load the plugin and ask Claude to edit a file. A `PostToolUse` hook that exits 0 shows nothing in the transcript, so confirm it ran with [debug logging](</docs/en/hooks#debug-hooks>) or by what the script itself changes. Hooks in `hooks/hooks.json` and in the `hooks` manifest key both load. For every event and its payload, see [Hook events](</docs/en/hooks#hook-events>).
+Save the script at `scripts/format.sh` and make it executable. Load the plugin and ask Claude to edit a file. A `PostToolUse` hook that exits 0 shows nothing in the transcript, so confirm it ran with [debug logging](</docs/en/hooks#debug-hooks>) or by what the script itself changes. Hooks in `hooks/hooks.json` and in the `hooks` manifest key both load. For every event and its payload, see [Hook events](</docs/en/hooks#hook-events>). To write hooks as JavaScript functions that run inside Claude Code and can draw in its interface, list a module file under a `modules` key in the same `hooks/hooks.json`. A plugin with one is a mod. See [Create a mod](</docs/en/plugins/mods/create>).
####
@@ -408,7 +408,7 @@
The command runs in a shell, in the working directory the session started in. A monitor’s command is limited in where it starts and what it can reference:
- * **Interactive sessions only** : plugin monitors start in an interactive session and never in non-interactive mode with the `-p` flag. They also start only where the [Monitor tool](</docs/en/tools-reference#monitor-tool>) is available
+ * **Interactive sessions only** : plugin monitors start in an interactive session and never in non-interactive mode with the `-p` flag. They also don’t start in sessions where the API provider or telemetry settings make the [Monitor tool](</docs/en/tools-reference#monitor-tool>) unavailable
* **No user configuration** : `command` gets the path variables and `${ENV_VAR}` from the environment, but never `${user_config.*}`. A monitor that references one doesn’t start, and monitor processes don’t receive `CLAUDE_PLUGIN_OPTION_<KEY>` either
* **Disabling mid-session** : if you disable a plugin mid-session, Claude Code doesn’t stop monitors that are already running. They stop when the session ends
--- a/costs.md
+++ b/costs.md
@@ -253,7 +253,7 @@
Use `/usage` to check your current token usage, or [configure your status line](</docs/en/statusline#context-window-usage>) to display it continuously.
* **Clear between tasks** : Use `/clear` to start fresh when switching to unrelated work. Stale context wastes tokens on every subsequent message. Use `/rename` before clearing so you can easily find the session later, then `/resume` to return to it.
- * **Add custom compaction instructions** : `/compact Focus on code samples and API usage` tells Claude what to preserve during summarization. In a fresh session, `/compact` prints `Not enough messages to compact.` because there’s no conversation history to summarize yet.
+ * **Add custom compaction instructions** : `/compact Focus on code samples and API usage` tells Claude what to preserve during summarization.
You can also customize compaction behavior in your CLAUDE.md file at the root of your project:
Show diff (750 lines)
--- a/create.md
+++ b/create.md
@@ -1,399 +1,357 @@
-A plugin is a directory of skills, agents, hooks, and MCP servers, plus a `plugin.json` file, called the manifest, that names the plugin. Claude Code loads the directory as one unit, so you can share it with teammates, install it in several projects, or publish it to a marketplace. This page is for people writing their own plugins.
-
-These cases are covered on other pages:
-
- * **Installing someone else’s plugin** : see [Install plugins](</docs/en/plugins/install>)
- * **Not sure you need a plugin** : see [Decide whether you need a plugin](</docs/en/plugins/overview#decide-whether-you-need-a-plugin>) on the overview
- * **Your plugin’s users are on claude.ai or in Cowork** : the same folder installs there with a different subset of components. See [Plugin structure and testing](<https://claude.com/docs/plugins/build>) and the [component support table](<https://claude.com/docs/plugins/platform-support#compare-component-support-by-app>)
-
-Start from the section that matches what you already have:
-
- * **Nothing yet** : follow Create your first plugin, then Develop without a marketplace and Test and debug.
- * **Files under`.claude/` already**: do the first-plugin walkthrough once to learn the layout, then follow Convert an existing `.claude/` setup.
-
-##
-
-
-
-Decide when to use a plugin
-
-Skills, agents, hooks, and MCP servers all work standalone in your project or home directory. Keep that standalone setup while it serves one project or only you. Make a plugin when you want to share the setup with teammates, install it in several projects, or publish versioned releases. When you move standalone skills, agents, hooks, and MCP config into a plugin, their location and names change:
-
- * **Where the files go** : under the plugin’s own directory, called the plugin root, as `skills/`, `agents/`, `hooks/hooks.json`, and `.mcp.json`.
- * **How they’re named** : plugin skills and agents get the plugin name as a prefix, such as `/my-plugin:hello`, so two plugins can each provide a `hello` skill without colliding.
-
-To move an existing setup into a plugin, see Convert an existing `.claude/` setup.
-
-##
-
-
-
-Create your first plugin
-
-In this walkthrough, you create a plugin whose only component is one skill, a greeting, and run it with `--plugin-dir`, which loads a plugin for one session without installing it. A plugin can hold any mix of [components](</docs/en/plugins/components>), such as skills, agents, hooks, and MCP servers, and none is required; one skill is the smallest example that shows the layout. You need Claude Code [installed and signed in](</docs/en/quickstart#step-1-install-claude-code>). Open a terminal in the directory where you want to keep the plugin, such as `~/projects`, and run the commands in these steps from it. You can keep a plugin anywhere, because you pass its path to Claude Code when you start a session.
+A mod is a Claude Code [plugin](</docs/en/plugins/overview>) with an entry file, called the hooks module: a JavaScript or TypeScript file whose functions Claude Code calls when events happen. To make one:
+
+ * **Ask Claude to write it** : describe what you want in a Claude Code session
+ * **Write it yourself** : follow the tutorial to learn how a mod’s code works. You don’t need Node.js, a bundler, or a build step, because Claude Code loads `.js` and `.ts` files directly.
+
+If you haven’t decided whether a mod is the right tool, read the [comparison on the overview](</docs/en/plugins/mods/overview#compare-mods-settings-hooks-skills-and-mcp-servers>) first.
+
+Mods require Claude Code v2.1.287 or later. In your shell, run `claude --version` to check. To see whether mods can load for you, see [Check whether mods can load](</docs/en/plugins/mods/troubleshoot#check-whether-mods-can-load>).
+
+##
+
+
+
+Ask Claude for a mod
+
+Describe the mod you want in an interactive Claude Code session, and Claude writes it. Claude works from a built-in [skill](</docs/en/skills>) named `plugin-authoring`, which tells it where to write the mod, which events and methods your version has, and how the mod gets loaded. Claude can load the skill when you ask for a mod, or you can load it yourself by running `/plugin-authoring` at the Claude Code prompt. The mod runs once you approve it, except in sessions where a mod Claude writes can’t load.
1
+Describe the mod
+
+Ask for the mod in your own words, for example `make a mod that shows the current git branch above the prompt`. Claude writes the mod in a directory of its own in the session’s mods folder, which is `~/.claude/dev-mods/` followed by the session’s ID. A mod’s full path looks like `~/.claude/dev-mods/3f2a9c1e-5b7d-4e8a-9c21-6d0f4b8a7e13/git-branch/`.
+
+In the `default` and `acceptEdits` [permission modes](</docs/en/permission-modes#protected-paths>), Claude Code asks before Claude creates each of the mod’s files, because `~/.claude` is a protected path. Approve each file as it comes up.
+
+2
+
+Approve the mod
+
+When Claude saves the first file, Claude Code asks whether to enable hot reloading for the session. Hot reloading runs the mods Claude writes in this session and picks up each later change.Choose one of these answers:
+
+ * **Enable for this session** : the mods in the session’s mods folder load when the turn ends, and reload at the end of each turn that changes them. Your answer lasts for the session, including after you resume it.
+ * **Not now** : nothing loads for now. The files stay where Claude wrote them, and the mods load the next time that session starts. To keep a mod from ever loading, delete its directory.
+
+3
+
+Check that the mod loaded
+
+Run `/plugin` at the Claude Code prompt and press Tab until the **Installed** tab is selected. It lists the mod, and you can turn it off there.
+
+4
+
+Try the mod
+
+Use what you asked for. For the example prompt, the current branch name appears above the prompt box. If the mod doesn’t do what you wanted, tell Claude what to change. The mod reloads at the end of each turn that changes its files, so you can try the change as soon as Claude finishes.
+
+###
+
+
+
+Use the mod in other sessions
+
+A mod Claude wrote loads only in the session that made it, and Claude Code deletes that session’s mods folder once it’s older than [`cleanupPeriodDays`](</docs/en/settings-reference#cleanupperioddays>). To keep the mod, copy its directory out of the mods folder to a place of your own, such as `~/mods/git-branch`. Then choose how to load it:
+
+ * **In a session you start** : in your shell, run `claude --plugin-dir ~/mods/git-branch`
+ * **For other people** : add it to a marketplace so they can install it
+
+###
+
+
+
+Sessions where a mod Claude writes can’t load
+
+A mod Claude writes loads only after you approve it, in a trusted workspace where mods are allowed to run. In these sessions it doesn’t load:
+
+ * **Nobody is there to approve** : the session can’t show you a prompt, as in a `claude -p` run or [`dontAsk` mode](</docs/en/permission-modes>)
+ * **The workspace isn’t trusted** : you haven’t accepted the trust prompt for the directory
+ * **Mods are disabled** : you started with `--safe-mode` or `--bare`, you set `disableAllHooks`, or your organization’s [managed settings block it](</docs/en/plugins/mods/admin#choose-how-much-to-allow>)
+
+##
+
+
+
+Write a mod yourself
+
+In this tutorial you build a mod named `first-mod` that counts the tool calls Claude makes, shows the count beside the spinner while Claude works, and adds a `/tally` command that prints it. You then read the type declarations Claude Code writes beside your mod and run `claude plugin validate`. Together they show you the events and methods your version offers and what Claude Code reads from your code. This recording shows the finished mod. The spinner counts tool calls, `/tally` prints the count, and an edit to the code takes effect while the session runs:
+
+You write three files:
+
+ first-mod/
+ ├── .claude-plugin/
+ │ └── plugin.json
+ └── hooks/
+ ├── hooks.json
+ └── register.js
+
+ * **`plugin.json`** : the plugin’s [manifest](</docs/en/plugins/manifest-reference>)
+ * **`hooks.json`** : [points to your code file](</docs/en/plugins/mods/reference#files>)
+ * **`register.js`** : your code, called the hooks module
+
+1
+
Create the plugin directory
-Create the plugin directory, with a `.claude-plugin/` folder inside it to hold the manifest:
-
- mkdir -p my-first-plugin/.claude-plugin
+Create the two directories that hold the files:
+
+ * Bash or Zsh
+
+ * PowerShell
+
+ mkdir -p first-mod/.claude-plugin first-mod/hooks
+
+ New-Item -ItemType Directory -Force first-mod\.claude-plugin, first-mod\hooks
2
Write the manifest
-The [manifest](</docs/en/plugins/manifest-reference>) is a JSON file named `plugin.json` that tells Claude Code the plugin’s name and describes it. Save this one as `my-first-plugin/.claude-plugin/plugin.json`:
-
-my-first-plugin/.claude-plugin/plugin.json
+A mod is a plugin, and a mod needs a [manifest](</docs/en/plugins/manifest-reference>). This mod’s manifest has no special fields. Save this as `first-mod/.claude-plugin/plugin.json`:
+
+first-mod/.claude-plugin/plugin.json
{
- "name": "my-first-plugin",
- "description": "A greeting plugin to learn the basics",
- "version": "1.0.0",
- "author": {
- "name": "Your Name"
- }
+ "name": "first-mod",
+ "version": "0.1.0",
+ "description": "Counts Claude's tool calls, shows the count beside the spinner, and adds a /tally command",
+ "author": { "name": "Your Name" }
}
-The four fields do this:
-
- * **`name`** : required. It identifies the plugin and becomes the prefix on every skill and agent the plugin provides. Don’t put spaces in it.
- * **`description`** : the text users see for the plugin in `/plugin`.
- * **`version`** : optional. Setting it keeps users on that version until you change it; [Release a new version](</docs/en/plugins/host-marketplace#release-a-new-version>) says when to set or omit it.
- * **`author`** : who to credit. `name` is required inside it; `email` and `url` are optional.
-
-Every other field is on the [manifest reference](</docs/en/plugins/manifest-reference#fields>).Only `plugin.json` goes inside `.claude-plugin/`. The skill you add next goes directly under `my-first-plugin/`, next to that folder.
-
3
-Add a skill
-
-This plugin’s one component is a skill. Each skill is a directory under `skills/` that contains a `SKILL.md` file. Create the skill’s directory:
-
- mkdir -p my-first-plugin/skills/hello
-
-Then create `my-first-plugin/skills/hello/SKILL.md` with this content:
-
-my-first-plugin/skills/hello/SKILL.md
-
- ---
- name: hello
- description: Greet the user with a friendly message
- disable-model-invocation: true
- ---
-
- Greet the user warmly and ask how you can help them today.
-
-The `disable-model-invocation: true` line means Claude doesn’t run the skill on its own, so only you trigger it. Remove that line from a skill you want Claude to run on its own. The skill’s command combines the plugin name and the skill’s name, so you run this one as `/my-first-plugin:hello`. For the other frontmatter fields, see the [skill frontmatter reference](</docs/en/skills#frontmatter-reference>).
+Tell Claude Code where your code is
+
+When Claude Code loads a plugin, it reads the plugin’s `hooks/hooks.json`. The `modules` key in that file gives the path to your code, and having it is what makes the plugin a mod. List one path, relative to `hooks.json`. Here it points to `register.js`, which you write in the next step.Save this as `first-mod/hooks/hooks.json`:
+
+first-mod/hooks/hooks.json
+
+ {
+ "description": "The first-mod hooks module",
+ "modules": ["./register.js"]
+ }
4
-Validate the plugin
-
-Check the manifest and the skill’s frontmatter before you run anything:
-
- claude plugin validate ./my-first-plugin
-
-The command prints the manifest path it checked and `✔ Validation passed`. If it prints `✘ Validation failed` instead, each line above that result line names the field to fix. Look up each message under [`claude plugin validate` reports errors](</docs/en/plugins/troubleshooting#claude-plugin-validate-reports-errors>).
+Write the code
+
+This file is the mod’s code, called the hooks module. When the mod loads, Claude Code calls the `register` function the file exports and passes it a function named [`on`](</docs/en/plugins/mods/reference#the-hook-function>). Each call to `on` registers an event handler, called a hook, for the event it names.Save this as `first-mod/hooks/register.js`:
+
+first-mod/hooks/register.js
+
+ // The count, shared by the hooks below
+ let calls = 0
+
+ // Claude Code calls this once when the mod loads
+ export function register(on) {
+ // Runs when the session starts, before your first prompt
+ on('session.start', async ($, e, next) => {
+ // Add the /tally command
+ await $.command.register({
+ name: 'tally',
+ description: 'Show how many tool calls Claude has made',
+ })
+ // Let the session start as usual
+ return next(e)
+ })
+
+ // Runs each time Claude is about to use a tool
+ on('tool.call', async ($, e, next) => {
+ calls += 1
+ // Ask Claude Code to draw the interface again, so the new count shows
+ $.ui.invalidate('ui.render')
+ // Let the tool run as usual
+ return next(e)
+ })
+
+ // Runs when you type /tally, and only then, because of the matcher
+ on('command.run', { command: 'tally' }, async () => {
+ // The text to print in the transcript
+ return { text: 'Claude has made ' + calls + ' tool calls since this mod loaded' }
+ })
+
+ // Runs each time Claude Code draws the spinner
+ on('ui.render', { component: 'Spinner' }, async ($, e, next) => {
+ // Keep Claude Code's spinner, with the count added after its word
+ return next({ ...e, props: { ...e.props, suffix: ' · tool calls: ' + calls + '…' } })
+ })
+ }
+
+The file keeps a count in `calls` and registers four hooks:
+
+ * **[`session.start`](</docs/en/plugins/mods/reference#session>)** runs when the session starts, before your first prompt, and again each time the mod reloads. It adds the `/tally` command to Claude Code.
+ * **[`tool.call`](</docs/en/plugins/mods/reference#tools>)** runs each time Claude is about to use a tool. It adds one to `calls` and asks Claude Code to draw the interface again.
+ * **[`command.run`](</docs/en/plugins/mods/reference#commands-and-configuration>)** runs when you type `/tally`. It returns the text to print.
+ * **[`ui.render`](</docs/en/plugins/mods/reference#interface>)** runs each time Claude Code draws the spinner. It adds the count after the spinner’s word.
+
+How the example mod works explains the three arguments each hook takes and what each one returns.
5
-Run Claude Code with the plugin
-
-Start a session with the plugin loaded:
-
- claude --plugin-dir ./my-first-plugin
-
-Once Claude Code starts, run the skill:
-
- /my-first-plugin:hello
-
-Claude replies with a greeting.
-
-The plugin loads only in sessions you start with `--plugin-dir`. To keep working on it without the flag, or to test a `.zip` build, see Develop without a marketplace. To have Claude scaffold and check a larger plugin with you, [install](</docs/en/plugins/install#install-a-plugin>) Anthropic’s `plugin-dev` plugin from the `claude-plugins-official` marketplace, which adds skills and agents for writing components such as skills, hooks, and MCP servers and for validating the finished plugin. Once it’s installed, run `/plugin-dev:create-plugin` followed by a description of the plugin you want, and Claude walks you through designing, creating, and validating it.
-
-###
-
-
-
-Share your plugin
-
-A plugin you built with Create your first plugin exists only on your machine. When it’s ready for other people, there are three ways to get it to them:
-
- * **Send it to a few people directly** : give them the plugin’s directory or a `.zip` of it, and nothing needs to be published. See [Share a plugin without a marketplace](</docs/en/plugins/publish#share-a-plugin-without-a-marketplace>).
- * **List it in your own marketplace** : teammates add your marketplace once and install the plugin by name, and they receive your updates. See [Publish through your own marketplace](</docs/en/plugins/publish#publish-through-your-own-marketplace>).
- * **Submit it to Anthropic’s directory** : after it passes review, people can add it on claude.ai and in Cowork, and it reaches Claude Code through their account. See [Submit to Anthropic’s directory](</docs/en/plugins/publish#submit-to-anthropics-directory>).
-
-###
-
-
-
-Plugin layout
-
-Each kind of [component](</docs/en/plugins/components>), such as skills, agents, hooks, and MCP servers, goes in a fixed directory under the plugin root, which is the directory you pass to `--plugin-dir`. Add only the directories you use. To click through a complete plugin directory and read what each file does, open the [plugin explorer](</docs/en/plugins/components#explore-the-plugin-directory>). The table lists the directories most plugins start with, and the [full layout](</docs/en/plugins/manifest-reference#standard-layout>) lists the rest.
-
-Location| Contents
+Load the mod
+
+Start Claude Code with the `--plugin-dir` flag, which loads a plugin directory for one session without installing it:
+
+ claude --plugin-dir ./first-mod
+
+6
+
+Try the mod
+
+Ask Claude to do something that takes a few tool calls, such as `list the files here and read the README`. While Claude works, the spinner’s word is followed by a count that rises, as in `Thinking · tool calls: 2…`. When Claude finishes, type `/tally` and press Enter. The transcript shows `first-mod: Claude has made 2 tool calls since this mod loaded`, with your own count. Claude Code puts the plugin’s name in front of the command’s text.To check the command without an interactive session, run it in non-interactive mode:
+
+ claude -p "/tally" --plugin-dir ./first-mod
+
+ first-mod: Claude has made 0 tool calls since this mod loaded
+
+If `/tally` isn’t in the command list, the module didn’t load. See [Find out why a mod does nothing](</docs/en/plugins/mods/troubleshoot#find-out-why-a-mod-does-nothing>).
+
+7
+
+Change the code while the session runs
+
+Leave the session open. In `register.js`, change `' · tool calls: '` to `' · tools used: '` in the `ui.render` hook and save. The highlighted line is the one that changes:
+
+first-mod/hooks/register.js
+
+ // Runs each time Claude Code draws the spinner
+ on('ui.render', { component: 'Spinner' }, async ($, e, next) => {
+ // Keep Claude Code's spinner, with the count added after its word
+ return next({ ...e, props: { ...e.props, suffix: ' · tools used: ' + calls + '…' } })
+ })
+
+A line in the transcript says `first-mod` reloaded and lists its hooks, and the next spinner uses the new text, as in `Thinking · tools used: 1…`.
+
+###
+
+
+
+How the example mod works
+
+Each function you pass to `on` is a hook, which is an event handler. Claude Code passes every hook the same three arguments:
+
+ * **The mods API** , named `$`: every method a mod can call to reach outside itself, in [namespaces](</docs/en/plugins/mods/reference#mods-api-methods>) such as `$.ui` and `$.command`
+ * **The event** , named `e`: the [event’s input](</docs/en/plugins/mods/reference#events>) as plain data, such as a tool call’s name and arguments
+ * **The next handler** , named [`next`](</docs/en/plugins/mods/events#how-a-hook-handles-an-event>): a function that passes the event on to the other mods and then to Claude Code’s own behavior, and returns the result
+
+The hooks in `first-mod` handle their events in these ways:
+
+ * **Observe** : the `session.start` hook registers the command, and the `tool.call` hook counts the call and asks for a redraw. Both return `next(e)`, so the session starts and the tool runs as usual.
+ * **Answer** : the `command.run` hook returns its own result and never calls `next`. The second argument to `on`, `{ command: 'tally' }`, is a filter, called a [matcher](</docs/en/plugins/mods/events#filter-which-events-a-hook-handles>), so the hook runs only for `/tally`.
+ * **Rewrite** : the `ui.render` hook calls `next` with a copy of `e` whose `suffix` holds the count, so Claude Code draws its usual spinner with your text after the word
+
+Claude Code watches a directory loaded with `--plugin-dir` and hot-reloads the hooks module when a file in it changes. Each reload runs `register` again, so `calls` resets to `0` and `/tally` starts counting again. To keep a value across reloads, see [Keep state](</docs/en/plugins/mods/interface#keep-state>).
+
+##
+
+
+
+Keep working on a mod
+
+Once a mod loads, you can have Claude change it, check your code against the type definitions for your version, list the events and calls Claude Code finds in it, and test it.
+
+###
+
+
+
+Change a mod with Claude
+
+To change a mod you already have, start the session with `--plugin-dir` pointed at the mod’s directory, so that what Claude writes loads in the same session:
+
+ claude --plugin-dir ./first-mod
+
+Then ask for the change, for example `add a /tally-reset command to this mod that sets the tally back to zero`. Claude edits the hooks module, runs `claude plugin validate`, and fixes what it reports. A directory you load with `--plugin-dir` is a [protected path](</docs/en/permission-modes#protected-paths>), so in `default` and `acceptEdits` modes you’re asked to approve each of Claude’s edits to the mod. The protected paths table gives the result for the other permission modes. Files Claude saves during its turn reload when the turn ends, so you can try `/tally-reset` as soon as Claude finishes.
+
+###
+
+
+
+Get type definitions for your version
+
+Each time Claude Code loads or reloads a mod from a directory you pass to `--plugin-dir`, or a mod Claude wrote for you, it writes TypeScript declaration files, ending in `.d.ts`, into `.claude-plugin/types/` inside the mod’s directory. They describe the exact events, mods API methods, and elements in the Claude Code version you’re running, so your editor can autocomplete and type-check your hooks. To browse the declarations online, read [`mods/types/claude-code.d.ts`](<https://github.com/anthropics/claude-code/blob/main/mods/types/claude-code.d.ts>) in the Claude Code repository, whose first line names the version that wrote it. The directory holds these files:
+
+Path| What it declares
---|---
-`.claude-plugin/plugin.json`| The manifest. When you load a plugin with `--plugin-dir` and it has no manifest, Claude Code names the plugin after its directory
-`skills/`| One `<name>/SKILL.md` directory per skill
-`commands/`| Flat Markdown files, the older form of skills. Use `skills/` for new plugins
-`agents/`| One Markdown file per subagent
-`hooks/hooks.json`| Hook configuration: a top-level `"hooks"` key whose value has the same shape as `hooks` in a settings file
-`.mcp.json`| MCP server definitions
-
-Only `plugin.json` goes inside `.claude-plugin/`. Components saved there don’t load.The plugin root is the plugin’s own directory, not `~/.claude/` itself. A `.mcp.json` saved at `~/.claude/.mcp.json` doesn’t load.
-
-##
-
-
-
-Develop without a marketplace
-
-You don’t need a [marketplace](</docs/en/plugins/overview#get-plugins-from-a-marketplace>) to run a plugin you’re writing. Load it directly from disk or a URL instead:
-
- * `--plugin-dir`: loads a directory or `.zip` archive for one session.
- * `--plugin-url`: fetches a `.zip` archive from a URL for one session.
- * `claude plugin init`: scaffolds a plugin under `~/.claude/skills/` that loads every session.
-
-If two plugins loaded in different ways share a name, see [Name conflicts](</docs/en/plugins/loading#name-conflicts>) for which one Claude Code keeps.
-
-###
-
-
-
-Load a plugin for one session
-
-You can load a plugin for a single session in three ways: from a directory or `.zip` archive on disk with `--plugin-dir`, from a URL with `--plugin-url`, or from an environment variable when you can’t add a flag. Each plugin loads for that session only, and nothing is written to your settings for it. When you edit the plugin’s files during the session, run `/reload-plugins` to load the changes.
-
-####
-
-
-
-From a directory or `.zip`
-
-When you start `claude` from your shell, pass `--plugin-dir` with the plugin’s root directory or a `.zip` archive of it. Repeat the flag to load several plugins:
-
- claude --plugin-dir ./my-first-plugin --plugin-dir ./other-plugin.zip
-
-####
-
-
-
-From a folder of plugins
-
-To load several plugins from one place, pass a folder that holds them, such as `--plugin-dir ./plugins`. Loading a folder of plugins requires Claude Code v2.1.265 or later. If the folder has no `.claude-plugin/` directory and no plugin components at its top level, Claude Code treats it as a folder of plugins. Each immediate subfolder that has a `.claude-plugin/plugin.json` manifest then loads as a separate plugin. Everything else in the folder is skipped without an error, including a subfolder that has no manifest. If a plugin in the folder doesn’t load, check that its subfolder has a `.claude-plugin/plugin.json`. You can also pass a folder that keeps a `.claude-plugin/marketplace.json` beside its plugin folders. As long as that `.claude-plugin/` directory holds no `plugin.json`, the plugin folders still load. Nothing is installed or enabled from the marketplace file, because Claude Code doesn’t read it. Loading plugins from such a folder requires Claude Code v2.1.281 or later. In an interactive session, you can also add and remove plugins in the folder after startup:
-
- * A subfolder you add loads as a new plugin once its manifest exists.
- * When you remove a subfolder, its plugin unloads.
-
-A message appears in the session for each of these changes. If loading or unloading a plugin mid-conversation would [invalidate the prompt cache](</docs/en/prompt-caching#enabling-or-disabling-a-plugin>), the change is held instead, and the message tells you to run `/reload-plugins` to apply it.
-
-####
-
-
-
-From a URL
-
-When you start `claude` from your shell, pass `--plugin-url` with the address of a `.zip` archive, such as a build artifact your CI publishes:
-
- claude --plugin-url https://example.com/my-first-plugin.zip
-
-Claude Code downloads the archive at startup. To load several, repeat the flag or pass the URLs space-separated in one quoted argument. Point the flag only at archives you control or trust. If Claude Code can’t fetch the archive, or the archive is invalid, it starts without the plugin and records a plugin load error that you can review in the `/plugin` manager’s **Errors** tab.
-
-####
-
-
-
-From an environment variable
-
-To load plugins in a session where you can’t add the `--plugin-dir` flag, list their absolute paths in the [`CLAUDE_CODE_PLUGIN_DIRS`](</docs/en/env-vars#variables>) environment variable instead. Claude Code loads each path as it loads a `--plugin-dir` path. These plugins load in addition to any you pass with `--plugin-dir`. [Project and local settings can’t set this variable](</docs/en/settings-reference#variables-claude-code-ignores-in-env>). `CLAUDE_CODE_PLUGIN_DIRS` requires Claude Code v2.1.280 or later. Managed settings can turn off `--plugin-dir` and `CLAUDE_CODE_PLUGIN_DIRS`. See [Flags that load a plugin for one session](</docs/en/plugins/cli-reference#flags-that-load-a-plugin-for-one-session>). To test a plugin together with a plugin it depends on, see [Test a plugin and its dependency locally](</docs/en/plugins/dependencies#test-a-plugin-and-its-dependency-locally>).
-
-###
-
-
-
-Make a plugin load in every session
-
-Your personal skills directory is `~/.claude/skills/`. Claude Code loads any folder there that contains a `.claude-plugin/plugin.json` as a plugin in every session, with no flag and no install step. `claude plugin init` scaffolds one of these plugins for you.
-
-####
-
-
-
-Scaffold the plugin with `claude plugin init`
-
-`claude plugin init` writes a starter plugin under `~/.claude/skills/`. Requires Claude Code v2.1.157 or later. Scaffold one from your shell:
-
- claude plugin init my-tool
-
-The command creates `~/.claude/skills/my-tool/` with a `.claude-plugin/plugin.json` and a root `SKILL.md`. It prints `✔ Created plugin "my-tool" at ~/.claude/skills/my-tool` followed by `It will auto-load next session as my-tool@skills-dir. Run /reload-plugins to load it now.` Pass `--with skills` to have `claude plugin init` scaffold a skill under `skills/` for you. The other `--with` values are on the [plugin commands reference](</docs/en/plugins/cli-reference#plugin-init>).
-
-####
-
-
-
-Name the plugin’s skills
-
-The root skill at `~/.claude/skills/my-tool/SKILL.md` is also a personal skill, so you invoke it as `/my-tool`, not `/my-tool:my-tool`. Skills you add under `skills/` inside the plugin get the plugin-name prefix, such as `/my-tool:example`.
-
-####
-
-
-
-Stop loading the plugin
-
-To stop loading a scaffolded plugin, delete its directory, or run `claude plugin disable my-tool@skills-dir` in your shell with the `my-tool@skills-dir` name that `claude plugin init` printed. In the ID `my-tool@skills-dir`, `skills-dir` stands where a marketplace name would, because the plugin loads from your skills directory rather than from a marketplace.
-
-####
-
-
-
-Share the plugin through a repository
-
-`claude plugin init` writes the plugin to your personal skills directory at `~/.claude/skills/`, so it loads for you in every project. To make a plugin load for everyone in one repository, create the same layout yourself at `<project>/.claude/skills/<name>/`, including its `.claude-plugin/plugin.json`. See [Plugins shared through a repository](</docs/en/plugins/loading#plugins-shared-through-a-repository>) for the conditions under which Claude Code loads it.
-
-##
-
-
-
-Test and debug
-
-When a change to your plugin doesn’t show up, work through these checks in order. Each one tells you what Claude Code did with the plugin:
-
- 1. In your shell, run `claude plugin validate <path>`. It checks the manifest and the frontmatter of every skill, agent, and command file, and exits `0` on `Validation passed`. Add `--strict` to fail on warnings too. Exit codes and directory handling are on the [plugin commands reference](</docs/en/plugins/cli-reference#plugin-validate>).
- 2. In the running session, run `/reload-plugins` to apply edits you made on disk. It prints one `Reloaded:` line with counts. Then confirm a skill loaded by typing its `/plugin-name:skill` command, or by finding the plugin in the `/plugin` **Installed** tab.
- 3. In the same session, run `/plugin`. The **Installed** tab lists your plugin and, in the plugin’s details, the components Claude Code found. The **Errors** tab lists what failed to load and why, such as a path in your manifest that doesn’t exist.
- 4. Back in your shell, run `claude plugin list`. It prints session-only and skills-directory plugins in their own sections with `Status: ✔ loaded` or the load error. To include the plugin you’re developing, pass `--plugin-dir` with its path before `plugin list`.
-
-To check an MCP server, run `/mcp` in the session to see the server’s status. When the server is healthy, `/mcp` lists it as connected. If it isn’t, see [MCP servers that don’t start](</docs/en/plugins/troubleshooting#invalid-mcp-server-config-for-and-mcp-servers-that-dont-start>). To check a hook, trigger the event it matches. For example, ask Claude to edit a file to trigger a `PostToolUse` hook. Then read the [debug log](</docs/en/hooks#debug-hooks>), which shows which hooks matched, their exit codes, and their output. The next sections cover the failures you’re most likely to hit while developing, and the [troubleshooting page](</docs/en/plugins/troubleshooting#build-a-plugin>) has the full entry for each.
-
-###
-
-
-
-A component path isn’t found
-
-The **Errors** tab of `/plugin` shows `<component> path not found: <path>`, for example `commands path not found`. A component path in your manifest, such as `commands`, `skills`, `agents`, or `hooks`, points at nothing. Fix the path or create the directory, then run `/reload-plugins` in the session. See [`commands path not found`](</docs/en/plugins/troubleshooting#commands-path-not-found>).
-
-###
-
-
-
-`--plugin-dir` at a marketplace root doesn’t load the plugins under `plugins/`
-
-`--plugin-dir` takes the plugin’s root directory, the one that contains `.claude-plugin/plugin.json` and the component directories such as `skills/`. If you point it at a marketplace root instead, Claude Code doesn’t read `marketplace.json`, so a plugin under `plugins/` doesn’t load, and you see no error. Point the flag at one plugin’s folder, or add the marketplace. See [the troubleshooting entry](</docs/en/plugins/troubleshooting#plugin-dir-loads-a-plugin-with-no-components>).
-
-###
-
-
-
-The plugin loads but its skills are missing
-
-The `skills/` directory is inside `.claude-plugin/`, or a `skills` entry in the manifest points at a file. Move `skills/` to the plugin root, point each `skills` entry at a directory that contains `SKILL.md`, and run `/reload-plugins` in the session. See [Plugin loads but its skills are missing](</docs/en/plugins/troubleshooting#plugin-loads-but-its-skills-are-missing>).
-
-###
-
-
-
-The `userConfig` dialog never appears
-
-The dialog for your plugin’s [`userConfig`](</docs/en/plugins/components#user-configuration>) options is part of installing through `/plugin` in a session. Loading with `--plugin-dir` doesn’t show it, and neither does `claude plugin install` in the shell. With the plugin loaded, run `/plugin configure <plugin-name>` in the session to open it. See [The `userConfig` dialog never appears](</docs/en/plugins/troubleshooting#the-userconfig-dialog-never-appears>).
-
-###
-
-
-
-Check that the plugin changes Claude’s behavior
-
-A plugin that loads without errors can still fail to steer Claude the way you intend. `claude plugin eval`, which you run in your shell, runs your test cases with and without the plugin and scores the difference. See [Test plugins with evals](</docs/en/plugin-evals>), starting with [Create your first eval suite](</docs/en/plugin-evals#create-your-first-eval-suite>).
-
-##
-
-
-
-Convert an existing `.claude/` setup
-
-If you already have skills, agents, or hooks under a project’s `.claude/` directory, you can move them into a plugin without rewriting them. Run the commands in these steps from the project root, which is the directory that contains `.claude/`, because the `cp` paths are relative to it.
-
-1
-
-Create the plugin structure
-
-Create the plugin directory and its `.claude-plugin/` folder alongside `.claude/`. You can move the plugin anywhere afterwards.
-
- mkdir -p my-plugin/.claude-plugin
-
-Create `my-plugin/.claude-plugin/plugin.json`:
-
-my-plugin/.claude-plugin/plugin.json
-
- {
- "name": "my-plugin",
- "description": "Migrated from standalone configuration",
- "version": "1.0.0"
- }
-
-2
-
-Copy your existing files
-
-Copy each configuration directory you have to the plugin root, and skip the command for any directory you don’t have.
-
- cp -r .claude/commands my-plugin/
-
- cp -r .claude/agents my-plugin/
-
- cp -r .claude/skills my-plugin/
-
-Run `ls -a my-plugin` to confirm that each directory you copied appears next to `.claude-plugin`.
-
-3
-
-Move your hooks
-
-If you have hooks in `.claude/settings.json` or `.claude/settings.local.json`, create a hooks directory:
-
- mkdir -p my-plugin/hooks
-
-Create `my-plugin/hooks/hooks.json` and copy the `hooks` object from your settings file into it. The format is the same.This example shows the shape with one hook that runs a linter on each file Claude writes or edits. Replace the example with your own `hooks` object.
-
-my-plugin/hooks/hooks.json
-
- {
- "hooks": {
- "PostToolUse": [
- {
- "matcher": "Write|Edit",
- "hooks": [{ "type": "command", "command": "jq -r '.tool_input.file_path' | xargs npm run lint:fix" }]
- }
- ]
- }
- }
-
-4
-
-Test the migrated plugin
-
-Load the plugin for a session:
-
- claude --plugin-dir ./my-plugin
-
-Check each component under its new name:
-
- * **Skills** : run `/my-plugin:deploy` for a skill that was `/deploy`.
- * **Subagents** : ask Claude to use the `my-plugin:reviewer` agent for an agent that was `reviewer`.
- * **Hooks** : trigger the event each hook matches.
-
-If something is missing, work through Test and debug.
-
-While the originals are still under `.claude/`, they stay loaded alongside the plugin’s copies:
-
- * **Skills and agents** : the two sets don’t collide, because the plugin’s skills and agents carry the `my-plugin:` prefix. `/deploy` and `/my-plugin:deploy` both work, and Claude sees `reviewer` and `my-plugin:reviewer` as two subagents.
- * **Hooks** : hooks have no prefix, so a hook that is in both your settings file and `hooks/hooks.json` runs twice each time its event fires.
-
-After you’ve confirmed the plugin works, delete the originals from `.claude/` and remove the `hooks` object from your settings file.
+`claude-code/index.d.ts`| Every event and its input and result, every mods API namespace and method, and the elements each surface can draw
+`claude-code-tools/index.d.ts`| The built-in tools’ inputs and results, so that checking `e.tool === 'Bash'` narrows `e`
+`claude-code-mcp/index.d.ts`| The inputs of the MCP tools that were connected the last time you saved a file in the mod
+`index.d.ts` in a directory named for a plugin| What that plugin adds to the mods API. There’s one directory for each plugin your `plugin.json` lists under `dependencies`.
+`tsconfig.json`| Compiler options that fit a hooks module
+
+If your mod has no `tsconfig.json` of its own, Claude Code adds one at the mod’s root that extends the generated one, so your editor and `tsc -p ./first-mod` type-check the mod without more setup. The events and methods can change between releases, so trust these files over any page, this one included, when they disagree. `claude-code/index.d.ts` is the fullest reference for your build, with a comment and an example for every mods API method. To look something up, search the file for its name, such as `'tool.call'`.
+
+###
+
+
+
+Check what Claude Code reads from your mod
+
+To see your mod the way Claude Code sees it, without running your code or starting a session, use `claude plugin validate`. It checks the manifest and runs the same static analysis on the hooks module’s source that Claude Code runs when it loads a mod. In your shell, run it on the mod’s directory:
+
+ claude plugin validate ./first-mod
+
+For `first-mod`, the output includes these lines.
+
+ ❯ ./register.js hooks: session.start, tool.call, command.run{command=tally}, ui.render{component=Spinner}
+ ❯ ./register.js calls: $.command.register, $.ui.invalidate
+
+ ✔ Validation passed
+
+The `hooks:` line lists the events your module hooks, each with its filter in braces. The `calls:` line lists every mods API method it calls. A module that reads or sets environment variables also gets `env reads:` and `env writes:` lines, and one that uses [`$.state`](</docs/en/plugins/mods/interface#keep-state>) gets `state reads:` and `state writes:`. If an event you meant to handle is missing from the first line, Claude Code won’t call that hook either. The usual cause is a misspelled event name, which the command reports as an error such as `"tool.calls" is not an event`. Follow these rules so that static analysis can find every hook and call:
+
+ * Write each mods API call in full: `$`, the namespace, then the method, as in `$.store.get('notes')`. You can pass `$` to a function declared at the top level of the same file, and for a function of yours named `loadNotes`, the `calls:` line then reads `$.store.get (via loadNotes)`. Passing `$` to a method, a function defined inside the hook, or a function you import from another of your files fails validation. The `read` and `update` functions that [`$.state`](</docs/en/plugins/mods/interface#keep-state>) uses are the imports that can take it. Don’t assign `$` or one of its namespaces to a variable, destructure it, or index it with a computed name. `const ui = $.ui` fails with `$.ui is used as a value`.
+ * Write the event name in each `on` call as a string literal, such as `'tool.call'`. A variable, or a loop over a list of names, fails with `the event name passed to on() is not a string literal`.
+ * Inside `register`, don’t declare a second variable or parameter named `on`. Validation fails with `"on" is declared again (shadowed)`.
+ * Import only from files inside the plugin directory, by relative path. The one bare import allowed is `claude-code`, for types and a few helpers.
+ * Use `import` declarations at the top of the file, as in `import { name } from './file.js'`. A dynamic `import()` fails with `a dynamic import(); a hooks module imports its own files with an import declaration`.
+ * Write every file as an ES module, with `import` and not `require`. The [reference](</docs/en/plugins/mods/reference#files>) lists the file extensions Claude Code loads.
+
+###
+
+
+
+Test the mod
+
+You can write automated tests for a mod and run them from your shell with `claude plugin test`, with no session, sign-in, or network. A test fires the events your hooks handle and checks what the hooks did. This test fires two tool calls, runs `/tally`, and checks that the reply counts both. Save it as `first-mod/tests/first-mod.test.ts`:
+
+first-mod/tests/first-mod.test.ts
+
+ import { expect, test } from 'claude-code/testing'
+
+ test('/tally reports the tool calls the mod has seen', async ($, on) => {
+ // Answer each tool call in Claude Code's place, so no tool runs
+ on('tool.call', () => ({ result: 'ok' }))
+
+ // Fire two tool calls, which the mod's tool.call hook counts
+ await $.tool.call({ tool: 'Bash', command: 'ls' })
+ await $.tool.call({ tool: 'Read', file_path: 'README.md' })
+
+ // Run /tally and check the text its hook returns
+ const answer = await $.command.run({ command: 'tally', args: '' })
+ expect(answer.text).toBe('Claude has made 2 tool calls since this mod loaded')
+ })
+
+In your shell, run the tests from the `first-mod` directory:
+
+ claude plugin test
+
+The output names each test and whether it passed, with timings that vary from run to run:
+
+ tests/first-mod.test.ts:
+ (pass) /tally reports the tool calls the mod has seen [22.87ms]
+
+ 1 pass
+ 0 fail
+ Ran 1 test across 1 file. [0.19s]
+
+[Test a mod](</docs/en/plugins/mods/test>) covers stubbing a model call or the store, and testing timers and drawings.
+
+##
+
+
+
+Share your mod
+
+A mod is a plugin, so you version it in the manifest and people install and update it with the `/plugin` commands. To give it to other people, [add it to a marketplace](</docs/en/plugins/publish>). Before you do, check the plugin’s `name`: `claude plugin validate` fails a name that [looks like one of Anthropic’s own](</docs/en/plugins/manifest-reference#name>), such as one that starts with `claude-`. The events and methods can change between releases, so your README is the place to say which Claude Code version you tested with. Keep developing against the directory with `--plugin-dir`, not against an installed copy. Claude Code caches an installed plugin by version, so your edits don’t reach the installed copy until you increment the version and install again.
##
@@ -401,10 +359,9 @@
Next steps
- * [Plugin components](</docs/en/plugins/components>): add agents, hooks, MCP servers, LSP servers, and user configuration to your plugin
- * [Test plugins with evals](</docs/en/plugin-evals>): write eval cases and run them with `claude plugin eval` to check how reliably the plugin guides Claude’s behavior
- * [Publish a plugin](</docs/en/plugins/publish>): version it, put it in a marketplace, and submit it for review
- * [Plugin structure and testing](<https://claude.com/docs/plugins/build>): the same plugin folder installs on claude.ai and in Cowork. Some components are Claude Code-only, and the [component support table](<https://claude.com/docs/plugins/platform-support#compare-component-support-by-app>) lists which load on each surface
- * [Plugin manifest reference](</docs/en/plugins/manifest-reference>): every `plugin.json` field, path rule, and directory
- * [Skills](</docs/en/skills>): write the skills your plugin provides
- * [Anthropic’s plugins in the claude-code repository](<https://github.com/anthropics/claude-code/tree/main/plugins>): complete worked examples of the layout on this page, such as `feature-dev` and `code-review`
+ * [Draw in the interface](</docs/en/plugins/mods/interface>): open a pane, draw above the prompt, and add buttons and text fields
+ * [React to events](</docs/en/plugins/mods/events>): hook tool calls, prompts, and turns
+ * [Use the mods API](</docs/en/plugins/mods/api>): add commands and tools, call a model, and run work on a timer
+ * [Test a mod](</docs/en/plugins/mods/test>): stub what Claude Code would answer, and test timers and drawings
+ * [Troubleshoot a mod](</docs/en/plugins/mods/troubleshoot>): the reasons a mod does nothing, and the debug log
+ * [Read the source of built-in mods](</docs/en/plugins/mods/overview#read-the-source-of-built-in-mods>): complete plugins, each with its hooks module and tests
--- a/create-marketplace.md
+++ b/create-marketplace.md
@@ -104,7 +104,7 @@
* `source`: where Claude Code fetches the plugin from. Write a relative path string for a plugin inside the marketplace directory, as in the walkthrough, or a source object for a plugin outside it. See Choose a plugin source.
* `description`: the line people see next to the plugin when they browse your marketplace in `/plugin`.
-For the full field list, see [Plugin entries](</docs/en/plugins/marketplace-reference#plugin-entries>). An entry can also set any [`plugin.json`](</docs/en/plugins/manifest-reference>) field. For when an entry’s `plugin.json` fields apply to a plugin that has its own `plugin.json`, see [Entry and plugin.json](</docs/en/plugins/marketplace-reference#entry-and-plugin-json>).
+For the full field list, see [Plugin entries](</docs/en/plugins/marketplace-reference#plugin-entries>), which also covers the [`plugin.json`](</docs/en/plugins/manifest-reference>) fields an entry can set and when they apply.
##
--- a/cross-session-messaging.md
+++ b/cross-session-messaging.md
@@ -50,6 +50,7 @@
* The message is over the size cap. Claude Code refuses it in the sending session, before it leaves.
* A rapid burst to a session on this machine has reached what that session’s inbox accepts. Claude Code refuses further messages to that session.
+ * A session beyond this machine is listed as unable to receive cross-session messages. Claude Code refuses the message in the sending session, before it leaves this machine.
* The reply target on this machine fails a safety check, such as a symlinked target. [Refusing to send a cross-session message](</docs/en/errors#refusing-to-send-a-cross-session-message>) lists these checks.
The receiving session checks each arriving message against its own inbound controls, and the check ends in one of three outcomes:
@@ -140,7 +141,12 @@
On another of your machines| Through Anthropic servers, arriving over that machine’s [Remote Control](</docs/en/remote-control>) connection
In the [cloud](</docs/en/claude-code-on-the-web>)| Through Anthropic servers, straight to the cloud session
-Starting a conversation with a session on another of your machines requires Claude Code v2.1.225 or later and a target that appears in the listing. You can message a session shown as `offline` in the listing, one whose Remote Control connection has dropped. The send goes through, but the message arrives only after that session’s machine reconnects. A session inside a container and a session on the host can’t reach each other. Two sessions inside the same container can still message each other, including on a [self-hosted runner](</docs/en/self-hosted-environments>). A session inside WSL 2 and a native Windows session on the same computer can’t reach each other either. If this session isn’t connected to Remote Control when Claude sends to a session beyond this machine, the message still goes through, but without a reply address, so the receiving Claude can’t answer it. To require your approval before any message goes beyond this machine, set `isolatePeerMachines`.
+Starting a conversation with a session on another of your machines requires Claude Code v2.1.225 or later and a target that appears in the listing. A session’s row in the listing can show a condition that changes what happens when Claude messages that session:
+
+ * **`offline`** : that session’s Remote Control connection has dropped. The message goes through, but arrives only after that session’s machine reconnects.
+ * **`can't receive cross-session messages (off in that session)`** : messaging isn’t available in that session, or its [`crossSessionInbound`](</docs/en/settings-reference#crosssessioninbound>) value is `refuse`. Claude Code refuses a message to that session before the message leaves this machine. The result under Claude’s `SendMessage` call begins `Not sent` and names the reason. Once the cause is fixed in that session, a later listing no longer shows this condition, and Claude can message that session.
+
+A session inside a container and a session on the host can’t reach each other. Two sessions inside the same container can still message each other, including on a [self-hosted runner](</docs/en/self-hosted-environments>). A session inside WSL 2 and a native Windows session on the same computer can’t reach each other either. If this session isn’t connected to Remote Control when Claude sends to a session beyond this machine, the message still goes through, but without a reply address, so the receiving Claude can’t answer it. To require your approval before any message goes beyond this machine, set `isolatePeerMachines`.
##
@@ -303,6 +309,7 @@
* **Cloud session missing** : a cloud session appears only while this session is connected to [Remote Control](</docs/en/remote-control>).
* **Other-machine session missing** : a session on another of your machines appears only when it runs with [Remote Control](</docs/en/remote-control>) and this session is connected as well.
* **Other-machine session`offline`**: a message to a session listed as `offline` goes through, but arrives only after that session’s machine reconnects.
+ * **Cloud or other-machine session`can't receive cross-session messages`**: a message to a session listed with this condition doesn’t leave this machine, and the result under `SendMessage` begins `Not sent`.
* **Older cloud or other-machine session missing** : Claude Code reads those session lists newest first and stops after a bounded number of pages, so Claude can’t message a session that fell past them by name.
In a session with messaging, `/status` also shows a `Peer address` row with the session’s own inbox address, or `unavailable` and the reason when Claude Code couldn’t set up an inbox.
--- a/debug-your-config.md
+++ b/debug-your-config.md
@@ -51,11 +51,15 @@
Check hooks
-Run `/hooks` to list every hook registered for the current session, grouped by event. If a hook you defined doesn’t appear, it isn’t being read: hooks go under the `"hooks"` key in a settings file, not in a standalone file. If the hook appears but doesn’t fire, the matcher is the usual cause. Check it for these mistakes:
+Run `/hooks` to list every hook registered for the current session, grouped by event. If a hook you defined doesn’t appear, Claude Code didn’t load it. Check for these causes:
+
+ * The hook is defined in a standalone file. Hooks go under the `"hooks"` key in a [settings file](</docs/en/settings#settings-files>).
+ * The `matcher` value is an array instead of a single string. Claude Code lists the entry as an invalid setting when you start an interactive session and in `claude doctor`. If the array is under `PreToolUse` or `PermissionRequest`, none of that file’s other hooks load either.
+
+If the hook appears but doesn’t fire, the matcher is the usual cause. Check it for these mistakes:
* The `matcher` field is a single string that uses `|` to match multiple tool names, for example `"Edit|Write"`. A `,` separator is equivalent, so `"Edit,Write"` matches the same tools. Before v2.1.191, a comma fell through to regex evaluation and the matcher never matched, so use `|` if you aren’t on v2.1.191 yet.
* A misspelled tool name produces a matcher that matches nothing, so the hook fails silently.
- * An array value is a schema error: Claude Code shows a settings error notice and rejects the whole user, project, or local settings file, `claude doctor` reports the validation failure, and no hook from that file appears in `/hooks`. In [managed settings](</docs/en/managed-settings>), Claude Code drops the whole `hooks` key from the file that contains the array, so none of that file’s hooks apply. The file’s other settings still apply, and `claude doctor` lists the dropped key.
When you edit `settings.json`, the change takes effect in the running session after a brief file-stability delay, even if you create the file or the project’s `.claude/` folder itself after the session started. You don’t need to restart. Before v2.1.257, Claude Code didn’t detect edits in a `.claude/` folder created after the session started. If `/hooks` still shows the old definition a few seconds after you save, run `/hooks` again to refresh the view. If `/hooks` shows the hook but it still does not fire, the next step is to watch hook evaluation live. Start a session with `claude --debug` and trigger the tool call. The debug log records each event, which matchers were checked, and the hook’s exit code and output. See [Debug hooks](</docs/en/hooks#debug-hooks>) for the log format and [hooks troubleshooting](</docs/en/hooks-guide#limitations-and-troubleshooting>) for common failure patterns.
--- a/desktop.md
+++ b/desktop.md
@@ -84,11 +84,19 @@
**Auto**| `auto`| Claude runs without routine prompts; before actions such as shell commands and network requests run, a background classifier checks that they align with your request. Appears when auto mode is available; there is no separate Settings toggle for it.
**Bypass permissions**| `bypassPermissions`| Claude runs without permission prompts, except for the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>), safety classifiers when Claude acts on external sites, or desktop actions where Claude always asks first, such as archiving a session. Equivalent to `--dangerously-skip-permissions` in the CLI. On Pro and Max plans, enable it in your Settings → Claude Code under “Allow bypass permissions mode”; on Team and Enterprise plans there is no Settings toggle, and organization policy controls it instead. Only use this in sandboxed containers or VMs.
-Earlier versions of the Code tab labeled these modes Ask permissions, Auto accept edits, and Plan mode. The `dontAsk` permission mode is available only in the [CLI](</docs/en/permission-modes#allow-only-pre-approved-tools-with-dontask-mode>). Auto mode is available to all users on the Anthropic API and requires Claude Opus 4.6 or later, Sonnet 4.6 or later, or a [Fable model](</docs/en/model-config#work-with-fable>). Organization administrators can turn auto mode off with the `disableAutoMode` key in managed settings. In Enterprise deployments that route Desktop to Google Cloud’s Agent Platform, auto mode is also available by default; see [Auto mode on Bedrock, Agent Platform, or Foundry](</docs/en/permission-modes#enable-auto-mode-on-bedrock-agent-platform-or-foundry>) for the supported models.
+Earlier versions of the Code tab labeled these modes Ask permissions, Auto accept edits, and Plan mode. The `dontAsk` permission mode is available only in the [CLI](</docs/en/permission-modes#allow-only-pre-approved-tools-with-dontask-mode>).
Start complex tasks in Plan so Claude maps out an approach before making changes. Once you approve the plan, switch to Accept edits or Manual to execute it. See [explore first, then plan, then code](</docs/en/best-practices#explore-first-then-plan-then-code>) for more on this workflow.
Cloud sessions support Accept edits, Plan, and Auto. Accept edits corresponds to `default` mode: cloud sessions pre-approve file edits, so the selector shows Accept edits instead of Manual. Bypass permissions isn’t available in cloud sessions, including sessions in a [self-hosted environment](</docs/en/self-hosted-environments>). Enterprise admins can restrict which permission modes are available. See enterprise configuration for details.
+
+####
+
+
+
+Auto mode availability
+
+Auto mode is available to all users on the Anthropic API and requires Claude Opus 4.6 or later, Sonnet 4.6 or later, or a [Fable model](</docs/en/model-config#work-with-fable>). Organization administrators can turn auto mode off with the `disableAutoMode` key in managed settings. In Enterprise deployments that route Desktop to Google Cloud’s Agent Platform, auto mode is also available by default; see [Auto mode on Bedrock, Agent Platform, or Foundry](</docs/en/permission-modes#enable-auto-mode-on-bedrock-agent-platform-or-foundry>) for the supported models.
###
@@ -677,7 +685,7 @@
Cloud sessions
-Cloud sessions continue in the background even if you close the app. Usage counts toward your [subscription plan limits](</docs/en/costs>) with no separate compute charges. You can create custom cloud environments with different network access levels and environment variables. When you start a cloud session, open the environment dropdown in the prompt box to manage them:
+Cloud sessions continue in the background even if you close the app. Usage counts toward your [subscription plan limits](</docs/en/costs>) with no separate compute charges. You can create custom cloud environments with different network access levels and environment variables. To manage them, open the environment dropdown in the prompt box and select **Cloud** :
* **Add an environment** : select **Add cloud environment**
* **Edit or archive one of your own environments** : hover over it and click the gear icon
--- a/desktop-linux.md
+++ b/desktop-linux.md
@@ -81,7 +81,7 @@
sudo apt install ./claude-desktop_*.deb
-If apt reports `E: Unsupported file ./claude-desktop_*.deb given on commandline`, the pattern didn’t match a `.deb` file in the current directory. Confirm the download completed, then run the command again from the directory that contains the file. Installing the `.deb` also registers Anthropic’s apt repository at `/etc/apt/sources.list.d/claude-desktop.list`, so future updates arrive with your system’s regular package updates.
+If apt reports `E: Unsupported file ./claude-desktop_*.deb given on commandline`, the pattern didn’t match a `.deb` file in the current directory. Confirm the download completed, then run the command again from the directory that contains the file. The `.deb` contains Anthropic’s signing key and installs it at `/usr/share/keyrings/claude-desktop-archive-keyring.asc`, so you don’t need to download the key yourself. Unless you turned registration off with `CLAUDE_DESKTOP_ADD_REPO`, the package also registers the apt repository at `/etc/apt/sources.list.d/claude-desktop.list`, so future updates arrive with your system’s regular package updates.
##
@@ -151,6 +151,20 @@
+Your sign-in won’t be saved on this device
+
+Claude Desktop saves your sign-in in your desktop’s keyring, such as GNOME Keyring or KDE Wallet. If it can’t reach an unlocked keyring, your sign-in isn’t saved and you sign in again each time you launch the app. Pick the case that matches your system:
+
+ * **No keyring installed, on a desktop other than KDE Plasma** : if you installed with `--no-install-recommends`, or on a minimal image that skips recommended packages, apt didn’t install a keyring. Install GNOME Keyring with `sudo apt install gnome-keyring`.
+ * **KDE Plasma with GNOME Keyring also installed** : KDE Wallet comes with the Plasma desktop. The two keyrings conflict, and Claude Desktop can show this notice even though KDE Wallet works. Remove the extra one with `sudo apt remove gnome-keyring`, then restart your computer.
+ * **Keyring installed but locked** : unlock it.
+
+After the fix, restart the app and sign in. Then quit and launch it again to confirm the app opens with you still signed in.
+
+###
+
+
+
Cowork isn’t available
If the Cowork tab shows one of these messages, fix the requirement it names, then restart the app:
--- a/env-vars.md
+++ b/env-vars.md
@@ -150,7 +150,7 @@
`ANTHROPIC_FOUNDRY_API_KEY`| API key for Microsoft Foundry authentication (see [Microsoft Foundry](</docs/en/microsoft-foundry>))
`ANTHROPIC_FOUNDRY_AUTH_TOKEN`| Bearer token for Microsoft Foundry authentication, such as a Microsoft Entra access token. Claude Code sends it as the `Authorization: Bearer` header. Takes precedence over `ANTHROPIC_FOUNDRY_API_KEY` and over the Azure default credential chain. See [Microsoft Foundry](</docs/en/microsoft-foundry>). Requires Claude Code v2.1.203 or later
`ANTHROPIC_FOUNDRY_BASE_URL`| Full base URL for the Microsoft Foundry resource (for example, `https://my-resource.services.ai.azure.com/anthropic`). Alternative to `ANTHROPIC_FOUNDRY_RESOURCE` (see [Microsoft Foundry](</docs/en/microsoft-foundry>))
-`ANTHROPIC_FOUNDRY_RESOURCE`| Microsoft Foundry resource name (for example, `my-resource`). Required if `ANTHROPIC_FOUNDRY_BASE_URL` is not set (see [Microsoft Foundry](</docs/en/microsoft-foundry>))
+`ANTHROPIC_FOUNDRY_RESOURCE`| Microsoft Foundry resource name (for example, `my-resource`). Claude Code [refuses a URL or host name](</docs/en/errors#anthropic-foundry-resource-must-be-a-foundry-resource-name>). Required if `ANTHROPIC_FOUNDRY_BASE_URL` is not set (see [Microsoft Foundry](</docs/en/microsoft-foundry>))
`ANTHROPIC_MODEL`| Name of the model setting to use (see [Model Configuration](</docs/en/model-config#environment-variables>))
`ANTHROPIC_ORGANIZATION_ID`| Organization ID for [Workload Identity Federation](<https://platform.claude.com/docs/en/manage-claude/workload-identity-federation>). Set it together with `ANTHROPIC_FEDERATION_RULE_ID`. See [authentication precedence](</docs/en/authentication#authentication-precedence>)
`ANTHROPIC_PROFILE`| Name of the Anthropic profile to authenticate with, such as one created by [`ant auth login`](<https://platform.claude.com/docs/en/cli-sdks-libraries/cli/authentication>) or by [signing in to a Console account without an API key](</docs/en/authentication#sign-in-without-an-api-key>). See [authentication precedence](</docs/en/authentication#authentication-precedence>)
@@ -175,7 +175,7 @@
`CLAUDE_ASYNC_AGENT_STALL_TIMEOUT_MS`| Stall timeout in milliseconds for subagents. Default `600000` (10 minutes); if you raise `CLAUDE_STREAM_IDLE_TIMEOUT_MS` while the stream watchdog is on, the default rises with it, as [Handle slow or stalled API responses](</docs/en/agent-sdk/typescript#handle-slow-or-stalled-api-responses>) describes. The timer resets on each streaming progress event; if no progress arrives within the window, Claude Code aborts the subagent and reports the stall to the parent
`CLAUDE_AUTOCOMPACT_PCT_OVERRIDE`| Set the percentage (1-100) of the auto-compact window at which auto-compaction triggers. Use lower values like `50` to compact earlier; the variable can’t raise the threshold, so values above the default percentage are ignored. It applies only in sessions that [compact before the model’s context limit](</docs/en/model-config#context-window-and-auto-compaction>). Applies to both main conversations and subagents
`CLAUDE_AUTO_BACKGROUND_TASKS`| Set to `1` to force-enable automatic backgrounding of long-running agent tasks. When enabled, subagents are moved to the background after running for approximately two minutes. Also enables [automatic backgrounding of long MCP tool calls](</docs/en/mcp#automatic-backgrounding-of-long-tool-calls>) in non-interactive mode on Claude Code v2.1.212 or later
-`CLAUDE_AX_PREPARK_MS`| In [screen reader mode](</docs/en/accessibility#what-your-screen-reader-hears>), how many milliseconds Claude Code waits, with the cursor at the start of the line, before it writes a new or changed line. Default `50`. Set `0` to write immediately. Claude Code caps the wait at `5000`. Requires Claude Code v2.1.233 or later
+`CLAUDE_AX_PREPARK_MS`| In [screen reader mode](</docs/en/accessibility>), how many milliseconds Claude Code waits before it writes a new or changed line. Default `0`, so Claude Code doesn’t wait. Before v2.1.287, the default was `50`. Claude Code caps the wait at `5000`. Requires Claude Code v2.1.233 or later
`CLAUDE_AX_SCREEN_READER`| Set to `1` to render screen-reader friendly output: flat text without decorative borders or animations. Set to `0` to force screen-reader mode off even when [`axScreenReader`](</docs/en/settings-reference#axscreenreader>) is `true`. The [`--ax-screen-reader`](</docs/en/cli-reference#cli-flags>) flag takes precedence. Requires Claude Code v2.1.181 or later
`CLAUDE_AX_STARTUP_QUIET_MS`| In [screen reader mode](</docs/en/accessibility>), how many milliseconds Claude Code holds the first interface render after the startup confirmation line, so your screen reader can speak the line in full before new output interrupts it. Default `3000`. Set `0` to render immediately. Claude Code caps the hold at `600000` (10 minutes). Your first keystroke ends the hold early. Requires Claude Code v2.1.217 or later
`CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR`| Return to the original working directory after each Bash or PowerShell command in the main session
@@ -215,6 +215,7 @@
`CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN`| Set to `1` to disable [fullscreen rendering](</docs/en/fullscreen>) and use the classic main-screen renderer. The conversation stays in your terminal’s native scrollback so `Cmd+f` and tmux copy mode work as usual. Takes precedence over `CLAUDE_CODE_NO_FLICKER` and the [`tui`](</docs/en/settings-reference#tui>) setting. You can also switch with `/tui default`. Does not apply to background sessions opened from [agent view](</docs/en/agent-view>), which always use fullscreen rendering
`CLAUDE_CODE_DISABLE_ARTIFACT`| Set to `1` to turn off the [Artifact](</docs/en/artifacts>) tool, which publishes session output as a private web page on claude.ai. Once you set it, no settings file turns the tool back on. To turn the tool off from a settings file instead, set [`enableArtifact`](</docs/en/settings-reference#enableartifact>) to `false`; the deprecated [`disableArtifact`](</docs/en/settings-reference#disableartifact>) key also turns it off
`CLAUDE_CODE_DISABLE_ATTACHMENTS`| Set to `1` to disable attachment processing. File mentions with `@` syntax are sent as plain text instead of being expanded into file content
+`CLAUDE_CODE_DISABLE_AUTH_REFRESH_LOCK`| Set to `1` to make a Claude Code process run its [`gcpAuthRefresh`](</docs/en/settings-reference#gcpauthrefresh>) or [`awsAuthRefresh`](</docs/en/settings-reference#awsauthrefresh>) command itself instead of waiting while another process runs it. Requires Claude Code v2.1.286 or later
`CLAUDE_CODE_DISABLE_AUTO_MEMORY`| Set to `1` to disable [auto memory](</docs/en/memory#auto-memory>). Set to `0` to force auto memory on even when `--bare` mode or [`autoMemoryEnabled: false`](</docs/en/settings-reference#automemoryenabled>) would otherwise disable it. When disabled, Claude does not create or load auto memory files
`CLAUDE_CODE_DISABLE_BACKGROUND_TASKS`| Set to `1` to disable all background task functionality, including the `run_in_background` parameter on Bash and subagent tools, auto-backgrounding, and the Ctrl+B shortcut
`CLAUDE_CODE_DISABLE_BEDROCK_CONTENT_TYPE_DEFAULT`| Set to `1` to stop Claude Code from treating an [Amazon Bedrock](</docs/en/amazon-bedrock>) streaming response with a missing or empty `Content-Type` header as Amazon Bedrock’s binary event stream. By default, Claude Code assumes a gateway dropped the header from an otherwise unmodified response, so it decodes the body and streaming keeps working. Set this only for a gateway that also re-emits the stream as server-sent events; Claude Code then reads the header-less body as server-sent events instead. Requires Claude Code v2.1.239 or later
@@ -226,7 +227,7 @@
`CLAUDE_CODE_DISABLE_CLAUDE_MDS`| Set to `1` to prevent loading any CLAUDE.md memory files into context, including user, project, and auto memory files
`CLAUDE_CODE_DISABLE_CRON`| Set to `1` to disable [scheduled tasks](</docs/en/scheduled-tasks>). The `/loop` skill and cron tools become unavailable and any already-scheduled tasks stop firing, including tasks that are already running mid-session
`CLAUDE_CODE_DISABLE_DANGEROUS_RM_TIMEOUT`| Set to `1` to turn off the time limit on [critical-path removal](</docs/en/permission-modes#critical-paths>) prompts. In `auto` mode Claude Code then sends these removals to the classifier instead, and in `bypassPermissions` mode the prompt waits for your answer. Set it in the environment that launches Claude Code, since Claude Code ignores a copy delivered through a settings `env` block. Requires Claude Code v2.1.281 or later
-`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS`| Set to `1` to strip Anthropic-specific `anthropic-beta` request headers and beta tool-schema fields (such as `defer_loading` and `eager_input_streaming`) from API requests. Use this when a proxy gateway rejects requests with errors like “Unexpected value(s) for the `anthropic-beta` header” or “Extra inputs are not permitted”. Standard fields (`name`, `description`, `input_schema`, `cache_control`) are preserved. [MCP tool search](</docs/en/mcp#scale-with-mcp-tool-search>) is disabled and all MCP tools load upfront, even when you set `ENABLE_TOOL_SEARCH`. On Claude Code v2.1.227 or later, [managed settings](</docs/en/managed-settings>) can keep tool search on. [Disable pre-release capabilities](</docs/en/llm-gateway-protocol#disable-pre-release-capabilities>) covers where the override applies
+`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS`| Set to `1` to strip pre-release `anthropic-beta` request headers, the body fields that pair with them, and beta tool-schema fields such as `defer_loading` and `eager_input_streaming` from API requests. Use this when a proxy gateway rejects requests with an `Unexpected value(s)` error for the `anthropic-beta` header or an `Extra inputs are not permitted` error. [Disable pre-release capabilities](</docs/en/llm-gateway-protocol#disable-pre-release-capabilities>) lists what the variable removes, including [MCP tool search](</docs/en/mcp#scale-with-mcp-tool-search>), and what Claude Code keeps sending
`CLAUDE_CODE_DISABLE_EXPLORE_PLAN_AGENTS`| Set to `1` to disable the built-in [Explore and Plan subagents](</docs/en/sub-agents#built-in-subagents>). Claude explores with its search tools or the general-purpose subagent instead, and [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) reads files directly rather than launching Explore and Plan agents. Custom subagents named `Explore` or `Plan` are unaffected. To remove every built-in subagent type in the Agent SDK or non-interactive mode, use `CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS` instead. Requires Claude Code v2.1.198 or later
`CLAUDE_CODE_DISABLE_FAST_MODE`| Set to `1` to disable [fast mode](</docs/en/fast-mode>)
`CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY`| Set to `1` to disable the “How is Claude doing?” session quality surveys. Surveys are also disabled when `DISABLE_TELEMETRY`, `DO_NOT_TRACK`, or `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` is set, unless `CLAUDE_CODE_ENABLE_FEEDBACK_SURVEY_FOR_OTEL` opts back in. To set a sample rate instead of disabling outright, use the [`feedbackSurveyRate`](</docs/en/settings-reference#feedbacksurveyrate>) setting. See [Session quality surveys](</docs/en/data-usage#session-quality-surveys>)
@@ -249,6 +250,7 @@
`CLAUDE_CODE_DISABLE_THINKING`| Set to `1` to omit the `thinking` parameter from API requests entirely. This is a compatibility option for proxies and gateways that reject the parameter. On models that think by default, omitting the parameter means the model may still think. To explicitly disable [extended thinking](<https://platform.claude.com/docs/en/build-with-claude/extended-thinking>) on the Anthropic API, use `MAX_THINKING_TOKENS=0` instead. Neither variable turns thinking off on Opus 5.5, Sonnet 5.5, or the Fable models, which can’t have thinking turned off. On [third-party providers](</docs/en/third-party-integrations>), `MAX_THINKING_TOKENS=0` likewise omits the parameter, so the two variables behave the same there
`CLAUDE_CODE_DISABLE_UNKNOWN_MODEL_WINDOW_ENFORCEMENT`| Set to `1` to skip proactive [auto-compaction](</docs/en/costs#reduce-token-usage>) when Claude Code doesn’t recognize the model ID, such as an [LLM gateway](</docs/en/llm-gateway>) alias. Without this variable, Claude Code compacts at the context window it assumes for the ID. `CLAUDE_CODE_MAX_CONTEXT_TOKENS` can correct the assumed window instead; see [Correct the window for a gateway or custom model ID](</docs/en/model-config#correct-the-window-for-a-gateway-or-custom-model-id>) for when each variable applies. Requires Claude Code v2.1.223 or later
`CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL`| Set to `1` to disable virtual scrolling in [fullscreen rendering](</docs/en/fullscreen>) and render every message in the transcript. Use this if scrolling in fullscreen mode shows blank regions where messages should appear
+`CLAUDE_CODE_DISABLE_WEB_FETCH`| Set to `1` to turn off the [WebFetch](</docs/en/tools-reference#webfetch-tool-behavior>) tool. The [WebSearch](</docs/en/tools-reference#websearch-tool-behavior>) tool stays available. Requires Claude Code v2.1.285 or later
`CLAUDE_CODE_DISABLE_WINDOWS_SHELL_LAUNCHER`| Set to `1` to start [PowerShell tool](</docs/en/tools-reference#powershell-tool>) commands on Windows directly instead of through the `cmd.exe` launcher. By default, the launcher lets a PowerShell command [running in the background](</docs/en/tools-reference#background-commands>) [carry over to the session’s next process](</docs/en/agent-view#the-supervisor-process>), such as when you [background the session](</docs/en/agent-view#from-inside-a-session>). If you set the variable, a backgrounded PowerShell command stops when the session’s process exits. Bash commands aren’t affected. Requires Claude Code v2.1.269 or later
`CLAUDE_CODE_DISABLE_WORKFLOWS`| Set to `1` to disable [workflows](</docs/en/workflows#turn-workflows-off>). Equivalent to the [`disableWorkflows`](</docs/en/settings-reference#disableworkflows>) setting
`CLAUDE_CODE_EFFORT_LEVEL`| Set the effort level for supported models. Values: `low`, `medium`, `high`, `xhigh`, `max`, or `auto` to use the model default. Available levels depend on the model. Takes precedence over `--effort`, `/effort`, and the `modelSettings` and `effortLevel` settings. A [`maxEffortLevel`](</docs/en/settings-reference#maxeffortlevel>) cap still applies. See [Adjust effort level](</docs/en/model-config#adjust-effort-level>)
@@ -331,7 +333,7 @@
`CLAUDE_CODE_REMOTE`| Set automatically to `true` when Claude Code is running as a [cloud session](</docs/en/claude-code-on-the-web>). Read this from a hook or setup script to detect whether you are in a cloud session
`CLAUDE_CODE_REMOTE_SESSION_ID`| Set automatically in [cloud sessions](</docs/en/claude-code-on-the-web>) to the current session’s ID. Read this to construct a link back to the session transcript. See [Link output back to the session](</docs/en/cloud-environments#link-output-back-to-the-session>)
`CLAUDE_CODE_RESTRICTED`| Set to `1` to start the session in restricted mode, the same as passing [`--restricted`](</docs/en/cli-reference#cli-flags>). Claude Code ignores this variable in a settings file’s `env` block. Requires Claude Code v2.1.248 or later
-`CLAUDE_CODE_RESUME_INTERRUPTED_TURN`| Set to `1` to automatically resume if the previous session ended mid-turn. Used in SDK mode so the model continues without requiring the SDK to re-send the prompt. To turn this off, unset the variable or set it to `0`. Before v2.1.221, Claude Code ignored `0` and other falsy values, so setting `0` still triggered the resume in non-interactive mode and unsetting the variable was the only way to turn it off
+`CLAUDE_CODE_RESUME_INTERRUPTED_TURN`| Set to `1` to automatically resume if the previous session ended mid-turn. Used in SDK mode so the model continues without requiring the SDK to re-send the prompt. To turn this off, unset the variable or set it to `0`. For the VS Code chat panel, see [Continue conversations after a reload](</docs/en/vs-code#continue-conversations-after-a-reload>)
`CLAUDE_CODE_RESUME_INTERRUPTED_TURN_MAX_AGE_MS`| Maximum age in milliseconds of the last transcript message for a session that ended mid-turn to continue automatically on resume. When the last message is older than this bound, Claude Code skips the `CLAUDE_CODE_RESUME_INTERRUPTED_TURN` automatic resume and its `CLAUDE_CODE_RESUME_PROMPT` continuation message, and the session starts idle so you continue explicitly. Unset or `0` means no bound, except that a turn whose last request failed with an API error resumes only while that error is less than six hours old. A positive value bounds every turn, including those; a negative or non-numeric value applies a one-hour bound. Spawn scripts for long-running agents can set this so a restart against an old transcript doesn’t re-run a stale prompt. Claude Code sets a one-hour bound itself when it restarts a crashed [agent view](</docs/en/agent-view>) session that inherited its conversation from an interactive session. Requires Claude Code v2.1.211 or later
`CLAUDE_CODE_RESUME_PROMPT`| Override the continuation message Claude Code sends to Claude when `CLAUDE_CODE_RESUME_INTERRUPTED_TURN` continues an interrupted turn instead of resending its prompt, or when you resume a [deferred tool call](</docs/en/hooks#defer-a-tool-call-for-later>) with `-p`. Defaults to `Continue from where you left off.`. An empty string uses the default
`CLAUDE_CODE_RETRY_WATCHDOG`| Set to `1` for unattended sessions such as eval harnesses, CI jobs, or remote workers. Retries `429` and `529` capacity errors indefinitely instead of failing after `CLAUDE_CODE_MAX_RETRIES` attempts. Claude Code fails at once when a standard-speed request gets a `429` that reports a spend limit or exhausted usage credits, even one from a [gateway spend cap](</docs/en/errors#spend-limit-reached>) that resets on a schedule. Before v2.1.239, the watchdog retried these indefinitely. For fast mode requests, see [Handle rate limits](</docs/en/fast-mode#handle-rate-limits>). The watchdog backs off up to 5 minutes between attempts, or until the limit resets when the response carries a rate-limit reset time, so a session that hits a usage limit waits out the remaining window. On v2.1.199 or later it also raises the default retry count for other transient errors, such as server errors, timeouts, and dropped connections, to 300, roughly three hours of backoff, and removes the cap of 15 on `CLAUDE_CODE_MAX_RETRIES` if you set that variable explicitly. Requires Claude Code v2.1.186 or later
@@ -512,6 +514,7 @@
* Sync the [skills](</docs/en/skills#where-synced-skills-load>) and [plugins](</docs/en/plugins/loading#synced-plugins>) enabled for your claude.ai account into your terminal sessions
* Use [the advisor tool](</docs/en/advisor#requirements>)
* Read or reply to [comments on an artifact](</docs/en/artifacts#collect-comments-on-an-artifact>)
+ * Have Claude read [another organization’s public artifact](</docs/en/artifacts#read-an-artifact-shared-with-you>)
* Have Claude Code probe claude.ai connector servers for [MCP protocol revision 2026-07-28](</docs/en/mcp#mcp-client-runtimes>) unless you set `MCP_PROTOCOL_NEGOTIATION=auto`
* Get the [PowerShell tool](</docs/en/tools-reference#powershell-tool>) by default for claude.ai and Console accounts on Windows with Git Bash installed; Claude Code routes shell commands through Git Bash unless you set `CLAUDE_CODE_USE_POWERSHELL_TOOL=1`. On Windows without Git Bash, the tool stays on
* Get [Claude-drafted feedback](</docs/en/tools-reference#sendfeedback-tool-behavior>), which Claude Code turns on through a fetched flag
Show diff (497 lines)
--- a/errors.md
+++ b/errors.md
@@ -65,7 +65,11 @@
`Remote Control stopped — the app running this session is now signed in to a different Claude account`| Authentication
`Remote Control stopped — the app running this session is signed out of Claude`| Authentication
`Couldn't verify your organization's policy for remote control`| [Troubleshoot Remote Control](</docs/en/remote-control#couldnt-verify-your-organizations-policy-for-remote-control>)
+`Remote Control is disabled by your organization's policy`| [Troubleshoot Remote Control](</docs/en/remote-control#remote-control-is-disabled-by-your-organizations-policy>)
+`Remote Control was turned off by your organization's policy`| [Troubleshoot Remote Control](</docs/en/remote-control#remote-control-was-turned-off-by-your-organizations-policy>)
`OAuth token revoked` / `OAuth token has expired`| Authentication
+`Failed to authenticate: OAuth token revoked`| Authentication
+`Your account does not have access to Claude. Please login again or contact your administrator.`| Authentication
`API Error: 401 Invalid authentication credentials`| Authentication
`Login expired · Please run /login`| Authentication
`Failed to start OAuth callback server`| Authentication
@@ -154,6 +158,7 @@
`Can't switch to the default model`| Request errors
`Model switch ... blocked by a PreModelSwitch hook`| Request errors
`couldn't save it as your default` / `couldn't confirm it was saved as your default`| Request errors
+`is less capable than the current main model` / `Advisor will not activate on the main model` / `cannot advise`| Request errors
`thinking.type.enabled is not supported for this model`| Request errors
`Effort '<level>' isn't available with thinking turned off on this model`| Request errors
`effort '<level>' is not supported when thinking is disabled`| Request errors
@@ -176,6 +181,7 @@
`The connection dropped while downloading the update`| Installation errors
`Download timed out: exceeded the total deadline`| Installation errors
`--bg and --print conflict`| Command-line errors
+`Error: Cannot use both --append-subagent-system-prompt and --append-subagent-system-prompt-file. Please use only one.`| Command-line errors
`Cloud sessions cannot be created from a --restricted session`| Command-line errors
`Cloud sessions are disabled by your organization's policy`| Command-line errors
`Couldn't verify your organization's policy for cloud sessions`| Command-line errors
@@ -193,6 +199,7 @@
`Could not read Claude Code config`| Command-line errors
`Could not import <server>: <reason>`| Command-line errors
`Cannot add MCP server to scope: managed`| Command-line errors
+`Cannot add MCP server: your organization's managed settings allow only MCP servers that plugins provide`| Command-line errors
`is Anthropic-hosted and doesn't support local OAuth`| Command-line errors
`Can't read .mcp.json: it isn't a regular file or is larger than 2097152 bytes`| Command-line errors
`MCP server "<name>" was not saved to` / `was not removed from`| Command-line errors
@@ -205,6 +212,7 @@
`Shell command permission check failed for pattern "..."`, from a skill that injects dynamic context| Command-line errors
`Skill <name> requires bash (`shell: bash` in frontmatter) but Git Bash was not found`| Command-line errors
`Input must be provided either through stdin or as a prompt argument when using --print`| Command-line errors
+`Claude Code can't read the keyboard here: stdin is not a terminal`| Command-line errors
`Error: Input contained only whitespace`| Command-line errors
`Blank prompt — the message was only whitespace, so nothing was sent to the model.`| Command-line errors
`Error: stream-json input carried over 256M characters with no newline`| Command-line errors
@@ -217,6 +225,9 @@
`The GitHub App preflight failed transiently (network or service hiccup) — retry in a moment to start from GitHub instead`| Command-line errors
`Not uploading this working tree` with `the upload cannot follow that setting`| Command-line errors
`GitHub isn't connected to your Claude account, so this repository can't be cloned in the cloud`| Command-line errors
+`Your GitHub organization has an IP allowlist that is blocking Claude`| Command-line errors
+`Your GitHub organization requires single sign-on`| Command-line errors
+`Your GitHub organization's identity provider (Microsoft Entra ID) has a Conditional Access policy that is blocking Claude`| Command-line errors
`Single sign-on authorization needed`| Command-line errors
`Failed to resume the conversation`| Command-line errors
`No conversation found with session ID: <session-id>`| Command-line errors
@@ -230,16 +241,21 @@
`Skill usage reports are not available on this connection.`| Command-line errors
`Custom output styles can't be selected over Remote Control or from a relayed message`| Command-line errors
`Output styles are saved to local settings (.claude/settings.local.json), which this session doesn't load`| Command-line errors
+`/recap only runs when you ask for it yourself in this session`| Command-line errors
``plugin eval` is currently in early access` / ``plugin eval` is currently unavailable`| Plugin errors
`Marketplace "<name>" is registered from an untrusted source`| Plugin errors
`Claude Code refuses the marketplace name "<name>"`| Plugin errors
`Marketplace name impersonates an official Anthropic/Claude marketplace`| Plugin errors
`Marketplace "<name>" is already added from a different source`| Plugin errors
`"<name>" is another spelling of "<reserved>", a reserved marketplace name`| Plugin errors
+`Marketplace "<name>" is added but ignored`| [Plugin troubleshooting](</docs/en/plugins/troubleshooting#marketplace-is-added-but-ignored>)
+`Marketplace "<name>" is registered but was refused (see the debug log)`| [Plugin troubleshooting](</docs/en/plugins/troubleshooting#marketplace-is-added-but-ignored>)
`references ${user_config.*} in a shell-form command`| Plugin errors
`Monitor "<name>" from plugin <plugin> references ${user_config.*} in its command`| Plugin errors
`headersHelper for MCP server '<name>' references ${user_config.*}`| Plugin errors
`Plugin archive integrity check failed`| Plugin errors
+`An npm plugin source must name a registry package`| [Plugin troubleshooting](</docs/en/plugins/troubleshooting#an-npm-plugin-source-must-name-a-registry-package>)
+`The packages it lists are not installed` / `The packages it lists were not installed, because`| [Plugin troubleshooting](</docs/en/plugins/troubleshooting#the-packages-it-lists-are-not-installed>)
`path escapes plugin directory`| Plugin errors
`path could not be checked`| Plugin errors
`its marketplace entry path does not stay inside the marketplace directory`| Plugin errors
@@ -250,6 +266,7 @@
`"<plugin>" was not uninstalled: it is still switched on in <file>`| Plugin errors
`"<plugin>" was not uninstalled: <file> is there and could not be read`| Plugin errors
`Plugin "<plugin>" was not uninstalled: installed_plugins.json`| [Plugin troubleshooting](</docs/en/plugins/troubleshooting#installed-plugins-json-holds-a-record-this-version-cannot-read>)
+`Error: No such tool available: <tool name>`| Tool errors
`would be spawned with zero tools — refusing`| Tool errors
`File is covered by a Read deny rule in your permission settings`| Tool errors
`cannot contain null bytes (\0)`| Tool errors
@@ -277,9 +294,13 @@
`Command output was lost: the temp filesystem at <dir> is full` / `is out of inodes`| Tool errors
`the source file is not valid UTF-8 text` / `the source file is not valid UTF-16 text`| Tool errors
`the source file has the replacement character U+FFFD`| Tool errors
+`Not published: that file is on a network share`| Tool errors
`Reading a local file from outside this session's connected folders, or through a link, needs the approval card`| Tool errors
`cannot read file_path (...) — the file could not be examined, and no one can answer the approval card`| Tool errors
`WebFetch cannot fetch localhost or other hostnames without a dot`| Tool errors
+`The safety check for domain ... is rate-limited`| Tool errors
+`The safety check for domain ... is temporarily rate-limited`| Tool errors
+`Unable to verify if domain ... is safe to fetch`| Tool errors
`Can't open MCP settings while no terminal is attached to this background session`| Background session errors
`Can't open MCP settings in a background session`| Background session errors
`blocked because the path is spelled in a form that cannot be safely resolved`| Background session errors
@@ -329,6 +350,7 @@
`Unable to read managed policy settings`| Configuration warnings
`otelHeadersHelper failed; telemetry is not being exported. See /status: ...`| Configuration warnings
`"crossSessionInbound" must be one of "accept", "hold", "refuse"`| Configuration warnings
+`API Error: ANTHROPIC_FOUNDRY_RESOURCE must be a Foundry resource name`| Configuration warnings
`headersHelper not run — this workspace has no persisted trust`| Configuration warnings
`Invalid permission rule "..." was skipped: Malformed Tool(content) rule`| Configuration warnings
`... is not matched by file permission checks`| Configuration warnings
@@ -347,6 +369,7 @@
Claude Code retries transient failures up to 10 times with exponential backoff before showing you an error. It doesn’t always retry a failure that arrives partway through Claude’s response. When you see one of the errors on this page, Claude Code has already made whatever retries apply to that failure. Claude Code retries these failures:
* Server errors, overloaded responses, and request timeouts that arrive before any of Claude’s response has streamed.
+ * A server error or overloaded response that arrives after Claude has finished thinking but before it has started any text or tool call. Claude Code retries a server error at that point up to two times. Before v2.1.284, Claude Code ended the turn with the error at that point.
* Dropped connections. When a connection drops partway through a request before Claude has completed any part of its response, including its thinking, Claude Code re-issues the request with the same backoff and the turn continues, even if some text had already started streaming. When it drops after Claude has finished thinking but before it has started any text or tool call, Claude Code instead re-issues the request up to two times in quick succession, and ends the turn with `Connection lost before a response was produced` if the connection keeps dropping at that point.
* A connection that Claude Code detects was broken by your computer going to sleep partway through a request. Claude Code counts it as a dropped connection under the rules above; once the retry label names the specific reason, it reads `Connection lost while your computer was asleep`, and if the turn ends after Claude has finished thinking but before any text or tool call, the message reads `Your computer went to sleep before a response was produced`.
* A stalled response stream, when the response headers have arrived but none of Claude’s response has arrived, or when Claude has finished thinking but hasn’t started any text or tool call: Claude Code aborts the stalled connection and re-issues the request at most once, outside the 10-attempt budget above. If the response stalls a second time after Claude has finished thinking but before any text or tool call, Claude Code ends the turn with `The response stalled before a response was produced`.
@@ -642,7 +665,7 @@
You've hit your Opus limit · resets 3:45pm
You've hit your Sonnet limit · resets 3:45pm
-Claude Code blocks further requests until the reset time shown in the message. The session and weekly limits are shared across all models, so switching models doesn’t restore access. The Opus and Sonnet limits each apply only to requests to that model family, so switching to a model outside the family with `/model` keeps you working. In an interactive session signed in with a claude.ai subscription, Claude Code can also wait in the open session and continue the interrupted task shortly after the reset. While it waits, a line at the bottom of the session reads `Usage limit reached · continuing automatically at 3:45pm · esc to cancel`. Press `Esc` at an empty prompt to cancel the wait. See [Wait for a usage limit to reset](</docs/en/interactive-mode#wait-for-a-usage-limit-to-reset>) for what you see, how to start or cancel a wait, and how to turn automatic continue off. Before v2.1.234, Claude Code didn’t offer this wait. Usage counts against the session and weekly allowances at the same time. A single burst of heavy activity, such as a large workflow fanout, can exhaust the weekly allowance before the session window resets. **What to do:**
+Claude Code blocks further requests until the reset time shown in the message. The session and weekly limits are shared across all models, so switching models doesn’t restore access. The Opus and Sonnet limits each apply only to requests to that model family, so switching to a model outside the family with `/model` keeps you working. In an interactive session signed in with a claude.ai subscription, Claude Code can also wait in the open session and continue the interrupted task shortly after the reset. See [Wait for a usage limit to reset](</docs/en/interactive-mode#wait-for-a-usage-limit-to-reset>) for what you see, how to start or cancel a wait, and how to turn automatic continue off. Before v2.1.234, Claude Code didn’t offer this wait. Usage counts against the session and weekly allowances at the same time. A single burst of heavy activity, such as a large workflow fanout, can exhaust the weekly allowance before the session window resets. **What to do:**
* Wait for the reset time shown in the error
* In the Code tab of the [Desktop app](</docs/en/desktop>), the session-limit card offers an **Auto-continue when limits reset** checkbox. The weekly-limit card doesn’t. When it’s checked, the Desktop app retries the interrupted turn after the reset and shows the retry time on the card. The Desktop checkbox and the CLI’s **Continue automatically at usage limit** setting in `/config` are separate, so turn each off on its own.
@@ -812,7 +835,7 @@
Not logged in · Please run /login
-In a session the Claude Desktop app runs, such as the Code tab or Cowork, the message reads `Authentication required · Sign in again to continue`, and you sign in again from the app. **What to do:**
+In a session the Claude Desktop app runs, such as the Code tab or Cowork, the message reads `Authentication required · Sign in again to continue`, and you sign in again from the app. If you sign in with your claude.ai account in another Claude Code window that uses the same [configuration directory](</docs/en/claude-directory>), an interactive session showing this message starts using that login on its own. You don’t need to restart it. Before v2.1.286 on macOS, the session could keep showing the message after you signed in from another window. On those versions, restart the session that shows the message. **What to do:**
* Run `/login` to authenticate with your Claude subscription or Console account
* If you expected an environment variable to authenticate you, confirm `ANTHROPIC_API_KEY` is set and exported in the shell where you launched `claude`
@@ -1078,9 +1101,15 @@
OAuth token revoked · Please run /login
Please run /login · API Error: 401 OAuth token has expired ...
-**What to do:**
-
- * Run `/login` to sign in again
+In [non-interactive mode](</docs/en/headless>) (`-p`) and the [Agent SDK](</docs/en/agent-sdk/overview>), the messages read as follows, and the structured error code is `authentication_failed`:
+
+ Failed to authenticate: OAuth token revoked. Please log in again or contact your administrator.
+ Failed to authenticate. API Error: 401 OAuth token has expired ...
+
+Before v2.1.287, in non-interactive mode and the Agent SDK, the revoked message read `Your account does not have access to Claude. Please login again or contact your administrator.` **What to do:**
+
+ * Run `/login` at the Claude Code prompt to sign in again
+ * If your `-p` command or Agent SDK program uses a saved login, run `claude` in the same environment, complete `/login`, then run the command or program again. For automation that can’t sign in interactively, authenticate with [`ANTHROPIC_API_KEY`](</docs/en/env-vars>) or [generate a long-lived token with `claude setup-token`](</docs/en/authentication#generate-a-long-lived-token>).
* If you authenticate with the `CLAUDE_CODE_OAUTH_TOKEN` environment variable, Claude Code keeps sending the value you set after a request fails with a 401, rather than switching to a stored login’s token. [`/status`](</docs/en/commands>) shows this credential as an `Auth token` row reading `CLAUDE_CODE_OAUTH_TOKEN`. Generate a fresh token with [`claude setup-token`](</docs/en/authentication#generate-a-long-lived-token>) and restart with it, or unset the variable and run `/login`. Before v2.1.225, Claude Code could replace the variable’s value mid-session with the short-lived access token from a stored login, and the session failed with 401 errors again once that token expired.
* For repeated prompts to log in across launches, see the system clock checks and macOS credential-storage recovery steps in [Troubleshooting](</docs/en/troubleshoot-install#not-logged-in-or-token-expired>)
* For other failures including `403 Forbidden` and OAuth browser issues, see [Login and authentication](</docs/en/troubleshoot-install#login-and-authentication>)
@@ -1119,6 +1148,7 @@
This is not the same state as OAuth token revoked or expired. Those messages report a rejection the API returned. Claude Code itself produces `Login expired` for a login it already failed to renew, so it sends no request. When the renewal fails because the account itself is suspended rather than the login being stale, Claude Code shows Your account is on hold instead. Sessions authenticated with an API key, [`CLAUDE_CODE_OAUTH_TOKEN`](</docs/en/env-vars>), or a third-party provider don’t use the saved login and never see this message. You can check for this state before a request fails: [`/status`](</docs/en/commands>) shows a `Login` row reading `Expired — log in again`, plus the organization and email it has saved for the expired login. The row appears only when the saved login is your active credential and can no longer be refreshed. Sessions authenticated another way don’t show the row, even if an expired login remains saved. Before v2.1.210, `/status` gave no indication in this state that a login had ever existed, because the cleared credential left it nothing to report. **What to do:**
* Run `/login` to sign in again. Retrying without signing in shows the same message on every request.
+ * If you sign in with your claude.ai account in another Claude Code window, see Not logged in for when this session starts using that login on its own.
* In non-interactive mode, run `claude` in the same environment, complete `/login`, then rerun your command. For automation that can’t sign in interactively, authenticate with `ANTHROPIC_API_KEY` or [generate a long-lived token with `claude setup-token`](</docs/en/authentication#generate-a-long-lived-token>).
* If signing in keeps failing, see [Login and authentication](</docs/en/troubleshoot-install#login-and-authentication>)
@@ -1216,19 +1246,19 @@
Not signed in to the Cloud gateway — run /login.
-Model requests fail with this message when the session has no gateway sign-in, for example because you haven’t run `/login` since the policy reached the machine. If the machine also holds an Anthropic-issued credential and the managed settings set `forceLoginMethod` or `forceLoginOrgUUID`, Claude Code exits at startup instead. That credential can be an `ANTHROPIC_API_KEY` or `ANTHROPIC_AUTH_TOKEN` variable, an `apiKeyHelper` setting, or an API key saved by an earlier Claude Console login. The message begins:
-
- Administrator policy requires a Cloud gateway sign-in on this machine; the
- Anthropic-issued credential configured here (ANTHROPIC_API_KEY,
- ANTHROPIC_AUTH_TOKEN, or apiKeyHelper) is not used.
-
-**What to do:**
-
- * Run `/login` and complete the sign-in on the **Cloud gateway** screen
- * For the startup message, remove the `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, or `apiKeyHelper` setting you configured. To remove a saved Console API key, run `claude auth logout`, which also removes a saved claude.ai login. If you select a cloud provider with `CLAUDE_CODE_USE_*`, the session then starts with no sign-in. Otherwise start `claude` and run `/login`
+Model requests fail with this message when the session has no gateway sign-in, for example because you haven’t run `/login` since the policy reached the machine. If the machine also holds an Anthropic-issued credential and the managed settings set `forceLoginMethod` or `forceLoginOrgUUID`, Claude Code exits at startup instead. That credential can be an `ANTHROPIC_API_KEY` or `ANTHROPIC_AUTH_TOKEN` variable, an `apiKeyHelper` setting, or an API key saved by an earlier Claude Console login. The startup message names the credential the session is configured with, where it’s set, and the step that removes it. For example, with an `ANTHROPIC_API_KEY` variable set in your shell, it reads:
+
+ Administrator policy requires a Cloud gateway sign-in on this machine, but this session is configured with an API key from ANTHROPIC_API_KEY, which a gateway machine does not accept.
+
+ To continue: unset ANTHROPIC_API_KEY (or run in a shell without it), then run claude and sign in with /login.
+
+**What to do:**
+
+ * For `Not signed in to the Cloud gateway`, run `/login` and complete the sign-in on the **Cloud gateway** screen
+ * For the startup message, remove the credential by following the steps at the end of the message
* If you believe the machine shouldn’t require the gateway, ask the administrator who manages it to remove `forceLoginMethod` and `forceLoginGatewayUrl` from its managed settings
-On v2.1.265, a regression also showed the first message in some LLM-gateway and proxy configurations that authenticate with an API key, `apiKeyHelper`, or custom headers, even with no administrator requirement on the machine. Update to v2.1.266 or later. You don’t need to change your configuration. Before v2.1.261, on machines that set `forceLoginMethod` to `"gateway"`, Claude Code used a leftover saved login instead of failing model requests, and reported a configured environment credential with `This machine's managed settings require a first-party login` instead of the startup message. Before v2.1.265, a machine whose managed settings set only `forceLoginGatewayUrl` didn’t require the gateway sign-in, and Claude Code used a leftover credential there.
+Before v2.1.284, the startup message listed the possible credentials instead of naming the configured one. It began `Administrator policy requires a Cloud gateway sign-in on this machine; the Anthropic-issued credential configured here (ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, or apiKeyHelper) is not used.` If you see that wording and can’t tell which credential to remove, update to v2.1.284 or later and start `claude` again. On v2.1.265, a regression also showed the first message in some LLM-gateway and proxy configurations that authenticate with an API key, `apiKeyHelper`, or custom headers, even with no administrator requirement on the machine. Update to v2.1.266 or later. You don’t need to change your configuration. Before v2.1.261, on machines that set `forceLoginMethod` to `"gateway"`, Claude Code used a leftover saved login instead of failing model requests, and reported a configured environment credential with `This machine's managed settings require a first-party login` instead of the startup message.
###
@@ -1718,8 +1748,8 @@
You may also see a TLS certificate that doesn’t match the destination’s real certificate. Cloud sessions route outbound traffic through a proxy that enforces the network policy, so a mismatched certificate means the proxy terminated the connection, not the destination. This is not a client-side network problem. Cloud sessions and [routines](</docs/en/routines>) run inside a sandboxed VM whose outbound traffic through the session’s network is filtered to the [cloud environment’s](</docs/en/cloud-environments>) allowlist; [GitHub operations](</docs/en/cloud-environments#github-proxy>) and MCP connector traffic use separate channels, which is why they can keep working while other hosts are blocked. The **Default** environment uses **Trusted** access, which permits the [default allowlist](</docs/en/cloud-environments#default-allowed-domains>) of package registries, cloud provider APIs, container registries, and common development domains and blocks other domains on that path. **What to do:** These steps change one of your own environments. An [organization-shared environment](</docs/en/cloud-environments#organization-shared-environments>) opens read-only in the selector, so ask an Owner to change its network access from the **Cloud environments** page in [admin settings](<https://claude.ai/admin-settings>).
- * Open the routine for editing, or start a cloud session. Select the cloud icon showing your environment’s name, such as **Default** , to open the selector. Hover over your environment and click the settings icon.
- * In the **Update cloud environment** dialog, change **Network access** from **Trusted** to **Custom** , then add the blocked domain to **Allowed domains**. Enter one domain per line. Check **Also include default list of common package managers** to keep the [default allowlist](</docs/en/cloud-environments#default-allowed-domains>) alongside your custom domains. Select **Full** instead if you want unrestricted access.
+ * Open your environment for editing, either from the [routine’s form](</docs/en/routines#environments-and-network-access>) or from the [environment selector](</docs/en/cloud-environments#configure-your-environment>) where you start cloud sessions.
+ * In the **Edit cloud environment** dialog, change **Network access** from **Trusted** to **Custom** , then add the blocked domain to **Allowed domains**. Enter one domain per line. Check **Also include default list of common package managers** to keep the [default allowlist](</docs/en/cloud-environments#default-allowed-domains>) alongside your custom domains. Select **Full** instead if you want unrestricted access.
* Click **Save changes**. The next run uses the updated allowlist. For a cloud session that’s already open, see [when a network access change reaches existing sessions](</docs/en/cloud-environments#network-access>).
See [Network access](</docs/en/cloud-environments#network-access>) for access levels and the default allowlist. Local CLI sessions are not affected by this policy.
@@ -2009,7 +2039,7 @@
API Error: 400 ... Extra inputs are not permitted ... context_management
-Claude Code sends beta-only fields such as `context_management` and `effort` alongside an `anthropic-beta` header that enables them. When a gateway forwards the body but drops the header, the API sees fields it doesn’t recognize. **What to do:**
+Claude Code sends beta-only fields such as `context_management` alongside an `anthropic-beta` header that enables them. When a gateway forwards the body but drops the header, the API sees fields it doesn’t recognize. **What to do:**
* Configure your gateway to forward the `anthropic-beta` header. See [feature pass-through](</docs/en/llm-gateway-protocol#feature-pass-through>) for what gateways must forward.
* As a fallback, set [`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`](</docs/en/env-vars>) before launching. [Disable pre-release capabilities](</docs/en/llm-gateway-protocol#disable-pre-release-capabilities>) covers the exact scope.
@@ -2041,7 +2071,7 @@
API Error: 400 ... tool_use.name: String should have at most 200 characters
-Claude Code cuts such a name to 200 characters when the response arrives and when it loads a saved conversation, so the call fails with an ordinary `No such tool available` tool error and the conversation continues without this API error. **What to do:**
+Claude Code cuts such a name to 200 characters when the response arrives and when it loads a saved conversation, so the call fails with a `No such tool available` tool error and the conversation continues without this API error. **What to do:**
* Run `claude update`, then resume the conversation. The updated version repairs the overlong name when it loads the transcript, so a conversation that was stuck works again.
@@ -2254,6 +2284,29 @@
+Advisor is less capable than the current main model
+
+Your [advisor model](</docs/en/advisor>) ranks below your session’s main model, so Claude Code keeps the selection but doesn’t attach the advisor to the main model’s requests.
+
+ Advisor set to Opus 4.8
+ Note: Opus 4.8 is less capable than the current main model (Sonnet 5.5), so the advisor will not activate. Choose a more capable advisor, or switch to a smaller main model.
+
+Other messages report the same condition:
+
+ * In an interactive session, a notification reads `Advisor will not activate on the main model (advisor is less capable); subagents may still use it and may use more tokens · /advisor`.
+ * At launch with the `--advisor` flag, a warning reads `"<advisor>" cannot advise "<main model>" (the advisor must be at least as capable as the main model). The advisor will not be used for the main model.` and the session starts anyway.
+
+**What to do:**
+
+ * Choose a higher-ranked advisor or a lower-ranked main model. [Choose an advisor model](</docs/en/advisor#choose-an-advisor-model>) shows the ranking and lists the accepted advisors for each main model.
+ * Leave the advisor set if you want [subagents](</docs/en/sub-agents>) whose model it can advise to keep using it
+
+Before v2.1.287, Claude Code ranked several pairings differently. It showed this note for a Sonnet 5.5 advisor with an Opus 4.7 or Opus 4.8 main model, a pairing it now accepts. It also attached some advisors that now produce this note, such as an Opus 4.8 advisor with a Sonnet 5.5 main model.
+
+###
+
+
+
thinking.type.enabled is not supported for this model
Your Claude Code version is older than the minimum for the selected model. The CLI sent a thinking configuration the model no longer accepts.
@@ -2485,6 +2538,20 @@
+Conflict between a system prompt flag and its file form
+
+You passed [`--append-subagent-system-prompt`](</docs/en/cli-reference#cli-flags>) together with `--append-subagent-system-prompt-file` in one `claude` invocation, so `claude` exits with code 1 instead of starting the session:
+
+ Error: Cannot use both --append-subagent-system-prompt and --append-subagent-system-prompt-file. Please use only one.
+
+Before v2.1.283, `claude` exited the same way when you passed `--system-prompt` with `--system-prompt-file`, or `--append-system-prompt` with `--append-system-prompt-file`, because those pairs conflicted instead of [combining](</docs/en/cli-reference#system-prompt-flags>). On those versions the message names the pair you combined. **What to do:**
+
+ * Keep one form of the flag and drop the other. To combine a fixed prompt file with per-run text, merge the text into the file before launching instead of passing both flags
+
+###
+
+
+
Invalid `--agents` configuration
The value you passed to `--agents` is invalid, so `claude` exits with code 1 instead of starting the session. When you pass `--safe-mode` or set [`CLAUDE_CODE_SAFE_MODE`](</docs/en/env-vars#variables>), Claude Code ignores `--agents` entirely. With `--resume` or `--continue`, an inline JSON value isn’t checked and the session starts; a value read from a file is checked on every launch. Before v2.1.242, Claude Code started the session anyway.
@@ -2733,6 +2800,21 @@
+Cannot add MCP server when managed settings allow only plugin servers
+
+You ran `claude mcp add` or `claude mcp add-json` while your organization’s managed settings set [`strictPluginOnlyCustomization`](</docs/en/settings-reference#strictpluginonlycustomization>) to `true` or to a list that includes `mcp`. With that setting, Claude Code doesn’t load MCP servers from `~/.claude.json` or `.mcp.json`, so the command exits with code 1 instead of saving a server that would never load:
+
+ Cannot add MCP server: your organization's managed settings allow only MCP servers that plugins provide. Install a plugin that provides this server, or ask your administrator to make it available.
+
+`claude mcp add-from-claude-desktop` reports each server you select as not imported, with this message as the reason. [`/import`](</docs/en/commands#all-commands>) reports this message for each MCP server it tries to add and still imports the other items it found. Before v2.1.284, these commands saved the server and reported success, and the server never loaded. **What to do:**
+
+ * Install a [plugin](</docs/en/plugins/install>) that provides the server
+ * Ask your administrator to distribute the server in a [plugin](</docs/en/plugins/org>), or to provide it through [`managedMcpServers`](</docs/en/settings-reference#managedmcpservers>) if it’s a remote HTTP or SSE server
+
+###
+
+
+
Can’t read .mcp.json
A command that reads the project’s [`.mcp.json`](</docs/en/mcp#project-scope>), such as `claude mcp add` or `claude mcp add-json` with `--scope project`, or `claude mcp remove`, found that the file in your current directory isn’t a regular file or is larger than 2 MiB, so it exits with this error instead of reading the file.
@@ -2895,6 +2977,30 @@
* For interactive use, run `claude` in a real terminal: Windows Terminal or the PowerShell console rather than ISE, and your IDE’s integrated terminal rather than an output pane
* For one-shot use, pass the prompt: `claude -p "your question"`, or pipe it with `echo "your question" | claude -p`
+
+###
+
+
+
+Claude Code can’t read the keyboard here
+
+You ran `claude` without [`-p`](</docs/en/headless>), which starts an [interactive session](</docs/en/interactive-mode>), but its standard input isn’t a terminal. Something piped or redirected it, or the program that launched `claude` supplied its own input stream. An interactive session needs a terminal to read your keystrokes from, and what Claude Code does without one depends on your platform:
+
+ * **Windows** : Claude Code prints the message to stderr and exits with code 1 instead of starting the interface
+ * **macOS and Linux** : Claude Code reads your keystrokes from `/dev/tty` and starts the session, with any piped text as your first prompt. You see the message when `/dev/tty` can’t be opened, and its first line names `/dev/tty` in place of the Windows wording.
+
+On Windows the message reads:
+
+ Claude Code can't read the keyboard here: stdin is not a terminal (it is piped, redirected, or supplied by the program that launched claude), and on Windows it can't fall back to the console for input yet.
+ Run claude directly in Windows Terminal, PowerShell, or Command Prompt, without piping or redirecting its input.
+ To send text as a prompt and print the reply instead, add -p; it also works with --continue and --resume <session-id> (for example: type notes.md | claude -p --continue).
+
+**What to do:**
+
+ * To work interactively, run `claude` directly in a terminal, without piping or redirecting its input
+ * To get a reply without the interactive interface, for example from a script, add `-p` and give the prompt as an argument or on stdin, as in `claude -p "your question"` or `echo "your question" | claude -p`. The same works with `--continue` and `--resume <session-id>`.
+
+Before v2.1.287, Claude Code started the interface instead of printing this message, then either showed nothing on screen or failed with an error containing `Raw mode is not supported`. If you see `Raw mode is not supported` during `claude install` instead, see [`Raw mode is not supported` during install](</docs/en/troubleshoot-install#raw-mode-is-not-supported-during-install>).
###
@@ -3091,6 +3197,31 @@
+A GitHub organization policy is blocking Claude
+
+You ran a command at the Claude Code prompt that starts a cloud session, such as [`/autofix-pr`](</docs/en/claude-code-on-the-web#auto-fix-pull-requests>). Before it creates the session, Claude Code checks Claude’s access to the repository on GitHub, and GitHub refused because your GitHub organization has a policy that blocks Claude. Claude Code stops there and shows a message naming the policy. When an IP allow list is what blocks the access, the message reads:
+
+ Your GitHub organization has an IP allowlist that is blocking Claude. Add Claude's IP ranges to your GitHub allowlist.
+
+When single sign-on is what blocks it, the message reads:
+
+ Your GitHub organization requires single sign-on. Disconnect and reconnect GitHub on the Connectors page in Claude on the web, click Authorize next to your organization when GitHub asks, then try again.
+
+When a Microsoft Entra ID Conditional Access policy is what blocks it, the message reads:
+
+ Your GitHub organization's identity provider (Microsoft Entra ID) has a Conditional Access policy that is blocking Claude. Ask your GitHub Enterprise or Entra ID admin to allow Claude in that policy.
+
+**What to do:**
+
+ * **IP allow list** : ask an owner of your GitHub organization or enterprise to allow Anthropic’s outbound IP addresses. See [GitHub allow lists and firewalls](</docs/en/network-config#github-allow-lists-and-firewalls>) for the addresses and the GitHub settings to change.
+ * **Single sign-on** : disconnect GitHub at [claude.ai/customize/connectors](<https://claude.ai/customize/connectors>), then connect it again. When GitHub asks, click **Authorize** next to your organization so the new connection is authorized for its single sign-on.
+ * **Conditional Access policy** : ask your GitHub Enterprise or Microsoft Entra ID administrator to allow Claude in that policy
+ * After the change, run the command again
+
+###
+
+
+
Single sign-on authorization needed
You ran [`/install-github-app`](</docs/en/github-actions#quick-setup>) and chose a repository whose organization enforces SAML single sign-on. Before setup, Claude Code checks your access to the repository with the GitHub CLI, and GitHub refused that check because your `gh` token isn’t authorized for the organization yet. The wizard shows the warning with the steps to authorize:
@@ -3120,7 +3251,7 @@
Claude Code exits with code 1 after showing the message. The `/resume` picker inside a running session reports `Failed to resume conversation` in the conversation instead, and your current session keeps running. Before v2.1.216, a failed resume from the `claude --resume` picker stayed on the `Resuming conversation…` spinner indefinitely instead of showing this message. **What to do:**
* Run `claude --resume <session-id>` with the session ID from the message to retry
- * If every retry fails the same way, run `claude update` and resume again. Versions before v2.1.275 fail the resume when the saved transcript contains an entry they can’t read.
+ * On a version before v2.1.285, if the retry fails the same way, run `claude update` and resume again. Those versions fail the resume when the saved transcript contains an entry they can’t read.
* If the retry fails again, run `claude` to start a new session
###
@@ -3276,6 +3407,21 @@
* Add `local` to the session’s setting sources and switch again
* Set the [`outputStyle`](</docs/en/settings-reference#outputstyle>) key in a settings file the session does load, such as `.claude/settings.json` in the project or `~/.claude/settings.json`. In the TypeScript SDK, set `outputStyle` inside the inline `settings` object instead; see [Activate an output style](</docs/en/agent-sdk/modifying-system-prompts#activate-an-output-style>)
+###
+
+
+
+/recap only runs when you ask for it yourself
+
+The [`/recap`](</docs/en/interactive-mode#session-recap>) request didn’t come from your own input. It arrived in a message relayed into the session from a Slack, Teams, or [project](</docs/en/claude-projects>) thread, or in a prompt that a [routine](</docs/en/routines>) or another program sent. A relayed message gets the notice even when you wrote it yourself. Claude Code can’t tell that a relayed or automated message came from the person whose account runs the session, so it answers with this notice instead of a summary:
+
+ /recap only runs when you ask for it yourself in this session: from the terminal, the Claude app or claude.ai/code, or over Remote Control. A message relayed from Slack, Teams or a project thread, or sent by a routine or another program, can't request it.
+
+A `/recap` you pass to `claude -p`, or that your own [Agent SDK](</docs/en/agent-sdk/overview>) application sends to a session it launched, counts as your own input. **What to do:**
+
+ * Open the session yourself and run `/recap` there: in its terminal, in the [Desktop app](</docs/en/desktop>) or the [mobile app](</docs/en/mobile>), at [claude.ai/code](<https://claude.ai/code>), or over [Remote Control](</docs/en/remote-control>)
+ * If a routine or another program sent it, remove `/recap` from that prompt
+
##
@@ -3553,7 +3699,23 @@
Tool errors
-These errors come from Claude’s built-in tools. Claude corrects most tool errors on its own. When one needs a change from you, that error’s **What to do** list says what to change.
+These errors come from Claude’s tool calls. Claude corrects most tool errors on its own. When one needs a change from you, that error’s **What to do** list says what to change.
+
+###
+
+
+
+No such tool available
+
+Claude called a tool by a name that isn’t in the session’s tool list. Claude Code returns the error to Claude as the tool call’s result, and the turn continues. When Claude Code can tell why the tool is missing, it adds a sentence after the tool name that gives the reason or names the tool to call instead, as in the second line:
+
+ Error: No such tool available: <tool name>
+ Error: No such tool available: read. Tool names are case-sensitive: call Read instead.
+
+Right after you resume a session, an MCP server can still be on its first connection attempt when Claude calls one of its tools. Claude Code then [waits for the server](</docs/en/mcp#tool-availability>) and returns this error if the tool still isn’t available when the wait ends. Before v2.1.284, such a call failed at once instead of waiting. A call whose tool name Claude Code cut to 200 characters also fails with this error. **What to do:**
+
+ * If it happens once, you don’t need to do anything. Claude reads the error and the turn continues.
+ * If calls to an MCP server’s tools keep failing with this error, run `/mcp` in the session or `claude mcp list` in your shell to check the server’s [status](</docs/en/mcp#server-status>), and reconnect a failed server from `/mcp`. In the Agent SDK, see [Error handling](</docs/en/agent-sdk/mcp#error-handling>).
###
@@ -3875,6 +4037,28 @@
+Not published: that file is on a network share
+
+Claude tried to publish an [artifact](</docs/en/artifacts>) from a file at a path that names a network host:
+
+ * On Windows, a `\\server\share` path that isn’t under a mapped network drive you passed at launch with [`--add-dir`](</docs/en/cli-reference#cli-flags>)
+ * On macOS or Linux, an automount path such as `/net/<host>/page.html`
+
+Looking up such a path contacts the host it names, and on Windows that contact can send the host your credentials. Claude Code refuses to publish the file and doesn’t read it. The refusal appears in the Artifact tool result:
+
+ Not published: that file is on a network share. Publish a file from this session's folders instead.
+
+**What to do:**
+
+ * Nothing, if you don’t need that exact file: the message tells Claude to publish a file from the session’s own folders instead
+ * To publish that exact file, copy it into a folder on a local disk and ask again
+ * On Windows, to let Claude publish directly from the share, map it to a drive letter and pass the drive when you start Claude Code. In PowerShell, for example, run `net use Z: \\server\share` and then `claude --add-dir Z:\`. Claude can then publish files from that drive. Adding the drive mid-session with `/add-dir` isn’t enough.
+ * On macOS or Linux, mount the share at a directory such as one under `/mnt` or `/Volumes`, and publish from that path instead of the automount path
+
+###
+
+
+
Reading a local file from outside the connected folders in a Cowork session
In a [Cowork](<https://claude.com/docs/cowork/overview>) session running on your machine in the Claude Desktop app, Claude named a local file for an [artifact](</docs/en/artifacts>). Claude Code couldn’t confirm the file is a plain file inside the session’s connected folders: the path sits outside those folders, passes through a symbolic link, or is spelled in a way that can name a different file than it appears to. Reading such a file needs your approval, and in a session that can’t show you the approval card, such as one set to skip all approvals, Claude Code refuses the read. The refusal appears in the Artifact tool result; when the file couldn’t be examined at all, it names that failure instead:
@@ -3903,6 +4087,23 @@
* Usually nothing: the message points Claude at `curl` through the Bash tool, which can reach local and intranet servers
Before v2.1.268, WebFetch reported these URLs with a generic `Invalid URL` error.
+
+###
+
+
+
+WebFetch domain safety check failed
+
+Before fetching a URL, WebFetch sends the URL’s hostname to `api.anthropic.com` to check it against Anthropic’s [domain safety blocklist](</docs/en/data-usage#webfetch-domain-safety-check>). If the check can’t complete, WebFetch can’t confirm that the domain is safe, so it doesn’t fetch the page and the tool result carries one of these messages instead:
+
+ The safety check for domain example.com is rate-limited (too many domain checks from this network; the limit is shared and can stay exhausted for minutes). Do not retry WebFetch in a loop or sleep to wait it out; continue without this page and report that its safety check was rate-limited. A single later attempt is fine; if that is rate-limited too, stop.
+
+ Unable to verify if domain example.com is safe to fetch. This may be due to network restrictions or enterprise security policies blocking claude.ai.
+
+ * `rate-limited`: the check endpoint answered with HTTP `429`. The message tells Claude to continue without the page and to try again at most once later. Claude Code doesn’t cache a failed check, so a later fetch of that domain runs the check again. If sessions on your network hit this often, you can skip the check with [`skipWebFetchPreflight: true`](</docs/en/settings-reference#skipwebfetchpreflight>) in settings.
+ * `Unable to verify`: the check request failed, timed out, or got another error status. If your network blocks `api.anthropic.com`, allowlist that domain, or skip the check with [`skipWebFetchPreflight: true`](</docs/en/settings-reference#skipwebfetchpreflight>) in settings.
+
+Before v2.1.286, the rate-limited message read `The safety check for domain example.com is temporarily rate-limited (too many domain checks from this network). Retry after about a minute; retrying sooner will fail the same way.`. Before v2.1.285, a rate-limited check was reported with the `Unable to verify` message instead.
##
@@ -4224,7 +4425,7 @@
* **`The home directory is trusted one session at a time`** : the session’s directory is your home directory. Claude Code never saves trust for the home directory, so accepting the dialog there in an earlier session doesn’t count.
* **`<path> could not be resolved on disk`**: Claude Code couldn’t find the session’s directory on disk.
-**What to do:**
+Before v2.1.286, on Windows, this message could also appear in a directory you had already trusted, if its trust record was saved with the path in a different letter case. Update to v2.1.286 or later. **What to do:**
* Run `claude` in the directory the message names and accept the trust dialog, then run the command again
* For the home-directory message, run the command from a terminal in your home directory so the dialog can appear, or start the session from a project directory instead
@@ -4740,6 +4941,21 @@
+ANTHROPIC_FOUNDRY_RESOURCE must be a Foundry resource name
+
+You set [`ANTHROPIC_FOUNDRY_RESOURCE`](</docs/en/env-vars>) to something other than a bare [Microsoft Foundry](</docs/en/microsoft-foundry>) resource name, such as the endpoint URL or its host name. Claude Code refused the value before sending a request. The message appears in place of Claude’s reply, not as a startup warning:
+
+ API Error: ANTHROPIC_FOUNDRY_RESOURCE must be a Foundry resource name (2-64 letters, digits and hyphens, not starting or ending with a hyphen, such as my-resource), not a URL or host name. To use a full URL, set ANTHROPIC_FOUNDRY_BASE_URL instead.
+
+**What to do:**
+
+ * Set `ANTHROPIC_FOUNDRY_RESOURCE` to the resource name alone and restart Claude Code. For the endpoint `https://my-resource.services.ai.azure.com/anthropic`, the name is `my-resource`.
+ * To give the full endpoint URL instead, set [`ANTHROPIC_FOUNDRY_BASE_URL`](</docs/en/env-vars>) to the URL and remove `ANTHROPIC_FOUNDRY_RESOURCE`, then restart Claude Code. Claude Code accepts only one of the two variables.
+
+###
+
+
+
The 200K limit isn’t enforced
You set [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](</docs/en/env-vars>), which normally makes [auto-compaction](</docs/en/model-config#default-auto-compact-thresholds>) hold sessions on 1M-context models to a 200K window, but no compaction threshold caps this session at or below 200K, so the conversation can grow past it.
Show diff (328 lines)
--- a/events.md
+++ b/events.md
@@ -0,0 +1,325 @@
+A hook is an event handler: a function that Claude Code runs when a named event happens. Claude Code fires an event at each point where it’s about to act, such as when it runs a tool, submits a prompt, sends a request to the model, or starts or ends a session. Your hook runs before Claude Code acts, so it can observe the event, rewrite it, or answer it in Claude Code’s place. You register a hook with [`on(eventName, handler)`](</docs/en/plugins/mods/reference#the-hook-function>). Build your [first mod](</docs/en/plugins/mods/create>) before you start here. For every event and its exact fields, see the [reference](</docs/en/plugins/mods/reference#events>) or read [the types for your build](</docs/en/plugins/mods/create#get-the-types-for-your-build>).
+
+##
+
+
+
+How a hook handles an event
+
+A hook sits between an event and what Claude Code would do about it, so it can observe the event, rewrite it, or answer it itself. It receives three arguments: the [mods API](</docs/en/plugins/mods/api>) as `$`, the event as `e`, and the next handler as `next`. The handlers for an event form a middleware chain. `next(e)` calls the next handler, which is another mod’s hook or, at the end of the chain, Claude Code’s own behavior, and it resolves to the result. What your hook does with `next` decides which of the three it does.
+
+###
+
+
+
+Observe an event
+
+To observe an event without changing it, do your work and return `next(e)`. This hook logs each tool Claude is about to use:
+
+ on('tool.call', async ($, e, next) => {
+ // Runs before the tool does
+ $.ui.log('Claude is about to use ' + e.tool)
+ // Pass the event on unchanged
+ return next(e)
+ })
+
+Before each tool runs, a dim line such as `● my-mod: Claude is about to use Bash` appears in the transcript, where `my-mod` is your plugin’s name. The tool runs as it would without the mod. To act after the event, `await next(e)`, do your work, and return the result. This hook logs each tool after it has run:
+
+ on('tool.call', async ($, e, next) => {
+ // Let the tool run, and wait for its result
+ const result = await next(e)
+ // Runs after the tool does
+ $.ui.log(e.tool + ' finished')
+ // Give the result back unchanged
+ return result
+ })
+
+The line now appears after each tool finishes. Claude reads the same result either way, because the hook returns what `next(e)` resolved to.
+
+###
+
+
+
+Rewrite an event
+
+To change what Claude Code acts on, such as the text of a prompt, call `next` with a modified copy of the event. The event itself is immutable: it’s deeply frozen, and assigning to a field throws. This hook trims each prompt before it’s sent:
+
+ on('prompt.submit', async ($, e, next) => {
+ // Pass on a copy of the event with its text changed
+ return next({ ...e, text: e.text.trim() })
+ })
+
+Later handlers and Claude Code receive the trimmed prompt and never see the original. You can also change the result: `await next(e)`, then return a copy of the result with a field replaced.
+
+###
+
+
+
+Answer an event
+
+To handle an event yourself, return a result without calling `next`. That short-circuits the chain, so later mods and Claude Code’s own behavior don’t run. This hook refuses every Bash command:
+
+ on('tool.call', { tool: 'Bash' }, async () => {
+ // No call to next, so the command never runs
+ return { deny: 'Bash is turned off in this project. Use the file tools.' }
+ })
+
+When Claude tries a Bash command, the command doesn’t run, and Claude reads the `deny` text as the tool’s result. Each event has its own result shape, which the [events reference](</docs/en/plugins/mods/reference#events>) lists.
+
+###
+
+
+
+Filter which events a hook handles
+
+To run a hook for some events only, pass a filter as the second argument to `on`. Claude Code calls the filter a matcher. It’s an object whose fields are compared with the event’s, and the hook runs only when every field matches. A field can be a value, an array of allowed values, or a regular expression. Each line in this example registers the same function, `hook`, for a narrower set of tool calls:
+
+ // A string matches one value: Bash calls only
+ on('tool.call', { tool: 'Bash' }, hook)
+ // An array matches any value in it: Edit calls and Write calls
+ on('tool.call', { tool: ['Edit', 'Write'] }, hook)
+ // A regular expression matches by pattern: every tool of one MCP server
+ on('tool.call', { tool: /^mcp__github__/ }, hook)
+
+`hook` runs once for a Bash, Edit, or Write call, and once for a call to a tool whose name starts with `mcp__github__`. A call to any other tool, such as Read, matches none of the three, so `hook` doesn’t run for it. The event name can be a wildcard. `'classic.*'` matches every settings hook event. `'*'` matches every event except the [telemetry events](</docs/en/plugins/mods/reference#telemetry>), which take their own name and a `{ to: 'collector' }` filter. Register each event once per matcher. If you call `on` twice for `session.start` with no matcher, the module fails to load with `on("session.start") is registered twice without a matcher`. Put everything your mod does at session start in one hook.
+
+##
+
+
+
+Hook what Claude is doing
+
+Handle these events to see or change a tool call, a prompt, or a turn as it happens. For every event and what a hook can return, see the [events reference](</docs/en/plugins/mods/reference#events>).
+
+###
+
+
+
+Guard or change a tool call
+
+A `tool.call` hook sees each tool Claude is about to use, so it can refuse the call, change its arguments, or let it through. `tool.call` fires when Claude Code is about to run a tool, including calls a subagent makes and calls to MCP tools. `e.tool` is the tool’s name and the tool’s arguments are fields of `e`, such as `e.command` for Bash. When you call `next(e)`, Claude Code runs the permission check and then the tool. This hook refuses a Bash command that force-pushes, and tells Claude why:
+
+ // The matcher limits the hook to Bash calls, so e.command is the shell command
+ on('tool.call', { tool: 'Bash' }, async ($, e, next) => {
+ if (/git push .*--force/.test(e.command)) {
+ // Returning without calling next answers the event, so the command never runs
+ return { deny: 'Force pushes are not allowed in this repository. Push to a new branch instead.' }
+ }
+ // Every other command goes on to the permission check and then to Bash
+ return next(e)
+ })
+
+When Claude tries `git push --force`, the command doesn’t run and no permission prompt appears, because the hook never calls `next`. Claude reads the `deny` text as the tool’s result, so write it as an instruction Claude can act on. Every other Bash command runs as it would without the mod. To act after a tool has run, `await next(e)`, do your work, and return what `next` gave you. This hook logs each `.mdx` file Claude changes, with [`$.ui.log`](</docs/en/plugins/mods/api#show-something-without-starting-a-turn>), which adds a dim line to the transcript that Claude doesn’t read:
+
+ on('tool.call', { tool: ['Edit', 'Write'] }, async ($, e, next) => {
+ // Wait for the permission check and the tool, and keep what they produced
+ const result = await next(e)
+ // A refused call comes back as { deny }, and a failed one has isError set
+ const changed = !result.deny && !result.isError
+ if (changed && e.file_path.endsWith('.mdx')) $.ui.log('Claude changed ' + e.file_path)
+ // Return the result as it came, so Claude reads what the tool returned
+ return result
+ })
+
+After Claude edits or writes an `.mdx` file, a dim line in the transcript names the file. Nothing is logged for another kind of file, or for a call that was refused or failed. Claude’s view of the call doesn’t change, because the hook returns the result it received. To change a call, pass changed arguments to `next`. To retry a call, call `next(e)` again: a hook that sees `isError` on the first result can run the tool a second time and return that result. To answer a call yourself, return an object with a `result` field, such as `{ result: 'Skipped by my-mod' }`, without calling `next`. When you do that, no permission prompt appears and the tool doesn’t run, so the result you return is all Claude learns about what happened. Hooks in your organization’s [managed settings](</docs/en/server-managed-settings>) run before any mod’s `tool.call` hook, and a block from one of them is final.
+
+####
+
+
+
+Hold a tool call until the user decides
+
+A hook can pause a tool call and ask the user what to do before it goes ahead. A `tool.call` hook can `await` before it calls `next` or returns, and the tool call stays pending until then. To put the question to the user, call `$.ui.ask`. It shows your question above a numbered list of your options, in the dialog Claude uses to ask you something, and resolves to the label the user picks. After your options, the dialog adds a row for typing a different answer and a **Chat about this** row. The `RISKY` pattern in this example matches `rm -r`, `rm -rf`, `git reset --hard`, and `git push` with `--force`, and it misses other spellings such as `git push -f`. This module asks before it runs a Bash command that matches the pattern:
+
+ const RISKY = /\brm\s+-rf?\b|\bgit\s+reset\s+--hard\b|\bgit\s+push\b.*--force/
+
+ export function register(on) {
+ on('tool.call', { tool: 'Bash' }, async ($, e, next) => {
+ // Let every other command through without a question
+ if (!RISKY.test(e.command)) return next(e)
+ // Start from the safe answer, so a question nobody answers refuses the command
+ let answer = 'Refuse'
+ try {
+ // The tool call waits here until the user picks one of the two labels
+ answer = await $.ui.ask('Run this command? ' + e.command, ['Run it', 'Refuse'])
+ } catch {
+ // The user dismissed the question, or this is a claude -p run with nobody to ask
+ }
+ if (answer !== 'Run it') {
+ // Answer without calling next, so the command doesn't run
+ return { deny: 'The user declined this command. Ask before trying a different approach.' }
+ }
+ return next(e)
+ })
+ }
+
+When Claude tries a command such as `rm -rf build`, the question appears with the command in it, and the command waits for the answer:
+
+ * **The user picks Run it** : the hook calls `next(e)`, and the usual permission check still runs after it
+ * **The user picks Refuse** : the command doesn’t run, and Claude reads the `deny` text
+ * **The user types an answer** : `$.ui.ask` resolves to the typed text. The hook compares it with `Run it`, so any other text refuses the command.
+ * **Nobody answers** : `$.ui.ask` rejects when the user dismisses the question or picks **Chat about this** , and in a `claude -p` run, so the `catch` block leaves the answer at `Refuse`
+
+Keep the wait inside a mods API call such as `$.ui.ask`, because that time doesn’t count against the hook’s [time limit](</docs/en/plugins/mods/reference#limits>). Time spent awaiting a promise of your own does count. Claude Code skips a hook that times out, so the held command would run.
+
+####
+
+
+
+Approve or refuse a tool call before the user is asked
+
+To decide whether a tool call may run, handle [`tool.check`](</docs/en/plugins/mods/reference#tools>), the event where Claude Code makes that decision. It fires after the permission rules and the settings hooks have decided, and `next(e)` resolves to their decision: `allow`, `ask`, or `deny`. Your hook returns that decision or a different one. `e.input` holds the tool’s arguments, such as `command` for Bash. For a fixed command or path, use a [permission rule](</docs/en/permissions#permission-rule-syntax>) such as `Bash(npm test)`, which takes no code. Handle `tool.check` when the decision depends on what’s true at that moment, such as the current Git branch or a value another hook recorded. This hook refuses `git push` while the current branch is `main`:
+
+ on('tool.check', { tool: 'Bash' }, async ($, e, next) => {
+ // What the permission rules and settings hooks decided: 'allow', 'ask', or 'deny'
+ const decided = await next(e)
+ if (!e.input.command.includes('git push')) return decided
+ const branch = await $.process.run(['git', 'branch', '--show-current'])
+ if (branch.stdout.trim() !== 'main') return decided
+ return { decision: 'deny', reason: 'Push from a branch other than main' }
+ })
+
+On `main`, the hook returns `deny`, even when a rule allows `git push`. On another branch, and for other commands, the call gets the decision it would get without the mod. The hook matches the text of the command, so treat it as a reminder for Claude. To block pushes to `main` for everyone, protect the branch on your Git host. A hook can return `allow`, `ask`, or `deny`, so it can also approve a call that a `PreToolUse` hook outside managed settings blocked. [Extend permissions with hooks](</docs/en/permissions#extend-permissions-with-hooks>) lists which decisions hold over a mod.
+
+###
+
+
+
+Rewrite or add to a prompt
+
+A `prompt.submit` hook sees each prompt before the turn starts, so it can rewrite the text or add to it. `e.text` is what was typed.
+
+To do this| Return this
+---|---
+Rewrite the prompt. The message in the transcript shows the new text.| `next({ ...e, text: newText })`
+Add text only Claude reads, after the prompt| `next({ ...e, context: [...(e.context ?? []), extraText] })`
+Stop the prompt from being sent| `{ drop: 'the reason' }`
+
+This hook adds the current branch name for Claude whenever a prompt mentions a pull request:
+
+ on('prompt.submit', async ($, e, next) => {
+ // Pass on a prompt that doesn't mention a pull request as it is
+ if (!/\bPR\b|pull request/i.test(e.text)) return next(e)
+ const git = await $.process.run(['git', 'branch', '--show-current'])
+ // Outside a git repository the command fails, so there's no branch to add
+ if (git.exitCode !== 0) return next(e)
+ // Keep any context an earlier hook added, and add one more line for Claude
+ return next({ ...e, context: [...(e.context ?? []), 'Current branch: ' + git.stdout.trim()] })
+ })
+
+When you send a prompt such as `open a PR for this change`, your message looks the same in the transcript, and Claude also reads a line such as `Current branch: feature/auth` after it. A prompt that doesn’t mention a pull request goes through unchanged, and `git` doesn’t run. [Other events](</docs/en/plugins/mods/reference#prompts-and-what-claude-reads>) cover the rest of what Claude reads: `prompt.section` for each section of the system prompt, `prompt.context` for the context sent with the first message, and `skill.prompt` for a skill’s text. Text from these hooks that changes between requests [invalidates the prompt cache](</docs/en/prompt-caching>).
+
+###
+
+
+
+Follow a turn
+
+A turn is everything Claude does in answer to one prompt. Handle `turn.start`, `turn.step`, and `turn.complete` to follow one:
+
+Event| When it fires| What a hook can do
+---|---|---
+`turn.start`| A turn begins| Observe. `e.turnId` identifies the turn in the other two events.
+`turn.step`| Claude Code is about to send one request to the model. A turn with tool calls has several. `e.agentId` is set for a subagent’s request.| Read each request’s token usage, send it to a different model with `next({ ...e, model })`, or answer without calling the model
+`turn.complete`| The turn ended, including a turn the user interrupted, where `e.isAborted` is `true`. `e.answer` is Claude’s final text, `e.durationMs` how long it took, and `e.usage` the turn’s token totals. A subagent’s turn fires it with `e.agentId` set.| Observe, or return an object with a `text` field, such as `{ text: 'Done in 12 seconds' }`, to show a line under the answer
+
+Write a `turn.step` hook as an async generator, because the event streams. `yield* next(e)` forwards the response as it streams and evaluates to the finished result. This hook logs how much of each request the Claude API served from the [prompt cache](</docs/en/prompt-caching>):
+
+ // function* makes the hook a generator, which can pass the response on piece by piece
+ on('turn.step', async function* ($, e, next) {
+ // Send the request, forward each piece as it arrives, and keep the finished result
+ const result = yield* next(e)
+ // Skip a result that reports no token counts
+ if (result.usage) {
+ $.ui.log('cache read ' + result.usage.cache_read_input_tokens + ' · wrote ' + result.usage.cache_creation_input_tokens)
+ }
+ // Return the result unchanged, so the turn continues as usual
+ return result
+ })
+
+Claude’s response streams to the screen as it does without the mod. After each request finishes, a dim line in the transcript gives the number of tokens read from the cache and the number written to it. A turn with tool calls has several requests, so it adds several lines. `result.usage` holds the token counts the Claude API reports for a request, plus the `model` that answered: `input_tokens`, `output_tokens`, `cache_read_input_tokens`, and `cache_creation_input_tokens`. The hook runs for subagents’ requests too, so check `e.agentId` when you want only the main conversation.
+
+###
+
+
+
+Handle the settings hook events
+
+Settings hooks are the command, HTTP, prompt, and agent hooks you configure in settings files. Each [settings hook event](</docs/en/hooks#hook-events>), such as `Stop`, `SessionEnd`, or `PostToolUse`, is also an event named `classic.` followed by the settings hook event’s name, such as `classic.Stop`. `e` is the JSON a settings hook receives on stdin, including `transcript_path`. This hook uses `Stop`, which fires when Claude finishes responding, to log where the session’s transcript is saved:
+
+ on('classic.Stop', async ($, e, next) => {
+ // e has the same fields a Stop hook in a settings file reads from stdin
+ $.ui.log('Transcript saved at ' + e.transcript_path)
+ // Pass the event on, so Stop hooks in your settings files still run
+ return next(e)
+ })
+
+Each time Claude finishes responding, a dim line in the transcript gives the path of the transcript file. The hook returns `next(e)`, so it observes the event and changes nothing about how the turn ends.
+
+##
+
+
+
+Run alongside other mods
+
+Several mods can handle the same event, and any one of them can fail. If your mod blocks tool calls, check its position in the chain and what happens when its hook fails.
+
+###
+
+
+
+The order mods run in
+
+Hooks on the same event form one middleware chain. Each mod’s `next` calls the following mod’s hook, and the last `next` reaches Claude Code’s own behavior. The first mod is outermost: it sees the event before the others and the result after them, and it decides whether the others run at all. A later mod can’t stop an earlier one from seeing an event. Claude Code orders the chain by where each mod comes from:
+
+ 1. The built-in guard `sec-default@builtin`, a mod built into Claude Code that `/plugin` lists as `cc-plugin-sec-default`, where [it loads](</docs/en/plugins/mods/admin#know-what-happens-by-default>), mods your organization lists in [`prependPlugins`](</docs/en/plugins/mods/admin#install-your-organizations-mods>), and then any other mod that counts as your organization’s and isn’t in `appendPlugins`
+ 2. Mods you install
+ 3. Mods your organization lists in `appendPlugins`
+ 4. Other mods built into Claude Code
+
+Among the mods you install, a mod runs before the mods it lists under `dependencies` in its manifest. Within one module, hooks run in the order `register` called `on`.
+
+####
+
+
+
+Where settings hooks run in the order
+
+The `PreToolUse` hooks configured in settings files also run during a tool call, at fixed points in the chain of mods:
+
+ * **`PreToolUse` hooks from managed settings**: run before the first mod’s `tool.call` hook, and a block from one of them is final, so no mod sees the call.
+ * **`PreToolUse` hooks from every other settings file and from plugins’ `hooks/hooks.json`**: run after the last mod calls `next`, as part of Claude Code’s own behavior. A mod that answers `tool.call` without calling `next` keeps them from running, and a mod that calls `next` sees their decision in the result it returns.
+
+`tool.check` fires after those hooks and the permission rules have decided, so a hook on it can approve a call that a hook in the second group blocked.
+
+###
+
+
+
+Handle a hook that fails
+
+A hook that fails doesn’t break the session, and you can decide what happens instead. When a hook with no `.catch` handler throws, times out, or returns a result of the wrong shape, what happens next depends on whether it had called `next`:
+
+ * **It failed before calling`next`**: Claude Code skips it, and the next handler runs in its place
+ * **It failed after`next` resolved**: that result stands, and nothing runs a second time
+
+One line names the mod, the event, and the reason, such as `my-mod: tool.call hook skipped: threw Error: boom`. Where you read it depends on the session, as [Find out why a mod does nothing](</docs/en/plugins/mods/troubleshoot#find-out-why-a-mod-does-nothing>) lists. A `ui.render` hook whose drawing doesn’t validate is reported differently, as [Build a tree from elements](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) describes. To make a hook that blocks calls fail closed, add a `.catch` error handler that answers in its place. Here, `guard` is your hook function:
+
+ // on returns a registration, and .catch attaches a handler to that one hook
+ on('tool.call', { tool: 'Bash' }, guard).catch(async ($, e, next) => {
+ // next.error.kind is 'throw' or 'timeout', which says how guard failed
+ return { deny: 'The command guard failed, so this command was not run: ' + next.error.kind }
+ })
+
+While `guard` works, the handler never runs. When `guard` throws or times out on a Bash call, Claude Code calls the handler with the same event. The handler returns `{ deny }`, so the command doesn’t run, and Claude reads the text with `throw` or `timeout` at the end. Without the handler, Claude Code would skip `guard` and run the command. The handler has a shorter [time limit](</docs/en/plugins/mods/reference#limits>) of its own.
+
+##
+
+
+
+Next steps
+
+ * [Use the mods API](</docs/en/plugins/mods/api>): add commands and tools, call a model, and run work on a timer
+ * [Draw in the interface](</docs/en/plugins/mods/interface>): show what your hooks collect in a pane or above the prompt
+ * [Test a mod](</docs/en/plugins/mods/test>): fire any of these events from a test
+ * [Mods reference](</docs/en/plugins/mods/reference>): every event, every mods API method, and the limits
--- a/feature-availability.md
+++ b/feature-availability.md
@@ -33,7 +33,7 @@
These have provider-specific differences:
* **MCP servers** : [connectors from claude.ai](</docs/en/mcp#use-mcp-servers-from-claude-ai>) load only when your claude.ai subscription is the active authentication method. [Tool search](</docs/en/mcp#configure-tool-search>) is off by default when `ANTHROPIC_BASE_URL` points to a non-first-party host, and isn’t supported on Google Cloud’s Agent Platform models earlier than the Claude 4.5 generation or on Microsoft Foundry [deployments hosted on Azure](<https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#hosting-options>)
- * **Subagents** : the built-in [Explore subagent](</docs/en/sub-agents#built-in-subagents>) caps its inherited model at Opus on the Claude API, and inherits the main conversation’s model directly on any other provider, including Claude Platform on AWS
+ * **Subagents** : when the main conversation runs Fable, the built-in [Explore subagent](</docs/en/sub-agents#built-in-subagents>) runs on Opus with a Claude subscription, an Anthropic Console account, or an [LLM gateway](</docs/en/llm-gateway>) reached through `ANTHROPIC_BASE_URL`. On other providers, including Claude Platform on AWS, it runs on Fable
* **[Commands](</docs/en/commands#all-commands>)** :
* `/design-sync` and `/import` with its `claude import` subcommand form are unavailable on Amazon Bedrock, Google Cloud’s Agent Platform, Microsoft Foundry, and Claude Platform on AWS, and through a [Claude apps gateway](</docs/en/claude-apps-gateway#availability-and-limitations>)
* `/voice` requires a claude.ai account
--- a/fullscreen.md
+++ b/fullscreen.md
@@ -87,6 +87,8 @@
* **Click a setting’s value in the`/config` panel** to change it, and scroll the settings list with the mouse wheel. Requires Claude Code v2.1.271 or later.
* **Scroll a select or multi-select menu with the mouse wheel** when it has more options than it shows at once, such as the `/model` list in a short terminal window. The wheel scrolls the list while the pointer is over its options. Requires Claude Code v2.1.280 or later.
* **Scroll an overflowing list with its scrollbar.** In list panels such as `/skills`, `/mcp`, and `/plugin`’s Installed list, a scrollbar appears beside a list with more rows than fit while the pointer is over it. Click the track to jump to that point, or drag the thumb. Requires Claude Code v2.1.281 or later.
+ * Where the bar has `↑` and `↓` arrows at its ends, click an arrow to scroll a single row, or hold it to keep scrolling. The arrows require Claude Code v2.1.286 or later.
+ * **Click the`↑ N more` or `↓ N more` row at the edge of a list** to jump to that end of the list without choosing an option. Requires Claude Code v2.1.286 or later.
* **Click a collapsed tool result** to expand it and see the full output. Click again to collapse. The tool call and its result expand together. Only messages that have more to show are clickable.
* Clicking also expands the output of a `!` shell command, whether an older truncated result or the live progress row while the command runs. Requires Claude Code v2.1.257 or later.
* Clicking also expands a dim `Message from @<sender>` line when the sender is a [teammate](</docs/en/agent-teams>) or another agent running in your session. The line for a message from [one of your other sessions](</docs/en/cross-session-messaging#what-a-message-looks-like>) also shows the message’s first line and isn’t clickable, so press `Ctrl+o` to read that one.
@@ -187,7 +189,7 @@
Watch your changes in the diff panel
-In fullscreen rendering, [`/diff`](</docs/en/interactive-mode#review-changes-with-%2Fdiff>) opens a panel beside the conversation rather than a viewer you have to close, so you can watch the changes accumulate while Claude works. In a wide terminal the panel can also open on its own once Claude starts editing files. [Diff panel](</docs/en/interactive-mode#diff-panel>) covers what it shows, how to keep it closed, and how to change what it compares against.
+In fullscreen rendering, [`/diff`](</docs/en/interactive-mode#review-changes-with-%2Fdiff>) opens a panel beside the conversation, so you can watch the changes accumulate while Claude works. [Diff panel](</docs/en/interactive-mode#diff-panel>) covers what it shows, when it opens on its own, how to keep it closed, and how to change what it compares against.
##
Show diff (376 lines)
--- a/gallery.md
+++ b/gallery.md
@@ -0,0 +1,373 @@
+A mod draws its interface from elements: text, boxes, buttons, fields, and a few that format content for you. The samples here show the code that draws an element, and most come with a screenshot of the result in a terminal pane, so you can pick an element by how it looks. To learn how drawing works, start with [Draw in the interface](</docs/en/plugins/mods/interface>). For the main props and which apps draw each element, see the [elements reference](</docs/en/plugins/mods/reference#elements>). The [type declarations](</docs/en/plugins/mods/create#get-the-types-for-your-build>) list every prop.
+
+##
+
+
+
+Try a sample
+
+The samples on this page are snippets, not whole mods. Each one is the code for one element and anything nested inside it. To see a sample in your own terminal, create the small mod in these steps and paste the sample into it. The mod adds a `/gallery` command that opens a pane and draws the sample there. A [pane](</docs/en/plugins/mods/interface#pick-where-to-draw>) is a sidebar beside the transcript in a wide fullscreen terminal, or a framed region above the prompt otherwise.
+
+1
+
+Create the mod
+
+Create a directory named `gallery` with `.claude-plugin` and `hooks` directories inside it. [Create a mod](</docs/en/plugins/mods/create#write-a-mod-yourself>) explains the files.Save the manifest as `gallery/.claude-plugin/plugin.json`:
+
+gallery/.claude-plugin/plugin.json
+
+ {
+ "name": "gallery",
+ "version": "0.1.0",
+ "description": "Opens a pane that draws one sample",
+ "author": { "name": "Your Name" }
+ }
+
+Name your entry point in `gallery/hooks/hooks.json`:
+
+gallery/hooks/hooks.json
+
+ {
+ "modules": ["./register.js"]
+ }
+
+Save the code as `gallery/hooks/register.js`. It adds a `/gallery` command that opens a pane, and draws `Plain text` in that pane:
+
+gallery/hooks/register.js
+
+ // Stands in for your own callback in the samples that take one
+ const noop = () => {}
+ // The Select sample keeps its choice here
+ let picked = 'md'
+
+ // The Raster sample packs its cells with this function
+ const DEFAULT_COLOR = 0x01000000
+ function cellsOf(rows) {
+ const numbers = rows.flat().flatMap(([char, color]) => [char.codePointAt(0), color, DEFAULT_COLOR])
+ return new Uint8Array(Uint32Array.from(numbers).buffer).toBase64()
+ }
+
+ export function register(on) {
+ on('session.start', async ($, e, next) => {
+ await $.command.register({ name: 'gallery', description: 'Open the sample pane' })
+ return next(e)
+ })
+
+ on('command.run', { command: 'gallery' }, async ($) => {
+ await $.ui.open({ id: 'gallery', focus: true, closeOnEscape: true })
+ return {}
+ })
+
+ on('ui.render', { component: 'Pane' }, async ($, e, next) => {
+ if (e.requestId !== 'gallery') return next(e)
+ const { Box, Text, Button, Input, Select, Link, Markdown, Code, Raster, Svg } = $.ui.resolve(e)
+ // Replace the element after return with a sample
+ return Text({ children: ['Plain text'] })
+ })
+ }
+
+2
+
+Run the mod
+
+In your shell, start Claude Code from the directory that holds `gallery`:
+
+ claude --plugin-dir ./gallery
+
+At the Claude Code prompt, run `/gallery`. A pane opens with `Plain text` in it.
+
+3
+
+Swap in a sample
+
+Copy a sample from this page. In `register.js`, paste it over `Text({ children: ['Plain text'] })`, so that it follows `return`, and save the file. Claude Code reloads the module each time you save, so run `/gallery` again to see the new sample.
+
+##
+
+
+
+Pick an element
+
+The samples are grouped by what you want to put on screen:
+
+ * **Show text** : `Text`, `Markdown`, and `Link`
+ * **Show code and changes** : `Code`
+ * **Arrange elements** : `Box`
+ * **Take input** : `Button`, `Input`, and `Select`
+ * **Draw pictures** : `Raster`, `Svg`, `Image`, and `Client`
+
+##
+
+
+
+Show text
+
+Three elements put words on screen: `Text` for your own styling, `Markdown` for content that’s already formatted, and `Link` for a URL.
+
+###
+
+
+
+`Text`
+
+`Text` draws a string with the styles you give it. This sample shows one line for each style:
+
+ Box({
+ flexDirection: 'column',
+ children: [
+ Text({ children: ['Plain text'] }),
+ Text({ bold: true, children: ['bold'] }),
+ Text({ italic: true, children: ['italic'] }),
+ Text({ underline: true, children: ['underline'] }),
+ Text({ strikethrough: true, children: ['strikethrough'] }),
+ Text({ dimColor: true, children: ['dimColor'] }),
+ Text({ inverse: true, children: ['inverse'] }),
+ Text({ color: 'red', children: ["color: 'red'"] }),
+ Text({ backgroundColor: 'blue', children: ["backgroundColor: 'blue'"] }),
+ ],
+ })
+
+`dimColor` draws the text in gray. `backgroundColor` fills only as wide as the text.
+
+###
+
+
+
+`Markdown`
+
+`Markdown` formats text the way Claude’s replies are formatted. Pass the content in `text`, not in `children`:
+
+ Markdown({
+ text: '## Release notes\n\nThis build has **two** fixes and one `flag`:\n\n- Faster start\n- Fewer prompts\n\n> Quoted text',
+ })
+
+A heading draws in bold without its `#` marks. Inline code draws in color without its backticks. A quote draws in italics with a bar on its left.
+
+###
+
+
+
+`Link`
+
+`Link` draws a label followed by its URL:
+
+ Link({ href: 'https://code.claude.com/docs', label: 'Claude Code docs' })
+
+The terminal draws the URL as text after the label. Whether a click opens it depends on the user’s terminal.
+
+##
+
+
+
+Show code and changes
+
+`Code` draws source text with Claude Code’s own syntax colors, or a diff.
+
+###
+
+
+
+`Code`
+
+Name the `language`, or pass a `path` for Claude Code to infer it from. With `startLine`, the lines are numbered from that number:
+
+ Code({
+ language: 'javascript',
+ startLine: 1,
+ source: "const name = 'mods'\nconsole.log('hello ' + name)",
+ })
+
+The colors come from the user’s theme.
+
+###
+
+
+
+`Code` as a diff
+
+With `format: 'diff'`, `source` is one or more unified diff hunks:
+
+ Code({
+ format: 'diff',
+ source: '@@ -1,3 +1,3 @@\n # Mods\n-A mod is a plugin.\n+A mod is a plugin that runs code.\n Read on.',
+ })
+
+Claude Code draws line numbers in place of the `@@` line. Where a removed line and an added line are alike, the words that changed get a stronger shade.
+
+##
+
+
+
+Arrange elements
+
+###
+
+
+
+`Box`
+
+`Box` lays out what’s inside it in a row or a column, and can draw a border. This sample puts a row of words above a bordered box:
+
+ Box({
+ flexDirection: 'column',
+ gap: 1,
+ children: [
+ Box({
+ flexDirection: 'row',
+ columnGap: 4,
+ children: [Text({ children: ['a row'] }), Text({ children: ['of three'] }), Text({ children: ['items'] })],
+ }),
+ Box({
+ borderStyle: 'round',
+ paddingX: 1,
+ children: [Text({ children: ["borderStyle: 'round'"] })],
+ }),
+ ],
+ })
+
+The border stretches to the width of the pane.
+
+##
+
+
+
+Take input
+
+`Button`, `Input`, and `Select` are controls: the user moves between them with Tab and uses the one that has the focus. [Keyboard focus and hotkeys](</docs/en/plugins/mods/interface#know-which-keys-your-mod-can-receive>) covers which keys reach them. Opening a pane with `focus: true` gives the pane keyboard focus. Typed letters reach an `Input` once it has the focus, so add `autoFocus: true` to a field that should take typing as soon as the pane opens.
+
+###
+
+
+
+`Button`
+
+A button runs `onPress`. This sample shows the default form, a `plain` button with a hotkey, and a dim one:
+
+ Box({
+ flexDirection: 'column',
+ children: [
+ Button({ key: 'save', label: 'Save', onPress: noop }),
+ Button({ key: 'next', label: 'Next', hotkey: 'n', plain: true, onPress: noop }),
+ Button({ key: 'skip', label: 'Skip', dimColor: true, onPress: noop }),
+ ],
+ })
+
+A button that has the focus draws in inverse video. Here the user has pressed Tab twice:
+
+###
+
+
+
+`Input`
+
+An `Input` is a one-line text field that runs `onSubmit` when the user presses Enter:
+
+ Input({
+ key: 'title',
+ label: 'Title',
+ placeholder: 'Type a title and press Enter',
+ value: '',
+ submitLabel: 'save',
+ onSubmit: noop,
+ })
+
+Without the focus, the field shows its label and its placeholder: With the focus, the label turns bold, a cursor appears, and the `submitLabel` shows after `⏎`: Typing replaces the placeholder:
+
+###
+
+
+
+`Select`
+
+A `Select` lets the user pick one of several options, and runs `onSelect` with the option’s `value`:
+
+ Select({
+ key: 'format',
+ label: 'Format',
+ value: picked,
+ options: [
+ { value: 'md', label: 'Markdown' },
+ { value: 'html', label: 'HTML' },
+ { value: 'txt', label: 'Plain text' },
+ ],
+ onSelect: (value) => {
+ picked = value
+ },
+ })
+
+Closed, it shows its label and the current option: Open, it lists its options and marks one: After the user picks an option, the list closes:
+
+##
+
+
+
+Draw pictures
+
+###
+
+
+
+`Raster`
+
+A `Raster` is a grid of colored character cells, for a heat map, a sparkline, or a game board. The terminal draws it. This sample uses the `cellsOf` function in the starter module, which packs the cells into the string a `Raster` takes. [Draw a grid of colored cells](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>) explains it:
+
+ Raster({
+ key: 'grid',
+ columns: 3,
+ rows: 2,
+ cells: cellsOf([
+ [['█', 0x2e7d32], ['█', 0xf9a825], ['█', 0xc62828]],
+ [['█', 0x2e7d32], ['█', 0x2e7d32], ['█', 0xf9a825]],
+ ]),
+ })
+
+A `Raster` rounds each color to a smaller palette, so `0x2e7d32` draws as `#337733`.
+
+###
+
+
+
+`Svg`
+
+An `Svg` draws an SVG document in the Desktop app:
+
+ Svg({
+ alt: 'Three bars of rising height',
+ width: 120,
+ height: 60,
+ source:
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 60"><rect x="10" y="40" width="20" height="20" fill="#2e7d32"/><rect x="50" y="25" width="20" height="35" fill="#f9a825"/><rect x="90" y="5" width="20" height="55" fill="#c62828"/></svg>',
+ })
+
+In the terminal, a pane that returns only an `Svg` opens empty. To draw something else there, check [`e.surface`](</docs/en/plugins/mods/interface#pick-where-to-draw>) and return a different tree.
+
+###
+
+
+
+`Image` and `Client`
+
+Two more elements have no sample here. `Image` draws a PNG or raw pixels in the terminal. `Client` is a region that a second file of yours draws, for animation and pointer input. The [elements reference](</docs/en/plugins/mods/reference#elements>) lists their props.
+
+##
+
+
+
+See where a mod can draw
+
+The samples all draw in a pane. A mod can also draw in other places, and call Claude Code to show something for it:
+
+ * **Pane and band** : [Pick where to draw](</docs/en/plugins/mods/interface#pick-where-to-draw>)
+ * **Claude Code’s own rows, such as the spinner** : [Change what Claude Code already draws](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>)
+ * **Toast, status line, and log line** : [Show something without starting a turn](</docs/en/plugins/mods/api#show-something-without-starting-a-turn>)
+ * **Question dialog** : [Hold a tool call until the user decides](</docs/en/plugins/mods/events#hold-a-tool-call-until-the-user-decides>)
+
+##
+
+
+
+Next steps
+
+ * [Draw in the interface](</docs/en/plugins/mods/interface>): build a pane with tabs, step by step
+ * [Test a drawing](</docs/en/plugins/mods/test#test-a-drawing>): press your buttons from a test
+ * [Elements reference](</docs/en/plugins/mods/reference#elements>): each element’s main props and the apps that draw it
--- a/goal.md
+++ b/goal.md
@@ -1,4 +1,4 @@
-The `/goal` command sets a completion condition and Claude keeps working toward it without you prompting each step. After each turn, a small fast model checks whether the condition holds. If the model judges it not yet met, Claude starts another turn instead of returning control to you. The goal clears automatically once the condition is met, if the model judges the condition impossible to satisfy, or if a turn fails on an error you have to fix. Use a goal for substantial work with a verifiable end state:
+The `/goal` command sets a completion condition and Claude keeps working toward it without you prompting each step. After each turn, a model checks whether the condition holds. If the model judges it not yet met, Claude starts another turn instead of returning control to you. The goal clears automatically once the condition is met, if the model judges the condition impossible to satisfy, or if a turn fails on an error you have to fix. Use a goal for substantial work with a verifiable end state:
* Migrating a module to a new API until every call site compiles and tests pass
* Implementing a design doc until all acceptance criteria hold
@@ -115,7 +115,7 @@
How evaluation works
-`/goal` is a wrapper around a session-scoped [prompt-based Stop hook](</docs/en/hooks#prompt-based-hooks>). Each time Claude finishes a turn, Claude Code sends the condition and the conversation so far to your configured [small fast model](</docs/en/model-config>), which defaults to Haiku on the Claude API; on a third-party provider, check your [provider page](</docs/en/third-party-integrations>) for the platform’s default. The model returns one of three verdicts, each with a short reason:
+`/goal` is a wrapper around a session-scoped [prompt-based Stop hook](</docs/en/hooks#prompt-based-hooks>). Each time Claude finishes a turn, Claude Code sends the condition and the conversation so far to your configured [small fast model](</docs/en/model-config>). The model returns one of three verdicts, each with a short reason:
* **Not yet met** : Claude keeps working and takes the reason as guidance for the next turn.
* **Met** : Claude Code clears the goal and records an achieved entry in the transcript.
--- a/headless.md
+++ b/headless.md
@@ -41,6 +41,14 @@
MCP servers| `--mcp-config <file-or-json>`
Custom agents| `--agents <json>`
A plugin| `--plugin-dir <path>`, `--plugin-url <url>`
+
+Bare mode also limits what happens while the session runs:
+
+ * **MCP servers** : only servers supplied on the command line connect, for example with `--mcp-config`. In an interactive session, Claude Code also skips the automatic IDE connection unless you pass `--ide`.
+ * **System reminders** : Claude gets your prompts and the tool results without the [system reminders](</docs/en/glossary#system-reminder>) Claude Code would add alongside them. For example, Claude isn’t told when a file it read earlier changes on disk, and it doesn’t get the list of available skills, including skills from an `--add-dir` folder.
+ * **Background tasks** : none run. A command that reaches its [timeout](</docs/en/tools-reference#timeout-and-output-limits>) stops instead of [moving to the background](</docs/en/tools-reference#background-commands>).
+
+Before v2.1.286, these limits held only partly: an interactive `--bare` session connected the MCP servers that a normal session would, every `--bare` session sent system reminders, and background tasks stayed available.
`--bare` is the recommended mode for scripted and SDK calls, and will become the default for `-p` in a future release.
--- a/hooks.md
+++ b/hooks.md
@@ -266,7 +266,7 @@
* **Top-level fields** are accepted on every event: `systemMessage` shows a message to the user, and `continue` (`continue_` in Python) determines whether the agent keeps running after this hook. Some events discard them or deliver them elsewhere. Each [event’s section](</docs/en/hooks#hook-events>) on the hooks page says where they land.
* **`hookSpecificOutput`** controls the current operation. The fields you set inside depend on the hook event type:
- * For `PreToolUse` hooks, this is where you set `permissionDecision` (`"allow"`, `"deny"`, `"ask"`, or `"defer"`), `permissionDecisionReason`, and `updatedInput`. If you return `"defer"`, the query ends so you can [resume it later](</docs/en/hooks#defer-a-tool-call-for-later>).
+ * For `PreToolUse` hooks, this is where you set `permissionDecision` (`"allow"`, `"deny"`, `"ask"`, or `"defer"`), `permissionDecisionReason`, and `updatedInput`. If you return `"defer"`, the turn ends with a result message whose `stop_reason` is `"tool_deferred"`, so you can [resume the call later](</docs/en/hooks#defer-a-tool-call-for-later>).
* For `PostToolUse` hooks, you can set `additionalContext` to append information to the tool result. To replace the tool’s output before Claude sees it, set `updatedToolOutput`, which works for any tool in both SDKs. The older `updatedMCPToolOutput` field replaces MCP tool output only and is deprecated.
* In the TypeScript SDK, a `PostToolUse` callback can also return `classifierContext`, a short note about the tool call’s result for the [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) permission classifier. Because your callback runs in your application’s own process, the classifier may weigh a user statement you relay in the note as user intent. The field requires TypeScript Agent SDK v0.3.236 or later. [Annotate a result for the auto mode classifier](</docs/en/hooks#annotate-a-result-for-the-auto-mode-classifier>) covers the length cap, the synchronous-only rule, and what not to put in the note.
--- a/hooks-guide.md
+++ b/hooks-guide.md
@@ -57,7 +57,7 @@
Verify the configuration
-Type `/hooks` to open the hooks browser. You’ll see a list of all available hook events, with a count next to each event that has hooks configured. Select `Notification` to confirm your new hook appears in the list. Selecting the hook shows its details: the event, matcher, type, source file, and command.
+Type `/hooks` at the Claude Code prompt to open the hooks browser. Your new hook appears in the list under `Notification`.
3
@@ -65,8 +65,6 @@
Press `Esc` to return to the CLI. Press `Shift+Tab` until the status bar shows `⏸ manual mode on`, ask Claude to do something that requires permission, then switch away from the terminal. You should receive a desktop notification.
-The `/hooks` menu is read-only. To add, modify, or remove hooks, edit your settings JSON directly or ask Claude to make the change.
-
##
@@ -107,7 +105,7 @@
If no notification appears
-`osascript` routes notifications through the built-in Script Editor app. If Script Editor doesn’t have notification permission, the command fails silently, and macOS won’t prompt you to grant it. Run this in Terminal once to make Script Editor appear in your notification settings:
+`osascript` routes notifications through the built-in Script Editor app. If Script Editor doesn’t have notification permission, the command fails silently, and macOS won’t prompt you to grant it.Run this in Terminal once to make Script Editor appear in your notification settings:
osascript -e 'display notification "test"'
@@ -155,7 +153,7 @@
If no dialog appears
-This command opens a dialog box rather than a notification in the corner of your screen, so the dialog can open behind your terminal window. Test the command directly in PowerShell first. If you run Claude Code inside WSL, `powershell.exe` must be available on your `PATH` through Windows interop.
+This command opens a dialog box rather than a notification in the corner of your screen, so the dialog can open behind your terminal window. Test the command directly in PowerShell first.If you run Claude Code inside WSL, `powershell.exe` must be available on your `PATH` through Windows interop.
The empty `matcher` fires on all notification types. To fire only on specific events, set it to one of these values:
@@ -174,7 +172,7 @@
`quota_auto_resume_stale`| A claude.ai usage limit reset while your computer slept for more than about 30 minutes. Claude Code waits for you to press `Enter` instead of continuing. After a shorter sleep it continues and fires `quota_auto_resume_fired` instead
`quota_auto_resume_disabled`| Claude Code ends its wait for a claude.ai usage limit without continuing your task: [`autoContinueAtUsageLimit`](</docs/en/settings-reference#autocontinueatusagelimit>) turned off or the reset moved more than 24 hours away during a wait Claude Code started on its own, the continued task kept hitting the limit, or the continuation was blocked before it reached the model. Doesn’t fire when you press `Esc` or `Ctrl+C`, or pick **Don’t continue automatically**
-Claude Code times `permission_prompt` differently in a terminal and in Claude Desktop, the VS Code extension, and other hosts that answer permission requests through the Agent SDK. See [when each notification type fires](</docs/en/hooks#notification>) for both timings. The `agent_needs_input` and `agent_completed` matchers require Claude Code v2.1.198 or later. The `quota_auto_resume_fired`, `quota_auto_resume_stale`, and `quota_auto_resume_disabled` matchers require Claude Code v2.1.234 or later. In terminal sessions, `permission_prompt` for a sandboxed command’s network request requires Claude Code v2.1.246 or later. `agent_needs_input` for a teammate’s terminal setup question requires Claude Code v2.1.248 or later. Type `/hooks` and select `Notification` to confirm the hook is registered. For the full event schema, see the [Notification reference](</docs/en/hooks#notification>).
+Claude Code times `permission_prompt` differently in a terminal and in Claude Desktop, the VS Code extension, and other hosts that answer permission requests through the Agent SDK. See [when each notification type fires](</docs/en/hooks#notification>) for both timings. The `quota_auto_resume_fired`, `quota_auto_resume_stale`, and `quota_auto_resume_disabled` matchers require Claude Code v2.1.234 or later. In terminal sessions, `permission_prompt` for a sandboxed command’s network request requires Claude Code v2.1.246 or later. `agent_needs_input` for a teammate’s terminal setup question requires Claude Code v2.1.248 or later. Type `/hooks` at the Claude Code prompt and confirm the hook appears under `Notification`.
###
@@ -896,7 +894,7 @@
Hooks and permission modes
-`PreToolUse` hooks fire before any permission-mode check, in every [permission mode](</docs/en/permission-modes>), including `dontAsk`. A hook that returns `permissionDecision: "deny"` blocks the tool even in `bypassPermissions` mode or with `--dangerously-skip-permissions`. This lets you enforce policy that users can’t bypass by changing their permission mode. The reverse is not true: a hook returning `"allow"` doesn’t bypass deny rules from settings, and it can’t suppress the prompt for MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) or for connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) in sessions where that setting reaches Claude Code. Hooks can tighten restrictions but not loosen them past what permission rules allow.
+`PreToolUse` hooks fire before any permission-mode check, in every [permission mode](</docs/en/permission-modes>), including `dontAsk`. A hook that returns `permissionDecision: "deny"` blocks the tool even in `bypassPermissions` mode or with `--dangerously-skip-permissions`. This lets you enforce policy that users can’t bypass by changing their permission mode. The reverse is not true: a hook returning `"allow"` doesn’t bypass deny rules from settings, and it can’t suppress the prompt for MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) or for connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) in sessions where that setting reaches Claude Code. Hooks in settings files and in a plugin’s `hooks/hooks.json` can tighten restrictions but not loosen them past what permission rules allow. A [mod](</docs/en/plugins/mods/overview>) you install that handles `tool.check` can approve a call that your `PreToolUse` hook blocked, unless the hook is in managed settings. [Extend permissions with hooks](</docs/en/permissions#extend-permissions-with-hooks>) lists which rules hold over a mod.
###
@@ -939,6 +937,7 @@
* File edits are normally picked up automatically. If they haven’t appeared after a few seconds, the file watcher may have missed the change: restart your session to force a reload.
* Verify your JSON is valid: trailing commas and comments aren’t allowed
* Confirm the settings file is in the correct location: `.claude/settings.json` for project hooks, `~/.claude/settings.json` for global hooks
+ * If the menu shows `Only hooks from managed settings run here`, your organization has set [`allowManagedHooksOnly`](</docs/en/settings-reference#allowmanagedhooksonly>). Hooks in your user, project, and local settings files don’t run and aren’t listed
###
--- a/install.md
+++ b/install.md
@@ -33,7 +33,7 @@
/plugin install commit-commands@claude-plugins-official
-To browse instead, run `/plugin` with no plugin name: the panel opens on the **Discover** tab, which lists plugins from every marketplace you’ve added, and you can type to search, then press **Enter** on a plugin to open its details.
+To browse instead, run `/plugin` with no plugin name: the panel opens on the **Discover** tab, which lists the plugins from your marketplaces, and you can type to search, then press **Enter** on a plugin to open its details.
2
@@ -369,9 +369,9 @@
-Update one plugin now
-
-In a session, open the plugin on the **Installed** tab in `/plugin` and select **Update now** , or in your shell run `claude plugin update <plugin>@<marketplace>`.
+Update plugins now
+
+To update one plugin, open it on the **Installed** tab in `/plugin` during a session and select **Update now** , or run `claude plugin update <plugin>@<marketplace>` in your shell. There’s no command that updates every plugin at once. To update the plugins you installed from one marketplace at once, go to the **Marketplaces** tab in `/plugin`, select the marketplace, and choose **Update marketplace**. That refreshes the marketplace’s listing, updates the plugins you installed from it, and reports any plugin it left for you to update yourself. A plugin with a [`command` source](</docs/en/plugins/marketplace-reference#command-plugin-source>) or with a marketplace entry that sets a `headersHelper` command isn’t updated this way, so you update it from its view on the **Installed** tab or with `claude plugin update <plugin>@<marketplace>`. If you run `claude plugin marketplace update` in your shell with no name, it refreshes every marketplace’s listing but leaves your installed plugins at their current versions.
###
Show diff (147 lines)
--- a/interactive-mode.md
+++ b/interactive-mode.md
@@ -392,7 +392,7 @@
* Exit with `Escape`, `Backspace`, or `Ctrl+U` on an empty prompt
* Pasting text that starts with `!` into an empty prompt enters shell mode automatically, matching typed `!` behavior
-Unless your session is one of those listed under [strict sandbox mode](</docs/en/sandboxing#the-unsandboxed-retry-escape-hatch>), commands you type in shell mode run outside the [sandbox](</docs/en/sandboxing>) even when you’ve enabled sandboxing, because the sandbox applies to the commands Claude runs. Claude responds to the command output automatically once it lands in the transcript, so you can run `! npm test` and get an explanation of the failures without a second prompt. The response costs the same as sending a normal prompt. To restore the earlier behavior where the output is added to context without a response, set [`respondToBashCommands`](</docs/en/settings-reference#respondtobashcommands>) to `false` in `settings.json`. Before v2.1.186, shell mode always added output to context without a response.
+Unless your session is one of those listed under [strict sandbox mode](</docs/en/sandboxing#turn-off-the-retry-with-strict-sandbox-mode>), commands you type in shell mode run outside the [sandbox](</docs/en/sandboxing>) even when you’ve enabled sandboxing, because the sandbox applies to the commands Claude runs. Claude responds to the command output automatically once it lands in the transcript, so you can run `! npm test` and get an explanation of the failures without a second prompt. The response costs the same as sending a normal prompt. To restore the earlier behavior where the output is added to context without a response, set [`respondToBashCommands`](</docs/en/settings-reference#respondtobashcommands>) to `false` in `settings.json`. Before v2.1.186, shell mode always added output to context without a response.
##
@@ -400,7 +400,7 @@
Queue messages while Claude works
-Type a message and press `Enter` while Claude is working. Claude Code queues the message instead of interrupting the turn, and lists the queued entries in the conversation until it sends them. You can queue `!` shell commands and most [commands](</docs/en/commands>) the same way, apart from the commands, such as `/status`, that Claude Code runs as soon as you send them. Sent and queued messages show in gray until Claude starts responding to them, so you can tell which messages Claude hasn’t started on yet. If you queue a message with a selection attached from a [connected IDE](</docs/en/vs-code#the-built-in-ide-mcp-server>) or the diff panel, it keeps the selection you had when you pressed `Enter`, whatever you select afterward.
+Type a message and press `Enter` while Claude is working. Claude Code queues the message instead of interrupting the turn, and lists the queued entries in the conversation until it sends them. You can queue `!` shell commands and most [commands](</docs/en/commands>) the same way, apart from the commands, such as `/status`, that Claude Code runs as soon as you send them. Sent and queued messages show in gray until Claude starts responding to them, so you can tell which messages Claude hasn’t started on yet. If you queue a message with a selection attached from a [connected IDE](</docs/en/vs-code#the-built-in-ide-mcp-server>), it keeps the selection you had when you pressed `Enter`, whatever you select afterward.
###
@@ -596,7 +596,7 @@
Invisible characters in prompts
-Pasted text can carry Unicode characters that a terminal draws as nothing at all, such as tag characters, bidirectional controls, and zero-width spaces, so a prompt can contain text you never see. To keep copied text from carrying instructions your terminal doesn’t draw, Claude Code removes those characters when you press Enter, before sending anything. It cleans both the prompt and the contents of any collapsed [pasted-text reference](</docs/en/terminal-config#paste-large-content>) the prompt includes. Claude Code keeps the joiners that Persian and Indic scripts write and the selectors inside emoji sequences. If Claude Code removed anything, that Enter sends nothing. The cleaned prompt goes back into the input box with a notice such as `Removed 3 invisible characters · review and press Enter to send`, and pressing Enter again sends the text as shown. When you pass a prompt on the command line, as in `claude "fix the login bug"`, or pipe one into an interactive session, Claude Code doesn’t wait for a second Enter. It removes the characters, shows a notice, and sends the cleaned prompt. If the cleaned prompt would begin with `/`, Claude Code puts it in the input box for you to review and send instead.
+Pasted text can carry Unicode characters that a terminal draws as nothing at all, such as tag characters, bidirectional controls, and zero-width spaces, so a prompt can contain text you never see. To keep copied text from carrying instructions your terminal doesn’t draw, Claude Code removes those characters when you press Enter, before sending anything. It cleans both the prompt and the contents of any collapsed [pasted-text reference](</docs/en/terminal-config#paste-large-content>) the prompt includes. Claude Code keeps the joiners that Persian and Indic scripts write and the selectors inside emoji sequences. If Claude Code removed anything, that Enter sends nothing. The cleaned prompt goes back into the input box with a notice such as `Removed 3 invisible characters · review and press Enter to send`, and pressing Enter again sends the text as shown. When you pass a prompt on the command line, as in `claude "fix the login bug"`, Claude Code doesn’t wait for a second Enter. It removes the characters, shows a notice, and sends the cleaned prompt. If the cleaned prompt would begin with `/`, Claude Code puts it in the input box for you to review and send instead.
##
@@ -604,7 +604,12 @@
Review changes with /diff
-Run `/diff` to look over the changes in your working tree without leaving Claude Code. You see the edits Claude has made so far alongside anything else you haven’t committed. In the changes `/diff` reads from git, a submodule appears as a single entry, and only when the commit it points to changes; edits to files inside the submodule don’t appear there. In [fullscreen rendering](</docs/en/fullscreen>), `/diff` opens the diff panel beside the conversation, which stays open and updates while you keep working. In the classic renderer, `/diff` opens the diff viewer in place of the prompt, and you close it when you’re done reading.
+Run `/diff` to look over the changes in your working tree without leaving Claude Code. You see the edits Claude has made so far alongside anything else you haven’t committed. What `/diff` opens depends on which renderer is active:
+
+ * **[Fullscreen rendering](</docs/en/fullscreen>)** : the diff panel opens beside the conversation. It stays open and updates while you keep working.
+ * **Classic renderer** : the diff dialog opens above the prompt, and you close it when you’re done reading.
+
+The panel and the dialog both come from `cc-plugin-diff`, one of the [mods built into Claude Code](</docs/en/plugins/mods/overview#mods-built-into-claude-code>). If you disable that mod in `/plugin`, `/diff` opens Claude Code’s earlier panel and [diff viewer](</docs/en/keybindings#diff-actions>) instead. In the changes `/diff` reads from git, a submodule appears as a single entry, and only when the commit it points to changes; edits to files inside the submodule don’t appear there. The panel and the dialog also offer a view of each turn’s edits once Claude has edited files. These turn views come from Claude’s file edits rather than from git, so a change Claude makes through a shell command appears only under `Current`, the working-tree view.
###
@@ -612,37 +617,35 @@
Diff panel
-The diff panel lists the changed files with their added and removed line counts, and shows each file’s diff under the list. Claude Code refreshes it each time Claude edits a file or runs a shell command. To close it, run `/diff` again or click the `✕` in its header. To use the panel you need:
+The diff panel lists the changed files with their added and removed line counts, and shows each file’s diff under the list. Claude Code refreshes it each time Claude edits a file or runs a shell command. To close the panel, run `/diff` again or click the `✕` in its header. To use the panel you need:
* [Fullscreen rendering](</docs/en/fullscreen>)
* A git repository
* A terminal at least 110 columns wide
- * Claude Code v2.1.260 or later
-
-When the panel can’t open, `/diff` opens the diff viewer instead or tells you why. The panel also opens on its own once Claude starts editing files, if your terminal is at least 144 columns wide. After you’ve opened it yourself with `/diff`, later sessions open it as soon as Claude edits a file in any terminal wide enough to fit it. Close the panel and it stays closed, in this session and later ones, until you run `/diff` again. While the panel is open, you can:
+ * Claude Code v2.1.287 or later
+
+The panel also opens on its own once Claude starts editing files, if your terminal is at least 144 columns wide. After you’ve opened it yourself with `/diff`, later sessions open it as soon as Claude edits a file in any terminal wide enough to fit it. Close the panel and it stays closed, in this session and later ones, until you run `/diff` again. While the panel is open, you can:
* **Jump to a file** : click its row in the list. Scroll the panel with the mouse wheel. When the file list itself is too long to fit, scroll it with `Alt+Up` and `Alt+Down`, or `Ctrl+Up` and `Ctrl+Down`.
- * **Ask Claude about specific lines** : select them in the panel with the mouse. Claude Code attaches the selection to your next prompt and shows a line count in the input until you send it.
- * To send the prompt without the selection, move the cursor to just after the line-count indicator and press `Backspace` to delete it. Requires Claude Code v2.1.271 or later.
+ * **Ask Claude about a file’s changes** : click `ask`, at the right of the file’s name above its diff. Claude Code attaches that file’s diff to your next prompt, and the button reads `asked ✓` until you send that prompt. Asking on a second file replaces the first.
+ * **Show one turn’s edits** : click the `source` picker in the panel’s header, then choose a turn with `Up` and `Down` and press `Enter`. Turns are labeled `T1`, `T2`, and so on. The picker appears once Claude has edited files, and `Current` returns you to the working tree.
* **Show the files the panel leaves out** : the list skips test files and generated files, and collapses changes from before this session into one line at the bottom. Click either count line to expand it.
- * **Change what the panel compares against** : press `Ctrl+X B` to cycle from this session’s changes, to your uncommitted changes as one list, to everything since your branch split from the default branch. Claude Code remembers the choice for each project.
-
-To bind keys to these actions, see [Diff panel actions](</docs/en/keybindings#diff-panel-actions>).
-
-###
-
-
-
-Diff viewer
-
-The diff viewer takes the place of the prompt until you close it. Its **Current** view shows your uncommitted changes from git, or, when there are none, what your branch adds on top of the default branch. The viewer also has a turn view for each prompt after which Claude edited files, showing just those edits. Claude Code builds the turn views from Claude’s file edits rather than from git, so a change Claude makes through a shell command appears only under Current. Use these keys in the viewer:
-
- * **Left and Right** : move between Current and the turn views.
+ * **Change what the panel compares against** : press `Ctrl+X B` to cycle from this session’s changes, to your uncommitted changes as one list, to everything since your branch split from the default branch. Claude Code remembers the choice for each repository.
+
+To rebind the keys that scroll the file list or change the comparison, see [Diff panel actions](</docs/en/keybindings#diff-panel-actions>).
+
+###
+
+
+
+Diff dialog
+
+The diff dialog opens as a bordered block above the prompt and lists your changed files with their added and removed line counts. It compares them against `HEAD`, or against whatever you last chose in the diff panel for this repository. Once Claude has edited files, a `source` picker appears above the list. It offers one turn view, labeled `T1`, `T2`, and so on, for each of your prompts that led Claude to edit files. A turn view shows only that turn’s edits, and `Current` returns you to the working tree. Use these keys in the dialog:
+
* **Up and Down** : select a file.
* **Enter** : open the selected file’s diff. Scroll it with Up and Down, or PageUp and PageDown.
- * **Esc** : return from a file’s diff to the list, or close the viewer from the list.
-
-To rebind these keys, see [Diff actions](</docs/en/keybindings#diff-actions>).
+ * **Esc** : return from a file’s diff to the list, or close the dialog from the list.
+ * **Tab** : move to the `source` picker, then choose `Current` or a turn view with Up and Down and press Enter. In a file’s diff, Tab moves to the `ask` button. Press Enter to attach that file’s diff to your next prompt.
##
@@ -694,7 +697,7 @@
Session recap
-When you return to the terminal after stepping away, Claude Code shows a one-line recap of what happened in the session so far. The recap generates in the background once at least three minutes have passed since the last completed turn and the terminal is unfocused, so it’s ready when you switch back. Recaps only appear once the session has at least three turns, and never twice in a row. Run `/recap` to generate a summary on demand. Claude Code caps both automatic recaps and `/recap` output at 400 characters. To turn automatic recaps off, open `/config` and turn off **Session recap**. Session recap is on by default for every plan and provider. The recap is always skipped in non-interactive mode.
+When you return to the terminal after stepping away, Claude Code shows a one-line recap of what happened in the session so far. The recap generates in the background once at least three minutes have passed since the last completed turn and the terminal is unfocused, so it’s ready when you switch back. Recaps only appear once the session has at least three turns, and never twice in a row. Run `/recap` to generate a summary on demand. It runs only when you ask for it yourself. When it arrives in a message relayed from a Slack, Teams, or project thread, or in a prompt a routine sent, you get a [notice](</docs/en/errors#recap-only-runs-when-you-ask-for-it-yourself>) instead of a recap. Session recap is on by default for every plan and provider. To turn automatic recaps off, open `/config` and turn off **Session recap**. The automatic recap never appears in non-interactive mode. Claude Code caps both automatic recaps and `/recap` output at 400 characters.
##
@@ -702,14 +705,15 @@
Wait for a usage limit to reset
-When a claude.ai [usage limit](</docs/en/errors#youve-hit-your-session-limit>) stops Claude mid-task, Claude Code waits in the open session and continues the task on its own after the limit resets. Automatic continue is on by default in interactive sessions signed in with a claude.ai subscription. Requires Claude Code v2.1.234 or later. While Claude Code waits, a line at the bottom of the session shows when it will continue:
-
- Usage limit reached · continuing automatically at 3:45pm · esc to cancel
-
-Keep the session open. What happens next depends on how the wait ends:
-
- * **At the reset** : the line reads `continuing shortly`, then `Usage limit reset · continuing automatically`, and Claude Code sends Claude a fixed prompt to pick the task up where it stopped. It doesn’t resend your last message.
- * **After your computer slept** : if it slept for more than about 30 minutes and the limit reset while it slept, the line reads `Your usage limit has reset · press enter to continue`. Press `Enter` to continue. After a shorter sleep, Claude Code continues on its own.
+When a claude.ai [usage limit](</docs/en/errors#youve-hit-your-session-limit>) stops Claude mid-task, Claude Code waits in the open session and continues the task on its own after the limit resets. Automatic continue is on by default in interactive sessions signed in with a claude.ai subscription. Requires Claude Code v2.1.234 or later. While Claude Code waits, the lines at the bottom of the session show when your limit resets and when Claude will continue:
+
+ Usage limit reached · limit resets 3:45pm
+ Continuing automatically at 3:45pm · esc to cancel
+
+Either line can carry more after these words, such as a help link on the first or `/usage-credits to continue now` on the second. When the wait starts on its own, the conversation also records it with a line that reads `Usage limit reached · continuing automatically at 3:45pm · esc to cancel`. Keep the session open. What happens next depends on how the wait ends:
+
+ * **At the reset** : the second line changes to `Continuing shortly · esc to cancel`. Then `Usage limit reset · continuing automatically` appears in the conversation, and Claude Code prompts Claude to pick the task up where it stopped. It doesn’t resend your last message.
+ * **After your computer slept** : if it slept for more than about 30 minutes and the limit reset while it slept, the first line reads `Your usage limit has reset` and the second reads `Press enter to continue`. Press `Enter` to continue. After a shorter sleep, or one that ended before the reset, Claude Code continues on its own.
* **Early** : when you finish adding [usage credits](</docs/en/costs#add-usage-credits-to-your-subscription>) with `/usage-credits`, sign back in after `/upgrade`, or switch models with `/model` during the wait, Claude Code checks whether usage is available again and continues right away if it is. It doesn’t check after an upgrade or purchase you make in a browser on your own. Under [`opusplan`](</docs/en/model-config#opusplan-model-setting>) and other model settings that run plan mode on a different model, Claude Code waits for the reset instead.
The continued task runs like any other turn. Claude Code still asks for [permissions](</docs/en/permissions>) as usual, so the task can stop on a prompt while you’re away. If it hits the limit again, Claude Code re-arms the wait on its own at most twice in a row, then stops and shows `Automatic continue stopped after repeated usage-limit hits · /rate-limit-options to try again`.
@@ -720,9 +724,9 @@
Cancel the wait
-Press `Esc` at an empty prompt, or `Ctrl+C`, while the line shows, or run [`/rate-limit-options`](</docs/en/commands#all-commands>) and pick **Don’t continue automatically**. Claude Code confirms with a line that starts `Automatic continue cancelled`. After a cancel, nothing continues until you send a prompt or pick the row that starts **Wait here, then continue automatically** from `/rate-limit-options` again. Claude Code doesn’t start a wait on its own again for that reset window; the next reset window starts fresh. The wait also ends without continuing the task in these cases:
-
- * **You send a prompt** : Claude Code runs your prompt instead of waiting.
+Press `Esc` at an empty prompt, or `Ctrl+C`, while the lines show, or run [`/rate-limit-options`](</docs/en/commands#all-commands>) and pick **Don’t continue automatically**. Claude Code confirms with a line that starts `Automatic continue cancelled`. After a cancel, nothing continues until you send a prompt or pick the row that starts **Wait here, then continue automatically** from `/rate-limit-options` again. Claude Code doesn’t start a wait on its own again for that reset window; the next reset window starts fresh. The wait also ends without continuing the task in these cases:
+
+ * **You send a prompt** : Claude Code sends your prompt instead of waiting. If your prompt hits the limit too, it stays in the conversation and Claude Code starts the wait again.
* **You exit Claude Code** : the wait doesn’t restart when you resume the session.
* **The conversation changes hands** : you switch accounts with `/login`, clear or rewind the conversation, `/resume` another session, pull one with `/teleport`, relaunch with `/tui`, or hand the session to Claude Desktop, a background session, or the cloud.
* **The setting turns off, or the reset moves past 24 hours** : this ends only a wait Claude Code started on its own. A wait you picked from `/rate-limit-options` keeps counting down.
Show diff (803 lines)
--- a/interface.md
+++ b/interface.md
@@ -0,0 +1,800 @@
+A mod can draw its own interface in Claude Code and change parts of the interface Claude Code already draws. Each place a mod can draw is called a [render site](</docs/en/plugins/mods/reference#render-sites>), such as a pane, the band above the prompt, or the spinner. Claude Code fires the [`ui.render`](</docs/en/plugins/mods/reference#interface>) event each time it’s about to draw a render site, and your hook for that event returns what to draw there. This map shows where a mod can draw in a terminal session: In a narrower terminal, the pane sits above the prompt instead of beside the transcript. Build your [first mod](</docs/en/plugins/mods/create>) before you start here. Begin with the worked example, which builds a pane with two tabs and a counter, then read the section for each piece you want to change.
+
+To look up one prop or limit, see the [reference](</docs/en/plugins/mods/reference#render-sites>).
+
+##
+
+
+
+Build a pane with tabs
+
+In this section you build a mod that adds a `/hello-tabs` command, and the command opens a pane. A pane is a sidebar beside the transcript in a wide fullscreen terminal, or a framed region above the prompt otherwise. This pane shows two tabs, and the second tab has a button that adds one to a counter. The count is still there after you restart Claude Code. The finished mod looks like this. The recording opens the pane, switches to the second tab, presses the button a few times, and returns to the first tab:
+
+The tabs are two buttons in a row. The mod keeps track of which one is active and draws that tab’s content under the row.
+
+1
+
+Create the plugin
+
+A mod is a plugin with a manifest, a `hooks.json` that points to your code, and the code file. [Create a mod](</docs/en/plugins/mods/create#write-a-mod-yourself>) explains each one. Create a directory named `hello-tabs` with `.claude-plugin` and `hooks` directories inside it, then save the first two files.Save the manifest as `hello-tabs/.claude-plugin/plugin.json`:
+
+hello-tabs/.claude-plugin/plugin.json
+
+ {
+ "name": "hello-tabs",
+ "version": "0.1.0",
+ "description": "Opens a pane with two tabs and a counter",
+ "author": { "name": "Your Name" }
+ }
+
+Name your entry point in `hello-tabs/hooks/hooks.json`:
+
+hello-tabs/hooks/hooks.json
+
+ {
+ "modules": ["./register.js"]
+ }
+
+2
+
+Write the code
+
+This list says what each hook does, in the order they appear in the code:
+
+ * Adds the `/hello-tabs` command, and loads the count an earlier session saved
+ * Opens the pane when you run that command
+ * Draws the pane’s content: the row of tabs and the open tab’s body
+
+Two module-level variables, `tab` and `count`, hold the pane’s state.Save this as `hello-tabs/hooks/register.js`:
+
+hello-tabs/hooks/register.js
+
+ // The pane's id, used to open the pane and to recognize it when drawing
+ const PANE = 'hello-tabs'
+
+ // What the pane shows: which tab is open, and the counter's value
+ let tab = 'one'
+ let count = 0
+
+ export function register(on) {
+ // Runs before your first prompt, and again after a reload
+ on('session.start', async ($, e, next) => {
+ await $.command.register({ name: 'hello-tabs', description: 'Open the hello-tabs pane' })
+ // Load the count an earlier session saved, if there is one
+ const saved = await $.store.get('count')
+ if (typeof saved === 'number') count = saved
+ return next(e)
+ })
+
+ // Runs when you type /hello-tabs
+ on('command.run', { command: 'hello-tabs' }, async ($) => {
+ // Open the pane, give it the keyboard, and let Esc close it
+ await $.ui.open({ id: PANE, title: 'Hello tabs', focus: true, closeOnEscape: true })
+ // Print nothing in the transcript
+ return {}
+ })
+
+ // Runs each time Claude Code draws a pane
+ on('ui.render', { component: 'Pane' }, async ($, e, next) => {
+ // Leave other mods' panes alone
+ if (e.requestId !== PANE) return next(e)
+ // Get the elements this app can draw
+ const { Box, Text, Button } = $.ui.resolve(e)
+ // Ask Claude Code to run this hook again
+ const redraw = () => $.ui.invalidate('ui.render')
+
+ // One tab: a button that switches to its tab when pressed
+ const tabButton = (name, label, hotkey) =>
+ Button({
+ key: 'tab-' + name,
+ label,
+ hotkey,
+ plain: true,
+ // Dim the tab that isn't open
+ dimColor: tab !== name,
+ onPress: () => {
+ tab = name
+ redraw()
+ },
+ })
+
+ // What goes under the tabs, depending on which one is open
+ const body =
+ tab === 'one'
+ ? [Text({ children: ['This is the first tab.'] })]
+ : [
+ Box({
+ flexDirection: 'row',
+ columnGap: 2,
+ children: [
+ Button({
+ key: 'more',
+ label: 'Add one',
+ hotkey: 'a',
+ onPress: async () => {
+ count += 1
+ redraw()
+ // Save the count so it's there after a restart
+ await $.store.set('count', count)
+ },
+ }),
+ Text({ children: ['Count: ' + count] }),
+ ],
+ }),
+ ]
+
+ // The whole pane: the row of tabs, a blank line, then the body
+ return Box({
+ flexDirection: 'column',
+ children: [
+ Box({
+ flexDirection: 'row',
+ columnGap: 3,
+ children: [tabButton('one', 'One', '1'), tabButton('two', 'Two', '2')],
+ }),
+ Text({ children: [' '] }),
+ ...body,
+ ],
+ })
+ })
+ }
+
+Each hook also does something the code doesn’t make plain:
+
+ * **[`session.start`](</docs/en/plugins/mods/reference#session>)** also reads the saved count from `$.store`, a key-value store that persists between sessions.
+ * **[`command.run`](</docs/en/plugins/mods/api#add-a-command>)** only tells Claude Code the pane exists. Opening a pane draws nothing by itself: Claude Code then fires `ui.render` to ask what goes in it.
+ * **`ui.render`** returns the element tree, a `Box` that holds other boxes, text, and buttons, and builds it again from `tab` and `count` each time it runs.
+
+Pressing a button runs its `onPress` callback, which changes a variable and calls `redraw`. Claude Code then runs the `ui.render` hook again, and the hook builds a new tree from the new values. Every interactive drawing uses that render cycle: a callback changes state, and the hook renders again from the new state.
+
+3
+
+Open the pane
+
+In your shell, start Claude Code with `claude --plugin-dir ./hello-tabs`. At the Claude Code prompt, run `/hello-tabs`. A pane opens with `1: One` and `2: Two` across the top. Press `2`, then press `a`, the hotkey for **Add one** , a few times. The count rises.
+
+4
+
+Check that the count was saved
+
+Press Esc to close the pane, then exit the session. In your shell, start Claude Code again with the same `claude --plugin-dir ./hello-tabs` command, and at the Claude Code prompt run `/hello-tabs`. The count is where you left it.To clear the count, have the mod call `$.store.delete('count')`. Keep state covers how long each kind of value lasts.
+
+##
+
+
+
+Pick where to draw
+
+A `ui.render` hook runs for every render site unless you narrow it to the one you want to draw in. To choose the render site, pass a filter, called a [matcher](</docs/en/plugins/mods/events#filter-which-events-a-hook-handles>), as the second argument to `on`. `{ component: 'Pane' }` runs the hook only for panes. In the hook, `e.component` names the site, `e.surface` says which app is drawing, and `e.props` holds the site’s own data. For a pane, `e.requestId` is the `id` you opened it with. The pane and the band are empty until a mod fills them. Select a tab to see what each one is and how to draw in it:
+
+ * Pane
+
+ * Band above the prompt
+
+A pane is a sidebar beside the transcript in a wide fullscreen terminal, or a framed region above the prompt otherwise. With several panes open, each gets a tab that shows its title.A pane appears when your mod calls `$.ui.open` with an `id` you choose, as in `$.ui.open({ id: 'hello-tabs' })`. Open a pane at the right time covers the other fields and when a pane waits for a wider terminal.To draw in your pane, filter on `{ component: 'Pane' }` and check that `e.requestId` is your `id`.
+
+The band is a strip directly above the prompt input. It’s always there, and every mod shares it.Your hook returns a tree to show something in the band, or `next(e)` to show nothing. A tree replaces what the mods [after yours](</docs/en/plugins/mods/events#the-order-mods-run-in>) draw there. To keep theirs, put the result of `await next(e)` among the children of a `Box` in your tree.To draw in the band, filter on `{ component: 'AbovePrompt' }`.
+
+###
+
+
+
+Change what Claude Code already draws
+
+Claude Code draws most of its interface itself: messages, tool call rows, the spinner, and more. Each of those parts is a render site too, so a mod can restyle or replace it. To change one, filter your `ui.render` hook on its name from this table:
+
+Site| What it is
+---|---
+`UserMessage`, `AssistantMessage`| A message in the transcript
+`ToolUse`, `ToolResult`, `ToolGroup`| A tool call’s row, its result, and a collapsed group of calls
+`CommandOutput`| The row a command printed
+`AskUserQuestion`| The dialog Claude opens to ask you a question
+`Spinner`, `ToolProgress`, `TurnDuration`| Status lines for a turn: the line that animates while Claude works, a running tool’s live progress line, and the line that closes a turn
+`InfoNotice`, `SessionMode`, `PromptHint`| Status lines under the logo, the mode labels in the footer, and the hint line under the prompt
+
+At a site Claude Code already draws, your hook can change a detail, replace the drawing, or leave it alone. Select a tab to see each one applied to the spinner. The examples read a `calls` variable that another hook counts, as in the [tutorial mod](</docs/en/plugins/mods/create#write-a-mod-yourself>).
+
+ * Change a detail
+
+ * Replace the drawing
+
+ * Leave it alone
+
+To keep Claude Code’s drawing and change one part of it, pass `next` a copy of the event with changed `props`. This hook changes the text after the spinner’s word:
+
+ on('ui.render', { component: 'Spinner' }, async ($, e, next) => {
+ // Keep Claude Code's spinner, and change the text after its word
+ return next({ ...e, props: { ...e.props, suffix: ' · tool calls: ' + calls + '…' } })
+ })
+
+The spinner keeps its animation and its word, and your text follows the word:
+
+ Thinking · tool calls: 2…
+
+To draw something of your own in the site’s place, return a tree and don’t call `next`. This hook draws one line of text where the spinner would be:
+
+ on('ui.render', { component: 'Spinner' }, async ($, e) => {
+ const { Text } = $.ui.resolve(e)
+ // No call to next, so this line is drawn in the spinner's place
+ return Text({ children: ['Claude has made ' + calls + ' tool calls'] })
+ })
+
+While Claude works, your line shows and Claude Code’s spinner doesn’t:
+
+ Claude has made 2 tool calls
+
+To leave the site as Claude Code draws it, return `next(e)`. A hook often does that for some events and not others. This hook leaves the spinner alone until there’s a call to count:
+
+ on('ui.render', { component: 'Spinner' }, async ($, e, next) => {
+ // Nothing to show yet, so pass the event on unchanged
+ if (calls === 0) return next(e)
+ return next({ ...e, props: { ...e.props, suffix: ' · tool calls: ' + calls + '…' } })
+ })
+
+Before the first tool call, the spinner looks the way it does without the mod:
+
+ Thinking…
+
+At these sites, `next(e)` returns a reference to Claude Code’s drawing, `{ type: 'engine', ref }`, unless a mod that runs after yours returned a tree of its own. To change what’s in that drawing, pass `next` a copy of the event with different props, as the **Change a detail** tab does. You can return the reference as it is, or place it in a `Box` beside elements of your own:
+
+ on('ui.render', { component: 'Spinner' }, async ($, e, next) => {
+ const { Box, Text } = $.ui.resolve(e)
+ const theirs = await next(e)
+ return Box({ flexDirection: 'column', children: [theirs, Text({ children: ['under the spinner'] })] })
+ })
+
+While Claude works, the spinner animates as before, and `under the spinner` appears below it. The 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. A tree for the dialog has to hold the reference exactly once, with your elements above it. Otherwise, Claude Code draws its own dialog. The terminal and the Desktop app don’t raise all the same sites. `Pane`, `AbovePrompt`, `Spinner`, and the transcript sites work in both. A few other status lines are raised in the terminal only. The [render sites table](</docs/en/plugins/mods/reference#render-sites>) lists where each one is raised.
+
+###
+
+
+
+Open a pane at the right time
+
+A pane appears only when your mod opens it. How and when you open it decides whether it takes keyboard focus, how much room it asks for, and whether it shows at all in a narrow terminal. To open a pane, call [`$.ui.open`](</docs/en/plugins/mods/reference#mods-api-methods>) with an `id` you choose. The `id` is the pane’s name: your `ui.render` hook checks for it, and you pass it again to close the pane.
+
+ await $.ui.open({ id: 'hello-tabs', title: 'Hello tabs', focus: true })
+
+To close the pane, call `$.ui.close` with the `id` you opened it with:
+
+ await $.ui.close({ id: 'hello-tabs' })
+
+Besides `id`, `$.ui.open` takes these optional fields:
+
+Field| What it does
+---|---
+`title`| The pane’s tab label when more than one pane is open
+`focus`| Requests keyboard focus
+`closeOnEscape`| Makes Esc close the pane
+`holdToasts`| Holds toasts, the small notices from [`$.ui.toast`](</docs/en/plugins/mods/api#show-something-without-starting-a-turn>), until the pane closes
+`rows`| The height to ask for when the pane sits above the prompt. The default is a third of the space.
+`columns`| The width to ask for when the pane sits beside the transcript
+
+`focus`, `closeOnEscape`, and `holdToasts` are optional and accept only `true`. To leave one off, omit it. Passing `false` throws an error such as `ui.open: focus is true or left out`. To set one of them conditionally, add the field only when the condition holds. This call asks for keyboard focus only when `items` isn’t empty:
+
+ const pane = { id: 'hello-tabs', title: 'Hello tabs' }
+ await $.ui.open(items.length > 0 ? { ...pane, focus: true } : pane)
+
+To let a command open the pane while Claude is working, add `immediate: true` when you [register the command](</docs/en/plugins/mods/api#add-a-command>). Without it, a command typed during a turn waits for the turn to end.
+
+####
+
+
+
+When a pane waits for a wider terminal
+
+A pane your mod opens without being asked doesn’t appear in a narrow terminal, so it can’t take over a small screen. Whether it appears depends on what opened it:
+
+ * **Opened by something the user did** , such as a command they ran or a button they pressed, the pane appears at any width
+ * **Opened by your mod acting by itself** , such as from a timer or a [`turn.start`](</docs/en/plugins/mods/events#follow-a-turn>) hook, the pane appears only in a terminal at least 144 columns wide. After the user has opened that pane once themselves, 110 columns is enough.
+
+When the pane appears, `$.ui.open` resolves to `{ isPlaced: true }`. When the pane is waiting, `isPlaced` is `false` and `reason` is a string that says why. A waiting pane appears when the user opens it or widens the terminal. To say something is available without opening a pane, call `$.ui.toast('Your message')`, which shows a toast notification.
+
+##
+
+
+
+Build a tree from elements
+
+What a `ui.render` hook returns is an element tree: a description of what to draw, made of boxes, text, and controls nested inside each other. You describe the drawing, and Claude Code renders it in the terminal or the Desktop app. To get the elements, call `$.ui.resolve(e)` in your hook, as in `const { Box, Text, Button } = $.ui.resolve(e)`. Each element is a function. You pass it props, and you put the elements and strings that go inside it in `children`. Select a tab to see each of the most common elements and how the terminal draws it:
+
+ * Text
+
+ * Box
+
+ * Button
+
+ * Input
+
+`Text` draws a string, with optional styling such as `bold` and `color`:
+
+ Text({ children: ['This is the first tab.'] })
+
+ This is the first tab.
+
+`Box` arranges what’s inside it, in a row or a column. This one puts a button and a line of text side by side, two columns apart:
+
+ Box({
+ flexDirection: 'row',
+ columnGap: 2,
+ children: [
+ Button({ key: 'more', label: 'Add one', onPress: addOne }),
+ Text({ children: ['Count: 0'] }),
+ ],
+ })
+
+ [ Add one ] Count: 0
+
+`Button` is a control the user can press. It runs your `onPress` callback. With `plain: true` it has no brackets and shows its hotkey:
+
+ Button({ key: 'more', label: 'Add one', onPress: addOne })
+ Button({ key: 'tab-one', label: 'One', hotkey: '1', plain: true, onPress: showTabOne })
+
+ [ Add one ]
+ 1: One
+
+`Input` is a text field. It runs your `onSubmit` callback with the text when the user presses Enter:
+
+ Input({
+ key: 'new-note',
+ label: 'Note',
+ placeholder: 'Type a note and press Enter',
+ value: '',
+ submitLabel: 'add',
+ onSubmit: addNote,
+ })
+
+ Note: Type a note and press Enter
+
+The [interface gallery](</docs/en/plugins/mods/gallery>) has samples and screenshots of most elements. This table lists every element:
+
+Element| What it draws| Where
+---|---|---
+`Box`| A flex container. Takes layout props such as `flexDirection`, `columnGap`, `padding`, `borderStyle`, and `width`.| Everywhere
+`Text`| Styled text. Takes `color`, `bold`, `dimColor`, `italic`, and `wrap`. A `color` is a theme key or a color such as `'red'`. A `wrap` is `'wrap'`, `'truncate'`, `'truncate-start'`, `'truncate-middle'`, or `'truncate-end'`.| Everywhere
+`Button`| A control that calls `onPress`| Everywhere
+`Link`, `Code`, `Markdown`| A link with `href` and an optional `label`, a code block, and text formatted the way Claude’s replies are. `Markdown` takes its content in a `text` prop, not in `children`, and needs a `key` when you pass `onLinkPress`.| Everywhere
+`Input`, `Select`| A text field and a dropdown| Terminal, Desktop
+`Svg`| An SVG document| Desktop
+`Client`| A region drawn by a second file of yours, for animation and pointer input. That file gets no mods API. It reaches your hooks only by posting data, which arrives as a `ui.message` event.| Terminal, Desktop
+`Raster`, `Image`| A grid of colored cells, and a picture| Terminal
+
+If your module is a `.tsx` or `.jsx` file, you can write the tree as JSX. Destructure the elements from `$.ui.resolve(e)` first. If a tree uses an element the app doesn’t have, a prop an element doesn’t take, or a child where none goes, Claude Code draws its own version of the site. In a session started with `--plugin-dir`, a transcript line says so, such as `ui.render (Pane) refused: Text prop "bogusProp" is not allowed; the engine drew its own`. The [debug log](</docs/en/plugins/mods/troubleshoot#read-the-debug-log>) records it as `ui.render (Pane): a hook returned a tree that does not validate` with the same reason. Nothing else appears in the session, so when a drawing doesn’t show up, check that line or the log.
+
+###
+
+
+
+Draw a grid of colored cells
+
+For a heat map, a sparkline, or a game board in the terminal, draw one `Raster` and not a `Box` for each cell. A `Raster` takes a `key`, its size in `columns` and `rows`, and `cells`, a base64 string that packs every cell. Each cell is three numbers: the character’s code point, its color, and its background color. A color is a 24-bit RGB value in hexadecimal, such as `0xc62828` for a red. The value `0x01000000`, one above that range, means the terminal’s default. The Desktop app has no `Raster`, so check `e.surface` and draw text there. This pane body draws a three by two heat map:
+
+ // The value that means "use the terminal's default color"
+ const DEFAULT_COLOR = 0x01000000
+
+ // Pack rows of [character, color] pairs into the one string a Raster takes
+ // One cell is three numbers: the character's code point, its color, and its background
+ function cellsOf(rows) {
+ const numbers = rows.flat().flatMap(([char, color]) => [char.codePointAt(0), color, DEFAULT_COLOR])
+ return new Uint8Array(Uint32Array.from(numbers).buffer).toBase64()
+ }
+
+ on('ui.render', { component: 'Pane' }, async ($, e, next) => {
+ // Draw only in the pane opened with the id 'heat'
+ if (e.requestId !== 'heat') return next(e)
+ const { Box, Text, Raster } = $.ui.resolve(e)
+ // Two rows of three cells, each a block character and its color
+ const rows = [
+ [['█', 0x2e7d32], ['█', 0xf9a825], ['█', 0xc62828]],
+ [['█', 0x2e7d32], ['█', 0x2e7d32], ['█', 0xf9a825]],
+ ]
+ if (e.surface !== 'terminal') {
+ return Text({ children: ['The heat map needs the terminal.'] })
+ }
+ return Box({
+ flexDirection: 'column',
+ children: [Raster({ key: 'grid', columns: 3, rows: 2, cells: cellsOf(rows) })],
+ })
+ })
+
+In the terminal, the pane shows the grid: The `rows` array is the part you’d change, and `cellsOf` turns it into the packed string. The hook draws only in a pane whose `id` is `heat`, so open one with `$.ui.open({ id: 'heat' })` from a command, as the `hello-tabs` example opens its pane. Each character has to be one cell wide. To animate a `Raster` that’s already on screen, call `$.ui.blit` with the pane’s `id` as `requestId`, the `Raster`’s `key`, the same size, and new cells. For this example, that’s `$.ui.blit({ requestId: 'heat', key: 'grid', columns: 3, rows: 2, cells: cellsOf(newRows) })`. It repaints that one element without running your `ui.render` hook again.
+
+##
+
+
+
+Respond to presses and typing
+
+When the user presses a button, types into a field, or picks from a list your mod drew, Claude Code calls that control’s callback, which runs in your module. Each control takes its own callbacks:
+
+ * **`Button`** : takes `onPress(e)`, where `e.surface` is the app the press came from
+ * **`Input`** : takes `onSubmit(value)` and `onInput(value)`
+ * **`Select`** : takes `onSelect(value)` with its choices in `options`, a list of at least one choice with unique values, such as `[{ value: 'sm', label: 'Small' }, { value: 'lg', label: 'Large' }]`
+
+A test presses or types into a control by its `key`, so give each control one. Each use of a control also fires [`ui.press`, `ui.input`, or `ui.select`](</docs/en/plugins/mods/reference#interface>) with the `key` in `e.element`, and another mod can handle those events. Its hook runs before your callback, so it sees what the user types into your `Input` and can change it or answer in place of your callback. The mods API has no method that presses another mod’s button.
+
+###
+
+
+
+Keyboard focus and hotkeys
+
+Your mod never reads the keyboard itself. The user presses a key, Claude Code decides which of your controls it’s for, and that control’s callback runs. Apart from a [digit hotkey on the band](</docs/en/plugins/mods/reference#elements>), that happens only while your pane or band has keyboard focus. The rest of the time, keys go to the prompt.
+
+####
+
+
+
+How a pane gets keyboard focus
+
+A pane gets keyboard focus when:
+
+ * Your mod opens it with `focus: true` from a command or a press
+ * The user presses Ctrl+X then Tab
+ * The user clicks it
+
+Claude Code grants `focus: true` only while the prompt is empty and nothing else has keyboard focus. A pane that opens while the user is typing doesn’t take their keystrokes.
+
+####
+
+
+
+What each key does
+
+This table lists what a key does while your pane or band has keyboard focus:
+
+Key| What it does
+---|---
+Tab| Moves to the next control
+Up and Down| Move between controls while your drawing fits. When the pane or band has more rows than it can show, they scroll it.
+Enter| Presses the focused `Button`, submits the focused `Input`, or picks in a `Select`
+A button’s hotkey| Presses that button. While an `Input` has the focus, every printable key goes to the field.
+Esc| Returns keyboard focus to the prompt. With `closeOnEscape: true`, it also closes the pane.
+
+A mod can’t bind Tab or the arrow keys to anything else, so a game steers with `w`, `a`, `s`, and `d`.
+
+####
+
+
+
+Set a hotkey and the first focus
+
+These props on a control decide how the keyboard reaches it:
+
+ * **`hotkey`** : to let the user press a `Button` with one key, give it a `hotkey` of one digit or one lowercase letter, as in `hotkey: 'a'`
+ * **`autoFocus`** : to choose which control has the focus when the pane opens, add `autoFocus: true` to it. The prop accepts only `true`, so omit it on the other controls.
+
+How a hotkey shows depends on the button and the app:
+
+Button| In the terminal| In the Desktop app
+---|---|---
+With brackets, the default| `[ Add one ]`, with no hotkey shown| The label with a small key beside it
+With `plain: true`| `1: One`| The label with a small key beside it
+
+In the terminal, name the key in a bracketed button’s label, or use `plain: true`, so the user can see what to press. The [elements reference](</docs/en/plugins/mods/reference#elements>) has the other `Button` rules: `action`, digit hotkeys on the band, and two buttons on one hotkey.
+
+###
+
+
+
+Take typed input and draw a row for each item
+
+Many panes are a text field with a list under it. The example in this section is a notes pane: you type a note and press Enter to add it, and each note has an `x` button that deletes it. With two notes added, the terminal draws the pane this way:
+
+ ╭──────────────────────────────────────────────────────────╮
+ │ Note: Type a note and press Enter ⏎ add ✕ │
+ │ x buy milk │
+ │ x call bob │
+ ╰──────────────────────────────────────────────────────────╯
+
+The example uses these techniques:
+
+ * **Take typed input** : an `Input` calls `onSubmit(value)` with the field’s text when the user presses Enter, and `onInput(value)` on every change
+ * **Draw a list** : map your data to one row each, and give every row’s button its own `key`
+
+This hook draws the pane’s content:
+
+ // The list the pane draws
+ let notes = []
+
+ on('ui.render', { component: 'Pane' }, async ($, e, next) => {
+ // Draw only in the pane opened with the id 'notes'
+ if (e.requestId !== 'notes') return next(e)
+ const { Box, Text, Button, Input } = $.ui.resolve(e)
+ const redraw = () => $.ui.invalidate('ui.render')
+
+ return Box({
+ flexDirection: 'column',
+ children: [
+ Input({
+ key: 'new-note',
+ label: 'Note',
+ placeholder: 'Type a note and press Enter',
+ // Draw the field empty each time, which clears it after a submit
+ value: '',
+ submitLabel: 'add',
+ autoFocus: true,
+ // Runs when you press Enter in the field
+ onSubmit: async (value) => {
+ // Ignore an empty line
+ if (!value.trim()) return
+ notes = [...notes, value.trim()]
+ redraw()
+ await $.store.set('notes', notes)
+ },
+ }),
+ // One row for each note: a delete button, then the note's text
+ ...notes.map((note, i) =>
+ Box({
+ flexDirection: 'row',
+ columnGap: 1,
+ children: [
+ Button({
+ // A key of its own, so each row's button can be told apart
+ key: 'delete-' + i,
+ label: 'x',
+ plain: true,
+ onPress: async () => {
+ notes = notes.filter((_, j) => j !== i)
+ redraw()
+ await $.store.set('notes', notes)
+ },
+ }),
+ Text({ children: [note] }),
+ ],
+ }),
+ ),
+ ],
+ })
+ })
+
+To try the pane:
+
+ * **Add a note** : type a line and press Enter. The line appears as a new row, and the field empties.
+ * **Delete a note** : press Tab until the note’s `x` button has the focus, then press Enter. The `x` is the button’s label and not a hotkey, so typing the letter doesn’t press it.
+
+Each change follows the same render cycle as `hello-tabs`: the callback changes `notes`, calls `redraw`, and saves the list to `$.store`. The field empties after each submit because of its `value` prop. `value` is the text the field holds when it’s drawn, and the user’s typing replaces it until your hook draws the field again. The example always draws the field with `''`. The example saves the notes and doesn’t load them. To bring them back in the next session, read them in a `session.start` hook, the way `hello-tabs` reads `count`. These props make up the field’s line, `Note: Type a note and press Enter ⏎ add`:
+
+Prop| In the example| What it is
+---|---|---
+`label`| `Note`| The text before the field. The terminal draws `: ` after it.
+`placeholder`| `Type a note and press Enter`| Dim text that shows while the field is empty
+`submitLabel`| `add`| The word after `⏎` that says what Enter does
+
+Submitting an `Input` doesn’t start a turn unless your callback calls [`$.prompt.submit`](</docs/en/plugins/mods/api#start-a-turn-from-a-background-job>).
+
+##
+
+
+
+Redraw a site
+
+A drawing is a snapshot: it shows what your `ui.render` hook returned the last time the hook ran. To show something new, the hook has to run again. Claude Code runs it again for some changes, and your mod asks for the rest.
+
+###
+
+
+
+When Claude Code redraws without being asked
+
+Claude Code runs your `ui.render` hook again when the site’s props change or the terminal’s width changes. It doesn’t run the hook on a timer, and it can’t tell when a variable in your module changes.
+
+###
+
+
+
+Redraw when your data changes
+
+To have your sites drawn again after your own data changes, call `$.ui.invalidate('ui.render')`. This pane counts presses. The button’s callback changes `count`, then asks for a redraw:
+
+ let count = 0
+
+ on('ui.render', { component: 'Pane' }, async ($, e, next) => {
+ if (e.requestId !== 'counter') return next(e)
+ const { Box, Text, Button } = $.ui.resolve(e)
+ return Box({
+ flexDirection: 'row',
+ columnGap: 2,
+ children: [
+ Button({
+ key: 'more',
+ label: 'Add one',
+ onPress: () => {
+ count += 1
+ // The data changed, so ask Claude Code to draw the pane again
+ $.ui.invalidate('ui.render')
+ },
+ }),
+ Text({ children: ['Count: ' + count] }),
+ ],
+ })
+ })
+
+Each press raises the number in the pane. The `hello-tabs` example wraps the same call in its `redraw` function. A value you keep in `$.state` doesn’t need the call, because writing the value redraws the sites that read it.
+
+###
+
+
+
+Redraw on a timer
+
+To keep a clock, a countdown, or a value from outside the session current, redraw on a schedule. Start a timer in the module’s `session.start` hook. If the module already has one, as `hello-tabs` does, add the [`$.clock.every`](</docs/en/plugins/mods/api#run-work-in-the-background>) line to it:
+
+ on('session.start', async ($, e, next) => {
+ // Every 1000 milliseconds, ask Claude Code to draw your sites again
+ $.clock.every(1000, () => $.ui.invalidate('ui.render'))
+ return next(e)
+ })
+
+Claude Code now runs your `ui.render` hook once a second. The timer stops when the module reloads, and the new instance of the module starts its own.
+
+###
+
+
+
+How often a site can redraw
+
+Claude Code throttles redraws of a site, so your mod can call `$.ui.invalidate` as often as its data changes. For how often each site can redraw, see the [limits table](</docs/en/plugins/mods/reference#limits>). Calls that come faster than the limit are coalesced into one redraw. That redraw runs your hook once, and the hook reads your data as it is at that moment, so the latest value shows and the values in between don’t. An animation can’t run faster than the limit.
+
+##
+
+
+
+Keep state
+
+Where a mod keeps a value decides how long the value lasts: until the module reloads, until the session ends, or from one session to the next. Choose by how long the value has to last:
+
+Keep it in| It lasts until| Use it for
+---|---|---
+A module-level variable| The module reloads, which happens every time you save a file during development| Values you can lose, as `tab` is in `hello-tabs`
+`$.state`| The session ends, or the user runs `/clear`, `/resume`, or `/branch`| Values a drawing depends on that should survive a reload
+`$.store`| Your mod deletes it, or no session reads or writes the store for [`cleanupPeriodDays`](</docs/en/settings-reference#cleanupperioddays>). The store is a key-value store, saved as a JSON file of your plugin’s own under `~/.claude/plugins/store/`.| Settings, history, anything the user expects to find next time
+
+`$.store.get(key)` resolves to the value or `undefined`, and `$.store.set(key, value)` takes any JSON value.
+
+###
+
+
+
+Keep a value in `$.state`
+
+`$.state` holds values for the length of a session, and it redraws for you. It’s reactive state: a `ui.render` hook that reads a value subscribes to it, so Claude Code redraws that site each time you write the value, and you don’t call `$.ui.invalidate`. A value in `$.state` also survives a reload of the module, which a variable doesn’t. To set it up, declare your values, point your manifest at the declaration, then define and use each value. The examples move the `count` from `hello-tabs` into `$.state`.
+
+####
+
+
+
+Declare the values
+
+Declare the values in a type declaration file. The outer key is your plugin’s name, and each entry under it is a value and its type. Save this as `hello-tabs/types/index.d.ts`:
+
+hello-tabs/types/index.d.ts
+
+ declare module 'claude-code' {
+ interface PluginState {
+ 'hello-tabs': {
+ tab: 'one' | 'two'
+ count: number
+ }
+ }
+ }
+
+####
+
+
+
+Point the manifest at the declaration
+
+To let `claude plugin validate` check your code against that file, add a `types` field to the manifest with its path:
+
+hello-tabs/.claude-plugin/plugin.json
+
+ {
+ "name": "hello-tabs",
+ "version": "0.1.0",
+ "description": "Opens a pane with two tabs and a counter",
+ "author": { "name": "Your Name" },
+ "types": "./types/index.d.ts"
+ }
+
+####
+
+
+
+Define, read, and write a value
+
+In your module, define each value with a default, read it while drawing, and write it from a callback. `atom` names a value and its default, `read` returns it, and `update` writes it. The three helpers call `$.state.get` and `$.state.set` for you:
+
+ import { atom, read, update } from 'claude-code'
+
+ // At the top of the module: name the value and give its default
+ const count = atom({ plugin: 'hello-tabs', key: 'count' }, 0)
+
+ // In the ui.render hook: read the value to draw it
+ const n = await read($, count)
+
+ // In a Button: write a new value from the old one
+ onPress: () => update($, count, (value) => value + 1)
+
+Because the `ui.render` hook read `count`, Claude Code runs the hook again each time the button writes it. These rules apply to the code:
+
+ * **Write`plugin` and `key` as string literals**: `claude plugin validate` reads them from your source
+ * **Declare every value in the type declaration file** : otherwise validation fails with `hello-tabs.count is not declared`
+ * **Write from a callback or another event’s hook** : a `ui.render` hook can read state and can’t write it, so write from `onPress`, `onSubmit`, or a hook for another event
+
+####
+
+
+
+Change `hello-tabs` to use `$.state`
+
+To move `count` in `hello-tabs` into `$.state`, change every line that uses it:
+
+ * **At the top of the module** : add the `import` line, and replace `let count = 0` with the `atom` line
+ * **In the`ui.render` hook**: add the `read` line before `tabButton`, and draw `'Count: ' + n` in the `Text`
+ * **In the Add one button** : replace `onPress` with the one in Save from more than one session, which saves the count as well as writing it
+ * **In the`session.start` hook**: replace the two lines that read `saved` with the `loadCount` call from Load a saved value again after `/clear`
+
+Keep `redraw` for the tab buttons, because `tab` is still a variable.
+
+###
+
+
+
+Load a saved value again after `/clear`
+
+If your mod copies a saved value from `$.store` into `$.state` at `session.start`, it has to copy it again after `/clear`, `/resume`, or `/branch`. Those commands reset every `$.state` value to its default, and `session.start` doesn’t fire again. [`classic.SessionStart`](</docs/en/plugins/mods/events#hook-the-settings-hook-events>) does fire after each of them, with `e.source` set to `clear`, `resume`, or `fork`, so copy the value again in a hook on it. Otherwise your drawing shows the default, and a callback that saves the `$.state` value writes the default over what you stored. This code loads `count` from both hooks. It builds on the `$.state` version of `hello-tabs`, where `count` is an atom and `update` is imported. Put `loadCount` above `register`, and add the `loadCount` call to the `session.start` hook you already have. `classic.SessionStart` also fires at startup and after compaction, which doesn’t reset `$.state`, so the filter on `source` keeps the hook to the three resets:
+
+ // Copy the saved count from $.store into $.state, or 0 if nothing is saved
+ async function loadCount($) {
+ const saved = Number((await $.store.get('count')) ?? 0)
+ await update($, count, () => saved)
+ }
+
+ // Runs before your first prompt, and again after a reload
+ on('session.start', async ($, e, next) => {
+ await loadCount($)
+ return next(e)
+ })
+
+ // Runs again after /clear, /resume, and /branch, which reports fork
+ on('classic.SessionStart', { source: ['clear', 'resume', 'fork'] }, async ($, e, next) => {
+ await loadCount($)
+ return next(e)
+ })
+
+With both hooks in place, the pane shows the saved count after `/clear` and not `0`, and the next press of **Add one** adds to the saved count. `loadCount` writes the stored value over the one in `$.state`, and `session.start` fires again each time the module reloads. To keep the store from falling behind, save on every change, as the **Add one** button does. To check the reload without a session, [test the drawing after `/clear`](</docs/en/plugins/mods/test#test-a-drawing-after-clear>).
+
+###
+
+
+
+Save from more than one session
+
+Every session on your machine that runs your mod shares one `$.store`. A `get` followed by a `set` isn’t atomic. When two sessions each read a value, change it, and write it back, they race, and the second write replaces the first. To make that less likely:
+
+ * **Give each item its own key** : a `set` changes only its own key, so sessions that write different keys don’t overwrite each other
+ * **Read again right before you write** : for a value that several sessions change, `get` the key in the callback and build the new value from that, not from a copy you loaded at `session.start`. Another session’s write is still lost if it lands between your `get` and your `set`.
+
+This button adds one to whatever the store holds now, then updates the drawing:
+
+ onPress: async () => {
+ // Read what the store holds now, which another session may have changed
+ const saved = Number((await $.store.get('count')) ?? 0)
+ // Save the new count, then show it
+ await $.store.set('count', saved + 1)
+ await update($, count, () => saved + 1)
+ }
+
+If a second session has pressed its own button three times since this session started, this press shows and saves a count that includes those three.
+
+##
+
+
+
+Next steps
+
+ * [React to events](</docs/en/plugins/mods/events>): feed your drawing from tool calls and turns
+ * [Use the mods API](</docs/en/plugins/mods/api>): feed your drawing from timers and model calls
+ * [Test a drawing](</docs/en/plugins/mods/test#test-a-drawing>): press your buttons from a test, on more than one surface
+ * [Render sites](</docs/en/plugins/mods/reference#render-sites>) and [elements](</docs/en/plugins/mods/reference#elements>): each site’s props and each element’s props
--- a/keybindings.md
+++ b/keybindings.md
@@ -342,7 +342,7 @@
Diff actions
-Actions available in the `DiffDialog` context:
+These actions reach only Claude Code’s earlier diff viewer, which `/diff` opens outside [fullscreen rendering](</docs/en/fullscreen>) after you disable the [`cc-plugin-diff` mod](</docs/en/plugins/mods/overview#mods-built-into-claude-code>) in `/plugin`. While that mod is enabled, `/diff` opens the [diff dialog](</docs/en/interactive-mode#diff-dialog>) instead. A `keybindings.json` that names these actions loads without errors either way. Actions available in the `DiffDialog` context:
Action| Default| Description
---|---|---
@@ -370,11 +370,11 @@
Diff panel actions
-Actions for the [diff panel](</docs/en/interactive-mode#diff-panel>) that `/diff` opens in fullscreen rendering. `app:cycleDiffBase` is in the `DiffPanel` context, which is active while the panel is open; the others are `Global`. The panel requires Claude Code v2.1.260 or later.
-
-Action| Default| Description
----|---|---
-`app:toggleReplTab`| (unbound)| Open or close the diff panel, the same as running `/diff`
+Actions for the [diff panel](</docs/en/interactive-mode#diff-panel>) that `/diff` opens in fullscreen rendering. `app:cycleDiffBase` is in the `DiffPanel` context, which is active while the panel is open; the others are `Global`. The built-in [`cc-plugin-diff` mod](</docs/en/plugins/mods/overview#mods-built-into-claude-code>) draws this panel and handles `app:cycleDiffBase`, `app:diffFileListUp`, and `app:diffFileListDown`. `app:toggleReplTab`, `app:toggleDiffNoiseFilter`, and `app:toggleDiffPreSession` reach only Claude Code’s earlier panel, which `/diff` opens after you disable `cc-plugin-diff` in `/plugin`.
+
+Action| Default| Description
+---|---|---
+`app:toggleReplTab`| (unbound)| Open or close the diff panel
`app:cycleDiffBase`| Ctrl+X B| Cycle the panel’s comparison base: this session, uncommitted, then branch
`app:diffFileListUp`| Ctrl+Up, Meta+Up| Scroll the panel’s file list up when it overflows
`app:diffFileListDown`| Ctrl+Down, Meta+Down| Scroll the panel’s file list down when it overflows
--- a/large-codebases.md
+++ b/large-codebases.md
@@ -184,7 +184,7 @@
Reduce file reads with code intelligence
-In a large codebase, finding where a symbol is defined or used can cost many file reads and grep calls. [Code intelligence plugins](</docs/en/plugins/code-intelligence>) connect Claude to a language server so it can jump to definitions, find references, and surface type errors directly instead of scanning the tree. The official marketplace has plugins for TypeScript, Python, Go, Rust, and other common languages. Run the command below inside a Claude Code session to install the TypeScript plugin:
+In a large codebase, finding where a symbol is defined or used can cost many file reads and grep calls. [Code intelligence plugins](</docs/en/plugins/code-intelligence>) connect Claude to a language server so it can jump to definitions, find references, and surface type errors directly instead of scanning the tree. The official marketplace has plugins for TypeScript, Python, Go, Rust, and other common languages. In the VS Code extension or the desktop app, install one by following [Install a plugin](</docs/en/plugins/install#install-a-plugin>). In a terminal, start Claude Code by running `claude`, then enter this at its prompt to install the TypeScript plugin:
/plugin install typescript-lsp@claude-plugins-official
--- a/llm-gateway-protocol.md
+++ b/llm-gateway-protocol.md
@@ -61,7 +61,7 @@
Streaming
-Stream inference responses. Claude Code reads the stream as it arrives, so if your gateway buffers complete responses before relaying them, Claude Code stalls. Deliver each response’s full event sequence without dropping, duplicating, or reordering events. When an event references a content block whose `content_block_start` never arrived, or a block whose `content_block_stop` already arrived, Claude Code stops reading the stream at that event instead of applying it, so a duplicated `content_block_stop` can’t run the same tool call twice. [The response above may be incomplete](</docs/en/errors#the-response-above-may-be-incomplete>) describes what the user sees, under the `Part of the response never arrived` and `The response stream was malformed` variants. Relay each response through its final `message_delta` and `message_stop` events before ending the body. A body that ends after a `message_delta` carrying a `stop_reason`, with no content block still open and no content block event after that frame, counts as complete even when `message_stop` is missing. A body that your gateway ends cleanly any earlier, once a content block has started, is treated the same as a dropped connection: [Automatic retries](</docs/en/errors#automatic-retries>) says when Claude Code re-issues the request, and [The response above may be incomplete](</docs/en/errors#the-response-above-may-be-incomplete>) covers what it keeps once visible content has arrived. Claude Code keeps the `stop_reason` a `message_delta` delivers, so a later usage-only `message_delta` whose `delta` has `stop_reason: null` or no `stop_reason` key doesn’t clear it. When the client speaks the Amazon Bedrock format, relay the `InvokeModelWithResponseStream` response body and its `Content-Type: application/vnd.amazon.eventstream` header unmodified, and don’t convert the stream to server-sent events. See [Streaming errors behind a gateway or proxy](</docs/en/amazon-bedrock#streaming-errors-behind-a-gateway-or-proxy>). Forward keep-alive pings as well, because Claude Code aborts a streaming response once no bytes reach it for [five minutes by default](</docs/en/network-config#streaming-idle-watchdogs>). During a long thinking pause, the upstream’s SSE `ping` events can be the only bytes on the stream. If your gateway strips or buffers them, Claude Code aborts the response partway through the pause. When you translate from an upstream that sends no pings at all, such as Amazon Bedrock’s binary event-stream, emit your own `ping` events during silent gaps.
+Stream inference responses. Claude Code reads the stream as it arrives, so if your gateway buffers complete responses before relaying them, Claude Code stalls. Deliver each response’s full event sequence without dropping, duplicating, or reordering events. When an Amazon Bedrock guardrail blocks a reply, forward the events it sends unchanged, even when they reference a content block whose `content_block_stop` already arrived. [AWS Guardrails](</docs/en/amazon-bedrock#aws-guardrails>) describes how that reply ends. When any other event references a content block whose `content_block_start` never arrived, or a block whose `content_block_stop` already arrived, Claude Code stops reading the stream at that event instead of applying it, so a duplicated `content_block_stop` can’t run the same tool call twice. [The response above may be incomplete](</docs/en/errors#the-response-above-may-be-incomplete>) describes what the user sees, under the `Part of the response never arrived` and `The response stream was malformed` variants. Relay each response through its final `message_delta` and `message_stop` events before ending the body. A body that ends after a `message_delta` carrying a `stop_reason`, with no content block still open and no content block event after that frame, counts as complete even when `message_stop` is missing. A body that your gateway ends cleanly any earlier, once a content block has started, is treated the same as a dropped connection: [Automatic retries](</docs/en/errors#automatic-retries>) says when Claude Code re-issues the request, and [The response above may be incomplete](</docs/en/errors#the-response-above-may-be-incomplete>) covers what it keeps once visible content has arrived. Claude Code keeps the `stop_reason` a `message_delta` delivers, so a later usage-only `message_delta` whose `delta` has `stop_reason: null` or no `stop_reason` key doesn’t clear it. When the client speaks the Amazon Bedrock format, relay the `InvokeModelWithResponseStream` response body and its `Content-Type: application/vnd.amazon.eventstream` header unmodified, and don’t convert the stream to server-sent events. See [Streaming errors behind a gateway or proxy](</docs/en/amazon-bedrock#streaming-errors-behind-a-gateway-or-proxy>). Forward keep-alive pings as well, because Claude Code aborts a streaming response once no bytes reach it for [five minutes by default](</docs/en/network-config#streaming-idle-watchdogs>). During a long thinking pause, the upstream’s SSE `ping` events can be the only bytes on the stream. If your gateway strips or buffers them, Claude Code aborts the response partway through the pause. When you translate from an upstream that sends no pings at all, such as Amazon Bedrock’s binary event-stream, emit your own `ping` events during silent gaps.
###
@@ -224,10 +224,10 @@
Feature| Header and body pair| Symptom when broken| Remediation
---|---|---|---
[Adaptive reasoning](</docs/en/model-config#adjust-effort-level>)| No beta header. Claude Code sends `thinking: {"type": "adaptive"}` for Claude 4.6 and later, and treats model names it doesn’t recognize, such as gateway aliases, as current models that receive the field| `400` naming the `thinking` field or the `adaptive` tag when the upstream model build doesn’t accept it| Upgrade the upstream. On Opus 4.6 and Sonnet 4.6, developers can set `CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING=1` instead
-[Context management](<https://platform.claude.com/docs/en/build-with-claude/context-editing>)| Context management beta header pairs with the `context_management` body field| `400` with `Extra inputs are not permitted`. Common when a gateway accepts Anthropic-format requests but forwards them to Amazon Bedrock| Forward both, or [`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`](</docs/en/env-vars>)
+[Context management](<https://platform.claude.com/docs/en/build-with-claude/context-editing>)| Context management beta header pairs with the `context_management` body field| `400` with `Extra inputs are not permitted`. Common when a gateway accepts Anthropic-format requests but forwards them to Amazon Bedrock| Forward both, or `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`
[Extended context](<https://platform.claude.com/docs/en/build-with-claude/context-windows#context-window-sizes-by-model>) and [interleaved thinking](<https://platform.claude.com/docs/en/build-with-claude/extended-thinking#interleaved-thinking>)| Beta headers only, no body field| Silently unavailable when the header is stripped; the upstream never sees the capability request| Forward `anthropic-beta` verbatim
Beta [tool fields](<https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview>)| Tool-related beta headers pair with tool schema fields such as `strict` and `defer_loading`| `400` naming the unrecognized tool schema field when the body passes through without its header| Forward both, or `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`
-[Effort](<https://platform.claude.com/docs/en/build-with-claude/effort>) and [structured outputs](<https://platform.claude.com/docs/en/build-with-claude/structured-outputs>)| The `output_config` body field carries effort, structured-output format, and task budget settings; each pairs with its own beta header| `400` naming `output_config`, often `Extra inputs are not permitted`, on Amazon Bedrock and Google Cloud’s Agent Platform upstreams| Forward the field and its headers together
+[Effort](<https://platform.claude.com/docs/en/build-with-claude/effort>) and [structured outputs](<https://platform.claude.com/docs/en/build-with-claude/structured-outputs>)| The `output_config` body field carries effort, structured-output format, and task budget settings; each pairs with its own beta header| `400` naming `output_config`, often `Extra inputs are not permitted`, on Amazon Bedrock and Google Cloud’s Agent Platform upstreams| Forward the field and its headers together, or have developers set `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`, which removes the format and task budget settings but not effort
[Prompt caching](</docs/en/prompt-caching>)| No beta pairing. Claude Code attaches `cache_control` markers to `system` blocks and to `messages` entries, including `role: "system"` entries appended mid-conversation| No error: the conversation bills as uncached input on every turn, visible as high `input_tokens` with little or no cache activity in `usage`| Forward `cache_control` unchanged wherever it appears, and don’t convert block-form `system` or message content to plain strings
[Token counting](<https://platform.claude.com/docs/en/build-with-claude/token-counting>)| No beta pairing; uses the `count_tokens` endpoint| No error: Claude Code falls back to a character-based estimate, so `/context` shows approximate counts| Expose the endpoint for exact token counts
@@ -244,6 +244,7 @@
* When the upstream rejects the `thinking` field, a mid-conversation system message, or the `cache_control` marker on such a message, Claude Code retries the request and disables the rejected capability for the rest of the conversation
* When the upstream rejects a [thinking signature](<https://platform.claude.com/docs/en/build-with-claude/extended-thinking>), including with a `400` whose message says the block is `bound to a different conversation`, Claude Code removes earlier thinking blocks from the request, retries, and keeps them out of every later request. New responses still include thinking
* When the gateway or its upstream rejects the [advisor tool](</docs/en/advisor>) entry in `tools` as an unrecognized tool type, Claude Code retries the request once without that entry and its `anthropic-beta` value. Later requests to that base URL leave the advisor out until Claude Code exits, and `/advisor` is unavailable to the developer for that time. Claude Code recognizes this rejection by a `400` or `422` response whose message names the tool type after `Input tag`, such as `Input tag 'advisor_20260301'`. Before v2.1.280, Claude Code didn’t retry this rejection
+ * When the upstream rejects `output_config.effort`, Claude Code retries the request without effort and leaves it out of later requests to that model until Claude Code exits. Claude Code recognizes this rejection by a `400` whose message names `output_config.effort` together with `Extra inputs are not permitted`, or says the model doesn’t support the effort parameter
* Claude Code doesn’t retry rejections of context management or tool schema fields, so those `400` errors reach the developer
The `bound to a different conversation` rejection comes from the API’s [preserved thinking](<https://platform.claude.com/docs/en/build-with-claude/preserved-thinking>) check, which fails when `system`, `tools`, or earlier `messages` content differs from the request that produced the thinking. A gateway that rewrites any of that content can cause the rejection itself; [Libraries, proxies, and gateways](<https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#libraries-proxies-gateways>) covers what to pass through unchanged. The retry logic matches on the upstream’s error wording, so forward error response bodies unmodified. A gateway that wraps upstream errors in its own envelope breaks the recovery path, even when it preserves the status code, unless the envelope’s message carries a stable `capability_rejected:` token. [Claude apps gateway substitutes those tokens for cloud providers’ error wording](</docs/en/claude-apps-gateway-config#upstream-error-messages>), for example `capability_rejected: prompt_too_long`.
@@ -254,7 +255,23 @@
Disable pre-release capabilities
-`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1` stops Claude Code from sending pre-release capabilities and their body fields, including context management and the beta tool fields. The variable doesn’t affect adaptive reasoning, which is selected by model rather than by beta. It never suppresses the OAuth capability that subscription authentication requires. When a host platform that embeds Claude Code sets [`CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST`](</docs/en/env-vars>), `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` doesn’t stop auto mode sessions on Amazon Bedrock, Google Cloud’s Agent Platform, Microsoft Foundry, or a [Claude apps gateway](</docs/en/claude-apps-gateway>) from asking the server for [classifier review](</docs/en/permission-modes#server-side-classifier-review>). That review adds an `anthropic-beta` value and a `safeguards` request field. Set `CLAUDE_CODE_AUTO_MODE_SERVER=0` to stop it there. On Claude Code v2.1.227 or later, your organization can keep [MCP tool search](</docs/en/mcp#scale-with-mcp-tool-search>) on under this variable through [managed settings](</docs/en/managed-settings>). What Claude Code sends with that override in place depends on how you connect:
+When your gateway or its upstream rejects pre-release `anthropic-beta` values or the body fields that pair with them, and you can’t forward both halves, have developers set `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`. With the variable set, Claude Code stops sending pre-release capabilities and the `anthropic-beta` values that pair with them, including:
+
+ * Context management and its `context_management` body field
+ * The beta tool schema fields, such as `strict` and `defer_loading`. The standard `name`, `description`, `input_schema`, and `cache_control` tool fields stay
+ * The structured-output `output_config.format` field. Requires Claude Code v2.1.287 or later
+ * The `output_config.task_budget` field
+ * [MCP tool search](</docs/en/mcp#scale-with-mcp-tool-search>), so every MCP tool loads upfront unless your organization keeps it on through managed settings
+
+The variable doesn’t strip every `anthropic-beta` value. What it leaves in place includes:
+
+ * The `anthropic-beta` values for extended context, interleaved thinking, and effort, which cloud providers also accept
+ * The `output_config.effort` field. Automatic retry and error forwarding covers an upstream that rejects it
+ * The adaptive reasoning `thinking` field, which has no beta header
+ * The OAuth `anthropic-beta` value that subscription authentication requires
+ * Header values and body fields developers add themselves through [`ANTHROPIC_BETAS`](</docs/en/env-vars>) or [`CLAUDE_CODE_EXTRA_BODY`](</docs/en/env-vars>)
+
+When a host platform that embeds Claude Code sets [`CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST`](</docs/en/env-vars>), `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` doesn’t stop auto mode sessions on Amazon Bedrock, Google Cloud’s Agent Platform, Microsoft Foundry, or a [Claude apps gateway](</docs/en/claude-apps-gateway>) from asking the server for [classifier review](</docs/en/permission-modes#server-side-classifier-review>). That review adds an `anthropic-beta` value and a `safeguards` request field. Set `CLAUDE_CODE_AUTO_MODE_SERVER=0` to stop it there. On Claude Code v2.1.227 or later, your organization can keep [MCP tool search](</docs/en/mcp#scale-with-mcp-tool-search>) on under this variable through [managed settings](</docs/en/managed-settings>). What Claude Code sends with that override in place depends on how you connect:
* On a direct connection, or through a gateway set with `ANTHROPIC_BASE_URL`, Claude Code keeps sending the tool-search beta header, `defer_loading` tool fields, and `tool_reference` blocks, and strips the rest
* On a cloud provider, or signed in through a [Claude apps gateway](</docs/en/claude-apps-gateway>), the override has no effect
--- a/loading.md
+++ b/loading.md
@@ -240,23 +240,24 @@
When the dependency install runs
-Claude Code runs the install inside the copied version directory each time it creates one:
+Claude Code installs the dependencies into the copied version directory each time it creates one:
* When you install a plugin
* When Claude Code updates a plugin to a new version
* At session start when an enabled plugin isn’t cached yet, such as on a new machine
-For a relative-path plugin loaded in place from a local-directory marketplace, Claude Code doesn’t install the dependencies into the source directory. Install them there yourself, or from a hook into [`${CLAUDE_PLUGIN_DATA}`](</docs/en/plugins/components#path-variables-and-persistent-data>). The install runs only when the plugin’s root directory contains both a `package.json` and a supported lockfile. The lockfile decides which command Claude Code runs:
-
-Lockfile| Command
+For a relative-path plugin loaded in place from a local-directory marketplace, Claude Code doesn’t install the dependencies into the source directory. Install them there yourself, or from a hook into [`${CLAUDE_PLUGIN_DATA}`](</docs/en/plugins/components#path-variables-and-persistent-data>). The install runs only when the plugin’s root directory contains both a `package.json` and a supported lockfile. The lockfile decides which package manager Claude Code runs:
+
+Lockfile| Package manager
---|---
-`bun.lock` or `bun.lockb`| `bun install --frozen-lockfile --ignore-scripts`
-`npm-shrinkwrap.json` or `package-lock.json`| `npm ci --ignore-scripts`
-
-If a plugin contains more than one of these lockfiles, Claude Code uses the first match, checking in order: `bun.lock`, `bun.lockb`, `npm-shrinkwrap.json`, `package-lock.json`. Claude Code skips the install for Yarn and pnpm lockfiles and for a `bunfig.toml` beside the Bun lockfile:
-
- * If your plugin has only a `yarn.lock` or `pnpm-lock.yaml`, replace it with an npm lockfile
- * If a `bunfig.toml` is in the same directory as the Bun lockfile, remove the `bunfig.toml`, or replace the Bun lockfile with an npm lockfile
+`bun.lock`| Bun
+`npm-shrinkwrap.json` or `package-lock.json`| npm
+
+If a plugin contains more than one of these lockfiles, Claude Code uses the first match, checking in order: `bun.lock`, `npm-shrinkwrap.json`, `package-lock.json`. Claude Code skips the install in these lockfile cases:
+
+ * **`bun.lockb`** : Bun’s binary lockfile can’t be checked. Ship a text `bun.lock` or an npm lockfile instead
+ * **`yarn.lock` or `pnpm-lock.yaml`**: replace it with an npm lockfile
+ * **A lockfile in a format Claude Code doesn’t read** : an npm lockfile needs a `lockfileVersion` of `2` or `3`, which npm 7 or later writes, and a `bun.lock` needs a `lockfileVersion` no higher than `2`
Include an npm lockfile to reach the most users. Claude Code runs the matched lockfile’s package manager from the user’s PATH and doesn’t try the other lockfile instead if that package manager is missing. For a plugin distributed through an npm source, use `npm-shrinkwrap.json`, because npm excludes `package-lock.json` from published packages.
@@ -268,8 +269,12 @@
Claude Code constrains this dependency install so that no code from the plugin or its packages executes during it, and bounds how long it can run:
- * **Frozen resolution** : Bun and npm install exactly what the lockfile pins, and fail rather than re-resolve versions when `package.json` and the lockfile disagree
+ * **Registry packages only** : every dependency must be a registry package pinned in the lockfile to an exact version. A plugin with a git, GitHub, folder, workspace, or linked dependency gets no install.
+ * **`https` downloads**: a download link in the lockfile must use `https`, unless it points at the installing user’s own default npm registry.
+ * **A separate install folder** : the package manager runs in a folder of its own that holds only a copy of the checked dependency list, so npm and Bun don’t read the plugin’s `.npmrc`, `.env`, or `bunfig.toml`. When the install succeeds, Claude Code moves the resulting `node_modules` into the plugin.
+ * **Frozen resolution** : the install uses exactly the versions the lockfile pins, and Claude Code skips it when `package.json` and the lockfile don’t list the same dependencies
* **No lifecycle scripts** : `--ignore-scripts` keeps `preinstall`, `install`, and `postinstall` scripts from running, so dependencies that build native modules in those scripts download but don’t compile during this install
+ * **No overrides or patches** : a plugin whose `package.json` sets npm `overrides` gets no install from an npm lockfile, and a plugin that sets Bun `patchedDependencies` gets no install from `bun.lock`
* **60-second timeout** : Claude Code stops an install that runs longer and treats it as failed
Claude Code fetches an npm-source plugin before this dependency install, and none of the package’s own install scripts run during the fetch. See [npm plugin source](</docs/en/plugins/marketplace-reference#npm-plugin-source>). You can’t turn the automatic install off. No setting or environment variable disables it. In restricted networks, see the [network access requirements](</docs/en/network-config#network-access-requirements>) for the hosts to allow.
@@ -280,13 +285,7 @@
When the dependency install fails or is skipped
-A failed or skipped install never blocks the plugin, and each case leaves a different sign:
-
- * A failed install, or one skipped because of a Yarn or pnpm lockfile or a `bunfig.toml`, appears as a warning in the `claude --debug` output
- * A plugin with a `package.json` and no lockfile is skipped without a log entry
- * A timed-out install can leave a partial `node_modules` tree in the cached copy
-
-When the automatic install can’t provide a dependency, install it from a hook into the [persistent data directory](</docs/en/plugins/components#path-variables-and-persistent-data>). That includes packages that need their lifecycle scripts to build, Python dependencies, and plugins locked with Yarn or pnpm.
+If the install fails or is skipped, the plugin still loads, but the parts of it that need the missing packages may not work. `/plugin` and `claude plugin list` show a note on an enabled plugin whose cached copy has a lockfile and a `package.json` that lists runtime dependencies, but no `node_modules` directory. The note says whether the install didn’t finish or can’t run for this plugin. See [the troubleshooting entry](</docs/en/plugins/troubleshooting#the-packages-it-lists-are-not-installed>) for what to do about each. When the automatic install can’t provide a dependency, install it from a hook into the [persistent data directory](</docs/en/plugins/components#path-variables-and-persistent-data>). That includes packages that need their lifecycle scripts to build, Python dependencies, plugins locked with Yarn or pnpm, and dependencies that aren’t registry packages, such as git dependencies.
##
@@ -294,7 +293,7 @@
Versions and updates
-If a plugin’s author pushed new commits and `claude plugin update` prints `<name> is already at the latest version (<version>).`, the version Claude Code computes for the plugin is unchanged, so nothing changes on disk. Claude Code computes a version for every plugin it installs, and that version is how it detects an update. `claude plugin update` and background auto-update compute the version again and skip the plugin when it matches what `installed_plugins.json` records. The version also names the plugin’s cache directory. A manifest that pins `"version"` is one way the computed version stays the same across commits. See How Claude Code computes the version for the resolution order. A plugin loaded in place from a local-directory marketplace loads its current source files at every session start, whatever its version string says. For a plugin from a [marketplace hosted on claude.ai](</docs/en/plugins/install#add-from-claude-ai>), the version claude.ai records for the plugin is its version, and the manifest’s `version` isn’t read.
+If a plugin’s author pushed new commits and `claude plugin update` prints `<name> is already at the latest version (<version>).`, the version Claude Code computes for the plugin is unchanged, so the plugin’s files on disk don’t change. Claude Code computes a version for every plugin it installs, and that version is how it detects an update. `claude plugin update` and background auto-update compute the version again and don’t replace the cached copy when it matches what `installed_plugins.json` records. An update that you start can still [retry an unfinished dependency install](</docs/en/plugins/troubleshooting#the-packages-it-lists-are-not-installed>) in that copy. The version also names the plugin’s cache directory. A manifest that pins `"version"` is one way the computed version stays the same across commits. See How Claude Code computes the version for the resolution order. A plugin loaded in place from a local-directory marketplace loads its current source files at every session start, whatever its version string says. For a plugin from a [marketplace hosted on claude.ai](</docs/en/plugins/install#add-from-claude-ai>), the version claude.ai records for the plugin is its version, and the manifest’s `version` isn’t read.
###
--- a/managed-mcp.md
+++ b/managed-mcp.md
@@ -498,6 +498,7 @@
`managed-mcp.json` is present and a user who could otherwise run Claude in Chrome runs `claude --chrome`| Claude Code exits at startup with `Claude in Chrome is blocked by your organization's managed MCP configuration (managed-mcp.json). An administrator can allow it with allowClaudeInChromeWithManagedMcp in device policy.`
The server is on a denylist and the user runs `claude mcp add`| `Cannot add MCP server "<name>": server is explicitly blocked by enterprise policy`
The server isn’t on the allowlist and the user runs `claude mcp add`| `Cannot add MCP server "<name>": not allowed by enterprise policy`
+[`strictPluginOnlyCustomization`](</docs/en/settings-reference#strictpluginonlycustomization>) is `true` or includes `mcp`, and the user runs `claude mcp add`| [`Cannot add MCP server: your organization's managed settings allow only MCP servers that plugins provide`](</docs/en/errors#cannot-add-mcp-server-when-managed-settings-allow-only-plugin-servers>)
The user runs `claude mcp remove` on a server from `managedMcpServers`| `MCP server "<name>" is provided by your organization (managed settings) and cannot be removed locally.`
A previously configured server is now blocked by policy| The server disappears from `/mcp` and `claude mcp list`
A server becomes blocked while a session is running, and the user selects **Reconnect** or turns it back on in `/mcp`| [`MCP server <name> is blocked by enterprise managed policy`](</docs/en/errors#mcp-server-is-blocked-by-enterprise-managed-policy>)
--- a/managed-settings.md
+++ b/managed-settings.md
@@ -141,7 +141,20 @@
3. Managed settings files, `managed-settings.d/*.json` and `managed-settings.json` merged together
4. The HKCU registry, on Windows, and on WSL once the HKLM registry or the Windows managed settings file turns [`wslInheritsWindowsSettings`](</docs/en/settings-reference#wslinheritswindowssettings>) on and the HKCU value also sets it. Claude Code reads it only when no admin document is present above it and no host-supplied parent settings supply a restrictive key
-Claude Code never applies the user-writable HKCU registry beneath an admin document that is present. A document is present when it sets any policy key to a value other than `null`, even a value Claude Code can’t read. An HKLM value, managed settings file, or `managed-settings.d` directory that exists but can’t be read is present too. On WSL, `/etc/claude-code` is user-writable as well, and the [`wslInheritsWindowsSettings`](</docs/en/settings-reference#wslinheritswindowssettings>) entry says when the Windows documents stand above it. This diagram shows the ranking, with examples of the cross-source keys Claude Code reads from the first three sources under either setting:
+This diagram shows the ranking, with examples of the cross-source keys Claude Code reads from the first three sources under either setting:
+
+###
+
+
+
+When an admin document counts as present
+
+In the ranking of managed sources, Claude Code never applies the user-writable HKCU registry beneath an admin document that is present. A document is present when:
+
+ * It sets any policy key to a value other than `null`, even a value Claude Code can’t read
+ * It is an HKLM value, managed settings file, or `managed-settings.d` directory that exists but can’t be read
+
+On WSL, `/etc/claude-code` is user-writable as well, and the [`wslInheritsWindowsSettings`](</docs/en/settings-reference#wslinheritswindowssettings>) entry says when the Windows documents stand above it.
###
@@ -397,7 +410,7 @@
[`strictPluginOnlyCustomization`](</docs/en/settings-reference#strictpluginonlycustomization>)| Block skills, agents, hooks, and MCP servers from user and project sources; `true` locks all four, an array names which
[`wslInheritsWindowsSettings`](</docs/en/settings-reference#wslinheritswindowssettings>)| When set in the HKLM registry or a file under `C:\Program Files\ClaudeCode`, have WSL read the Windows policy chain, and read `/etc/claude-code` only when no Windows admin document is present; the entry gives the order
-On Team and Enterprise plans, an Owner enables or disables [Remote Control](</docs/en/remote-control>) and [cloud sessions](</docs/en/claude-code-on-the-web>) organization-wide in [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>). Remote Control can additionally be disabled per device with the [`disableRemoteControl`](</docs/en/settings-reference#disableremotecontrol>) setting. Cloud sessions have no per-device managed settings key.To check whether these organization settings reached a given machine, run `claude doctor` there and read the `Organization policy` line, which says where Claude Code loaded the policy from or why it didn’t load. Requires Claude Code v2.1.261 or later. In a running session, `/status` shows the same line when the policy didn’t load.
+On Team and Enterprise plans, an Owner enables or disables [Remote Control](</docs/en/remote-control>) and [cloud sessions](</docs/en/claude-code-on-the-web>) organization-wide in [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>). When an Owner turns Remote Control off, already-connected sessions that run Claude Code v2.1.286 or later disconnect too. Each one disconnects the next time it refreshes your organization’s policy, about once an hour. For what happens in those sessions, see [`Remote Control was turned off by your organization's policy`](</docs/en/remote-control#remote-control-was-turned-off-by-your-organizations-policy>).Remote Control can additionally be disabled per device with the [`disableRemoteControl`](</docs/en/settings-reference#disableremotecontrol>) setting. Cloud sessions have no per-device managed settings key.To check whether these organization settings reached a given machine, run `claude doctor` there and read the `Organization policy` line, which says where Claude Code loaded the policy from or why it didn’t load. Requires Claude Code v2.1.261 or later. In a running session, `/status` shows the same line when the policy didn’t load.
##
Show diff (103 lines)
--- a/manifest-reference.md
+++ b/manifest-reference.md
@@ -126,10 +126,16 @@
`license`| String| SPDX identifier such as `MIT` or `Apache-2.0`
`keywords`| Array of strings| Discovery tags
`metadata`| Object| Free-form object for your own data. Claude Code doesn’t read it
+`icon`| String| Icon for the plugin’s listing in Anthropic’s directory. Claude Code doesn’t read it
+`documentationUrl`| String| Documentation link for the plugin’s listing in Anthropic’s directory. Claude Code doesn’t read it
+`supportUrl`| String| Support link for the plugin’s listing in Anthropic’s directory. Claude Code doesn’t read it
+`privacyPolicyUrl`| String| Privacy policy link for the plugin’s listing in Anthropic’s directory. Claude Code doesn’t read it
+`termsOfServiceUrl`| String| Terms of service link for the plugin’s listing in Anthropic’s directory. Claude Code doesn’t read it
`defaultEnabled`| Boolean| Whether the plugin starts enabled when the user hasn’t set it. Defaults to `true`
`dependencies`| Array of strings or objects| Plugins that must be enabled for this one to work
`settings`| Object| Settings Claude Code applies while the plugin is enabled. Only `agent` and `subagentStatusLine` take effect
`userConfig`| Object| Values Claude Code prompts the user for when the plugin is enabled
+`types`| Path| A `.d.ts` file that declares the `$.state` values and `$` nouns of a [mod](</docs/en/plugins/mods/reference#files>)
`channels`| Array of objects| Message channels the plugin provides, each bound to one of its MCP servers
`skills`| Path, or array of paths| Directories to scan for skills, each a directory of `<name>/SKILL.md` folders or one folder holding `SKILL.md` directly. `"."` names the plugin root. Adds to the default `skills/` scan
`commands`| Path, array of paths, or object| Flat `.md` command files, directories of them, or an object map of command name to `source` or `content`. Replaces the default `commands/` scan
@@ -152,7 +158,16 @@
`name`
-The plugin identifier. It must be non-empty, with no spaces, `@`, `:`, path separators, control characters, or bidirectional-formatting characters; use kebab-case. Claude Code namespaces every component under it, so an agent `reviewer` in plugin `deploy-tools` appears as `deploy-tools:reviewer`.
+The plugin identifier. It must be non-empty, with no spaces, `@`, `:`, path separators, control characters, or bidirectional-formatting characters; use kebab-case. Claude Code namespaces every component under it, so an agent `reviewer` in plugin `deploy-tools` appears as `deploy-tools:reviewer`. `claude plugin validate` also checks that the name doesn’t pass as one of Anthropic’s own plugins. The check ignores case and treats any run of separators as one:
+
+Name| Result
+---|---
+Starts with `claude-`, `anthropic-`, `anthropics-`, or `cc-plugin-`| Error
+Is `claude`, `anthropic`, `anthropics`, `claude-code`, or `claude-mods`| Error
+Puts `official` beside `claude` or `anthropic`, such as `official-claude-tools`| Error
+Has `claude`, `anthropic`, or `anthropics` as a whole word anywhere else, such as `mcp-for-claude`| Warning
+
+The error reads `Plugin name "<name>" is reserved: it passes as one of Anthropic's own`, and the warning reads `Plugin name "<name>" reads as one of Anthropic's own`. `claude plugin init` and `claude plugin tag` refuse a name that draws the error. Only these commands check the name. Claude Code still installs and loads a plugin whose name they refuse.
###
@@ -177,6 +192,14 @@
`metadata`
A free-form object for your own data, such as catalog or entitlement fields. Claude Code doesn’t read it. Requires Claude Code v2.1.222 or later.
+
+###
+
+
+
+Directory listing fields
+
+Anthropic’s directory reads the `icon`, `documentationUrl`, `supportUrl`, `privacyPolicyUrl`, and `termsOfServiceUrl` fields from `plugin.json` for your plugin’s listing when you [submit the plugin](</docs/en/plugins/publish#submit-to-anthropics-directory>). Claude Code ignores them at load time. Set them only in `plugin.json`. In a marketplace entry, `claude plugin validate` reports each one as an unknown field. Set `icon` to the path of an image file inside the plugin, such as `./logo.png`, and each of the four URL fields to an `https://` URL. `claude plugin validate` accepts these fields without a warning on Claude Code v2.1.281 or later. Earlier versions print an `Unknown field` warning for each one, so a `--strict` run fails on those versions.
###
@@ -256,7 +279,7 @@
`hooks`
-`hooks` takes a `.json` file path, an inline hooks object in the same shape as [`hooks` in `settings.json`](</docs/en/hooks#configuration>), or an array mixing both. For hook events and handler fields, see the [hooks reference](</docs/en/hooks#hook-events>). Claude Code merges whatever you declare with `hooks/hooks.json` when that file exists.
+`hooks` takes a `.json` file path, an inline hooks object in the same shape as [`hooks` in `settings.json`](</docs/en/hooks#configuration>), or an array mixing both. For hook events and handler fields, see the [hooks reference](</docs/en/hooks#hook-events>). A hooks file wraps the event map in a top-level `"hooks"` key, the shape [`hooks/hooks.json`](</docs/en/plugins/components#hooks>) uses. A file that contains only the event map, without that wrapper, fails to load. An inline object is the event map itself, with no wrapper. Claude Code merges whatever you declare with `hooks/hooks.json` when that file exists. This array loads one hooks file and declares one inline `PostToolUse` hook:
{
"hooks": [
@@ -272,6 +295,23 @@
]
}
]
+ }
+
+The file that array names carries the `"hooks"` wrapper around its own event map:
+
+config/extra-hooks.json
+
+ {
+ "hooks": {
+ "PreToolUse": [
+ {
+ "matcher": "Bash",
+ "hooks": [
+ { "type": "command", "command": "\"${CLAUDE_PLUGIN_ROOT}\"/scripts/check-command.sh" }
+ ]
+ }
+ ]
+ }
}
###
@@ -371,6 +411,8 @@
* **`skills`** : also accepts `"."`. Both `"."` and `"./"` denote the plugin root. Before v2.1.221, `"."` failed manifest validation, so use `"./"` when the plugin must load on earlier versions
* **`mcpServers`** : also accepts an `https://` bundle URL
+
+`experimental.evals` isn’t a component path, so the rules in this section don’t cover it, and `claude plugin eval` checks the value when it runs instead. It names a directory below the plugin root, such as `"quality/evals"`, with or without the `./` prefix. With an array, only the first entry is used. For what the value accepts and what happens with an unusable one, see [Use a different eval directory](</docs/en/plugin-evals#use-a-different-eval-directory>).
###
@@ -659,7 +701,7 @@
Marketplace entries and the manifest
-A [marketplace entry](</docs/en/plugins/marketplace-reference>) accepts every field on this page alongside [its own fields](</docs/en/plugins/marketplace-reference#plugin-entries>), including `strict`. The `strict` field decides whether the entry may add components to a plugin that has its own `plugin.json`. It defaults to `true`.
+A [marketplace entry](</docs/en/plugins/marketplace-reference>) accepts [its own fields](</docs/en/plugins/marketplace-reference#plugin-entries>), including `strict`, and every field on this page except the directory listing fields. The `strict` field decides whether the entry may add components to a plugin that has its own `plugin.json`. It defaults to `true`.
###
--- a/marketplace-reference.md
+++ b/marketplace-reference.md
@@ -67,7 +67,7 @@
Plugin entries
-Each object in the top-level `plugins` array of `marketplace.json` names a plugin and says where to fetch it. `name` and `source` are required. An entry also accepts every [`plugin.json` field](</docs/en/plugins/manifest-reference>), such as `description`, `version`, `author`, `commands`, and `hooks`. For when those fields apply, see How an entry combines with plugin.json. The table lists the entry’s own fields and the manifest fields whose meaning changes in an entry.
+Each object in the top-level `plugins` array of `marketplace.json` names a plugin and says where to fetch it. `name` and `source` are required. Apart from the [directory listing fields](</docs/en/plugins/manifest-reference#directory-listing-fields>), an entry also accepts every [`plugin.json` field](</docs/en/plugins/manifest-reference>), such as `description`, `version`, `author`, `commands`, and `hooks`. For when those fields apply, see How an entry combines with plugin.json. The table lists the entry’s own fields and the manifest fields whose meaning changes in an entry.
Field| Type| Description
---|---|---
@@ -94,7 +94,7 @@
The entry’s fields apply differently to a fetched plugin that has its own `.claude-plugin/plugin.json` and to one that doesn’t:
- * **No`plugin.json`**: the entry is the manifest regardless of `strict`. Every manifest field in the entry applies, including [`mcpServers`, `lspServers`, `userConfig`, and `channels`](</docs/en/plugins/manifest-reference>).
+ * **No`plugin.json`**: the entry is the manifest regardless of `strict`. Every manifest field that the entry accepts applies, including [`mcpServers`, `lspServers`, `userConfig`, and `channels`](</docs/en/plugins/manifest-reference>).
* **`plugin.json` present**: `plugin.json` is the manifest. Strict mode decides whether the entry’s six component fields, `commands`, `agents`, `skills`, `hooks`, `outputStyles`, and `themes`, are combined with it or rejected as a conflict. Entry `mcpServers`, `lspServers`, `userConfig`, and `channels` don’t apply. Declare them in `plugin.json`.
####
@@ -146,8 +146,8 @@
Relative path| the string itself| A directory inside the marketplace, resolved from the marketplace root. Must start with `./`, unless you write a bare name under `metadata.pluginRoot`. `"."` on its own means the root itself
`github`| `repo`, `ref`, `sha`| GitHub repository in `owner/repo` form
`url`| `url`, `ref`, `sha`| Any git repository by URL
-`git-subdir`| `url`, `path`, `ref`, `sha`| One subdirectory of a git repository, fetched with a sparse partial clone
-`npm`| `package`, `version`, `registry`| npm package, fetched with your npm client and unpacked without running install scripts
+`git-subdir`| `url`, `path`, `ref`, `sha`| One subdirectory of a git repository, fetched with a sparse checkout
+`npm`| `package`, `version`, `registry`| npm registry package or tarball link, fetched with your npm client and unpacked without running install scripts
`archive`| `url`, `sha256`| Zip archive over HTTPS. Requires Claude Code v2.1.224 or later
`command`| `command`, `timeout`, `mode`| Directory printed by a command Claude Code runs on the user’s machine. Requires Claude Code v2.1.229 or later
@@ -227,7 +227,7 @@
git-subdir plugin source
-`url` accepts a full git URL or GitHub `owner/repo` shorthand. `path` is the subdirectory that holds the plugin, and Claude Code downloads only that subdirectory.
+`url` accepts a full git URL or GitHub `owner/repo` shorthand. `path` is the subdirectory that holds the plugin, and Claude Code checks out only that subdirectory. Over an `https` or SSH URL, Claude Code asks the server for a partial clone, so from a host that supports partial clones, a plugin in a large monorepo installs without downloading the rest of the repository.
{
"name": "formatter",
@@ -246,11 +246,17 @@
An `npm` source takes these fields:
- * `package`: a package name, or a scoped name such as `@your-org/formatter`
- * `version`: a version or range
+ * `package`: a registry package name such as `@your-org/formatter`, a name with a version appended such as `@your-org/formatter@2.0.0`, or an `https` link to the package’s tarball file
+ * `version`: a version, a semver range, or a dist-tag, used when `package` is a package name with no version appended. Omit it to fetch `latest`
* `registry`: a registry URL for a package that isn’t on the default registry
-Claude Code fetches the package with your npm client. The package’s install scripts, such as `preinstall` or `postinstall`, never run, and its dependencies aren’t installed during the fetch. If the package has a supported lockfile beside its `package.json`, Claude Code installs those [Node.js package dependencies](</docs/en/plugins/loading#node-js-package-dependencies>) in a separate step, also with scripts disabled.
+Claude Code fetches the package with your npm client. The package’s install scripts, such as `preinstall` or `postinstall`, never run, and its dependencies aren’t installed during the fetch. If the package has a supported lockfile beside its `package.json`, Claude Code installs those [Node.js package dependencies](</docs/en/plugins/loading#node-js-package-dependencies>) in a separate step, also with scripts disabled. Claude Code checks the `package` value before fetching anything. A refused value fails the install with a message that names the value and the reason. The refused values include:
+
+ * **A git address, a folder or`file:` path, or an `npm:` alias**: use a `github`, `url`, or `git-subdir` source for a git repository, a relative path for a folder in the marketplace, and the package’s own name for an alias
+ * **A tarball link on github.com, gist.github.com, gitlab.com, bitbucket.org, or git.sr.ht** : refused even when the link is a GitHub release download, unless it’s a GitLab npm registry link under `gitlab.com/api/v4/`
+ * **A tarball link over`http`**: refused unless it points at the installing user’s own default npm registry
+
+The `registry` URL must use `https` unless it is the installing user’s own default npm registry. With any other `http` registry, the install fails before npm contacts it.
{
"name": "formatter",
@@ -468,6 +474,8 @@
`Author name cannot be empty`| Error| `owner.name`
`Plugin name cannot contain spaces. Use kebab-case (e.g., "my-plugin")`| Error| `plugins[i].name`
`Plugin name cannot contain control or bidirectional-formatting characters`| Error| `plugins[i].name`
+`Plugin name "x" is reserved: it passes as one of Anthropic's own`| Error| `plugins[i].name`. See the manifest’s [`name`](</docs/en/plugins/manifest-reference#name>) for the reserved names
+`Plugin name "x" reads as one of Anthropic's own`| Warning| `plugins[i].name`
`Claude Code cannot install plugins from marketplace "x". Each part of a plugin id (plugin@marketplace) may use only the letters a-z and A-Z, digits, ".", "_" and "-", and must start with a letter or digit. Change the marketplace's "name".`| Error| `name`
`Claude Code cannot install plugin "x". Each part of a plugin id (plugin@marketplace) may use only the letters a-z and A-Z, digits, ".", "_" and "-", and must start with a letter or digit. Change this entry's "name".`| Error| `plugins[i].name`
`Duplicate plugin name "x" found in marketplace`| Error| Two entries share a `name`
--- a/memory.md
+++ b/memory.md
@@ -137,7 +137,7 @@
How CLAUDE.md files load
-Claude Code loads `CLAUDE.md` and `CLAUDE.local.md` from your current working directory and every directory above it. Run Claude Code in `foo/bar/` and it loads instructions from `foo/bar/CLAUDE.md`, `foo/CLAUDE.md`, and any `CLAUDE.local.md` files alongside them. All discovered files are concatenated into context rather than overriding each other. Across the directory tree, content is ordered from the filesystem root down to your working directory. For the `foo/bar/` example, `foo/CLAUDE.md` appears in context before `foo/bar/CLAUDE.md`, so instructions closer to where you launched Claude are read last. Within each directory, `CLAUDE.local.md` is appended after `CLAUDE.md`, so your personal notes are the last thing Claude reads at that level. Claude also discovers `CLAUDE.md` and `CLAUDE.local.md` files in subdirectories under your current working directory. Instead of loading them at launch, they are included when Claude reads files in those subdirectories. If you work in a large monorepo where other teams’ CLAUDE.md files get picked up, use `claudeMdExcludes` to skip them. For the full layout of root and per-directory CLAUDE.md files and rules, see [Monorepos and large repos](</docs/en/large-codebases>). Block-level HTML comments (`<!-- maintainer notes -->`) in CLAUDE.md files are stripped before the content is injected into Claude’s context. Use them to leave notes for human maintainers without spending context tokens on them. Comments inside code blocks are preserved. When you open a CLAUDE.md file directly with the Read tool, comments remain visible.
+Claude Code loads `CLAUDE.md` and `CLAUDE.local.md` from your current working directory and every directory above it. Run Claude Code in `foo/bar/` and it loads instructions from `foo/bar/CLAUDE.md`, `foo/CLAUDE.md`, and any `CLAUDE.local.md` files alongside them. All discovered files are concatenated into context rather than overriding each other. Across the directory tree, content is ordered from the filesystem root down to your working directory. For the `foo/bar/` example, `foo/CLAUDE.md` appears in context before `foo/bar/CLAUDE.md`, so instructions closer to where you launched Claude are read last. Within each directory, `CLAUDE.local.md` is appended after `CLAUDE.md`, so your personal notes are the last thing Claude reads at that level. Claude also discovers `CLAUDE.md` and `CLAUDE.local.md` files in subdirectories under your current working directory. Instead of loading them at launch, they are included when Claude reads files in those subdirectories. For files inside a worktree under `.claude/worktrees/`, see [Isolate subagents with worktrees](</docs/en/worktrees#isolate-subagents-with-worktrees>). If you work in a large monorepo where other teams’ CLAUDE.md files get picked up, use `claudeMdExcludes` to skip them. For the full layout of root and per-directory CLAUDE.md files and rules, see [Monorepos and large repos](</docs/en/large-codebases>). Block-level HTML comments (`<!-- maintainer notes -->`) in CLAUDE.md files are stripped before the content is injected into Claude’s context. Use them to leave notes for human maintainers without spending context tokens on them. Comments inside code blocks are preserved. When you open a CLAUDE.md file directly with the Read tool, comments remain visible.
####
@@ -198,7 +198,7 @@
- Use the standard error response format
- Include OpenAPI documentation comments
-Rules without a `paths` field are loaded unconditionally and apply to all files. Path-scoped rules trigger when Claude reads files matching the pattern, not on every tool use. As of v2.1.198, matching also works when Claude reaches a file through a symlinked path to the project directory, for example in a symlinked checkout. Use glob patterns in the `paths` field to match files by extension, directory, or any combination:
+Rules without a `paths` field are loaded unconditionally and apply to all files. Path-scoped rules trigger when Claude reads files matching the pattern, not on every tool use. Matching also works when Claude reaches a file through a symlinked path to the project directory, for example in a symlinked checkout. Use glob patterns in the `paths` field to match files by extension, directory, or any combination:
Pattern| Matches
---|---
@@ -496,7 +496,12 @@
Enable or disable auto memory
-Auto memory is on by default. To toggle it, open `/memory` in a session and use the auto memory toggle, which saves `autoMemoryEnabled` to your user settings at `~/.claude/settings.json`. To turn it off for a single project, set `autoMemoryEnabled` in that project’s settings:
+Auto memory is on by default in local sessions. Outside [Claude Tag](<https://claude.com/docs/claude-tag/overview>) sessions, a session in a [self-hosted environment](</docs/en/self-hosted-environments-configuration#how-each-session%E2%80%99s-config-is-assembled>) runs with auto memory off by default. To toggle it, open `/memory` in a session and use the auto memory toggle, which saves `autoMemoryEnabled` to your user settings at `~/.claude/settings.json`. The toggle turns auto memory off but doesn’t turn it back on in these sessions:
+
+ * A [background session](</docs/en/agent-view>)
+ * A session that another Claude Code session started, such as when Claude runs `claude` through its Bash tool
+
+While auto memory is off there, the toggle reads `off · can't be turned on here; use a session started outside Claude Code`. To turn auto memory back on, run `claude` directly in your terminal and use the `/memory` toggle in that session. To turn it off for a single project, set `autoMemoryEnabled` in that project’s settings:
{
"autoMemoryEnabled": false
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -77,6 +77,8 @@
# Or provide the full base URL:
# export ANTHROPIC_FOUNDRY_BASE_URL=https://{resource}.services.ai.azure.com/anthropic
+Set `ANTHROPIC_FOUNDRY_RESOURCE` to the resource name alone, such as `my-resource`. Claude Code [refuses a URL or host name](</docs/en/errors#anthropic-foundry-resource-must-be-a-foundry-resource-name>) when you send a message.
+
###
--- a/model-config.md
+++ b/model-config.md
@@ -204,7 +204,7 @@
* **Fallback model chains** : entries outside the allowlist are dropped
* **Plan-mode upgrades** : on the Anthropic API and Claude Platform on AWS, an upgrade such as `opusplan` to an excluded model uses the newest permitted version of the upgrade family. On providers with provider-specific model IDs, and when no version is permitted, the upgrade is skipped and planning continues on the session’s model
* **Automatic model fallback** : a fallback whose target is excluded does not run, so the flagged request ends with a refusal instead
- * **[Auto mode classifier](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>)** : the classifier’s Claude Sonnet 5 default applies only when the allowlist permits Sonnet 5. When it’s excluded, the classifier runs on the session’s model, which the allowlist already governs, or on an Opus model when the session runs on a Fable model. On providers other than the Anthropic API, that Opus fallback runs on the provider’s default Opus model without consulting the allowlist. Requires Claude Code v2.1.210 or later
+ * **[Auto mode classifier](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>)** : the classifier’s Claude Sonnet 5 default applies only when the allowlist permits Sonnet 5. When it’s excluded, the classifier runs on the session’s model, which the allowlist already governs, or on an Opus model when the session runs on a Fable model. On providers other than the Anthropic API, that Opus fallback runs on the model you set in `ANTHROPIC_DEFAULT_OPUS_MODEL` or otherwise on Opus 5, without consulting the allowlist. Requires Claude Code v2.1.210 or later
* **[Fast mode](</docs/en/fast-mode>)** : enabling fast mode is refused when the model the session would run on afterward is outside the allowlist
{
@@ -351,7 +351,7 @@
* a `model` value in [managed settings](</docs/en/managed-settings>) or supplied through `--settings`
* a `model` value in your user, project, or local settings, including a model you save with `/model`
-Admins can also configure the organization default to override user selection. With override on, it takes precedence over the `model` value in user, project, and local settings, so a model you save with `/model` applies for the current session and the organization default returns on the next launch. When your selection differs, `/model` shows `Your organization's default (<model>) applies on restart`. The `--model` flag, `ANTHROPIC_MODEL`, managed settings, and `--settings` still take precedence even with override on. Override is available to a limited set of organizations; ask your Anthropic account team about availability. To limit which models members can select, use organization model restrictions or `availableModels` instead. Claude Code reads the organization default once at startup, so a default the admin changes mid-session takes effect on the next launch. When the organization default doesn’t override user selection, the first interactive launch after the admin changes it clears the `model` key from your user settings once, so the new default applies. It changes nothing else in the file, and a model you save with `/model` after that launch is kept. The organization default passes through these restriction checks before it is adopted:
+Admins can also configure the organization default to override user selection. With override on, it takes precedence over the `model` value in user, project, and local settings, so a model you save with `/model` applies for the current session and the organization default returns on the next launch. When your selection differs, `/model` shows `Your organization's default (<model>) applies on restart`. The `--model` flag, `ANTHROPIC_MODEL`, managed settings, and `--settings` still take precedence even with override on. To limit which models members can select, use organization model restrictions or `availableModels` instead. Claude Code reads the organization default once at startup, so a default the admin changes mid-session takes effect on the next launch. When the organization default doesn’t override user selection, the first interactive launch after the admin changes it clears the `model` key from your user settings once, so the new default applies. It changes nothing else in the file, and a model you save with `/model` after that launch is kept. The organization default passes through these restriction checks before it is adopted:
* With the default prefix matching, `availableModels` on its own doesn’t apply to the organization default, so an organization default outside the allowlist still applies. When `enforceAvailableModels` is also set, an organization default outside the allowlist is remapped to the first allowlist entry as well
* an organization default that organization model restrictions deny for your account is replaced by the newest allowed model in its family, or a lower-cost family when every version of it is restricted
@@ -437,6 +437,20 @@
* **Opus 5** : cybersecurity-flagged requests re-run on Opus 4.8. Biology-flagged requests end with a refusal instead, because Opus 5 runs its own biology classifiers with no fallback model.
On Amazon Bedrock, Google Cloud’s Agent Platform, and Microsoft Foundry, Claude Code resolves these targets through your deployment’s model IDs instead. See Enable fallback on Bedrock, Agent Platform, and Foundry. After a fallback, the session continues on the fallback model. To return to your original model, run `/model`. Category-based fallback requires Claude Code v2.1.219 or later. Before v2.1.219, every flagged Fable 5 request re-ran on your provider’s default Opus model, and Opus 5 was not a fallback source. The fallback model is checked against `availableModels`. When it is blocked, no fallback occurs. The refusal is shown as a normal error and the session’s model is unchanged.
+
+####
+
+
+
+Effort level after a fallback
+
+When Claude Code switches your session to the fallback model, it keeps the effort level the flagged request ran at in place of that model’s default effort. For example, a session on Opus 5.5 at its default `medium` that falls back to Opus 4.8 stays at `medium`, although Opus 4.8 defaults to `high`. A different level applies in cases such as these:
+
+ * **Settings or organization default** : a level in your settings that applies to the fallback model, or a default effort your organization set for it, applies instead.
+ * **Your own change** : once you choose an effort level, pick a model in `/model`, or resume the session later, the flagged request’s level no longer carries over.
+ * **Skill effort** : a level that a skill’s `effort` frontmatter set for the flagged request applies to that turn, and later turns run at the level the effort resolution order gives the fallback model.
+
+The session header shows the level in effect next to the model name. To change it, run `/effort` in the session.
####
@@ -504,7 +518,7 @@
1. An explicit choice: the [`CLAUDE_CODE_EFFORT_LEVEL`](</docs/en/env-vars#variables>) environment variable, launching with `--effort`, or `/effort` in the session (a non-interactive `/effort` has narrower effect)
2. Your settings: the level you saved for the model or an [`effortLevel`](</docs/en/settings-reference#effortlevel>) key, with the precedence between them and across settings files stated at [`modelSettings`](</docs/en/settings-reference#modelsettings>)
- 3. The model’s default effort: `high` on every model that supports effort, except that Opus 5.5 and Sonnet 5.5 default to `medium`, Opus 4.7 defaults to `xhigh`, and, when your organization sets a default effort level for its organization default model, that level is the default when you run that model
+ 3. The model’s default effort: `high` on every model that supports effort, except that Opus 5.5 and Sonnet 5.5 default to `medium`, Opus 4.7 defaults to `xhigh`, and, when your organization sets a default effort level for its organization default model, that level is the default when you run that model. After an automatic model fallback, see Effort level after a fallback for the level that applies.
Opus 5.5 starts at `medium` unless one of the sources above sets a level for it, and a top-level `effortLevel` in your user settings file doesn’t count for Opus 5.5. That key is the older form `/effort` wrote before Claude Code saved levels per model: it keeps applying where it applied before, on Opus 5, Fable 5.1, and earlier models, while Opus 5.5 and models released after it start at their own default until you choose a level for them with `/effort` or the `/model` picker. A top-level `effortLevel` in project, local, or managed settings, or one passed with `--settings`, applies to every model. When you set `low`, `medium`, `high`, or `xhigh` in an interactive session on your machine, you choose how long it lasts by how you confirm it:
--- a/monitoring-usage.md
+++ b/monitoring-usage.md
@@ -221,7 +221,7 @@
`duration_ms`| Wall-clock duration including retries|
`ttft_ms`| Time to first token in milliseconds|
`first_content_ms`| Time from request start to the first content block of the successful attempt, in milliseconds. Absent on requests that fell back to the non-streaming path. Requires Claude Code v2.1.268 or later|
-`input_tokens`| Input token count from the API usage block|
+`input_tokens`| Input token count from the API usage block. Excludes tokens read from or written to the prompt cache, which are reported in `cache_read_tokens` and `cache_creation_tokens`|
`output_tokens`| Output token count|
`cache_read_tokens`| Tokens read from prompt cache|
`cache_creation_tokens`| Tokens written to prompt cache|
@@ -263,7 +263,7 @@
* A call to any tool other than Read, Edit, Write, Bash, WebFetch, WebSearch, and MCP tools
* A Read that returns anything other than file text, such as an image, a PDF, or a re-read of a file whose contents haven’t changed
* An Edit or Write call, unless you also set `OTEL_LOG_TOOL_DETAILS=1`
- * A WebFetch or WebSearch call that Claude Code moved to the background because you interrupted the turn to [send your queued messages right away](</docs/en/interactive-mode#when-claude-code-sends-what-you-queued>) while the call ran. Claude receives that result later, after the tool span has ended
+ * A WebFetch or WebSearch call that Claude Code moved to the background while it ran so that a waiting message could reach Claude. The result that arrives later isn’t recorded either. To learn when Claude Code moves a call, see [When Claude Code sends what you queued](</docs/en/interactive-mode#when-claude-code-sends-what-you-queued>) for the terminal and the [`priority` field](</docs/en/agent-sdk/typescript#sdkusermessage>) for Agent SDK sessions
The event carries these attributes, each truncated at the content limit (60 KB by default). `Gated by` names the variable an attribute needs on top of `OTEL_LOG_TOOL_CONTENT=1`, and for Edit and Write that variable gates the event itself rather than the attribute.
@@ -635,7 +635,7 @@
Incremented after each API request. **Attributes** :
* All standard attributes
- * `type`: (`"input"`, `"output"`, `"cacheRead"`, `"cacheCreation"`)
+ * `type`: (`"input"`, `"output"`, `"cacheRead"`, `"cacheCreation"`). The `"input"` type excludes tokens read from or written to the prompt cache, which are counted under `"cacheRead"` and `"cacheCreation"`
* `model`: Model identifier (for example, “claude-sonnet-5”)
* `query_source`: Category of the subsystem that issued the request. One of `"main"`, `"subagent"`, or `"auxiliary"`
* `speed`: `"fast"` when the request used fast mode. Absent otherwise
@@ -782,7 +782,7 @@
* `cost_usd`: Estimated cost in USD
* `cost_usd_micros`: Estimated cost in millionths of a US dollar, emitted as an integer
* `duration_ms`: Request duration in milliseconds
- * `input_tokens`: Number of input tokens
+ * `input_tokens`: Number of input tokens, excluding tokens read from or written to the prompt cache
* `output_tokens`: Number of output tokens
* `cache_read_tokens`: Number of tokens read from cache
* `cache_creation_tokens`: Number of tokens used for cache creation
@@ -1325,7 +1325,7 @@
Metric| Analysis Opportunity
---|---
-`claude_code.token.usage`| Break down by `type` (input/output), user, team, model, `skill.name`, `plugin.name`, or `agent.name`
+`claude_code.token.usage`| Break down by token `type`, user, team, model, `skill.name`, `plugin.name`, or `agent.name`
`claude_code.session.count`| Track adoption and engagement over time
`claude_code.lines_of_code.count`| Measure productivity by tracking code additions and removals, broken down by model
`claude_code.commit.count` & `claude_code.pull_request.count`| Understand impact on development workflows
@@ -1382,6 +1382,27 @@
* Error patterns by tool type
**Performance monitoring** : track API request durations and tool execution times to identify performance bottlenecks.
+
+###
+
+
+
+Map input tokens to OpenTelemetry GenAI semantic conventions
+
+Claude Code exports input token counts as they appear in the API response’s usage block, so these values exclude tokens read from or written to the [prompt cache](</docs/en/prompt-caching>):
+
+ * `input_tokens` on the `claude_code.llm_request` span and the `api_request` event
+ * The `"input"` type of the `claude_code.token.usage` metric
+
+Claude Code doesn’t set `gen_ai.usage.*` attributes. The [OpenTelemetry GenAI semantic conventions](<https://github.com/open-telemetry/semantic-conventions-genai>) say `gen_ai.usage.input_tokens` should include tokens read from and written to the cache. To compute that total:
+
+ * From the span or event: add `input_tokens`, `cache_read_tokens`, and `cache_creation_tokens`
+ * From the `claude_code.token.usage` metric: add its `"input"`, `"cacheRead"`, and `"cacheCreation"` types
+
+The conventions also define separate attributes for cache reads and cache writes:
+
+ * `cache_read_tokens` maps to `gen_ai.usage.cache_read.input_tokens`
+ * `cache_creation_tokens` maps to `gen_ai.usage.cache_write.input_tokens`. Older versions of the conventions name the cache write attribute `gen_ai.usage.cache_creation.input_tokens`, so use the name your backend expects.
##
--- a/network-config.md
+++ b/network-config.md
@@ -235,7 +235,15 @@
Desktop and claude.ai
-The preceding table covers the standalone CLI. The Claude Desktop app and claude.ai in a browser load their application code and user content from additional Anthropic CDN hosts, including `assets-proxy.anthropic.com` and the other `*.claudeusercontent.com` origins that serve [artifacts](</docs/en/artifacts>) in those apps. Allowing `claude.ai` while blocking those hosts produces a blank page rather than an error. See [network access requirements](</docs/en/desktop#network-access-requirements>) on the Desktop page. An [artifact](</docs/en/artifacts>) that loads a typeface from [Google Fonts](</docs/en/artifacts#improve-the-visual-design>) also requests `fonts.googleapis.com` and `fonts.gstatic.com`. Both hosts are optional. If you block them, artifacts render in fallback typefaces. Block with a fast rejection rather than a silent drop so the font request fails immediately instead of delaying the page’s first render. Artifacts can also load JavaScript libraries, such as React or a charting package, from `cdnjs.cloudflare.com`, `cdn.jsdelivr.net`, `cdn.tailwindcss.com`, `code.jquery.com`, and `unpkg.com`, and from no other external host. If you block those hosts, the parts of an artifact that depend on a library don’t work, and unlike a blocked font, a blocked library has no fallback. Block with a fast rejection here too, so a blocked library request fails at once rather than hanging until it times out.
+The preceding table covers the standalone CLI. The Claude Desktop app and claude.ai in a browser load their application code and user content from additional Anthropic CDN hosts, including `assets-proxy.anthropic.com` and the other `*.claudeusercontent.com` origins that serve [artifacts](</docs/en/artifacts>) in those apps. Allowing `claude.ai` while blocking those hosts produces a blank page rather than an error. See [network access requirements](</docs/en/desktop#network-access-requirements>) on the Desktop page. Claude Desktop and claude.ai also render some tool results inside a conversation as interactive widgets, such as the [MCP Apps](<https://claude.com/docs/connectors/building/mcp-apps/getting-started>) some connectors provide. Those widgets load from generated subdomains of `claudemcpcontent.com`, so allow `*.claudemcpcontent.com` with the wildcard intact. If you block it, the rest of the app keeps working, but those widgets don’t load.
+
+####
+
+
+
+Third-party hosts for artifact fonts and libraries
+
+An [artifact](</docs/en/artifacts>) that loads a typeface from [Google Fonts](</docs/en/artifacts#improve-the-visual-design>) also requests `fonts.googleapis.com` and `fonts.gstatic.com`. Both hosts are optional. If you block them, artifacts render in fallback typefaces. Block with a fast rejection rather than a silent drop so the font request fails immediately instead of delaying the page’s first render. Artifacts can also load JavaScript libraries, such as React or a charting package, from `cdnjs.cloudflare.com`, `cdn.jsdelivr.net`, `cdn.tailwindcss.com`, `code.jquery.com`, and `unpkg.com`, and from no other external host. If you block those hosts, the parts of an artifact that depend on a library don’t work, and unlike a blocked font, a blocked library has no fallback. Block with a fast rejection here too, so a blocked library request fails at once rather than hanging until it times out.
##
--- a/org.md
+++ b/org.md
@@ -194,12 +194,14 @@
`pluginTrustMessage`| Appends your text to the trust warning that `/plugin` shows before a plugin installs| Doesn’t change the warning’s own text
`allowedChannelPlugins`| Replaces the default list of plugins allowed to push channel messages. Requires `channelsEnabled: true`| See [Restrict which channel plugins can run](</docs/en/channels#restrict-which-channel-plugins-can-run>)
[`CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL=1`](</docs/en/env-vars>)| Stops interactive terminal sessions from auto-registering the official marketplace| Doesn’t remove a marketplace already registered. The allowlist and blocklist gate the same auto-registration without it. A machine that started once with it set doesn’t resume auto-registration after you unset it
-
-Every key in the table is a managed setting, apart from `enabledPlugins`, `syncClaudeAiPlugins`, and `CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL`:
+[`allowManagedModsOnly`](</docs/en/plugins/mods/admin#stop-user-installed-mods-from-loading>)| Stops every installed [mod](</docs/en/plugins/mods/overview>) that doesn’t [count as your organization’s](</docs/en/plugins/mods/admin#install-your-organizations-mods>) from loading| Doesn’t stop a plugin that contains a mod from installing. For that, use the marketplace keys in this table
+
+Every key in the table is a managed setting, apart from `enabledPlugins`, `syncClaudeAiPlugins`, `CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL`, and `allowManagedModsOnly`:
* **`enabledPlugins`** : you can set it in any scope, and managed settings lock it.
* **`syncClaudeAiPlugins`** : each user can also set it in their own user or local settings. See its [scope in the settings reference](</docs/en/settings-reference#syncclaudeaiplugins>).
* **`CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL`** : this is an environment variable that you deliver through the managed `env` block shown under Turn updates off for the whole fleet.
+ * **`allowManagedModsOnly`** : this is an option on a built-in plugin, which you set under `pluginConfigs` in managed settings. See [Stop user-installed mods from loading](</docs/en/plugins/mods/admin#stop-user-installed-mods-from-loading>).
Each settings key here has an entry in the [settings reference](</docs/en/settings-reference>).
@@ -453,5 +455,6 @@
* [Marketplace reference](</docs/en/plugins/marketplace-reference#marketplace-sources>): the `source` values `extraKnownMarketplaces`, `strictKnownMarketplaces`, and `blockedMarketplaces` accept
* [Host and maintain a marketplace](</docs/en/plugins/host-marketplace>): run the marketplace your policy points at
* [Plugin security and trust](</docs/en/plugins/security>): what a plugin can do on a machine and how to review one before installing
+ * [Manage mods for your organization](</docs/en/plugins/mods/admin>): turn off or limit mods, the plugins that run JavaScript inside Claude Code
* [Server-managed settings](</docs/en/server-managed-settings>): deliver these keys from the claude.ai admin console
* [Troubleshoot plugins](</docs/en/plugins/troubleshooting#blocked-by-your-organization>): the messages users see when policy blocks them
--- a/permission-modes.md
+++ b/permission-modes.md
@@ -123,7 +123,9 @@
* Web and mobile
-**During a session** : press `Shift+Tab` to cycle permission modes. From `auto`, the first press switches to `default`, and the cycle then runs `default` → `acceptEdits` → `plan` → back to `default`. Optional modes, described below, slot in after `plan`. The status bar shows the active mode as a gray `⏸ manual mode on` for `default`, or as `⏵⏵ accept edits on`, `⏸ plan mode on`, `⏵⏵ auto mode on`, `⏵⏵ don't ask on`, or `⏵⏵ bypass permissions on`.Not every mode is in the default cycle:
+**During a session** : press `Shift+Tab` to cycle permission modes. From `auto`, the first press switches to `default`, and the cycle then runs `default` → `acceptEdits` → `plan`. Optional modes slot in after `plan`. The status bar shows the active mode as a gray `⏸ manual mode on` for `default`, or as `⏵⏵ accept edits on`, `⏸ plan mode on`, `⏵⏵ auto mode on`, `⏵⏵ don't ask on`, or `⏵⏵ bypass permissions on`.Watch the status bar in this clip of a session that started in auto mode. Each time you press `Shift+Tab`, it changes from `auto mode on` to `manual mode on`, `accept edits on`, `plan mode on`, and back to `auto mode on`.
+
+Not every mode is in the default cycle:
* `auto`: appears when auto mode is available; cycling to it switches permission modes without a confirmation prompt
* `bypassPermissions`: appears after you start with `--permission-mode bypassPermissions`, `--dangerously-skip-permissions`, `--allow-dangerously-skip-permissions`, or `permissions.defaultMode: "bypassPermissions"` in [user, `--settings`, or managed settings](</docs/en/settings-reference#permissions-defaultmode>). The `--allow-` variant adds the permission mode to the cycle without activating it
@@ -260,7 +262,7 @@
In auto mode, Claude Code can ask the server to check the actions that the decision order sends for review, as part of the session’s model requests, in place of sending its own classifier requests. These sessions ask:
- * **A direct connection to the Anthropic API** : in an interactive terminal session, on every claude.ai plan and on accounts that use the Claude API, as Anthropic rolls it out. Requires Claude Code v2.1.271 or later on Pro, Max, and Team plans, and v2.1.278 or later on Enterprise plans and Claude API accounts. From v2.1.282, a session that [doesn’t fetch feature flags](</docs/en/env-vars#features-that-need-feature-flag-fetching>), for example because you turned telemetry off, asks the server by default in any kind of session.
+ * **A direct connection to the Anthropic API** : in interactive terminal sessions and in `-p`, Agent SDK, [VS Code extension](</docs/en/vs-code>), and [desktop app](</docs/en/desktop>) sessions, whatever your plan or account type, as Anthropic rolls it out. In interactive terminal sessions, this requires Claude Code v2.1.271 or later on Pro, Max, and Team plans, and v2.1.278 or later on Enterprise plans and Claude API accounts. In `-p`, Agent SDK, VS Code extension, and desktop app sessions, this requires Claude Code v2.1.281 or later. From v2.1.282, a session that [doesn’t fetch feature flags](</docs/en/env-vars#features-that-need-feature-flag-fetching>), for example because you turned telemetry off, asks the server by default in any kind of session.
* **A cloud provider, or an LLM gateway or proxy** : on [Claude Platform on AWS](</docs/en/claude-platform-on-aws>), Amazon Bedrock, Google Cloud’s Agent Platform, and Microsoft Foundry, and whenever you point `ANTHROPIC_BASE_URL` at an [LLM gateway or proxy](</docs/en/llm-gateway>), whatever your plan. Asking by default requires Claude Code v2.1.278 or later.
* **A signed-in[Claude apps gateway](</docs/en/claude-apps-gateway>) session**: requires Claude Code v2.1.280 or later
@@ -269,7 +271,7 @@
* **The server doesn’t review the session** : a response completes with no review results, or the server answers that it doesn’t review this session. The most common causes are an LLM gateway or proxy that drops the request for review or the results, and a platform, region, or credential that doesn’t have server-side checks yet. Claude Code falls back to its own classifier requests. Once that fallback holds for the rest of the session, it shows a [notice about classifier request charges](</docs/en/auto-mode-classifier-billing>) on accounts where those requests are billed.
* **The server gives no verdict for an action** : Claude Code denies the action rather than run it unreviewed. On any connection, this happens when the response ends before the review results arrive or the results arrive in a form Claude Code can’t read. An LLM gateway or proxy that cuts responses short or rewrites the results can cause either. On a direct connection to the Anthropic API, it also happens when the server’s check fails for the action, for example by timing out. [The server returned no safety verdict](</docs/en/errors#the-server-returned-no-safety-verdict>) covers the denial message, what happens when denials repeat, and what to do.
-To skip asking the server and always use Claude Code’s own classifier requests, set [`CLAUDE_CODE_AUTO_MODE_SERVER=0`](</docs/en/env-vars>). On a direct connection to the Anthropic API, the variable requires Claude Code v2.1.281 or later. Setting it to `1` there turns server review on in a session that doesn’t have it yet, such as a `-p` or Agent SDK session, unless you’ve also set `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`. If you set `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1` and leave `CLAUDE_CODE_AUTO_MODE_SERVER` unset, Claude Code also stops asking the server, except as [Disable pre-release capabilities](</docs/en/llm-gateway-protocol#disable-pre-release-capabilities>) describes.
+To skip asking the server and always use Claude Code’s own classifier requests, set [`CLAUDE_CODE_AUTO_MODE_SERVER=0`](</docs/en/env-vars>). On a direct connection to the Anthropic API, the variable requires Claude Code v2.1.281 or later. Setting it to `1` there turns server review on in a session that doesn’t have it yet, unless you’ve also set `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`. If you set `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1` and leave `CLAUDE_CODE_AUTO_MODE_SERVER` unset, Claude Code also stops asking the server, except as [Disable pre-release capabilities](</docs/en/llm-gateway-protocol#disable-pre-release-capabilities>) describes.
###
@@ -302,19 +304,16 @@
* Interactive shells or port-forwards into a sensitive remote target
* Opening a tunnel or reverse shell that makes a local service reachable from the public internet
* Printing a live credential or token into the transcript or a file
- * Accessing a location listed as a sensitive data location in your [environment](</docs/en/auto-mode-config#define-trusted-infrastructure>), or copying data out of one. As of v2.1.198 this also blocks sending data from one to an audience the entry excludes
- * Routing a package install around your internal package registry to a public registry. As of v2.1.198, this also applies when you’ve told Claude an internal registry or mirror exists in the conversation, not only when one is listed in your environment
+ * Accessing a location listed as a sensitive data location in your [environment](</docs/en/auto-mode-config#define-trusted-infrastructure>), copying data out of one, or sending data from one to an audience the entry excludes
+ * Routing a package install around your internal package registry to a public registry. This applies when an internal registry or mirror is listed in your environment or when you’ve told Claude in the conversation that one exists
* Running a command with a flag that disarms a safety guard, like `--insecure`
- * Launching an autonomous agent loop that runs without human approval or a sandbox, such as one started with `--dangerously-skip-permissions` or `--no-sandbox`. As of v2.1.198 this also covers running a third-party agent or eval harness with isolation and per-action approval disabled, such as a runner started with `--yes-always`
+ * Launching an autonomous agent loop that runs without human approval or a sandbox, such as one started with `--dangerously-skip-permissions` or `--no-sandbox`. This includes running a third-party agent or eval harness with isolation and per-action approval disabled, such as a runner started with `--yes-always`
* [Claude in Chrome](</docs/en/chrome>) browser actions that could send page content, cookies, or credentials off-origin
-
-Several of these categories depend on [environment](</docs/en/auto-mode-config#define-trusted-infrastructure>) entries, such as sensitive remote targets and protected IaC scopes, that you can narrow to concrete names. Claude Code v2.1.198 and later also block these by default:
-
* Deleting files in `/tmp`, `$TMPDIR`, or another shared scratch or cache directory by wildcard, glob, or age filter rather than by a specific named path
* Including sensitive details in content sent, uploaded, published, or written to other people or shared systems, when your own message didn’t authorize those details for that recipient. PR and issue bodies, commit messages, and comments count as this kind of outbound content when the repository is outside the trust boundary or public, including your organization’s own public repositories; internal file paths, code names, live API response data such as emails or account identifiers, and infrastructure identifiers count as sensitive details. The PR, issue, and commit-message scoping requires Claude Code v2.1.200 or later. Live personal data from an API response in a PR or issue body, such as an email address, an account or organization identifier, or a usage metric, requires you to name those details and the recipient regardless of the repository’s visibility or trust boundary. That check requires Claude Code v2.1.203 or later
* Sending keystrokes to Claude Code’s own tmux pane to drive its own interface, which the classifier treats as Claude changing its own permissions or oversight
-Claude Code v2.1.200 and later also block these by default:
+Several of these categories depend on [environment](</docs/en/auto-mode-config#define-trusted-infrastructure>) entries, such as sensitive remote targets and protected IaC scopes, that you can narrow to concrete names. Claude Code v2.1.200 and later also block these by default:
* Commenting out, deleting, or force-passing a test or assertion that guards security behavior, such as auth, access control, input validation, or sandboxing
* Deleting or tearing down a stateful resource Claude didn’t create in the session, when no more specific deletion rule applies and you didn’t name that resource
@@ -435,10 +434,11 @@
2. Read-only actions and file edits in your working directory are auto-approved, except writes to protected paths and the first read outside the working directories, which prompts you
* In a session with server-side classifier review, read-only and [sandboxed](</docs/en/sandboxing#sandbox-modes>) shell commands wait for that review and are blocked if it flags them
* A write inside your working directory that the [symlink check](</docs/en/permissions#symlinks>) resolves to a location outside it prompts you
+ * When Claude reads an [artifact someone else made](</docs/en/artifacts#read-an-artifact-shared-with-you>), the approval cases listed in that section apply
3. Everything else goes to the classifier, apart from critical-path removals under their default handling. The connector tools and `requiresUserInteraction` MCP tools that prompt you directly in step 1 never reach the classifier either, so neither an org-required approval nor a consent step is auto-approved
4. If the classifier blocks, Claude receives the reason. In most sessions the reason names the rule the classifier matched, such as `[Data Exfiltration]`, rather than giving a written explanation; see [Review denials](</docs/en/auto-mode-config#review-denials>)
-On entering auto mode, broad allow rules that grant arbitrary code execution are dropped:
+A [mod](</docs/en/plugins/mods/overview>) you install that handles `tool.check` can approve an action before step 3, and the classifier doesn’t check an action the mod approves. See [Extend permissions with hooks](</docs/en/permissions#extend-permissions-with-hooks>).In the VS Code extension, how [Claude in Chrome](</docs/en/chrome>) browser actions get approved depends on how the session connected to the browser: see [Permission prompts in VS Code sessions](</docs/en/chrome#permission-prompts-in-vs-code-sessions>).On entering auto mode, broad allow rules that grant arbitrary code execution are dropped:
* Blanket `Bash(*)` or `PowerShell(*)`
* Wildcarded interpreters like `Bash(python*)`
@@ -458,7 +458,7 @@
Cost and latency
-The classifier runs on Claude Sonnet 5 by default rather than on your `/model` selection. A classifier model that Anthropic configures server-side takes precedence over that default. When your session’s model is Claude Sonnet 4.6, or when [`availableModels`](</docs/en/model-config#restrict-model-selection>) excludes Sonnet 5, the classifier runs on the session’s model instead, or on an Opus model when the session runs on a [Fable model](</docs/en/model-config#work-with-fable>); on providers other than the Anthropic API, that Opus fallback is the provider’s default Opus model.The session’s first auto-mode request validates the Sonnet 5 default: if the request succeeds, Sonnet 5 stays the session’s classifier model, and if it fails because the model isn’t available, the session uses the fallback instead.On Enterprise plans and on accounts that use the Claude API, [Claude Platform on AWS](</docs/en/claude-platform-on-aws>), Amazon Bedrock, Google Cloud’s Agent Platform, or Microsoft Foundry, classifier calls count toward your token usage. Each check sends a portion of the transcript plus the pending action, adding a round-trip before execution. Reads and working-directory edits outside protected paths skip the classifier, so the overhead comes mainly from shell commands and network operations. Where the server reviews the actions as part of the session’s model requests, there are no separate classifier calls to count; see Server-side classifier review.Sandboxed network access adds no per-connection classifier requests. The classifier judges [the hosts a command names](</docs/en/sandboxing#per-command-allowed-domains-in-auto-mode>) together with the command in one review, and Claude Code checks each connection against the approved list without calling the classifier again.
+The classifier runs on Claude Sonnet 5 by default rather than on your `/model` selection. A classifier model that Anthropic configures server-side takes precedence over that default. When your session’s model is Claude Sonnet 4.6, or when [`availableModels`](</docs/en/model-config#restrict-model-selection>) excludes Sonnet 5, the classifier runs on the session’s model instead, or on an Opus model when the session runs on a [Fable model](</docs/en/model-config#work-with-fable>). On providers other than the Anthropic API, that Opus fallback is the model you set in [`ANTHROPIC_DEFAULT_OPUS_MODEL`](</docs/en/model-config#environment-variables>), or Opus 5 if you haven’t set one.The session’s first auto-mode request validates the Sonnet 5 default: if the request succeeds, Sonnet 5 stays the session’s classifier model, and if it fails because the model isn’t available, the session uses the fallback instead.On Enterprise plans and on accounts that use the Claude API, [Claude Platform on AWS](</docs/en/claude-platform-on-aws>), Amazon Bedrock, Google Cloud’s Agent Platform, or Microsoft Foundry, classifier calls count toward your token usage. Each check sends a portion of the transcript plus the pending action, adding a round-trip before execution. Reads and working-directory edits outside protected paths skip the classifier, so the overhead comes mainly from shell commands and network operations. Where the server reviews the actions as part of the session’s model requests, there are no separate classifier calls to count; see Server-side classifier review.Sandboxed network access adds no per-connection classifier requests. The classifier judges [the hosts a command names](</docs/en/sandboxing#per-command-allowed-domains-in-auto-mode>) together with the command in one review, and Claude Code checks each connection against the approved list without calling the classifier again.
##
@@ -476,7 +476,7 @@
Skip all checks with bypassPermissions mode
-`bypassPermissions` mode disables permission prompts and safety checks so tool calls execute immediately, including writes to protected paths. The actions no mode auto-approves still prompt in this mode. The Remove-Item in PowerShell denies also apply in this mode. Two [cross-session messaging](</docs/en/cross-session-messaging>) safeguards still apply in this mode, and in interactive terminal plan-mode sessions where bypass permissions are available:
+`bypassPermissions` mode disables permission prompts and safety checks so tool calls execute immediately, including writes to protected paths. The actions no mode auto-approves still prompt in this mode. Reading [another organization’s public artifact](</docs/en/artifacts#read-an-artifact-shared-with-you>) needs your approval, and this mode doesn’t ask for it, so Claude can’t read one. The Remove-Item in PowerShell denies also apply in this mode. Two [cross-session messaging](</docs/en/cross-session-messaging>) safeguards still apply in this mode, and in interactive terminal plan-mode sessions where bypass permissions are available:
* The [`isolatePeerMachines`](</docs/en/settings-reference#isolatepeermachines>) approval prompt for messages to your sessions beyond this machine still appears.
* When no [`crossSessionInbound`](</docs/en/cross-session-messaging#control-inbound-messages>) value applies, Claude Code holds an inbound message from another of your sessions for your approval, and delivers without asking only when the sending session identifies itself as also bypassing permission prompts. If you leave the permission mode while messages are held, Claude Code re-applies the inbound rules and delivers any held message they now accept.
@@ -535,6 +535,7 @@
* `.yarn`
* `.mvn`
* `.claude`, except for `.claude/worktrees` where Claude stores its own git worktrees
+ * A directory you loaded with [`--plugin-dir`](</docs/en/plugins/mods/create#change-a-mod-with-claude>), because Claude Code reloads and runs a mod’s code from it when a file changes
Protected files:
--- a/plugin-evals.md
+++ b/plugin-evals.md
@@ -19,7 +19,7 @@
* Claude Code v2.1.269 or later. Run `claude --version` to check and `claude update` to upgrade.
* Git 2.31 or later, if git is installed. Run `git --version` to check. With an older git, `claude plugin eval` stops before running any case. Without git, it runs normally.
* A plugin directory with a `plugin.json` or `.claude-plugin/plugin.json` manifest, or a [skills-directory plugin](</docs/en/plugins/loading#plugins-shared-through-a-repository>).
- * The same authentication and model provider your normal Claude Code sessions use. Eval runs, judge-scored graders, and `claude plugin eval init` call the model with your credentials, so they count against your plan’s usage limits or your API bill. When the command reports a cost, the figure is a [list-price estimate](</docs/en/costs>) of those calls.
+ * The same authentication and model provider your normal Claude Code sessions use. Eval runs, judge-scored graders, and `claude plugin eval init` call the model with your credentials, so they count against your plan’s usage limits or your API bill. When the command reports a cost, the figure is a [list-price estimate](</docs/en/costs>) of those calls. If you run Claude Code on Amazon Bedrock, Google Cloud’s Agent Platform, or Microsoft Foundry, run the suite from a shell that exports the same provider variables as your normal sessions, because each run inherits them from that shell as the `env` field describes.
##
@@ -189,7 +189,7 @@
Choose and weight graders
-A grader’s frontmatter sets its `type`, and optionally a `weight` that makes it count for more of the run’s score and an `arm` that controls how it’s scored against the baseline. Of the six types, `regex`, `tool_used`, `tool_order`, and `file_exists` are computed from the transcript and files and cost nothing, while `llm` and `baseline` call a judge model and add to the run’s cost. There are no custom-code graders. Grader types lists each type’s options and pass condition, and what a grader can look at lists the values `target` and `focus` accept. The judge for `llm` and `baseline` graders is a small fast model by default. Pass `--judge-model sonnet` or a full model ID to use a stronger one for nuanced rubrics.
+A grader’s frontmatter sets its `type`, and optionally a `weight` that makes it count for more of the run’s score and an `arm` that controls how it’s scored against the baseline. Of the six types, `regex`, `tool_used`, `tool_order`, and `file_exists` are computed from the transcript and files and cost nothing, while `llm` and `baseline` call a judge model and add to the run’s cost. There are no custom-code graders. Grader types lists each type’s options and pass condition, and what a grader can look at lists the values `target` and `focus` accept. By default, the judge for `llm` and `baseline` graders is the model Claude Code uses for background tasks. Pass `--judge-model sonnet` or a full model ID to choose the judge yourself.
####
@@ -293,7 +293,7 @@
* **Substitutions** : insert fields from the call’s input with `{{input.<field>}}`, and the contents of a fixture file beside the mock with `{{file:fixtures/{input.<field>}.json}}`.
* **`expect:`** : the `expect:` block guards the input. If a call violates it, the run aborts with score 0 and records why, so a case can assert what your plugin asked the server to do.
* **`error: true`** : set `error: true` to return the body as a tool error instead.
- * **`type: agent`** : set `type: agent` to have a small model answer as the server from instructions in the body.
+ * **`type: agent`** : set `type: agent` to have the judge model answer as the server from instructions in the body.
The mock file reference lists every key and the `_server.md` and `_tools.json` files. To grade the calls themselves, point a grader at `target: mock_calls`. To run against the plugin’s real MCP servers instead, pass one of these flags. Either way those processes run as you, outside the run’s sandbox, and their tools need an `--allow-tools` grant:
@@ -359,7 +359,7 @@
`--runs <n>`| Each case’s `runs`, else 3| Runs per case per arm
`-j`, `--concurrency <n>`| `1`| Run up to this many agent runs at once, from 1 to 8. They share your account’s rate limit, so this shortens wall-clock time rather than raising throughput past that limit. Results keep case order
`--model <model>`| Each case’s `model`, else `ANTHROPIC_MODEL` if set, else Claude Code’s default| Model for the agent under test. Pin it in CI so a model rollout isn’t mistaken for a plugin regression
-`--judge-model <model>`| A small fast model| Model for `llm` and `baseline` graders
+`--judge-model <model>`| The model for background tasks| Model for `llm` and `baseline` graders
`--ablation <mode>`| Decided per case; see Score against the no-plugin baseline| Whether to also run each case without the plugin to measure what it adds. `none` runs one arm; `with-without` adds the no-plugin baseline
`--threshold <0..1>`| `1.0`| A case passes when its with-arm score is at least this. Any case below it makes the command exit 1
`--max-cost-usd <usd>`| No ceiling| A ceiling on the run’s list-price cost estimate, not on plan usage. Checked before each run starts. Once spent, nothing further starts; runs that already started finish, so spend can pass the ceiling by those runs. If any run is left unstarted, the command exits 2 with partial results
@@ -403,7 +403,7 @@
The with-minus-without delta is reported but never changes the exit code, and neither do problems writing or publishing the HTML report. To see why a case scored low, run it locally without `--json` so the per-run progress and grader lines print. A CI runner also needs these in place:
- * **Install and credentials** : a CI runner needs a Claude Code install and [credentials in the environment](</docs/en/authentication>) such as `ANTHROPIC_API_KEY`.
+ * **Install and credentials** : a CI runner needs a Claude Code install and [credentials in the environment](</docs/en/authentication>) such as `ANTHROPIC_API_KEY` or your cloud provider’s variables.
* **Trust** : without `--trust-plugin`, a job whose checkout directory Claude Code doesn’t already trust needs the first-run trust prompt, and a run that can’t ask is refused with exit 1.
* **`init` in CI**: `claude plugin eval init` needs a terminal to ask you its questions; in CI, run `claude plugin eval init --bare <name>` to get the blank template.
@@ -615,7 +615,7 @@
Key| Default| Purpose
---|---|---
-`type`| `fixed`| `fixed` returns the body as written. `agent` treats the body as instructions for a small model that acts as the server for the run and sees earlier calls as history
+`type`| `fixed`| `fixed` returns the body as written. `agent` treats the body as instructions for the judge model, which acts as the server for the run and sees earlier calls as history
`expect`| unset| A map from dotted input paths to a type name such as `string`, `number`, `boolean`, `array`, or `object`, a `/regex/`, a literal, or a list of allowed literals. A call that violates it aborts the run with score 0 and is reported as `aborted` with the server, tool, and reason
`error`| `false`| `fixed` only. Return the body as a tool error
`abort_when`| unset| `agent` only. Prose listing the only conditions under which the agent may abort the run
--- a/python.md
+++ b/python.md
@@ -530,6 +530,7 @@
async def set_model(self, model: str | None = None) -> None
async def rewind_files(self, user_message_id: str) -> None
async def get_mcp_status(self) -> McpStatusResponse
+ async def get_context_usage(self) -> ContextUsageResponse
async def reconnect_mcp_server(self, server_name: str) -> None
async def toggle_mcp_server(self, server_name: str, enabled: bool) -> None
async def stop_task(self, task_id: str) -> None
@@ -554,6 +555,7 @@
`set_model(model)`| Change the model for the current session. Pass `None` to reset to [Claude Code’s default model](</docs/en/model-config>)
`rewind_files(user_message_id)`| Restore files to their state at the specified user message. Requires `enable_file_checkpointing=True`. See [File checkpointing](</docs/en/agent-sdk/file-checkpointing>)
`get_mcp_status()`| Get the status of all configured MCP servers. Returns `McpStatusResponse`
+`get_context_usage()`| Get a breakdown of context window usage by category, skill, and tool. The same data `/context` shows in an interactive session. Returns `ContextUsageResponse`. To compute the breakdown, Claude Code makes several token-counting API requests that don’t appear in the message stream; see how these requests are handled
`reconnect_mcp_server(server_name)`| Retry connecting to an MCP server that failed or was disconnected
`toggle_mcp_server(server_name, enabled)`| Enable or disable an MCP server mid-session. Disabling a stdio, SSE, or HTTP server removes its tools
`stop_task(task_id)`| Stop a running background task. A `TaskNotificationMessage` with status `"stopped"` follows in the message stream
@@ -1456,7 +1458,7 @@
Use with the `betas` field in `ClaudeAgentOptions` to enable beta features.
-The `context-1m-2025-08-07` beta is retired as of April 30, 2026. Passing this header with Claude Sonnet 4.5 or Sonnet 4 has no effect, and requests that exceed the standard 200k-token context window return an error. To use a 1M-token context window, migrate to [Claude Opus 5.5, Claude Opus 5, Claude Sonnet 5, Claude Sonnet 4.6, Claude Opus 4.6, Claude Opus 4.7, or Claude Opus 4.8](<https://platform.claude.com/docs/en/about-claude/models/overview>), which include 1M context at standard pricing with no beta header required.
+On the Claude API, the `context-1m-2025-08-07` beta is retired for Claude Sonnet 4.5 and Claude Sonnet 4. If you still pass it with either model, requests that exceed the standard 200K-token context window return an error, so remove it from `betas`. To run a session with a 1M-token context window, set `model` to a model that [runs with the 1M window by default](</docs/en/model-config#extended-context>), such as `claude-sonnet-5-5` or `claude-opus-5-5`. For a model that reaches 1M only through its `[1m]` variant, append the suffix to the model ID, as in `claude-opus-4-6[1m]`.
###
@@ -1572,6 +1574,37 @@
`config`| `McpServerStatusConfig` (optional)| Server configuration. Same shape as `McpServerConfig` (stdio, SSE, HTTP, or SDK), plus a `claudeai-proxy` variant for servers connected through claude.ai
`scope`| `str` (optional)| Configuration scope
`tools`| `list` (optional)| Tools provided by this server, each with `name`, `description`, and `annotations` fields
+
+###
+
+
+
+`ContextUsageResponse`
+
+Response from `ClaudeSDKClient.get_context_usage()`. This is the same payload Claude Code renders for the `/context` command in an interactive session, so alongside the token counts it carries display fields such as `color` and `gridRows` that Claude Code uses to draw the `/context` usage grid. Claude Code builds this payload by sending several requests to the [token-counting](<https://platform.claude.com/docs/en/build-with-claude/token-counting>) API. These requests don’t appear in the message stream, so cost tracking that reads the stream won’t see them. On the Anthropic API, token counting isn’t billed.
+
+ class ContextUsageResponse(TypedDict):
+ categories: list[ContextUsageCategory]
+ totalTokens: int
+ maxTokens: int
+ rawMaxTokens: int
+ percentage: float
+ model: str
+ isAutoCompactEnabled: bool
+ memoryFiles: list[dict[str, Any]]
+ mcpTools: list[dict[str, Any]]
+ agents: list[dict[str, Any]]
+ gridRows: list[list[dict[str, Any]]]
+ autoCompactThreshold: NotRequired[int]
+ deferredBuiltinTools: NotRequired[list[dict[str, Any]]]
+ systemTools: NotRequired[list[dict[str, Any]]]
+ systemPromptSections: NotRequired[list[dict[str, Any]]]
+ slashCommands: NotRequired[dict[str, Any]]
+ skills: NotRequired[dict[str, Any]] # skill usage with frontmatter breakdown
+ messageBreakdown: NotRequired[dict[str, Any]] # message tokens by type
+ apiUsage: NotRequired[dict[str, Any] | None]
+
+Each `ContextUsageCategory` entry carries `name`, `tokens`, `color`, and an optional `isDeferred` flag. `totalTokens` is the session’s current context usage, and `maxTokens` is the window that usage is measured against. That window is the model’s context window, or the lower auto-compaction window when one applies, and `rawMaxTokens` carries the same value as `maxTokens`. `apiUsage` holds the usage from the latest API response, not a running total for the session. Claude Code leaves the optional `deferredBuiltinTools`, `systemTools`, and `systemPromptSections` keys unset, so expect them to be absent even though the type declares them.
###
Show diff (355 lines)
--- a/reference.md
+++ b/reference.md
@@ -0,0 +1,352 @@
+Look up any event a [mod](</docs/en/plugins/mods/overview>) can handle, mods API method it can call, or render site it can draw in, for the Claude Code CLI and the Desktop app as of v2.1.287. Each entry gives the name and a one-line description, and links to the guide section that explains it where there is one.
+
+The complete reference is Claude Code’s [TypeScript declarations for mods](<https://github.com/anthropics/claude-code/blob/main/mods/types/claude-code.d.ts>), which describe every event, method, and element, with examples. The copy on GitHub can be older than the Claude Code version you have installed. When the two disagree, trust [the copy Claude Code writes for your version](</docs/en/plugins/mods/create#get-the-types-for-your-build>).
+
+##
+
+
+
+Files
+
+A mod is a plugin directory with these files:
+
+File| Required| Contents
+---|---|---
+`.claude-plugin/plugin.json`| Yes| The plugin [manifest](</docs/en/plugins/manifest-reference>). Mods add no required fields.
+`hooks/hooks.json`| Yes| `modules`: an array with one path, relative to this file, to the hooks module, as in `"modules": ["./register.js"]`. Can also hold [settings hooks](</docs/en/hooks>) under `hooks`.
+The hooks module, such as [`hooks/register.js`](</docs/en/plugins/mods/create#write-a-mod-yourself>)| Yes| The mod’s entry point. Exports `register(on, options)`. Named `.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.mts`, `.cts`, or `.tsx`. An ES module.
+[`types/index.d.ts`](</docs/en/plugins/mods/interface#declare-the-values>), named by `types` in the manifest| When the mod uses `$.state` or adds a namespace to the mods API| Declares `PluginState` values and any namespace the mod adds
+Files whose names end in `.test.ts` or `.test.tsx`| No| Tests that [`claude plugin test`](</docs/en/plugins/mods/test#write-a-test>) runs
+
+`register` receives `on` and `options`. `options` holds the values of the [`userConfig`](</docs/en/plugins/components#user-configuration>) fields the manifest declares, with defaults filled in.
+
+##
+
+
+
+The hook function
+
+A mod registers each of its hooks, which are event handlers, by calling `on` inside `register`. `on` takes the event’s name, an optional [matcher](</docs/en/plugins/mods/events#filter-which-events-a-hook-handles>), which is a filter on the event’s fields, and the hook, as in `on('tool.call', { tool: 'Bash' }, async ($, e, next) => next(e))`. `on` returns a registration with one method, `.catch(handler)`, which sets the hook’s [error handler](</docs/en/plugins/mods/events#handle-a-hook-that-fails>).
+
+Argument| What it is
+---|---
+[`$`](</docs/en/plugins/mods/events#how-a-hook-handles-an-event>)| The mods API: every method in mods API methods. Write each call in full, namespace then method, as in `$.fs.read('notes.md')`.
+[`e`](</docs/en/plugins/mods/events#how-a-hook-handles-an-event>)| The event’s input, as deeply frozen plain data. To change it, pass a copy to `next`.
+[`next(e)`](</docs/en/plugins/mods/events#how-a-hook-handles-an-event>)| The next handler, as in middleware. Runs the hooks after this one, then Claude Code’s behavior. Resolves to the event’s result.
+[`next.signal`](</docs/en/plugins/mods/api#stop-background-work>)| An `AbortSignal` that aborts when the event is abandoned
+`next.origin`| `{ plugin, tier }` of whoever fired the event. Claude Code itself is `{ plugin: 'engine', tier: 'core' }`. A mod’s `tier` is its priority group in the [order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>): `prepend`, `user`, `append`, or `builtin`.
+`next.budget`| The hook’s time limit in milliseconds: `next.budget.ms` is the whole limit, and `next.budget.remainingMs` is what’s left now
+`next.to(e, tier)`| Skips to a later tier, which is `append`, `builtin`, or `core`. `next.to(e, 'append')` skips the mods a user installed. Only a mod in `prependPlugins` or `appendPlugins` can call it.
+`next.error`, `next.called`| In a `.catch` handler only. `next.error.kind` is `throw` or `timeout`, `next.error.message` is the error’s text, and `next.called` is `true` when the failed hook had called `next`.
+
+##
+
+
+
+Events
+
+Events are grouped by what they concern, each with when it fires and what a hook on it can return. Hooks on `turn.step` and `process.spawn` are async generators, and other hooks are async functions. The last column of each table uses shorthand. `next(e)` passes the event on unchanged. `next({ ...e, text })` passes on a copy with the named field changed, as in `next({ ...e, text: e.text.trim() })`. An object answers the event without calling `next`, and a word such as `reason` stands for a string you write, as in `{ deny: 'Use the file tools.' }`.
+
+###
+
+
+
+Tools
+
+Tool events fire around each tool call Claude makes, from the description Claude reads to the decision on whether the call runs:
+
+Event| Fires when| A hook can return
+---|---|---
+[`tool.call`](</docs/en/plugins/mods/events#guard-or-change-a-tool-call>)| A tool is about to run| `next(e)`, `{ deny: reason }`, or `{ result }`
+[`tool.check`](</docs/en/plugins/mods/events#where-settings-hooks-run-in-the-order>)| Claude Code decides whether a tool call may run, after the `tool.call` and `PreToolUse` hooks. `next(e)` resolves to the decision the rules, the permission mode, and those hooks reached.| `{ decision }`, which is `allow`, `ask`, or `deny`
+`tool.describe`| Once for each tool, when its description is first sent to Claude| `{ description }`
+
+###
+
+
+
+Prompts and what Claude reads
+
+Prompt events cover the text the user types and the text Claude Code sends to Claude on its own, such as the system prompt and reminders:
+
+Event| Fires when| A hook can return
+---|---|---
+[`prompt.submit`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| A prompt is submitted| `next({ ...e, text })`, `next({ ...e, context })`, or `{ drop: reason }`
+`prompt.fill`, `prompt.suggest`| Text is about to go into the prompt box as a draft, or as a dim suggestion| `next(e)` with changed text
+`prompt.edit`| The user edits the prompt box| `next(e)`
+`prompt.compose`| Claude Code renders a system prompt| `{ sections }`, a list of `{ id, text, scope }` in the order they’re sent
+[`prompt.section`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| Once for each named section of the system prompt. `e.name` is the section’s `id` in `prompt.compose`.| `{ text }`, or `{ text: null }` to omit the section
+[`prompt.context`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| Once for each conversation, for the context sent with the first message| `{ blocks }`
+`prompt.attachment`| Claude Code adds a message of its own for Claude, such as a reminder. `e.type` names the kind, and for the kinds the types declare, `e.detail` holds the facts the text was written from.| `{ text }`, or `{ text: null }` to omit it
+[`skill.prompt`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| A skill’s text is expanded for Claude| `{ text }`
+`attribution.text`| Claude Code composes commit or pull request attribution text| `{ text }`
+
+###
+
+
+
+Commands and configuration
+
+Command and configuration events fire when a command runs or is listed, and when a `/config` row is shown or changed:
+
+Event| Fires when| A hook can return
+---|---|---
+[`command.run`](</docs/en/plugins/mods/api#add-a-command>)| A command is about to run| `{ text }`, `{}`, or `next(e)`
+`command.describe`| Once for each command, for the command list| `{ description, argumentHint, isHidden }`
+`config.set`| A `/config` row is about to change| `next({ ...e, value })` or `{ deny: reason }`
+`config.describe`| Once for each `/config` row| `{ label, description, isHidden }`
+
+###
+
+
+
+Turns
+
+Turn events follow one answer from start to finish, including each request to the model within it:
+
+Event| Fires when| A hook can return
+---|---|---
+[`turn.start`](</docs/en/plugins/mods/events#follow-a-turn>)| A turn begins| `next(e)`
+[`turn.step`](</docs/en/plugins/mods/events#follow-a-turn>)| One request is about to go to the model| `yield* next(e)`, or `next({ ...e, model })`, `next({ ...e, effort })`
+[`turn.complete`](</docs/en/plugins/mods/events#follow-a-turn>)| A turn ended| `next(e)`, or `{ text }` to show a line under the answer
+
+###
+
+
+
+Session
+
+Session events mark the session starting, ending, compacting, and exchanging messages with other sessions:
+
+Event| Fires when| A hook can return
+---|---|---
+[`session.start`](</docs/en/plugins/mods/api#add-a-command-or-a-tool>)| Once for each loaded mod, before the first prompt, and again after a reload of that mod. Not after `/clear`, `/resume`, or `/branch`.| `next(e)`
+`session.end`| The session ends, or `/clear`, `/resume`, or `/branch` runs. `e.reason` is `clear`, `resume`, `logout`, `prompt_input_exit`, or `other`. `/branch` reports `resume`.| `next(e)`
+`session.compact`| The conversation is about to be compacted| `{ skip: reason }`
+[`session.receive`](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>), [`session.send`](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>)| A message arrives from, or is about to go to, another agent or session. See [Send and receive messages between sessions](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>).| `{ consumed: reason }` for `receive`, `{ isDelivered: false, reason }` for `send`
+`session.append`| Once for each row the conversation keeps, such as a prompt, a response block, a tool result, or a notice, before it’s stored| `next({ ...e, message })` to rewrite the row’s `content`
+`session.attach`, `session.detach`| Another app connects to or disconnects from the session| `next(e)`
+`session.measure`| After each turn, and when a plan limit’s percent used changes| `next(e)`
+
+###
+
+
+
+Subagents
+
+Subagent events fire when a subagent type is offered to Claude and when one is about to start:
+
+Event| Fires when| A hook can return
+---|---|---
+`agent.offer`| A subagent type is offered to Claude| `{ isOffered: false }` to withhold it
+`agent.spawn`| A subagent is about to start| `{ model }` or `{ deny: reason }`
+
+###
+
+
+
+Interface
+
+Interface events fire when Claude Code draws a render site and when the user uses a control a mod drew. [Draw in the interface](</docs/en/plugins/mods/interface>) shows what a `ui.render` hook returns:
+
+Event| Fires when
+---|---
+[`ui.render`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| A render site is about to be drawn
+`ui.resolve`| Mods load, once for each app, render site, and mod. The result is the element table that `$.ui.resolve(e)` reads.
+[`ui.press`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>), [`ui.input`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>), [`ui.select`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>)| A `Button`, `Input`, or `Select` a mod drew is used
+`ui.focus`, `ui.scroll`| The focused control or the scroll position of a pane or the band is about to change
+`ui.close`| A pane is about to close. `e.id` is the pane and `e.origin.kind` is `plugin`, `person`, or `unload`.
+[`ui.message`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| A `Client` element posts data to its mod
+
+###
+
+
+
+Other mods
+
+These events let a mod act on other mods as they load, to refuse one or change the mods API it receives:
+
+Event| Fires when| A hook can return
+---|---|---
+[`plugin.register`](</docs/en/plugins/mods/admin#enforce-a-policy-with-a-mod-of-your-own>)| A hooks module is about to load. `e.uses` lists its events, mods API calls, environment variables, and state, as `claude plugin validate` prints them. Each call is written without the `$.` prefix, such as `fs.read`.| `{ refuse: reason }`
+`engine.create`| The mods API is being built for this mod| A changed mods API, to add a namespace or withhold one
+
+###
+
+
+
+Telemetry
+
+Telemetry events fire for the usage records Claude Code logs:
+
+Event| Fires when| A hook can return
+---|---|---
+`telemetry.log`, `telemetry.mark`| A telemetry record is about to be logged, or one use of a feature is marked. In a mod you install, give a telemetry hook the filter `{ to: 'collector' }`, as in `on('telemetry.log', { to: 'collector' }, hook)`. Without the filter, the mod fails `claude plugin validate`. `*` doesn’t match these events.| `next(e)`, or `{ deny: reason }`
+
+###
+
+
+
+Settings hook events
+
+Each [settings hook event](</docs/en/hooks#hook-events>) is an event named `classic.<Event>`, such as `classic.Stop` or `classic.PostToolUse`. `e` is the hook’s stdin JSON.
+
+###
+
+
+
+Mods API calls
+
+Every mods API method is also an event, named for its namespace and method, such as `fs.read`, `model.complete`, or `ui.open`. A hook on one intercepts calls from the mods that run after it, and can return `next(e)`, `{ deny: reason }`, or `{ value }`.
+
+##
+
+
+
+Mods API methods
+
+The mods API is the `$` argument every hook receives. Its methods are grouped in namespaces, such as `$.ui`. This table lists each namespace’s methods by name, so `open` in the `$.ui` row is the call `$.ui.open(...)`. The guides show the common ones in use, and [the types for your build](</docs/en/plugins/mods/create#get-the-types-for-your-build>) document every method with an example.
+
+Namespace| Methods
+---|---
+`$.plugin`| `name`, `root`: this plugin’s name and directory
+[`$.ui`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `resolve`, `invalidate`, `open`, `close`, `panes`, `focus`, `scroll`, `toast`, `status`, `log`, `notice`, `ask`, `copy`, `blit`
+[`$.command`](</docs/en/plugins/mods/api#add-a-command>)| `register`, `run`, `list`
+[`$.tool`](</docs/en/plugins/mods/api#add-a-tool>)| `register`, `call`, `check`, `list`
+`$.agent`| `register`, `spawn`, `list`
+[`$.model`](</docs/en/plugins/mods/api#call-a-model>)| `complete`, `fork`, `classify`
+[`$.prompt`](</docs/en/plugins/mods/api#start-a-turn-from-a-background-job>)| `submit`, `read`, `fill`, `suggest`, `compose`. Claude reads text from `submit({ text })` after a sentence that names your mod as the sender. `submit({ text, asUser: true })` sends the text as the user’s own words, without that sentence.
+`$.turn`| `abort`
+[`$.session`](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>)| `messages`, `cwd`, `root`, `model`, `turns`, `id`, `repo`, `surfaces`, `usage`, `version`, `compact`, `send`, `append`, `authorize`. `usage()` returns `{ startedAt, context, rateLimits, cost }`: `context` has `tokens`, `window`, and `percent`, and `rateLimits` is a list of `{ kind, percentUsed, resetsAt }`.
+`$.config`| `list`, `set`
+[`$.settings`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `read`
+[`$.env`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `get`, `set`
+[`$.fs`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `read`, `write`, `list`, `exists`, `stat`, `ancestors`. `write` isn’t atomic: it replaces the file’s content in place, so another process can read a partly written file. Keep data that several sessions change in `$.store`.
+[`$.store`](</docs/en/plugins/mods/interface#keep-state>)| `get`, `set`, `delete`, `keys`. A key-value store that every session on the machine shares. See [Save from more than one session](</docs/en/plugins/mods/interface#save-from-more-than-one-session>).
+[`$.state`](</docs/en/plugins/mods/interface#keep-a-value-in-$-state>)| Reactive state: `get`, `set`, with the helpers `atom`, `read`, `update`, `derive`, and `memberOf` imported from `claude-code`
+[`$.clock`](</docs/en/plugins/mods/api#run-work-in-the-background>)| `now`, `sleep`, `after`, `every`
+[`$.http`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `fetch`
+[`$.process`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `run`, `spawn`
+[`$.mcp`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `call`, `connect`. `connect(server)` connects an MCP server that your own plugin’s manifest lists.
+`$.audio`| `play`, `speak`
+`$.telemetry`| `log`, `mark`. A record is sent only when Claude Code or a built-in mod makes the call.
+
+##
+
+
+
+Render sites
+
+A render site is an extension point in Claude Code’s interface. Each row is a value of `e.component` in a `ui.render` hook, with the fields of `e.props` and the apps that render it. `e.surface` is `terminal` or `desktop`. [Change what Claude Code already draws](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>) shows what a hook can do at a site, with an example of each choice.
+
+Site| `e.props`| `e.requestId`| Rendered on
+---|---|---|---
+[`Pane`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `title`, `isFocused`, `bodyColumns`, `placement`, `scroll`, `view`| The pane’s `id`| Terminal, Desktop
+[`AbovePrompt`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `hasSurvey`, `isWorking`, `maxRows`, `bodyColumns`, `scroll`, `view`| One instance| Terminal, Desktop
+`UserMessage`| `text`, `origin`, `isExpanded`, and `task` or `from` by origin| The message id| Terminal, Desktop
+`AssistantMessage`| The reply’s text| The message id| Terminal, Desktop
+`ToolUse`, `ToolResult`, `ToolGroup`| The tool’s name, input, and result| The tool call id| Terminal, Desktop
+`CommandOutput`| `command`, `text`| The message id| Terminal, Desktop
+[`AskUserQuestion`](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>)| The question and options| The tool call id| Terminal, Desktop
+`ToolProgress`| `kind`| The tool call id| Terminal
+[`Spinner`](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>)| `word`, `message`, `suffix`, `mode`| The agent id| Terminal, Desktop
+`TurnDuration`| `word`, `durationMs`| The message id| Terminal
+`InfoNotice`| `text`, `command`| The message id| Terminal
+`SessionMode`| `modes`| One instance| Terminal, Desktop
+`PromptHint`| `isDraft`, `isWorking`, `hint`| One instance| Terminal, Desktop
+
+`e.viewport` holds `columns`, `rows`, and `isFullscreen`. It’s absent until the app has measured its window. Its `rows` is the height of the whole window, not of your pane. To fit a tree to its site, read these props in the hook:
+
+ * **Width of a`Pane` or the band**: draw to `e.props.bodyColumns`
+ * **Height of a`Pane` beside the transcript**: where `e.props.placement` is `'dock'`, `e.props.scroll.bodyRows` is the number of rows the pane has
+ * **Height of a`Pane` above the prompt**: where `e.props.placement` is `'inline'`, the pane grows with your tree up to a limit, and `bodyRows` counts only the rows showing now. The [`rows` field of `$.ui.open`](</docs/en/plugins/mods/interface#open-a-pane-at-the-right-time>) asks for a different limit.
+
+A tree taller than the pane scrolls as a whole.
+
+##
+
+
+
+Elements
+
+Elements are the building blocks of a tree a `ui.render` hook returns, and you get them from `$.ui.resolve(e)`. [Build a tree from elements](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) shows the common ones with how the terminal draws them, and the [interface gallery](</docs/en/plugins/mods/gallery>) has screenshots of most. A check mark means the app can draw the element.
+
+Element| Main props| Terminal| Desktop
+---|---|---|---
+[`Box`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `key`, flex layout, `gap`, `padding`, `margin`, `width`, `height`, `borderStyle`, `backgroundColor`, `position`, `hover`| ✓| ✓
+[`Text`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `color`, `backgroundColor`, `bold`, `italic`, `underline`, `dimColor`, `inverse`, `wrap`| ✓| ✓
+[`Button`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>)| `key`, `label`, `onPress`, `hotkey`, `plain`, `dimColor`, `autoFocus`, `action`| ✓| ✓
+`Link`| `href`, `label`| ✓| ✓
+`Code`| The code, up to 10,000 characters| ✓| ✓
+`Markdown`| `text`, up to 10,000 characters, `key`, `dimColor`, `onLinkPress`, `pressableLinks`| ✓| ✓
+[`Input`](</docs/en/plugins/mods/interface#take-typed-input-and-draw-a-row-for-each-item>)| `key`, `label`, `placeholder`, `value`, `submitLabel`, `onSubmit`, `onInput`, `autoFocus`| ✓| ✓
+`Select`| `key`, `label`, `options`, `value`, `onSelect`, `autoFocus`| ✓| ✓
+`Svg`| An SVG document, up to 131,072 characters| | ✓
+[`Client`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `module`, `key`| ✓| ✓
+[`Raster`](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>)| `key`, `columns` up to 512, `rows` up to 256, `cells`. See [Draw a grid of colored cells](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>).| ✓|
+`Image`| PNG or RGBA bytes up to 2 MiB, or a file path| ✓|
+
+More `Button` rules: `action` names one of Claude Code’s own [keybinding actions](</docs/en/keybindings>), and the user’s binding for it presses the button when that binding is a chord or a modified key. A digit `hotkey` on a button in the band also fires when the user types that digit alone into an empty prompt and pauses. When two buttons in one drawing name the same `hotkey`, the later one gets it. `autoFocus` accepts only `true` on any control, so omit the prop to leave it off.
+
+##
+
+
+
+Limits
+
+Hooks and mods API calls run under time and size limits. Claude Code skips a hook that exceeds a time limit and rejects a call that exceeds a size limit.
+
+Limit| Value
+---|---
+A hook’s own execution time for one event, not counting time inside `next` or a mods API call other than `$.clock.sleep`| 10 seconds
+A `.catch` handler’s execution time| 1 second
+All `session.end` hooks together| 1.5 seconds
+`$.process.run` timeout| 30 seconds by default, 10 minutes at most
+`$.model.complete` `maxTokens`| 1024 by default, up to 64,000 or the model’s output limit
+`$.fs.read` and `$.fs.write`| 4 MiB for one file
+One string child of a `Text`| 10,000 characters
+`$.store`| 4 MiB of JSON in total
+`$.session.messages()`| The newest 4,096 entries
+`$.ui.invalidate('ui.render')` redraws| Throttled to 10 a second, or 30 in the terminal for the visible pane, the expanded band, and the hint line under the prompt. Calls that come sooner are coalesced.
+`$.ui.toast`| Shown for 4 seconds unless you pass `{ timeoutMs }`
+A pane opened without the user asking| Placed from 144 terminal columns, 110 after they’ve opened it once
+Command, tool, subagent type, and pane names| Letters, digits, `_`, and `-`, up to 64 characters
+One `claude plugin test` test| 5 seconds unless the test sets `timeoutMs`
+
+##
+
+
+
+Settings and environment variables
+
+These are the settings and environment variables that affect mods. The Where column says which settings file or environment each one is read from:
+
+Name| Where| What it does
+---|---|---
+`CLAUDE_CODE_PLUGIN_DIRS`| Environment, or `env` in `~/.claude/settings.json`| Plugin directories to load as `--plugin-dir` does, for apps you can’t pass a flag to. Absolute paths separated by `:`, or `;` on Windows.
+`CLAUDE_CODE_PLUGIN_DIR_WATCH`| Environment| `1` makes a long-running non-interactive session reload `--plugin-dir` mods on save
+`prependPlugins`, `appendPlugins`| Managed settings. User settings only on a machine with no managed settings, for a user who isn’t signed in with a Team or Enterprise plan.| Lists of plugin ids, such as `acme-guard@acme-tools`. Mods in `prependPlugins` run before every mod a user installs, and mods in `appendPlugins` run after, in the listed order. See [The order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>).
+`allowManagedModsOnly`| Managed settings, as an [option on the built-in guard](</docs/en/plugins/mods/admin#set-options-on-the-built-in-guard>)| Only mods that [count as your organization’s](</docs/en/plugins/mods/admin#install-your-organizations-mods>), and mods built into Claude Code, load. Users’ settings hooks keep running.
+`allowModsToOverrideDenyRules`| Managed settings, as an [option on the built-in guard](</docs/en/plugins/mods/admin#set-options-on-the-built-in-guard>)| Lets a mod a user installed approve a tool call that a `deny` rule refuses
+`allowManagedHooksOnly`| Managed settings| Blocks hooks and installed mods that aren’t your organization’s. See [what keeps running](</docs/en/settings-reference#what-runs-under-allowmanagedhooksonly>).
+`disableAllHooks`| Any settings file| In managed settings, no mod or hook from an installed plugin runs. In your own settings, what your organization manages keeps running. See [`disableAllHooks`](</docs/en/settings-reference#disableallhooks>).
+`disableSideloadFlags`| Managed settings| Rejects `--plugin-dir` and `--plugin-url` at startup
+`pluginConfigs`| User or managed settings| Holds `userConfig` values for a mod, keyed by the plugin’s id, such as `acme-guard@acme-tools`, or its name and `@inline`, such as `first-mod@inline`, for one loaded with `--plugin-dir`
+
+`sec-default@builtin` is a guard built into Claude Code, listed as `cc-plugin-sec-default` in `/plugin` and the debug log. It loads ahead of every mod a person installs on a machine with managed settings, or for a user signed in with a Team or Enterprise plan. If managed `prependPlugins` is set, the guard loads only when that list names it, at the position listed. Its source is in the [`mods/sec-default` directory of the Claude Code repository](<https://github.com/anthropics/claude-code/tree/main/mods/sec-default>).
+
+##
+
+
+
+Commands
+
+These commands and flags load, inspect, and test a mod. The `claude` commands run in your shell and the `/` commands at the Claude Code prompt. In the table, `<directory>` stands for a path you type, as in `claude plugin validate ./first-mod`. Square brackets mark an optional argument.
+
+Command| What it does
+---|---
+[`/plugin`](</docs/en/plugins/mods/overview#see-which-mods-a-session-loaded>)| Shows a line such as `1 mod active · first-mod` under its tabs when a mod that isn’t built in has loaded
+[`claude plugin validate <directory>`](</docs/en/plugins/mods/create#check-what-claude-code-reads-from-your-mod>)| Reads a plugin’s manifest and hooks module and reports errors, the events it handles, and the mods API calls it makes. `--strict` treats warnings as errors and `--json` prints a machine-readable report.
+[`claude plugin test [directory]`](</docs/en/plugins/mods/test#write-a-test>)| Runs every file under the directory, or the current directory when you give none, whose name ends in `.test.ts` or `.test.tsx`. Exits with status 1 when a test fails.
+[`claude --plugin-dir <directory>`](</docs/en/plugins/mods/create#write-a-mod-yourself>)| Loads a plugin directory for one session and reloads its hooks module when you save. Repeat the flag to load several.
+`/reload-plugins`| Reloads plugins when you run it
--- a/remote-control.md
+++ b/remote-control.md
@@ -184,7 +184,7 @@
* **`claude remote-control --continue`** : brings back only the session the server started with, and exits when that session ends. If this directory has no record, Claude Code uses the newest one from this repository’s other git worktrees.
* **`claude remote-control --session-id<id>`**: brings back only the session whose ID you pass, and exits when that session ends. The ID is the part of the session’s URL at claude.ai/code between `/code/` and any `?`.
-These commands work for about four hours after the server stopped. After that, run `claude remote-control` to start a new session. If you archived a session in the meantime, `--continue` and `--session-id` unarchive it on Claude Code v2.1.228 or later. To bring back a session you started with `claude --remote-control` or `/remote-control`, resume the conversation with `claude --continue` or `claude --resume`. If Remote Control doesn’t reconnect, see Couldn’t reconnect to your Remote Control session. If you resume the conversation in a second terminal while the first one still has Remote Control on, Claude Code prints a `Remote Control not started here` notice in the second terminal and leaves Remote Control off there instead of taking the session away from the first. Run `/remote-control` in the second terminal to move Remote Control to it. When you resume a conversation in Claude Desktop or an IDE extension that had Remote Control on, Claude Code reattaches it to the existing claude.ai session instead of adding a new one to the session list.
+These commands work for about four hours after the server stopped. After that, run `claude remote-control` to start a new session. If you archived a session in the meantime, `--continue` and `--session-id` unarchive it on Claude Code v2.1.228 or later. To bring back a session you started with `claude --remote-control` or `/remote-control`, resume the conversation with `claude --continue` or `claude --resume`. For the permission mode that the resumed conversation starts in, see [permission mode on resume](</docs/en/sessions#permission-mode-on-resume>). If Remote Control doesn’t reconnect, see Couldn’t reconnect to your Remote Control session. If you resume the conversation in a second terminal while the first one still has Remote Control on, Claude Code prints a `Remote Control not started here` notice in the second terminal and leaves Remote Control off there instead of taking the session away from the first. Run `/remote-control` in the second terminal to move Remote Control to it. When you resume a conversation in Claude Desktop or an IDE extension that had Remote Control on, Claude Code reattaches it to the existing claude.ai session instead of adding a new one to the session list.
##
@@ -207,7 +207,7 @@
* **An enrolled device** : each browser, phone, or desktop app a member uses for Remote Control enrolls its own credential. Enrollment is only offered shortly after a full sign-in, so a device joins the trusted list as part of a real authentication rather than silently in the background.
* **A recent sign-in** : the member’s sign-in must be no more than 18 hours old. Instead of signing in again each day, members confirm presence with Face ID, Touch ID, Windows Hello, or a passkey. This biometric step-up refreshes the session immediately.
-Biometric checks run on the device through the operating system or browser, the same mechanism as passkey sign-in. Anthropic never receives or stores fingerprints, face data, or any other biometric information. Only the device’s public key and basic metadata such as display name, platform, and enrollment time are stored. The setting applies only to Remote Control. Regular Claude chat, Claude Code in the terminal, and API usage are unaffected.
+Biometric checks run on the device through the operating system or browser, the same mechanism as passkey sign-in. Anthropic never receives or stores fingerprints, face data, or any other biometric information. Only the device’s public key and basic metadata such as display name, platform, and enrollment time are stored. The setting applies to Remote Control in both Claude Code and [Cowork](<https://claude.com/docs/cowork/overview>). This page covers the Claude Code side. Regular Claude chat, Claude Code in the terminal, and API usage are unaffected.
###
@@ -327,13 +327,14 @@
* **Extended network outage** : if your machine is awake but can’t reach the network, what you do next depends on the mode:
* **Server mode** : Claude Code gives up after roughly 10 minutes and the `claude remote-control` process exits. Run `claude remote-control` again to start a new session.
* **Interactive session** : keep working locally. Claude Code retries for as long as the outage lasts and reconnects on its own when the network returns.
+ * **Attachments that don’t download** : if a file you attach from your phone or browser can’t be downloaded to your machine, Claude still receives your message and the files that were downloaded. In place of the missing files, Claude Code adds a note such as `[1 of 3 attachments did not arrive]` to the message.
* **Presence heartbeats failing** : if an interactive session disconnects with `could not reach the Remote Control server for about 30 minutes`, run `/remote-control` to reconnect.
* **Forwarded dialogs expire** : Claude Code keeps permission prompts and `AskUserQuestion` questions open until you answer them. When Claude Code forwards another kind of dialog to the remote session, such as the model-choice prompt shown after a safety refusal, it waits five minutes by default, then closes the dialog and continues with the dialog’s no-action default. Set [`dialogExpiry`](</docs/en/settings-reference#dialogexpiry>) to adjust or disable the deadline. Requires Claude Code v2.1.224 or later.
* **The Fable usage-credits consent prompt isn’t forwarded** : Claude Code shows the mid-session [Fable usage-credits consent prompt](</docs/en/model-config#fable-and-usage-credits>) only where the session runs, not on your device. When the session runs in a terminal and nobody there answers before Claude Code closes the prompt, the turn ends without sending the request; see [The prompt to confirm went unanswered](</docs/en/errors#the-prompt-to-confirm-went-unanswered>).
- * **Some commands are local-only** : commands that only run in the terminal interface, such as `/plugin` or `/resume`, work only from the local CLI, whether or not you pass an argument. The following work from mobile and web:
+ * **Some commands are local-only** : commands that only run in the terminal interface, such as `/plugin` or `/resume`, work only from the local CLI, whether or not you pass an argument. `/claude-api` is also unavailable when you type it from mobile or web. Claude can still [load that skill on its own](</docs/en/skills#work-on-claude-api-projects>) there. The following work from mobile and web:
* Text-output commands: `/compact`, `/clear`, `/context`, `/usage`, `/exit`, `/usage-credits`, `/recap`, and `/reload-plugins`. `/usage-credits` prints the billing URL instead of opening a browser. `/reload-plugins` works only when the session runs in an interactive terminal; a session without one declines it.
* `/model`, `/effort`, `/fast`, `/color`, and `/rename`: pass the value as an argument, for example `/model sonnet` or `/effort high`. From mobile and web, `/model` and `/effort` take the argument in place of the terminal picker or slider.
- * `/mcp`: from the mobile app, returns a text summary of server status instead of opening the picker. On the web, `/mcp` on its own opens a directory of [claude.ai connectors](</docs/en/mcp#use-mcp-servers-from-claude-ai>) instead of returning the summary. The `reconnect`, `enable`, and `disable` [subcommands](</docs/en/commands#all-commands>) work from both. Unlike the local CLI, `/mcp reconnect` without a server name reconnects every server that has failed or needs authentication.
+ * `/mcp`: from the mobile app, returns a text summary of server status instead of opening the picker. On the web, `/mcp` on its own opens a directory of [claude.ai connectors](</docs/en/mcp#use-mcp-servers-from-claude-ai>) instead of returning the summary. The `reconnect`, `enable`, and `disable` [subcommands](</docs/en/commands#all-commands>) work from both. `/mcp reconnect` with no server name retries every server that has failed or needs authentication.
* `/config`: from the mobile app, pass `key=value` to set a setting, or run it with no argument to list the keys you can set. On the web, `/config` opens the Claude Code section of your settings instead, and ignores text after the command.
* On Team and Enterprise, `/usage-credits` from mobile or web doesn’t send a [usage-credits request to your admin](</docs/en/costs#add-usage-credits-to-your-subscription>). Sending requires a confirmation that appears only in the interactive CLI, so the command tells you to run it there instead.
* `/autocompact`, from v2.1.221: pass the window size as an argument, for example `/autocompact 500k`. With no argument, it prints the current window size as text instead of opening the dialog the command shows in a terminal session.
@@ -416,7 +417,7 @@
-”Remote Control is disabled by your organization’s policy”
+“Remote Control is disabled by your organization’s policy”
A policy blocks Remote Control. Check these causes in order:
@@ -426,6 +427,19 @@
* **Otherwise, an Owner hasn’t enabled it for your organization** : Remote Control is off by default on Team and Enterprise plans. An Owner can enable it at [claude.ai/admin-settings/claude-code](<https://claude.ai/admin-settings/claude-code>) by turning on the **Remote Control** toggle. This toggle is a server-side organization setting.
Before v2.1.281, this message also appeared when Claude Code hadn’t loaded your organization’s policy on this machine, for example after starting offline. Later versions report that state as `Couldn't verify your organization's policy for remote control` instead.
+
+###
+
+
+
+“Remote Control was turned off by your organization’s policy”
+
+Your organization’s policy stopped allowing Remote Control while a session was connected, so Claude Code disconnected it. What happens to the session depends on how you started Remote Control:
+
+ * **With`/remote-control`, `claude --remote-control`, or auto-connect**: the session keeps running without Remote Control, and Claude Code archives it at claude.ai
+ * **With`claude remote-control`**: the server stops and archives the sessions it was serving, then exits
+
+You can still find an archived session by [filtering for archived sessions](</docs/en/claude-code-on-the-web#archive-sessions>). Remote Control doesn’t reconnect on its own. To turn it back on after your organization allows it again, run `/remote-control` in the session or `claude remote-control` in your shell. Either command fails with `Remote Control is disabled by your organization's policy` until Claude Code on this machine has fetched the changed policy. An open session fetches it about once an hour. To find out what is blocking Remote Control, match the full text the command prints against that entry.
###
--- a/routines.md
+++ b/routines.md
@@ -323,11 +323,7 @@
Repositories and branch permissions
-Routines need GitHub access to clone repositories. When you create a routine from the CLI with `/schedule`, Claude checks whether your account has GitHub access for the repository you ran it from and, if it doesn’t, adds a setup note naming how to grant it. See [GitHub authentication options](</docs/en/claude-code-on-the-web#github-authentication-options>) for the two ways to grant access. If your GitHub connection is missing or expired when a run is due, the routine skips runs until you reconnect, for up to 72 hours. Reconnect GitHub within that window and the routine resumes on its own. After 72 hours without a connection, the routine turns off, and you turn it back on after reconnecting GitHub. Each repository you add is cloned on every run. Claude starts from the repository’s default branch unless your prompt specifies otherwise. Claude pushes its work to branches prefixed with `claude/`, which are always accepted. When your prompt directs Claude to push to another branch, Claude Code checks the push first and rejects it if any of the following is true:
-
- * The branch is protected on GitHub
- * Someone else has an open pull request from that branch
- * The branch carries commits authored by someone other than you
+Routines need GitHub access to clone repositories. When you create a routine from the CLI with `/schedule`, Claude checks whether your account has GitHub access for the repository you ran it from and, if it doesn’t, adds a setup note naming how to grant it. See [GitHub authentication options](</docs/en/claude-code-on-the-web#github-authentication-options>) for the two ways to grant access. If your GitHub connection is missing or expired when a run is due, the routine skips runs until you reconnect, for up to 72 hours. Reconnect GitHub within that window and the routine resumes on its own. After 72 hours without a connection, the routine turns off, and you turn it back on after reconnecting GitHub. Each repository you add is cloned on every run. Claude starts from the repository’s default branch unless your prompt specifies otherwise. Claude pushes its work to a branch prefixed with `claude/` unless your prompt directs it to push to another branch. To control which branches a run can push to, use branch protection rules or rulesets on GitHub. For runs on Anthropic-managed infrastructure, and for self-hosted runs that push through [Anthropic’s git proxy](</docs/en/self-hosted-environments-deploy#use-the-anthropic-git-proxy>), GitHub applies them to the GitHub access you connected, so a rule that access can bypass doesn’t block a run’s push. A self-hosted run that pushes with the git credentials your deployment provides is checked against those instead. See [Configure git](</docs/en/self-hosted-environments-deploy#configure-git>).
###
@@ -367,7 +363,7 @@
Change the network access level
-In the **Update cloud environment** dialog, change **Network access** to **Custom** and enter your domains in **Allowed domains**. Check **Also include default list of common package managers** to keep the [default allowlist](</docs/en/cloud-environments#default-allowed-domains>) alongside your custom domains. Select **Full** instead for unrestricted access.
+In the **Edit cloud environment** dialog, change **Network access** to **Custom** and enter your domains in **Allowed domains**. Check **Also include default list of common package managers** to keep the [default allowlist](</docs/en/cloud-environments#default-allowed-domains>) alongside your custom domains. Select **Full** instead for unrestricted access.
5
--- a/sandbox-environments.md
+++ b/sandbox-environments.md
@@ -71,7 +71,7 @@
Sandbox runtime
-The [`@anthropic-ai/sandbox-runtime`](<https://github.com/anthropic-experimental/sandbox-runtime>) package wraps an entire process in the same Seatbelt or bubblewrap isolation that the built-in Bash sandbox uses. Running Claude Code through the runtime constrains every tool, hook, and MCP server in the session, not only shell commands. The runtime is a beta research preview, and its configuration format may change as the package evolves. This section covers what you configure and what the runtime enforces on its own. For deploying the runtime in Agent SDK applications, see the [secure deployment guide](</docs/en/agent-sdk/secure-deployment#sandbox-runtime>).
+The [`@anthropic-ai/sandbox-runtime`](<https://github.com/anthropics/sandbox-runtime>) package wraps an entire process in the same Seatbelt or bubblewrap isolation that the built-in Bash sandbox uses. Running Claude Code through the runtime constrains the session’s tools, hooks, and MCP servers as well as shell commands. The runtime is a beta research preview, and its configuration format may change as the package evolves. This section covers what you configure and what the runtime enforces on its own. For deploying the runtime in Agent SDK applications, see the [secure deployment guide](</docs/en/agent-sdk/secure-deployment#sandbox-runtime>).
###
@@ -79,11 +79,13 @@
Set up and launch the runtime
-On Linux and WSL2, the runtime relies on the same `bubblewrap` and `socat` packages as the built-in sandbox, plus `ripgrep`, which Claude Code bundles but the standalone runtime resolves from your PATH. Install `bubblewrap` and `socat` as described in [Set up Linux and WSL2](</docs/en/sandboxing#set-up-linux-and-wsl2>), and `ripgrep` from your distribution’s package manager. On macOS you need no additional packages. The runtime uses the built-in Seatbelt sandbox there. By default the runtime denies network access and confines writes to a small set of built-in runtime paths, so configure it before launching Claude Code through it. Put your configuration in `~/.srt-settings.json`, or in a file you pass with `--settings`. The package [README](<https://github.com/anthropic-experimental/sandbox-runtime>) documents the full configuration schema. Allow write access to at least:
+On Linux and WSL2, the runtime relies on the same `bubblewrap` and `socat` packages as the built-in sandbox, plus `ripgrep`, which Claude Code bundles but the standalone runtime resolves from your PATH. Install `bubblewrap` and `socat` as described in [Set up Linux and WSL2](</docs/en/sandboxing#set-up-linux-and-wsl2>), and `ripgrep` from your distribution’s package manager. On macOS you need no additional packages. The runtime uses the built-in Seatbelt sandbox there. By default the runtime denies network access and confines writes to a small set of built-in runtime paths, so configure it before launching Claude Code through it. Put your configuration in `~/.srt-settings.json`, or in a file you pass with `--settings`. The package [README](<https://github.com/anthropics/sandbox-runtime>) documents the configuration schema. Allow write access to at least:
* Your project directory.
* Claude Code’s configuration paths `~/.claude` and `~/.claude.json`.
- * `/tmp`, where Claude Code writes runtime files.
+ * The directory where Claude Code writes runtime files. Unless you set [`CLAUDE_CODE_TMPDIR`](</docs/en/env-vars>), that directory is:
+ * **Linux and WSL2** : `/tmp`
+ * **macOS** : `/private/tmp`. `/tmp` is a symlink to that directory, and Seatbelt checks the resolved path.
Allow the network domains your session needs:
@@ -139,7 +141,7 @@
Custom container
-You can run Claude Code in any Docker or OCI container image with your own network policies, mounted volumes, and seccomp profiles. This is the most common path for organizations with existing container infrastructure or CI runners. Several managed sandbox and remote execution services can host the container for you. The same checklist applies as for any container you operate: review what is mounted writable, what credentials and tokens are reachable inside it, and what the network egress policy allows. You can layer the built-in Bash sandbox inside the container for per-command restrictions. Unprivileged containers need the nested-sandbox setting described in [Sandboxing troubleshooting](</docs/en/sandboxing#troubleshooting>).
+You can run Claude Code in any Docker or OCI container image with your own network policies, mounted volumes, and seccomp profiles. This is the most common path for organizations with existing container infrastructure or CI runners. Several managed sandbox and remote execution services can host the container for you. The same checklist applies as for any container you operate: review what is mounted writable, what credentials and tokens are reachable inside it, and what the network egress policy allows. You can layer the built-in Bash sandbox inside the container for per-command restrictions. Unprivileged containers need `enableWeakerNestedSandbox`, described in [Bubblewrap fails to start inside a container](</docs/en/sandboxing#bubblewrap-fails-to-start-inside-a-container>).
##
Show diff (868 lines)
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -1,14 +1,57 @@
-The Bash sandbox lets Claude run most shell commands without stopping to ask permission. Instead of approving each command, you define which files and network domains commands can touch, and the operating system enforces that boundary for every Bash, PowerShell, or Monitor command and its child processes.
-
-To compare other isolation approaches such as dev containers, custom containers, and virtual machines, see [Sandbox environments](</docs/en/sandbox-environments>). To reduce permission prompts for tools other than Bash, see [permission modes](</docs/en/permission-modes>).
+The Bash sandbox is a boundary that the operating system enforces around the shell commands Claude runs on your machine. You set which files and network domains those commands can reach, and the limits apply to Bash, PowerShell, and Monitor commands and the processes they start. Because the operating system applies the limits while a command runs, Claude Code can run sandboxed commands without asking you to approve each one. The sandbox covers shell commands only. Claude’s file tools, MCP servers, and hooks run outside it. The sandbox runs on macOS, Linux, and WSL2. On native Windows, Claude Code runs commands unsandboxed. To use the sandbox on a Windows machine, run Claude Code inside a WSL2 distribution.
+
+This page covers the sandbox around shell commands on your own machine. Other pages cover related questions:
+
+ * For how a cloud session is isolated, see [Security and isolation](</docs/en/claude-code-on-the-web#security-and-isolation>)
+ * To compare other isolation approaches such as dev containers, custom containers, and virtual machines, see [Sandbox environments](</docs/en/sandbox-environments>)
+ * To reduce permission prompts for tools other than Bash, see [permission modes](</docs/en/permission-modes>)
##
+What the sandbox restricts
+
+While the sandbox is on, the shell commands Claude runs start inside its boundary, and so do the processes they start. The sandbox is off by default. To turn it on, run `/sandbox` in a session, as Get started shows, or set [`sandbox.enabled`](</docs/en/settings-reference#sandbox-enabled>) to `true` in a [settings file](</docs/en/settings>) such as `~/.claude/settings.json`. The table shows what a sandboxed command can reach by default and the settings that change each default.
+
+Access| Default| Change it with
+---|---|---
+Writes| The working directory, a per-user temp directory, and [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>). Protected paths stay write-denied| [`filesystem.allowWrite`](</docs/en/settings-reference#sandbox-filesystem-allowwrite>), [`filesystem.denyWrite`](</docs/en/settings-reference#sandbox-filesystem-denywrite>)
+Reads| Most of the machine, including credential files such as `~/.ssh` and `~/.aws/credentials`| [`filesystem.denyRead`](</docs/en/settings-reference#sandbox-filesystem-denyread>), `credentials`
+Network| No direct route out. Connections go through a proxy on your machine that checks each host against your allowed domains, which start empty. Your permission mode decides what happens to other hosts| [`network.allowedDomains`](</docs/en/settings-reference#sandbox-network-alloweddomains>), [`network.deniedDomains`](</docs/en/settings-reference#sandbox-network-denieddomains>)
+Environment variables| Inherited from Claude Code, including any secrets in its environment| `credentials`, [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>)
+
+Claude Code builds the sandbox on the open source [`@anthropic-ai/sandbox-runtime`](<https://github.com/anthropics/sandbox-runtime>) package.
+
+###
+
+
+
+What runs outside the sandbox
+
+The sandbox wraps shell commands. These tools and processes run outside it:
+
+ * **Built-in file and web tools** : tools such as Read, Edit, Write, WebFetch, and WebSearch follow [permission rules](</docs/en/permissions>) instead. A `denyRead` entry doesn’t stop the Read tool, and `allowedDomains` doesn’t limit WebFetch
+ * **Other processes Claude Code starts** : command [hooks](</docs/en/hooks>), local [MCP servers](</docs/en/mcp>), [plugin monitors](</docs/en/plugins/components#monitors>), [LSP servers](</docs/en/tools-reference#lsp-tool-behavior>), and helper commands such as your [status line](</docs/en/statusline>) command and `apiKeyHelper` run with your full access
+
+Some shell commands also run outside the sandbox, depending on your settings:
+
+ * **Commands you type yourself** : a command you enter at the [`!` shell-mode prompt](</docs/en/interactive-mode#shell-mode-with-prefix>) runs unsandboxed in most sessions. Strict sandbox mode lists the sessions where a command you type runs sandboxed
+ * **Excluded commands** : commands that match `excludedCommands` run unsandboxed
+ * **Unsandboxed retries** : Claude can ask to run a command unsandboxed, usually after it fails in the sandbox
+
+To put the tools, processes, and commands in this section behind one boundary, run the Claude Code process itself in a [container, virtual machine, or the sandbox runtime](</docs/en/sandbox-environments>).
+
+##
+
+
+
Get started
-The sandbox is built into Claude Code and runs on macOS, Linux, and WSL2. Native Windows is not supported. On Windows, run Claude Code inside a WSL2 distribution. On macOS, there is nothing to install: sandboxing uses the built-in Seatbelt framework. On Linux and WSL2, the sandbox relies on two packages, covered in Set up Linux and WSL2. Even if you haven’t installed them yet, you can start with `/sandbox`, because its panel shows whether anything is missing.
+The sandbox is built into Claude Code. What you install depends on your platform:
+
+ * **macOS** : sandboxing uses the built-in Seatbelt framework, so you can go straight to the steps
+ * **Linux and WSL2** : the sandbox relies on `bubblewrap` and `socat`, covered in Set up Linux and WSL2. Even if you haven’t installed them yet, you can start with `/sandbox`, because its panel shows whether anything is missing
1
@@ -36,13 +79,28 @@
Run a Bash command
-Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write to the working directory, a [per-user temp directory](</docs/en/env-vars>), and any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir`, `/add-dir`, or `permissions.additionalDirectories`.The first time a command needs a new network domain, Claude Code prompts for approval; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), Claude instead names the hosts a command needs on the command itself for the classifier to review with it.Commands that can’t run sandboxed fall back to the regular permission flow. Claude Code titles their permission prompt “Bash command (unsandboxed)” instead of “Bash command”, so you can tell which commands ran outside the sandbox. To widen or narrow what the sandbox allows, see Configure sandboxing.If sandboxed commands fail with `Operation not permitted` inside a container, see the Bubblewrap entry under Troubleshooting.
+Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write to the working directory, a [per-user temp directory](</docs/en/env-vars>), and any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir`, `/add-dir`, or `permissions.additionalDirectories`.The first time a command needs a new network domain, Claude Code prompts for approval; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), Claude instead names the hosts a command needs on the command itself for the classifier to review with it.To widen or narrow what the sandbox allows, see Configure sandboxing.If sandboxed commands fail with `Operation not permitted` inside a container, see Bubblewrap fails to start inside a container.
When you select a mode in the panel, Claude Code saves it to your project’s local settings at `.claude/settings.local.json`, which apply to the current project. Claude Code adds that file to your global gitignore when it saves a setting there. To enable the sandbox across all of your projects, set [`sandbox.enabled`](</docs/en/settings-reference#sandbox-enabled>) to `true` in your user settings at `~/.claude/settings.json`. To enforce sandboxing for every developer in an organization, use managed settings. To change the sandbox for one session without writing to a settings file, start Claude Code with [`--settings`](</docs/en/settings#change-a-setting-for-one-session>). For example, this command starts a sandboxed session in which Claude can’t retry a blocked command outside the sandbox:
claude --settings '{"sandbox": {"enabled": true, "allowUnsandboxedCommands": false}}'
-By default, if the sandbox cannot start because dependencies are missing or the platform is unsupported, Claude Code shows a warning and runs commands without sandboxing. To make this a hard failure instead, set [`sandbox.failIfUnavailable`](</docs/en/settings-reference#sandbox-failifunavailable>) to `true`. This is intended for managed deployments that require sandboxing as a security gate.
+By default, if the sandbox can’t start because a dependency is missing or the platform is unsupported, Claude Code runs commands without sandboxing. To make Claude Code exit at startup instead, set [`sandbox.failIfUnavailable`](</docs/en/settings-reference#sandbox-failifunavailable>) to `true`. Managed deployments that require sandboxing as a security gate can use this setting.
+
+###
+
+
+
+Confirm commands run inside the sandbox
+
+To check that the sandbox is working, ask Claude to run each line in the table. What you type at the `!` prompt usually runs outside the sandbox, so typing a line yourself doesn’t test it.
+
+Command| Result inside the sandbox
+---|---
+`touch ~/sandbox-probe`| Fails with `Operation not permitted` on macOS, or `Read-only file system` on Linux and WSL2
+`curl --noproxy '*' https://example.com`| Fails with `Could not resolve host`, because the command has no route around the sandbox proxy
+
+If Claude asks to retry a failed command outside the sandbox, decline the retry. If `touch` succeeds and your home directory isn’t one of the directories the sandbox lets commands write to, delete `~/sandbox-probe`. Then run `/sandbox` to check that the sandbox is on and its dependencies are installed.
###
@@ -50,7 +108,7 @@
Set up Linux and WSL2
-On Linux and WSL2, the sandbox relies on two packages:
+On Linux and WSL2, the sandbox relies on these packages:
* [`bubblewrap`](<https://github.com/containers/bubblewrap>): the unprivileged sandboxing tool that enforces filesystem isolation
* [`socat`](<http://www.dest-unreach.org/socat/>): the relay used to route network traffic through the sandbox proxy
@@ -87,7 +145,7 @@
WSL2 notes
-Check your WSL version with `wsl -l -v` from PowerShell. If you see `Sandboxing requires WSL2`, your distribution is running WSL1. Upgrade it to WSL2 or run Claude Code without sandboxing.On WSL2, WSL hands a launch of a Windows binary such as `cmd.exe`, `powershell.exe`, or anything under `/mnt/c/` to the Windows host over a Unix socket, so whether a sandboxed command can launch one follows the sandbox’s [Unix-socket settings](</docs/en/settings-reference#sandbox-network-allowunixsockets>): the optional seccomp filter has to be installed to block the socket in the first place. To allow these launches, set `allowAllUnixSockets`; to keep them out of the sandbox entirely, add the command to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>).
+Check your WSL version with `wsl -l -v` from PowerShell. If you see `Sandboxing requires WSL2`, your distribution is running WSL1. Upgrade it to WSL2 or run Claude Code without sandboxing.On WSL2, WSL hands a launch of a Windows binary such as `cmd.exe`, `powershell.exe`, or anything under `/mnt/c/` to the Windows host over a Unix socket, so whether a sandboxed command can launch one follows the sandbox’s [Unix-socket settings](</docs/en/settings-reference#sandbox-network-allowunixsockets>): the optional seccomp filter has to be installed to block the socket in the first place. To allow these launches, set `allowAllUnixSockets`, which opens every Unix socket to sandboxed commands.
###
@@ -103,14 +161,14 @@
Auto-allow mode
-When a command can be sandboxed, Claude Code runs it inside the sandbox and approves it automatically, without asking your permission. Commands that cannot be sandboxed, such as those needing network access to non-allowed hosts, fall back to the regular permission flow, where Claude Code checks your [permission rules](</docs/en/permissions>) and gates any command those rules do not already allow, with a prompt in Manual mode. Even in auto-allow mode, the following still apply:
+Claude Code approves a command automatically, with no prompt, when the command runs inside the sandbox. A command goes through the regular [permission flow](</docs/en/permissions>) when it runs outside the sandbox because it matches `excludedCommands` or because Claude retries it unsandboxed. A sandboxed command that connects to a host you haven’t allowed stays in the sandbox. Hosts outside your allowed domains covers who decides whether the connection goes through. Even in auto-allow mode, the following still apply:
* Explicit [deny rules](</docs/en/permissions>) are always respected
* `rm` or `rmdir` commands that target a [critical path](</docs/en/permission-modes#critical-paths>) still go through the regular permission flow
* Content-scoped [ask rules](</docs/en/permissions>) like `Bash(git push *)` still force a prompt even for sandboxed commands
- * A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones. Before v2.1.212, the skip applied in plan mode as well
-
-Auto-allow mode works independently of your permission mode setting, with three exceptions: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), an auto mode command that carries per-command allowed domains, and [server-side classifier review](</docs/en/permission-modes#how-the-classifier-evaluates-actions>) of sandboxed commands in auto mode. Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even in Manual mode, where the file edit tools would prompt.In plan mode, auto-allow doesn’t widen approvals; see [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) for how Claude Code gates commands while you plan. Before v2.1.212, auto-allow ran sandboxed commands without a prompt in plan mode too.
+ * A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones
+
+Auto-allow mode works independently of your permission mode setting, with three exceptions: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), an auto mode command that carries per-command allowed domains, and [server-side classifier review](</docs/en/permission-modes#how-the-classifier-evaluates-actions>) of sandboxed commands in auto mode. Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even in Manual mode, where the file edit tools would prompt.In plan mode, auto-allow doesn’t widen approvals; see [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) for how Claude Code gates commands while you plan.
####
@@ -126,7 +184,27 @@
The unsandboxed retry escape hatch
-Some commands can’t run inside the sandbox at all, such as tools that are incompatible with it or that need a host you haven’t allowed. Claude Code reports sandbox violations in the blocked command’s result, naming the path or host the sandbox denied, so Claude sees what the sandbox blocked. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: Claude analyzes the violation and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow. In Manual mode you get a confirmation prompt. In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), the classifier evaluates the underlying command. While [`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>) is on, a retry that needs approval to run outside the sandbox prompts you instead. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings-reference#sandbox-settings>). With the escape hatch disabled, Claude Code ignores the `dangerouslyDisableSandbox` parameter, and every command Claude runs must run sandboxed unless you’ve listed it in `excludedCommands`. The `/sandbox` **Overrides** tab shows this setting as **Strict sandbox mode**. Strict sandbox mode applies to the commands Claude runs. Commands you type yourself at the [`!` shell-mode prompt](</docs/en/interactive-mode#shell-mode-with-prefix>) run outside the sandbox unless the session is one of these:
+The unsandboxed retry is an escape hatch for commands that fail inside the sandbox, such as tools that are incompatible with it. When the sandbox blocks a network connection, Claude Code names the denied host in the command’s result, so Claude sees what was blocked. Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs unsandboxed. In an interactive terminal session, who approves it depends on your permission mode:
+
+ * **`bypassPermissions` mode**: the retry runs without a prompt
+ * **Manual mode and`acceptEdits` mode**: you get a prompt titled “Bash command (unsandboxed)”
+ * **[Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>)** : a separate classifier model evaluates the underlying command
+ * **`dontAsk` mode**: Claude Code denies the retry
+ * **Plan mode** : see [how Claude Code gates commands while you plan](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>)
+
+These rules and settings change who approves the retry:
+
+ * **A matching allow rule** : if an allow rule such as `Bash(curl *)` matches the command, it also approves the retry, so the command runs outside the sandbox with no prompt
+ * **An ask rule for the parameter** : add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)` to be prompted on Bash retries. You get the prompt in auto mode and `bypassPermissions` mode too, and the rule takes precedence over a matching allow rule
+ * **[`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>)** : [Actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) covers the retries that prompt while it’s on
+
+####
+
+
+
+Turn off the retry with strict sandbox mode
+
+You can disable the unsandboxed retry by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings-reference#sandbox-settings>). With the retry disabled, Claude Code ignores the `dangerouslyDisableSandbox` parameter. While the sandbox is running, commands Claude runs are then sandboxed unless they match an `excludedCommands` entry. To keep Claude Code from running commands unsandboxed when the sandbox can’t start, also set [`failIfUnavailable`](</docs/en/settings-reference#sandbox-failifunavailable>). The `/sandbox` **Overrides** tab shows this setting as **Strict sandbox mode**. A `false` in your user settings, `--settings`, or managed settings holds even when a project’s settings set `true`. A `false` in your user settings doesn’t make the sandbox admin-required, so a project’s other sandbox settings still apply. Before v2.1.285, a project’s `true` overrode a `false` in your user settings. If you or your administrator disable the retry in managed settings or with the `--settings` flag, the sandbox becomes admin-required. Claude Code then ignores the settings in a repository’s files that loosen the sandbox, `excludedCommands` entries included. Repository settings under an admin-required sandbox lists them. Strict sandbox mode applies to the commands Claude runs. Commands you type yourself at the [`!` shell-mode prompt](</docs/en/interactive-mode#shell-mode-with-prefix>) run outside the sandbox unless the session is one of these:
* **A[background session](</docs/en/agent-view>)**: strict sandbox mode covers shell-mode commands too
* **A Linux session with[`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars#variables>) set**: every command runs sandboxed, shell-mode commands included
@@ -158,15 +236,7 @@
}
}
-These paths are enforced at the OS level, so all commands running inside the sandbox, including their child processes, respect them. This is the recommended approach when a tool needs write access to a specific location, rather than excluding the tool from the sandbox entirely with `excludedCommands`. When you define the same filesystem array in multiple [settings scopes](</docs/en/settings#settings-precedence>), Claude Code merges them, combining paths from every scope rather than replacing one scope’s array with another’s. If you exclude a source with [`--setting-sources`](</docs/en/cli-reference>) on the CLI or [`settingSources`](</docs/en/agent-sdk/claude-code-features#control-filesystem-settings-with-settingsources>) in the Agent SDK, Claude Code ignores its `sandbox.filesystem` entries, its `Edit` permission rules, and its `Read` deny rules when building the sandbox configuration. Requires Claude Code v2.1.246 or later. When you edit these filesystem lists during a session, Claude Code [applies the change to the running session](</docs/en/settings#when-edits-take-effect>), so the next sandboxed command runs under the new paths. Path prefixes control how paths are resolved:
-
-Prefix| Meaning| Example
----|---|---
-`/`| Absolute path from filesystem root| `/tmp/build` stays `/tmp/build`
-`~/`| Relative to home directory| `~/.kube` becomes `$HOME/.kube`
-`./` or no prefix| Relative to the project root for project settings, or to `~/.claude` for user settings| `./output` in `.claude/settings.json` resolves to `<project-root>/output`
-
-This syntax differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. Sandbox filesystem paths use standard conventions: `/tmp/build` is absolute. For how Claude Code treats a trailing slash or a wildcard in these paths, see [Sandbox path prefixes](</docs/en/settings-reference#sandbox-path-prefixes>). You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`, and re-allow specific paths within a denied region using `sandbox.filesystem.allowRead`. When read rules overlap, the rule with the narrower path applies:
+These paths are enforced at the OS level, so all commands running inside the sandbox, including their child processes, respect them. This is the recommended approach when a tool needs write access to a specific location, rather than excluding the tool from the sandbox entirely with `excludedCommands`. When you define the same filesystem array in multiple [settings scopes](</docs/en/settings#settings-precedence>), Claude Code merges them, combining the paths rather than replacing one scope’s array with another’s. Claude Code leaves an entry out of the merge when a lock under Keep developers from widening the policy covers it. If you exclude a source with [`--setting-sources`](</docs/en/cli-reference>) on the CLI or [`settingSources`](</docs/en/agent-sdk/claude-code-features#control-filesystem-settings-with-settingsources>) in the Agent SDK, Claude Code ignores its `sandbox.filesystem` entries, its `Edit` permission rules, and its `Read` deny rules when building the sandbox configuration. Requires Claude Code v2.1.246 or later. When you edit these filesystem lists during a session, Claude Code [applies the change to the running session](</docs/en/settings#when-edits-take-effect>), so the next sandboxed command runs under the new paths. Sandbox filesystem paths use standard conventions: `/tmp/build` is absolute and `~/.kube` is relative to your home directory. This differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. For relative paths, trailing slashes, and wildcards, see [Sandbox path prefixes](</docs/en/settings-reference#sandbox-path-prefixes>). You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`, and re-allow specific paths within a denied region using `sandbox.filesystem.allowRead`. When read rules overlap, the rule with the narrower path applies:
Example rules| Result
---|---
@@ -174,7 +244,7 @@
`"allowRead": ["~/"]` with `"denyRead": ["~/.env"]`| `~/.env` stays blocked and the rest of the home directory is readable. The deny holds inside a wider allow, so a broad allow can’t silently re-expose a secret
`"allowRead": ["~/"]` with `"denyRead": ["~/**/.env"]`| Every `.env` under the home directory stays blocked and the rest is readable. A [wildcard deny](</docs/en/settings-reference#sandbox-path-prefixes>) holds inside a wider allow the same way an exact path does
-The example below blocks reading from the entire home directory while still allowing reads from the current project. Place it in your project’s `.claude/settings.json`, because the relative path `.` resolves to the project root only when the configuration lives in project settings:
+The example below blocks reading from the entire home directory while still allowing reads from the current project. Place it in your project’s `.claude/settings.json`, because the relative path `.` resolves to the project root when the configuration lives in project settings:
{
"sandbox": {
@@ -187,6 +257,39 @@
}
If you placed the same configuration in `~/.claude/settings.json`, `.` would resolve to `~/.claude` instead, and project files would remain blocked by the `denyRead` rule. To deny sandboxed commands read access to home directories and mounted volumes while keeping the working directories readable, set [`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>) instead of writing path rules.
+
+###
+
+
+
+Run commands outside the sandbox with `excludedCommands`
+
+List a command pattern in [`sandbox.excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>) to run matching commands outside the sandbox, which means no filesystem restrictions and no network proxy. Use it for a tool that can’t work inside the sandbox and that you trust with your full access. A tool that needs one more directory or one more host may work with `allowWrite` or `allowedDomains`, which keep the command sandboxed. This example takes `docker compose` commands out of the sandbox. Save it in `~/.claude/settings.json` to apply it to all of your projects:
+
+ {
+ "sandbox": {
+ "enabled": true,
+ "excludedCommands": ["docker compose *"]
+ }
+ }
+
+Claude Code checks your entries against each Bash and Monitor call. A call is the whole command line Claude sends, which can chain several commands. The following rules decide whether a call leaves the sandbox:
+
+ * **End the pattern with` *`**: entries use the same syntax as a `Bash(...)` [permission rule](</docs/en/permissions#permission-rule-syntax>), where a pattern with no wildcard is an exact match. `docker` matches only `docker` with no arguments. `docker *` matches `docker` with or without arguments
+ * **Every command in the call has to match** : `npm ci && docker compose build` stays sandboxed unless another entry covers `npm ci`
+ * **Claude Code matches the text of the call** : a script or `make` target that calls `docker` internally doesn’t match, and neither does `/usr/local/bin/docker`
+ * **Some calls stay sandboxed** : a redirect to a file, a `cd`, or a command substitution such as `$(...)` keeps the whole call sandboxed. The [reference entry](</docs/en/settings-reference#sandbox-excludedcommands>) lists more calls that stay sandboxed
+ * **Where you save the entry can matter** : while the sandbox is admin-required, Claude Code ignores entries in `.claude/settings.json` and `.claude/settings.local.json`
+
+An excluded command goes through the regular permission flow:
+
+ * [Read-only commands](</docs/en/permissions#read-only-commands>) and commands your allow rules cover run without a prompt
+ * In auto mode, the classifier reviews other excluded commands
+ * In `bypassPermissions` mode, an excluded command runs without a prompt unless an ask rule matches it
+
+To confirm an entry matches, switch to Manual mode and ask Claude to run a matching command that changes something, such as `docker compose up -d`. The permission prompt is titled “Bash command (unsandboxed)”.
+
+An excluded command runs with your full access. A broad entry such as `docker *` covers everything that tool can do. If you write a pattern that covers an interpreter, a script inside your working directory, or a tool that acts on a file there, as `docker compose` does with its compose file, Claude can write that file and then run it outside the sandbox. A narrower pattern leaves less that Claude can run outside the sandbox.
###
@@ -208,7 +311,7 @@
}
}
-The sandbox has two independent layers: filesystem isolation controls which paths sandboxed commands can read and write, and network isolation controls which domains they can reach. With the filesystem layer off, sandboxed commands get unrestricted read and write access to the host filesystem, while their network egress stays confined to your allowed domains. Turn the layer off when you sandbox to control where commands connect rather than what they write. The setting is off by default and applies on the platforms where the sandbox runs: macOS, Linux, and WSL2. Requires Claude Code v2.1.216 or later.
+The sandbox has two independent layers: filesystem isolation controls which paths sandboxed commands can read and write, and network isolation controls which domains they can reach. With the filesystem layer off, sandboxed commands get unrestricted read and write access to the host filesystem, while their network egress stays confined to your allowed domains. Turn the layer off when you sandbox to control where commands connect rather than what they write. `sandbox.filesystem.disabled` defaults to `false`. Requires Claude Code v2.1.216 or later.
With filesystem isolation off and commands auto-allowed, a sandboxed command can write files that later commands run or read, such as shell startup files, executables on `$PATH`, or `~/.claude/settings.json`, and use them to widen its own access on the next run. Set `filesystem.disabled` to `true` only for workloads you trust not to escalate their own access. Locking network domains with `allowManagedDomainsOnly` narrows the risk but doesn’t remove it, since that lock applies only to commands running inside the sandbox.
@@ -224,16 +327,7 @@
* When managed settings configure `sandbox.filesystem` at all, or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set the key. This keeps administrator-deployed filesystem restrictions in force; to relax such a deployment, set `"disabled": true` in managed settings.
* When [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>) is set, Claude Code ignores `filesystem.disabled` from every source, including managed settings, and keeps filesystem isolation on.
-Whether a managed `credentials.files` entry pins `filesystem.disabled`, locking the key to managed settings so developers can’t turn filesystem isolation off, depends on the entry’s `mode` and what happens to the entry when the sandbox starts:
-
-Managed entry| Pins `filesystem.disabled`| What protects the file when isolation is off
----|---|---
-`"mode": "deny"`| Yes| Nothing: the read block is part of the filesystem layer
-`"mode": "mask"`, applied as a mask| No| Masking itself: the sentinel copy and proxy on Linux and WSL2, the sandbox’s own read rules on macOS
-`"mode": "mask"`, fallen back to `deny` at setup| No| Nothing, same as `deny`. List a path that can’t be masked, such as a directory, as an explicit `deny` entry, which pins the key
-`"mode": "mask"`, [degraded to `deny` by validation](</docs/en/managed-settings#invalid-entries-in-managed-settings>)| Yes, like an explicit `deny`| Nothing, same as `deny`
-
-A fallback happens when the sandbox starts, after Claude Code has already read the settings the pin check runs on, so a fallen-back entry never pins. Validation rewrites an invalid entry to `deny` while settings load, so a degraded entry pins like one you wrote as `deny`.
+A [valid](</docs/en/settings-reference#invalid-credential-entries-in-managed-settings>) `mask` entry doesn’t lock the key, even when Claude Code falls back to `deny` for it at startup. List a path that can’t be masked, such as a credential directory, as an explicit `deny` entry in managed settings, which locks the key.
####
@@ -281,7 +375,7 @@
Environment variable entries and file entries also accept `"mode": "mask"`, described under Mask credentials. File paths follow the same [prefix rules](</docs/en/settings-reference#sandbox-path-prefixes>) as `sandbox.filesystem.*` settings. Claude Code merges the `deny` entries from every [settings scope](</docs/en/settings#settings-precedence>) the session loads. A `deny` entry only ever narrows access, so any scope can add one, but no scope can remove one that another scope added. When you exclude a settings source:
* **Project or local settings** : Claude Code applies none of their `credentials` entries. Requires Claude Code v2.1.246 or later.
- * **User settings** : Claude Code still applies the `deny` entries in `~/.claude/settings.json` and keeps its file `mask` entries as restrictions, but drops its environment variable `mask` entries.
+ * **User settings** : Claude Code still applies the `deny` entries in `~/.claude/settings.json` and keeps its file `mask` entries as restrictions that no longer authorize the proxy to substitute the real value, but drops its environment variable `mask` entries.
There is no built-in credential deny list, so only the files and variables you list are restricted. `sandbox.credentials` affects sandboxed Bash commands only. To strip credentials from all subprocesses regardless of sandboxing, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>).
@@ -291,7 +385,11 @@
Mask credentials
-Masking goes further than a `deny` entry under Protect credentials. Instead of blocking a credential, Claude Code shows sandboxed commands a placeholder, the sentinel, and the sandbox proxy swaps in the real value on outbound requests to hosts you allow. For files, the substitution is Linux and WSL2 behavior; macOS blocks the file instead.
+When you mask a credential, Claude Code shows sandboxed commands a per-session placeholder called the sentinel, and the sandbox proxy substitutes the real value on outbound requests to hosts you allow. A `deny` entry under Protect credentials blocks the credential instead. For files on macOS, Claude Code blocks the file instead of masking it. Masking environment variables requires Claude Code v2.1.199 or later. The [`sandbox.credentials`](</docs/en/settings-reference#sandbox-credentials>) reference lists every field. Masking requires the following:
+
+ * **TLS termination** : the proxy substitutes the real value inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) so the proxy terminates TLS itself. Without it, masking fails without exposing anything: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup.
+ * **An allowed destination** : each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. The proxy injects only on connections the domain allowlist admits, so each `injectHosts` host must also be reachable through `network.allowedDomains`. For a `mask` entry with no `injectHosts`, the proxy substitutes the real value on requests to every host in `network.allowedDomains`.
+ * **A trusted settings scope** : masking authorizes the proxy to send your real credential somewhere, so Claude Code honors `mask` entries, `network.tlsTerminate`, [`credentials.allowPlaintextInject`](</docs/en/settings-reference#sandbox-credentials-allowplaintextinject>), `awsPairs`, and `sigv4` only from user settings, managed settings, and the `--settings` flag. It ignores them in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. When your administrator delivers `mask` entries, `network.tlsTerminate`, or `credentials.allowPlaintextInject` through server-managed settings, they count as [settings that need approval](</docs/en/server-managed-settings#security-approval-dialogs>).
####
@@ -299,7 +397,7 @@
Mask environment variables
-`"mode": "mask"` protects a credential while keeping the tools that authenticate with it working. `deny` removes the variable entirely, which also breaks tools that need it, such as `gh` or `npm`. Requires Claude Code v2.1.199 or later. With `mask`, the sandboxed command sees a per-session sentinel value instead of the real one. Each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. When a request leaves the sandbox for one of them, the sandbox proxy replaces the sentinel with the real value. The command and anything it logs never hold the real credential, but its requests still authenticate. The proxy substitutes the credential inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) so the proxy terminates TLS itself. Without it, masking fails without exposing anything: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup. Substitution covers headers and request bodies. Requests that authenticate with a signature derived from the credential, rather than the credential itself, need re-signing at the proxy; Re-sign AWS requests covers how that works for AWS. The proxy injects only on connections the domain allowlist admits, so each `injectHosts` destination must also be reachable through `network.allowedDomains`. The example below masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`.
+To mask an environment variable, set `"mode": "mask"` on its `credentials.envVars` entry. The command and anything it logs never hold the real credential, but its requests still authenticate. When the same variable is listed with `deny` in any scope, `deny` takes precedence. This example masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`:
{
"sandbox": {
@@ -317,21 +415,12 @@
}
}
-Spell an IPv6 destination differently in the two lists, because each list has its own matcher:
-
- * **`network.allowedDomains`** : the bracketed form domain lists use, such as `"[::1]"`. The proxy checks this list to admit the connection.
- * **`injectHosts`** : the bare address in its canonical compressed form, such as `"::1"` or `"2001:db8::1"`. The proxy matches each entry against the connection’s bare destination address, ignoring ports, so a bracketed, zone-ID, or differently compressed spelling never matches and the proxy never injects the credential there.
-
-`claude doctor` flags `injectHosts` entries that can never match with the warning `Sandbox credential injectHosts entries can never match their destination`. This check requires Claude Code v2.1.229 or later. Unlike `deny`, masking authorizes the proxy to send your real credential to the listed hosts, so Claude Code honors it only from settings you or your administrator control: user settings, managed settings, and the `--settings` CLI flag. Claude Code ignores `mask` entries in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. In those files it also ignores `network.tlsTerminate` and [`credentials.allowPlaintextInject`](</docs/en/settings-reference#sandbox-credentials-allowplaintextinject>), the setting that lets the proxy inject credentials into unencrypted requests. If you exclude user settings, Claude Code drops the environment variable `mask` entries in `~/.claude/settings.json` too. When your administrator delivers `mask` entries, `network.tlsTerminate`, or `credentials.allowPlaintextInject` through server-managed settings, they count as [settings that need approval](</docs/en/server-managed-settings#security-approval-dialogs>). When the same variable is listed with `deny` in any scope, `deny` takes precedence. Masking replaces the variable’s entire value by default, which suits a bare token. Optional entry fields, which require Claude Code v2.1.224 or later, handle values with structure:
-
- * `extract`: a regular expression Claude Code applies across the value, replacing only the text captured by group 1 of each match, so a tool that parses the value, such as a `DATABASE_URL` connection string, still works inside the sandbox. The pattern must contain at least one capturing group.
- * `onExtractNoMatch` controls what happens when the pattern matches nothing:
- * `warn`, the default, warns and passes the variable through unmasked
- * `deny` unsets the variable inside the sandbox
- * `error` stops sandbox setup until you fix the configuration
- * `decode: "jwt"`: for a variable holding a JSON Web Token (JWT). Claude Code verifies the value is a JWT and replaces it with a structurally valid fake token, so code inside the sandbox that decodes the token keeps working. Add `maskClaims` to list top-level payload claims to mask individually instead of replacing the whole token; the other claims stay readable. When the value doesn’t verify as a JWT, or no listed claim matches, Claude Code passes the variable through unmasked with a warning. `decode` can’t be combined with `extract`.
-
-See the [`credentials.envVars[]` rows in the settings reference](</docs/en/settings-reference#sandbox-settings>) for the full field list.
+Masking replaces the whole value by default. For a value with structure, such as a `DATABASE_URL` connection string or a JWT, use the [`extract`, `decode`, `maskClaims`, and `onExtractNoMatch` fields](</docs/en/settings-reference#sandbox-credentials-envvars>) so tools that parse the value keep working. For an IPv6 destination, spell the address differently in the two lists:
+
+ * **`network.allowedDomains`** : the bracketed form, such as `"[::1]"`
+ * **`injectHosts`** : the bare address in its canonical compressed form, such as `"::1"`
+
+The proxy matches each `injectHosts` entry against the connection’s bare destination address, ignoring ports, so a bracketed, zone-ID, or differently compressed spelling never matches. `claude doctor` flags entries that can never match with the warning `Sandbox credential injectHosts entries can never match their destination`. This check requires Claude Code v2.1.229 or later.
####
@@ -339,36 +428,7 @@
Re-sign AWS requests
-AWS requests carry SigV4 signatures over the request contents, so mask `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` together. The proxy detects a SigV4 request by the access key’s sentinel and re-signs it after substituting the real values. Masking the secret alone leaves requests signed with the placeholder, which the proxy can’t detect, so they fail at AWS; Claude Code warns about this case at startup, but not when only the access key ID is masked. A detected request the proxy can’t re-sign, such as one missing its `x-amz-date` header, fails with a proxy error instead of reaching the server with a broken signature. Claude Code links the conventional `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` variables into one credential automatically when you mask their whole values. If your AWS credential lives in variables with other names, group them yourself with [`credentials.awsPairs`](</docs/en/settings-reference#sandbox-credentials-awspairs>), which requires Claude Code v2.1.224 or later. This example adds the pairing to a configuration that already masks `MY_KEY_ID`, `MY_SECRET_KEY`, and `MY_SESSION_TOKEN` whole-value, as in the masking configuration above:
-
- {
- "sandbox": {
- "credentials": {
- "awsPairs": [
- {
- "accessKeyIdVar": "MY_KEY_ID",
- "secretAccessKeyVar": "MY_SECRET_KEY",
- "sessionTokenVar": "MY_SESSION_TOKEN"
- }
- ]
- }
- }
- }
-
-Each entry follows these rules:
-
- * `accessKeyIdVar` and `secretAccessKeyVar` name the masked `envVars` entries holding the access key ID and the secret key. The optional `sessionTokenVar` names the entry holding the session token for temporary credentials; when set, the proxy sends the real token as `x-amz-security-token` on re-signed requests.
- * Each named variable must be a `mask` entry that masks its entire value, without `extract` or `decode`.
- * The proxy re-signs requests on the hosts listed in the access key ID entry’s `injectHosts`.
- * Naming any of the conventional variables in a pair replaces the automatic pairing.
-
-Like `mask` entries, `awsPairs` is honored only from user settings, managed settings, and the `--settings` CLI flag. Three AWS request forms carry signatures the proxy can’t recompute. When such a request is signed with a masked pair’s placeholder, the proxy fails it rather than forward a broken signature; requests signed with unmasked credentials are never affected. The [`credentials.sigv4`](</docs/en/settings-reference#sandbox-credentials-sigv4>) setting, which requires Claude Code v2.1.224 or later, relaxes this per form: setting a form’s key to `passthrough` forwards the request with its placeholder-derived signature, so the calling tool receives AWS’s own rejection response instead of a proxy error. Like `awsPairs`, `sigv4` is honored only from user settings, managed settings, and the `--settings` CLI flag.
-
-Request form| `sigv4` key| Why the proxy can’t re-sign it
----|---|---
-aws-chunked streaming uploads| `streaming`| Per-chunk signatures chain off the seed signature, so re-signing would require rewriting the body
-Presigned URLs| `presigned`| The signature lives in the URL itself, with no `Authorization` header
-SigV4A asymmetric signatures| `sigv4a`| There is no shared-key HMAC to recompute
+AWS requests carry SigV4 signatures over the request contents, so mask `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` together. The proxy detects a SigV4 request by the access key’s sentinel and re-signs the request with the real values, which requires Claude Code v2.1.221 or later. If you mask only the secret, requests are signed with a placeholder the proxy can’t detect, so they fail at AWS. Claude Code links the conventional `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` variables into one credential automatically when you mask their whole values. If your AWS credential is in variables with other names, group them with [`credentials.awsPairs`](</docs/en/settings-reference#sandbox-credentials-awspairs>), which requires Claude Code v2.1.224 or later. Streaming uploads, presigned URLs, and SigV4A requests carry signatures the proxy can’t recompute. When one of these requests is signed with a masked pair’s placeholder, the proxy fails it rather than forward a broken signature. Requests signed with unmasked credentials aren’t affected. Use [`credentials.sigv4`](</docs/en/settings-reference#sandbox-credentials-sigv4>), which requires Claude Code v2.1.224 or later, to forward one of these request forms instead. AWS still rejects the request, so the calling tool receives AWS’s own rejection response instead of a proxy error.
####
@@ -376,12 +436,12 @@
Mask credential files
-File entries also accept `"mode": "mask"`, which requires Claude Code v2.1.221 or later. What a sandboxed command sees depends on the platform:
-
- * **Linux and WSL2** : sandboxed commands read a sentinel copy of the file, a stand-in whose secret is replaced with a placeholder value, and the sandbox proxy substitutes the real value on egress.
- * **macOS** : sandboxed commands can’t read the listed file at all. Claude Code builds no sentinel copy and substitutes nothing on egress, so tools that authenticate with the file don’t work inside the sandbox, the same effect as `deny`. Unlike a `deny` entry, the read block holds even when you disable filesystem isolation.
-
-On every platform, Claude Code applies the [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) requirement and `injectHosts` the same way as for masked environment variables, and ignores repository settings the same way. If you exclude user settings, Claude Code keeps the file `mask` entries in `~/.claude/settings.json` as restrictions, but the entries no longer authorize the proxy to substitute the real value. The example below masks a GitHub token stored in `~/.config/gh/hosts.yml`; the `extract` pattern, covered below, tells Claude Code which part of the file is the secret. On Linux and WSL2, sandboxed commands that read the file get a sentinel in place of the token, and the proxy substitutes the real token on requests to `api.github.com`:
+To mask a credential file, set `"mode": "mask"` on its `credentials.files` entry. Masking files requires Claude Code v2.1.221 or later. What a sandboxed command sees depends on the platform:
+
+ * **Linux and WSL2** : sandboxed commands read a sentinel copy of the file, and the proxy substitutes the real value on outbound requests.
+ * **macOS** : sandboxed commands can’t read the file at all. Claude Code builds no sentinel copy, so tools that authenticate with the file don’t work inside the sandbox, the same effect as `deny`. The read block holds even when you disable filesystem isolation.
+
+This example masks a GitHub token stored in `~/.config/gh/hosts.yml`. The `extract` pattern marks which part of the file is the secret, so on Linux and WSL2 `gh` still parses the rest of its config:
{
"sandbox": {
@@ -403,16 +463,11 @@
}
}
-To confirm the mask is active, ask Claude to run `cat ~/.config/gh/hosts.yml` in a sandboxed command: on Linux and WSL2 the output shows a sentinel value in place of the token, and on macOS the read fails instead. On Linux and WSL2, the `extract` pattern is what keeps the rest of `hosts.yml` readable. Claude Code applies the regular expression across the whole file and replaces only the text captured by group 1 of each match, so `gh` still parses its config and only the token is a placeholder. Use `extract` for any structured file that tools parse, such as `.netrc`, JSON, or YAML; the pattern must contain at least one capturing group. Without `extract`, Claude Code replaces the entire file content with one sentinel value, which suits a file that holds a single bare secret and nothing else. For a file that holds a JSON Web Token (JWT), set `decode: "jwt"` instead of, or together with, `extract`. `decode` requires Claude Code v2.1.224 or later. Claude Code finds JWT candidates with a built-in pattern, or with your `extract` pattern when set, verifies each candidate is a JWT, and replaces it with a structurally valid fake token, so code that decodes the token inside the sandbox keeps working. Add `maskClaims` to mask only the named top-level payload claims inside each verified token and leave the other claims readable. When no candidate verifies, or no named claim matches, the `onExtractNoMatch` field below governs the outcome, as it does for a pattern that matches nothing. Two optional fields refine how matching behaves. Both apply only when `mode` is `mask` and `extract` or `decode` is set. On macOS, Claude Code applies `mask` entries as `deny` before the pattern runs whenever filesystem isolation is on, so these fields, and the no-match outcomes below, take effect there only when filesystem isolation is off:
-
- * `onExtractNoMatch` controls what happens when matching finds nothing to mask in the file:
- * `warn`, the default, warns and skips the entry, so sandboxed commands can read the real file unmasked. The default suits credentials that may be legitimately absent; if the secret might be present but the pattern might miss it, use `deny`
- * `deny` makes the file unreadable instead
- * `error` stops sandbox setup until you fix the configuration
-Claude Code treats `deny` as `error` whenever the read block wouldn’t be enforced: when you disable filesystem isolation, and when a `filesystem.allowRead` entry from any settings source re-opens the file’s path.
- * `maskDuplicates` also replaces verbatim copies of each masked credential value, an `extract` capture or a `decode`-verified token, found outside the matched spans, for a secret repeated where matching doesn’t reach. It matches raw substrings, so a short or common value would be replaced everywhere it appears; reserve it for long, high-entropy secrets. Default: false.
-
-`mask` applies to a single file, so list each credential file individually. Claude Code falls back to `deny` for a `mask` entry it can’t mask safely: a directory path, a glob pattern, a file larger than 8 MiB, or a file that isn’t UTF-8 text. Write directories as explicit `deny` entries instead; the table under Which settings can disable it covers whether each form pins `filesystem.disabled` and how it behaves with filesystem isolation off.
+To confirm the mask is active, ask Claude to run `cat ~/.config/gh/hosts.yml` in a sandboxed command. On Linux and WSL2 the output shows a sentinel in place of the token, and on macOS the read fails. Without `extract` or `decode`, Claude Code replaces the entire file with one sentinel, which suits a file holding a single bare secret. Use the [`extract`, `decode`, `maskClaims`, `onExtractNoMatch`, and `maskDuplicates` fields](</docs/en/settings-reference#sandbox-credentials-files>) to control partial masking and what happens when the pattern matches nothing.
+
+When matching finds nothing to mask, the default `onExtractNoMatch` value, `warn`, skips the entry, so sandboxed commands can read the real file unmasked. On macOS, Claude Code applies `mask` entries as `deny` before the pattern runs whenever filesystem isolation is on, so the no-match outcomes take effect there only when filesystem isolation is off. The default suits credentials that may be legitimately absent. If the secret might be present but the pattern might miss it, use [`deny`](</docs/en/settings-reference#mask-fields-for-files>).
+
+`mask` applies to a single file, so list each credential file individually. Claude Code falls back to `deny` for a `mask` entry it can’t mask safely: a directory path, a glob pattern, a file larger than 8 MiB, or a file that isn’t UTF-8 text.
##
@@ -429,11 +484,9 @@
The sandboxed Bash tool restricts file system access to specific directories:
* **Default write behavior** : read and write access to the current working directory and its subdirectories, any directories you’ve added with `--add-dir`, `/add-dir`, or [`permissions.additionalDirectories`](</docs/en/settings-reference#permissions-additionaldirectories>), plus the per-user temp directory that `$TMPDIR` points to
- * **Default read behavior** : read access to the entire computer, except certain denied directories. Note that this default still allows reading credential files such as `~/.aws/credentials` and `~/.ssh/`. Use `sandbox.credentials` to block reads of these files and unset secret environment variables, or add the paths to `denyRead`.
+ * **Default read behavior** : read access to the entire computer, except certain denied directories. This default still allows reading credential files, so protect credentials you don’t want commands to read.
* **Read block** : with [`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>) on, sandboxed commands also lose read access to your home directory and the other directories that hold user files, apart from the paths that [Sandboxed commands under the block](</docs/en/settings-reference#sandboxed-commands-under-the-block>) lists. That section also says when this part of the block doesn’t apply.
- * **Blocked access** : cannot modify files outside the working directory, added directories, and the per-user temp directory without explicit permission, including shell configuration files such as `~/.bashrc` and system binaries in `/bin/`
* **Git worktrees** : when the working directory is a [linked git worktree](</docs/en/worktrees>), the sandbox also allows writes to the main repository’s shared `.git` directory so commands such as `git commit` can update refs and the index. Writes to `hooks/` and `config` inside that directory remain denied.
- * **Configurable** : define custom allowed and denied paths through settings
To skip filesystem isolation entirely while keeping network isolation, set `sandbox.filesystem.disabled`.
@@ -450,7 +503,7 @@
* **Files that would turn your working directory into a bare git repository** : `HEAD`, `objects`, and `refs` at the top level, plus existing `config` and `hooks` entries there when a `HEAD` sits beside them. A file named `config` is denied even with no `HEAD`. On Linux and WSL2, the sandbox deletes a top-level `HEAD` file or `objects` or `refs` directory that appears while a sandboxed command is running
* **In`~/.claude`, or the directory `CLAUDE_CONFIG_DIR` points to**: most of its contents, plus `~/.claude.json` and the `.credentials.json` credential store
-If a symlink appears at a protected settings file’s path during the session, the sandbox also denies writes to the file it points to, starting with the next command. There is no way to exempt one of these paths: an `allowWrite` entry or an `Edit` allow rule that covers the path doesn’t lift the protection. The only way to turn the protection off is `filesystem.disabled`, which turns off filesystem isolation for every path. To see most of these paths resolved for your machine, run `/sandbox` and open the **Config** tab, which lists them under **Denied within allowed** , mixed in with your own `denyWrite` entries. If `git merge` or `git checkout` fails with `unable to unlink old` on one of these paths, see Troubleshooting.
+If a symlink appears at a protected settings file’s path during the session, the sandbox also denies writes to the file it points to, starting with the next command. There is no way to exempt one of these paths: an `allowWrite` entry or an `Edit` allow rule that covers the path doesn’t lift the protection. The only way to turn the protection off is `filesystem.disabled`, which turns off filesystem isolation for every path. To see most of these paths resolved for your machine, run `/sandbox` and open the **Config** tab, which lists them under **Denied within allowed** , mixed in with your own `denyWrite` entries. If `git merge` or `git checkout` fails with `unable to unlink old` on one of these paths, see A git command fails with `unable to unlink old`.
###
@@ -458,16 +511,25 @@
Network isolation
-Network access is controlled through a proxy server running outside the sandbox:
-
- * **Domain restrictions** : Claude Code pre-allows no domains by default. The first time a command needs a new domain, Claude Code prompts for approval; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), Claude instead names the hosts a command needs on the command itself, per Per-command allowed domains.
- * **Approval choices** : if you choose Yes when prompted, Claude Code allows the host for the rest of the current session and doesn’t prompt again for later connections to the same host. If you choose “Yes, and don’t ask again”, Claude Code saves a `WebFetch(domain:...)` allow rule to your [local settings](</docs/en/permissions#permission-system>), so the host stays allowed in future sessions.
+A sandboxed command has no direct route to the network:
+
+ * **Linux and WSL2** : the command runs in a separate network namespace that has no connection to your network
+ * **macOS** : the Seatbelt sandbox framework by default blocks connections other than the one to the sandbox proxy
+
+Claude Code runs the sandbox proxy on your machine, outside the sandbox, and directs commands to it with `HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`, and related environment variables. The proxy checks the hostname of each connection against your allowed and denied domains. What a tool can reach depends on whether it uses the proxy:
+
+ * **Tools that read the proxy variables** : `curl`, `npm`, `git` over HTTPS, and similar tools connect once their host is allowed. An `allowedDomains` entry with no port allows every port on that host
+ * **Tools that ignore the proxy variables** : plain `ssh`, most database drivers, and similar tools can’t connect, even to an allowed host. See A database client or other non-HTTP tool fails to reach an allowed host
+ * **Anything that isn’t TCP** : UDP, HTTP/3 over QUIC, and ICMP tools such as `ping` can’t leave the sandbox
+
+The following settings and behaviors control which hosts the proxy allows:
+
+ * **Domain restrictions** : your allowed domains start empty. Hosts outside your allowed domains covers what happens the first time a command needs a new domain.
+ * **Approval choices** : if you choose Yes when prompted, Claude Code allows the host for the rest of the current session. If you choose “Yes, and don’t ask again”, Claude Code saves a `WebFetch(domain:...)` allow rule to your [local settings](</docs/en/permissions#permission-system>), so the host stays allowed in future sessions. While the sandbox is admin-required, Claude Code saves the rule to your user settings, where it applies in every project.
* **Pre-allowed domains** : pre-allow domains with [`allowedDomains`](</docs/en/settings-reference#sandbox-network-alloweddomains>) to avoid the prompt entirely. Claude Code also pre-allows domains from `WebFetch(domain:...)` allow rules, as described in Permission rules.
- * **Strict allowlist** : if you set [`strictAllowlist`](</docs/en/settings-reference#sandbox-network-strictallowlist>) to `true` in user, managed, or CLI `--settings` settings, Claude Code denies sandboxed commands access to any host outside the allowlist instead of prompting. The allowlist is the same one the sandbox otherwise prompts against: `allowedDomains` plus domains from `WebFetch(domain:...)` allow rules, or only the managed settings entries when `allowManagedDomainsOnly` is set. Claude Code enforces this for sandboxed commands only; in-process tools such as `WebFetch` still follow their permission rules. Setting it in a repository’s `.claude/settings.json` or `.claude/settings.local.json` has no effect. Requires Claude Code v2.1.219 or later.
+ * **Strict allowlist** : if you set [`strictAllowlist`](</docs/en/settings-reference#sandbox-network-strictallowlist>) to `true` in user, managed, or CLI `--settings` settings, Claude Code denies sandboxed commands access to any host outside the allowlist instead of prompting. The allowlist is `allowedDomains` plus domains from `WebFetch(domain:...)` allow rules, or only the managed settings entries when `allowManagedDomainsOnly` is set. Locks that apply without an admin-required sandbox covers a repository’s entries. Claude Code enforces this for sandboxed commands only; in-process tools such as `WebFetch` still follow their permission rules. Setting it in a repository’s `.claude/settings.json` or `.claude/settings.local.json` has no effect. Requires Claude Code v2.1.219 or later.
* **Managed lockdown** : if [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>) is set in managed settings, non-allowed domains are blocked automatically instead of prompting, and only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are honored.
- * **Corporate proxy** : when your network requires outbound traffic to go through a corporate proxy, set `HTTPS_PROXY`, `HTTP_PROXY`, and `NO_PROXY` as [proxy configuration](</docs/en/network-config#proxy-configuration>) describes, in the `env` block of your settings so that [background agents](</docs/en/network-config#set-network-variables-in-settings-not-the-shell>) get them too, or in the environment you launch Claude Code from. Claude Code enforces the domain allowlist and then tunnels allowed connections through that upstream proxy.
- * **Custom proxy support** : advanced users can implement custom rules on outgoing traffic
- * **Comprehensive coverage** : restrictions apply to all scripts, programs, and subprocesses spawned by commands
+ * **Corporate proxy** : when your network requires outbound traffic to go through a corporate proxy, set `HTTPS_PROXY`, `HTTP_PROXY`, and `NO_PROXY` as [proxy configuration](</docs/en/network-config#proxy-configuration>) describes, in the `env` block of your settings so that [background agents](</docs/en/network-config#set-network-variables-in-settings-not-the-shell>) get them too, or in the environment you launch Claude Code from. Claude Code enforces the domain allowlist and then tunnels allowed connections through that upstream proxy. `http://` and `https://` proxy URLs work, with basic authentication in the URL if you need it.
In a `WebFetch(domain:...)` rule, the sandbox honors two wildcard forms: a leading `*.`, such as `*.example.com`, and a bare `*`. The bare `*` form requires Claude Code v2.1.186 or later. A wildcard in any other position, such as `WebFetch(domain:example.*)`, still matches fetches but has no effect on sandboxed commands.
@@ -477,6 +539,31 @@
+Hosts outside your allowed domains
+
+When a sandboxed command connects to a host that isn’t in your allowed domains, the command stays in the sandbox and waits for a decision. In an interactive terminal session, the decision depends on your permission mode:
+
+Permission mode| What happens to the connection
+---|---
+`bypassPermissions` mode, and plan mode with [bypass permissions available](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>)| Allowed without a prompt
+Manual mode, `acceptEdits` mode, and plan mode otherwise| You get a prompt
+Auto mode| Refused unless the command listed the host and the classifier approved the list
+`dontAsk` mode| Refused
+
+With [`strictAllowlist`](</docs/en/settings-reference#sandbox-network-strictallowlist>) or [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>) on, the built-in sandbox proxy refuses the connection in every permission mode. In `bypassPermissions` mode, hosts outside your allowed domains are allowed unless one of them is on. The unsandboxed retry escape hatch covers when a command can leave the sandbox in that mode. A connection to a host in [`deniedDomains`](</docs/en/settings-reference#sandbox-network-denieddomains>) is refused in every permission mode too.
+
+####
+
+
+
+Hostnames that resolve to local addresses
+
+After a hostname passes the allowlist, the sandbox proxy resolves it and refuses the connection when the name resolves only to local addresses. Local addresses include loopback addresses such as `127.0.0.1`, link-local addresses such as the `169.254.169.254` cloud metadata endpoint, and addresses assigned to your own machine. The names `localhost` and `*.localhost` are allowed to resolve to loopback. An allowed intranet hostname that resolves to a private range such as `10.0.0.0/8` connects. To let a name resolve to a refused address, add that IP address to `allowedDomains`, such as `"127.0.0.1:8080"`. The check applies to hostnames. Your allowed domains and permission mode decide a connection to an IP address. The proxy also skips the check for connections it sends through an upstream corporate proxy, because that proxy resolves the name.
+
+####
+
+
+
Per-command allowed domains in auto mode
In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) with sandboxing on, Claude names the hosts a command needs on the command itself instead of triggering a network approval for each connection. Each Bash, PowerShell, or [Monitor](</docs/en/tools-reference#monitor-tool>) command that runs in the sandbox can carry a list of hosts beyond the sandbox’s allowlist: a domain such as `registry.npmjs.org`, a wildcard such as `*.pythonhosted.org`, or an IP address, each with an optional `:port`. The classifier reviews the hosts together with the command. Requires Claude Code v2.1.271 or later. An approved list opens those hosts for that one command alone, for as long as it runs. Nothing is added to your session’s allowed hosts or your settings; the next command names its own hosts. A command that carries hosts goes to the classifier instead of being approved by a permission rule or the sandbox’s auto-allow mode. If an [ask rule](</docs/en/permissions#manage-permissions>) forces a prompt for the command, the permission dialog in your terminal lists the hosts beside it, and approving there covers both. A per-command list widens only what the sandbox denies by default. [`deniedDomains`](</docs/en/settings-reference#sandbox-network-denieddomains>) entries still block. When [`strictAllowlist`](</docs/en/settings-reference#sandbox-network-strictallowlist>) or [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>) locks the allowlist, Claude Code refuses per-command lists. While per-command lists apply, Claude Code refuses a connection to a host that no approved command listed, without a prompt or a classifier check. The refusal names the host in the command’s result, and Claude re-runs the command with the host added.
@@ -487,12 +574,12 @@
IPv6 addresses in domain lists
-The sandbox’s domain lists are `allowedDomains`, `deniedDomains`, and the `WebFetch(domain:...)` rules that feed them. To match an IPv6 address in any of them, write the literal in brackets: `"[::1]"` matches that address on every port, and `"[::1]:443"` matches it on port 443 only. Write the port as a number from 1 to 65535 with no leading zeros. The bracketed form requires Claude Code v2.1.229 or later. Before v2.1.229, when the text after an unbracketed entry’s last colon was a port number, Claude Code read it as one, so `::1:443` named the address `::1` on port 443. When you choose “Yes, and don’t ask again” at the network approval prompt for an IPv6 address, Claude Code saves the `WebFetch(domain:...)` rule with the address bracketed, so the rule keeps matching the address in future sessions. An unbracketed entry with two or more colons is ambiguous: `::1:443` is both a complete IPv6 address and an address followed by a port. Claude Code enforces ambiguous spellings conservatively instead of guessing which reading you meant:
-
- * **Deny lists** : Claude Code denies every reading the entry parses as, so whichever reading you meant is blocked. For an entry with no parseable reading, Claude Code blocks nothing.
- * **Allow lists** : Claude Code never allows more than you wrote. It rewrites an ambiguous entry to its host-and-port reading when that reading parses cleanly, and may drop the entry entirely rather than widen the allowlist.
-
-Run `claude doctor` in your terminal to find the affected entries: the `Sandbox network domain entries have unreliable spellings` warning names up to three of them and counts the rest. Rewrite each one in the bracketed form to clear the warning. The warning also names entries whose spelling is unreliable for other reasons, such as `@`, path or query characters, or wildcards inside brackets.
+To match an IPv6 address in `allowedDomains`, `deniedDomains`, or a `WebFetch(domain:...)` rule, write the address in brackets: `"[::1]"` matches that address on every port, and `"[::1]:443"` matches it on port 443 only. The bracketed form requires Claude Code v2.1.229 or later. An unbracketed entry such as `::1:443` is ambiguous between an address and an address with a port:
+
+ * **Deny lists** : Claude Code denies every reading the entry parses as, so whichever reading you meant is blocked. For an entry with no parseable reading, Claude Code blocks nothing
+ * **Allow lists** : Claude Code never allows more than you wrote. It rewrites an ambiguous entry to its host-and-port reading when that reading parses cleanly, and may drop the entry entirely rather than widen the allowlist
+
+To find ambiguous entries, run `claude doctor` in your terminal and look for the `Sandbox network domain entries have unreliable spellings` warning. Rewrite each ambiguous entry in the bracketed form.
###
@@ -506,7 +593,7 @@
* **Linux** : uses [bubblewrap](<https://github.com/containers/bubblewrap>) for isolation
* **WSL2** : uses bubblewrap, same as Linux
-WSL1 is not supported because bubblewrap requires kernel features only available in WSL2. These same primitives are available as the standalone [`@anthropic-ai/sandbox-runtime`](<https://github.com/anthropic-experimental/sandbox-runtime>) package, which the [Sandbox environments](</docs/en/sandbox-environments#sandbox-runtime>) page covers as a separate approach for wrapping the entire Claude Code process.
+You can also run the [`@anthropic-ai/sandbox-runtime`](<https://github.com/anthropics/sandbox-runtime>) package on its own to wrap the Claude Code process. See [Sandbox runtime](</docs/en/sandbox-environments#sandbox-runtime>).
##
@@ -573,7 +660,7 @@
Enforce sandboxing with managed settings
-To require the sandbox for every developer, deliver the `sandbox` keys through [managed settings](</docs/en/managed-settings#delivery-mechanisms>), either as a file managed by your MDM or through [server-managed settings](</docs/en/server-managed-settings>) on claude.ai. The following managed settings configuration enables the sandbox, refuses to start Claude Code if the sandbox cannot initialize, and prevents the model from retrying commands outside the sandbox:
+To require the sandbox for every developer, deliver the `sandbox` keys through [managed settings](</docs/en/managed-settings#delivery-mechanisms>), either as a file managed by your MDM or through [server-managed settings](</docs/en/server-managed-settings>) on claude.ai. The following managed settings configuration enables the sandbox, refuses to start Claude Code when the platform is unsupported or a dependency is missing, and prevents the model from retrying commands outside the sandbox:
{
"sandbox": {
@@ -585,10 +672,18 @@
The two keys beyond `enabled` control what happens when the sandbox cannot run a command:
- * **`failIfUnavailable`** : a missing dependency such as bubblewrap on Linux blocks Claude Code from starting rather than showing a warning and falling back to unsandboxed execution
+ * **`failIfUnavailable`** : a missing dependency such as bubblewrap on Linux blocks Claude Code from starting rather than falling back to unsandboxed execution
* **`allowUnsandboxedCommands: false`** : Claude Code ignores the `dangerouslyDisableSandbox` escape hatch, so when a command fails under the sandbox, Claude can’t retry it unsandboxed
-Two additions are worth considering alongside them. Add `excludedCommands` for any organization-approved tools that must run without isolation. Add `sandbox.credentials` entries for credential directories such as `~/.aws` and `~/.ssh` and for secret environment variables, since the default read policy still allows them. This configuration sandboxes the commands Claude runs. A developer can still type a command at the [`!` shell-mode prompt](</docs/en/interactive-mode#shell-mode-with-prefix>) and run it outside the sandbox, with the same access they already have in any terminal outside Claude Code. See The unsandboxed retry escape hatch for the sessions where typed commands run sandboxed. The sandbox does not run on native Windows, so if your fleet includes Windows hosts, scope this configuration to macOS and Linux or have those users run Claude Code inside WSL2 or a container.
+Consider these additions alongside them:
+
+ * Add `excludedCommands` for any organization-approved tools that must run without isolation, because this configuration stops a repository’s settings from taking commands out of the sandbox
+ * Add `sandbox.credentials` entries for credential directories such as `~/.aws` and `~/.ssh` and for secret environment variables, since the default read policy still allows them
+
+This configuration sandboxes the commands Claude runs. A developer can still type a command at the [`!` shell-mode prompt](</docs/en/interactive-mode#shell-mode-with-prefix>) and run it outside the sandbox, with the same access they already have in any terminal outside Claude Code. See strict sandbox mode for the sessions where typed commands run sandboxed. The sandbox doesn’t run on native Windows, so with `failIfUnavailable` set, Claude Code exits at startup on those machines. If your fleet includes Windows hosts, you can:
+
+ * **Deliver the configuration by operating system** : deploy it through your MDM or as a [managed settings file](</docs/en/managed-settings#delivery-mechanisms>) on macOS and Linux machines only. [Server-managed settings](</docs/en/server-managed-settings#current-limitations>) apply to all users in the organization
+ * **Move Windows users into a supported environment** : have them run Claude Code inside WSL2 or a container
###
@@ -596,7 +691,60 @@
Keep developers from widening the policy
-For boolean keys such as `enabled` and `failIfUnavailable`, Claude Code uses the managed value and ignores anything a developer sets locally. For array keys such as `excludedCommands` and `allowRead`, Claude Code merges entries from every scope the session loads, so a developer can append entries that widen the policy. Set `allowManagedReadPathsOnly` to `true` in managed settings so that only `allowRead` entries from managed settings are honored. This prevents developers from widening read access beyond the organization-approved paths. To lock network domains to the managed values the same way, set [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>). When managed settings configure `sandbox.filesystem` or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set `filesystem.disabled`, so developers can’t switch off administrator-deployed filesystem restrictions. Whether a `mask` entry pins the key depends on how it resolves; the table under Which settings can disable it covers the four cases. `excludedCommands` has no equivalent managed-only lockdown, so a developer can always append entries that run additional commands outside the sandbox. Keep the managed list narrow.
+When managed settings set a Boolean key such as `enabled` or `failIfUnavailable`, Claude Code uses the managed value and ignores anything a developer sets locally. For array keys such as `allowRead`, Claude Code merges entries from the scopes the session loads, so a developer can append entries that widen the policy unless a lock covers that key. Unless managed settings set them, a developer’s user settings or `--settings` can turn on the following keys. A repository’s `.claude/settings.json` can too, unless the sandbox is admin-required. Each one weakens the sandbox, so set it to `false` in managed settings if you don’t want it used:
+
+ * [`enableWeakerNestedSandbox`](</docs/en/settings-reference#sandbox-enableweakernestedsandbox>)
+ * [`enableWeakerNetworkIsolation`](</docs/en/settings-reference#sandbox-enableweakernetworkisolation>)
+ * [`network.allowAllUnixSockets`](</docs/en/settings-reference#sandbox-network-allowallunixsockets>)
+ * [`network.allowLocalBinding`](</docs/en/settings-reference#sandbox-network-allowlocalbinding>)
+ * [`allowAppleEvents`](</docs/en/settings-reference#sandbox-allowappleevents>), which a repository can’t turn on
+
+Set `allowManagedReadPathsOnly` to `true` in managed settings so that only `allowRead` entries from managed settings are honored. This prevents developers from widening read access beyond the organization-approved paths. To lock network domains to the managed values the same way, set [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>). With the lock on, only managed settings can set a proxy port. When managed settings configure `sandbox.filesystem` or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set `filesystem.disabled`, so developers can’t switch off administrator-deployed filesystem restrictions. A [valid](</docs/en/settings-reference#invalid-credential-entries-in-managed-settings>) `mask` entry doesn’t lock the key. See Which settings can disable it.
+
+####
+
+
+
+Repository settings under an admin-required sandbox
+
+The sandbox is admin-required while one of these settings is in effect:
+
+ * [`allowUnsandboxedCommands`](</docs/en/settings-reference#sandbox-allowunsandboxedcommands>) set to `false` in managed settings, or with the `--settings` flag unless managed settings set it to `true`
+ * [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>) set to `true` in managed settings
+
+These settings don’t turn the sandbox on, so set `enabled` as well. While the sandbox is admin-required, Claude Code takes the settings that loosen it only from managed settings, the `--settings` flag, and each developer’s `~/.claude/settings.json`. It ignores these settings in a repository’s `.claude/settings.json` and `.claude/settings.local.json`:
+
+Repository setting| What Claude Code ignores
+---|---
+`excludedCommands`, `ignoreViolations`, `network.allowedDomains`, `network.allowUnixSockets`, `network.allowMachLookup`, `network.httpProxyPort`, `network.socksProxyPort`| Every entry
+`filesystem.allowWrite`, `Edit(...)` allow rules, `permissions.additionalDirectories`| The write access each entry gives sandboxed commands. Claude’s file tools still follow the `Edit(...)` rules and additional directories
+`WebFetch(domain:...)` allow rules| The host each rule adds to the sandbox allowlist. The WebFetch tool still follows the rule
+`enableWeakerNestedSandbox`, `enableWeakerNetworkIsolation`, `network.allowAllUnixSockets`, `network.allowLocalBinding`| `true`. A `false` still applies
+`enabled`, `failIfUnavailable`| `false`, when the developer’s `~/.claude/settings.json` sets `true`
+`filesystem.allowRead`| An entry at or under a path that managed settings, `--settings`, or user settings deny reading, or a glob that could match one
+
+These settings still apply while the sandbox is admin-required:
+
+ * **In a repository’s files** : deny entries and the `autoAllowBashIfSandboxed` value. Set the key in managed settings to keep a repository from changing it
+ * **In a developer’s own settings** : the settings in the table still apply from `~/.claude/settings.json` or `--settings`, unless a managed-only lock such as `allowManagedDomainsOnly` covers them. Most of them, such as `excludedCommands` and `filesystem.allowWrite`, have no managed-only lock
+
+The configuration under Enforce sandboxing with managed settings makes the sandbox admin-required. Add the `excludedCommands`, `allowWrite`, and socket entries that your approved tools need to managed settings, because a repository can’t supply them. Requires Claude Code v2.1.285 or later. From v2.1.282 to v2.1.284, the same settings made Claude Code ignore a repository’s `excludedCommands` entries.
+
+####
+
+
+
+Locks that apply without an admin-required sandbox
+
+Some settings make Claude Code ignore the repository keys that directly override one restriction, even when the sandbox isn’t admin-required. Each one has this effect only when you set it in a file its row names, and the repository’s other sandbox settings still apply. Requires Claude Code v2.1.285 or later.
+
+Setting| Where you set it| What Claude Code ignores in a repository’s settings
+---|---|---
+`network.deniedDomains` or a `WebFetch(domain:...)` deny rule| Managed settings, `--settings`| `httpProxyPort` and `socksProxyPort`
+`network.strictAllowlist`| Managed settings, `--settings`, user settings| The proxy ports, `allowedDomains`, and `WebFetch(domain:...)` allow rules
+`filesystem.denyRead`, a `Read(...)` deny rule, or a `credentials.files` entry| Managed settings, `--settings`| An `allowRead`, `allowWrite`, `Edit(...)` allow, or `additionalDirectories` entry at or under a path that managed settings, `--settings`, or user settings deny reading, or a glob that could match one
+
+These locks change what sandboxed commands can reach. The WebFetch tool and Claude’s file tools still follow a repository’s rules and additional directories.
###
@@ -604,14 +752,7 @@
Custom proxy configuration
-For organizations requiring advanced network security, you can implement a custom proxy to:
-
- * Decrypt and inspect HTTPS traffic
- * Apply custom filtering rules
- * Log all network requests
- * Integrate with existing security infrastructure
-
-To point Claude Code at your proxy, set the proxy ports in [sandbox settings](</docs/en/settings-reference#sandbox-settings>):
+To inspect, filter, or log sandbox traffic with your own tooling, replace the built-in sandbox proxy with a proxy you run on the same machine. To route sandbox traffic through a corporate proxy elsewhere on your network, set `HTTPS_PROXY` instead, as the **Corporate proxy** entry under Network isolation describes. That way, Claude Code’s allowlist still applies. To direct sandboxed commands to your proxy, set the localhost ports it listens on in [sandbox settings](</docs/en/settings-reference#sandbox-settings>):
{
"sandbox": {
@@ -622,24 +763,203 @@
}
}
+If you set a port and also set `HTTPS_PROXY` or `HTTP_PROXY`, Claude Code doesn’t forward what sandboxed commands send to your proxy on to the proxy those variables name. To reach a corporate proxy, configure your own proxy to forward to it. Which files can set a port depends on your other sandbox settings. The first case that matches applies:
+
+ * **`allowManagedDomainsOnly` is on**: managed settings only
+ * **The sandbox isadmin-required, or a narrower network lock applies**: managed settings, `--settings`, and user settings
+ * **Otherwise** : any settings file
+
+Claude Code ignores a port set anywhere else. Before v2.1.285, any settings file could set a port.
+
+Once either port applies, your proxy is responsible for filtering everything sent to it. Claude Code’s own network controls, such as `allowedDomains`, `deniedDomains`, `strictAllowlist`, approval prompts, and the local-address check, stop applying to that traffic. A sandboxed command can connect to either proxy, so if you set only one port, Claude Code’s domain lists on the other proxy don’t limit what the command reaches through yours.
+
##
Troubleshooting
-Some commands fail inside the sandbox even though they work outside it. The fixes below cover the most common cases.
-
- * **Commands fail with a host-not-allowed error** : many CLI tools need to reach specific hosts. Granting permission when prompted adds the host to your allowed list so the tool runs inside the sandbox in future.
- * **`jest` hangs or fails**: `watchman` is incompatible with the sandbox. Run `jest --no-watchman` instead.
- * **Go-based CLIs fail TLS verification on macOS** : tools such as `gh`, `gcloud`, and `terraform` may fail TLS verification under Seatbelt. List these tools in [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>). If you are using `httpProxyPort` with a MITM proxy and custom CA, set [`enableWeakerNetworkIsolation`](</docs/en/settings-reference#sandbox-enableweakernetworkisolation>) to `true` instead.
- * **`open`, `osascript`, or browser-based auth flows fail with error `-600` on macOS**: the sandbox blocks Apple Events by default. Set [`allowAppleEvents`](</docs/en/settings-reference#sandbox-allowappleevents>) to `true` in your user, managed, or CLI settings to allow them. Project settings are ignored for this key. Enabling it removes code-execution isolation, since sandboxed commands can then launch other applications unsandboxed with no user prompt and send AppleScript commands to running applications, subject to the macOS automation-consent prompt (TCC). Alternatively, add the command to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>).
- * **`docker` commands fail**: `docker` is incompatible with the sandbox. Add `docker *` to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>).
- * **`pbcopy`, `xclip`, or `wl-copy` doesn’t update the clipboard**: these clipboard utilities can fail to reach the system clipboard from inside the sandbox, in which case the text piped to them doesn’t arrive. To put Claude’s output on your clipboard, ask Claude to print it in its response, then run [`/copy`](</docs/en/commands>). `/copy` writes to the clipboard from the Claude Code process rather than from a sandboxed command. When Claude pipes text to one of these tools, adding the tool to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>) doesn’t take that call out of the sandbox on its own.
- * **A git command fails with`unable to unlink old`**: `git merge`, `git checkout`, and similar commands fail this way when they need to replace a file the sandbox denies writes to, whether that file is under a protected path such as `.claude/skills`, under one of your `denyWrite` entries, or outside the directories the sandbox lets commands write to at all. On Linux and WSL2 the error ends with `Read-only file system`. After the failure, Claude may offer to rerun the command outside the sandbox; approve that retry, or run the git command yourself in another terminal. If you’ve set `allowUnsandboxedCommands` to `false`, Claude can’t offer the retry, so run the command yourself. If the same git command fails often, add it to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>).
- * **Bubblewrap fails to start inside a container** : in an unprivileged container, bubblewrap can’t mount a fresh `/proc` filesystem, so sandboxed commands fail with a `bwrap` error such as `Can't mount proc on /newroot/proc: Operation not permitted`. Set [`enableWeakerNestedSandbox`](</docs/en/settings-reference#sandbox-enableweakernestedsandbox>) to `true` so the inner sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since it exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
- * **0-byte read-only files appear at`.claude` settings paths, and “Yes, and don’t ask again” doesn’t save**: on Linux and WSL2, the sandbox holds a write denial on a file that doesn’t exist yet by creating a 0-byte read-only placeholder there while a sandboxed command runs. The sandbox removes the placeholder afterward. If a session is killed before that cleanup runs, for example by SIGKILL, the placeholders stay behind. Later sessions bind them read-only again on every start, so a settings write such as saving a permission choice fails where one sits. Run `claude doctor` to list the leftover placeholder files. The [`Stale sandbox mask files left by a killed session`](</docs/en/errors#stale-sandbox-mask-files-left-by-a-killed-session>) warning names up to three of them and counts the rest. Delete each file with `rm` while no other Claude Code session is running in that project. Before v2.1.257, Claude Code left the same placeholders behind without flagging them.
- * **`--dangerously-skip-permissions` fails as root**: this flag is blocked when running as root or via sudo on Linux and macOS, because root access combined with no permission prompts can modify any file or service on the system. The check is skipped automatically inside a recognized sandbox. To run autonomously in a container, use the [dev container](</docs/en/devcontainer>) configuration, which runs Claude Code as a non-root user.
+Some commands fail inside the sandbox even though they work outside it. Find the heading that matches your symptom or error message. If your organization’s sandbox is admin-required, Claude Code ignores the settings these fixes name in a project’s settings files, so save them in `~/.claude/settings.json`, where they apply in every project. If a fix still has no effect, your organization’s managed settings may set that key. A fix that adds an `excludedCommands` pattern removes the sandbox from the commands the pattern matches. See what an excluded command can do.
+
+###
+
+
+
+Commands fail with a host-not-allowed error
+
+Many CLI tools need to reach specific hosts. Approve the host when prompted, or add it to [`allowedDomains`](</docs/en/settings-reference#sandbox-network-alloweddomains>). If your organization locks the allowlist with `allowManagedDomainsOnly`, there’s no prompt, so ask your administrator to add the host.
+
+###
+
+
+
+`jest` hangs or fails
+
+`watchman` is incompatible with the sandbox. Run `jest --no-watchman` instead.
+
+###
+
+
+
+Go-based CLIs fail TLS verification on macOS
+
+Tools such as `gh`, `gcloud`, and `terraform` may fail TLS verification under Seatbelt. To run these tools outside the sandbox, add a pattern for each tool, such as `gh *`, to `excludedCommands`. The tool then runs with your full access and its stored credentials. If you are using `httpProxyPort` with a MITM proxy and custom CA, set [`enableWeakerNetworkIsolation`](</docs/en/settings-reference#sandbox-enableweakernetworkisolation>) to `true` instead.
+
+###
+
+
+
+`open`, `osascript`, or browser-based auth flows fail with error `-600` on macOS
+
+The sandbox blocks Apple Events by default. Set [`allowAppleEvents`](</docs/en/settings-reference#sandbox-allowappleevents>) to `true` in your user, managed, or CLI settings to allow them. Claude Code ignores this key in project settings. Enabling `allowAppleEvents` removes code-execution isolation, since sandboxed commands can then launch other applications unsandboxed with no user prompt, and can send AppleScript commands to running applications, subject to the macOS automation-consent prompt (TCC). Alternatively, add a pattern such as `open *` to `excludedCommands`. Each `open` call then goes through the permission flow, and `open` can launch any file or app, including one Claude wrote.
+
+###
+
+
+
+`docker` commands fail
+
+`docker` is incompatible with the sandbox. Take the `docker` commands you need out of the sandbox with an `excludedCommands` pattern such as `docker compose *`. Run commands outside the sandbox with `excludedCommands` explains what an excluded `docker` command can reach. A narrower pattern takes fewer commands out of the sandbox.
+
+###
+
+
+
+`pbcopy`, `xclip`, or `wl-copy` doesn’t update the clipboard
+
+The `pbcopy`, `xclip`, and `wl-copy` clipboard utilities can fail to reach the system clipboard from inside the sandbox, in which case the text piped to them doesn’t arrive. To put Claude’s output on your clipboard, ask Claude to print it in its response, then run [`/copy`](</docs/en/commands>). `/copy` writes to the clipboard from the Claude Code process rather than from a sandboxed command. When Claude pipes text to one of these tools, adding the tool to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>) doesn’t take that call out of the sandbox on its own.
+
+###
+
+
+
+A git command fails with `unable to unlink old`
+
+`git merge`, `git checkout`, and similar commands fail with `unable to unlink old` when they need to replace a file the sandbox denies writes to. On Linux and WSL2 the error ends with `Read-only file system`. The file can be in one of these places:
+
+ * Under a protected path such as `.claude/skills`
+ * Under one of your `denyWrite` entries
+ * Outside the directories the sandbox lets commands write to at all
+
+After the failure, Claude may offer to rerun the command outside the sandbox. Approve that retry, or run the git command yourself in another terminal. If you’ve set `allowUnsandboxedCommands` to `false`, Claude can’t offer the retry, so run the command yourself.
+
+###
+
+
+
+Bubblewrap fails to start inside a container
+
+In an unprivileged container, bubblewrap can’t mount a fresh `/proc` filesystem, so sandboxed commands fail with a `bwrap` error such as `Can't mount proc on /newroot/proc: Operation not permitted`. Set [`enableWeakerNestedSandbox`](</docs/en/settings-reference#sandbox-enableweakernestedsandbox>) to `true` so the sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since the setting exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
+
+###
+
+
+
+0-byte read-only files appear at `.claude` settings paths, and “Yes, and don’t ask again” doesn’t save
+
+On Linux and WSL2, the sandbox holds a write denial on a file that doesn’t exist yet by creating a 0-byte read-only placeholder there while a sandboxed command runs. The sandbox removes the placeholder afterward. If a session is killed before that cleanup runs, for example by SIGKILL, the placeholders stay behind. Later sessions bind the placeholders read-only again on every start, so a settings write such as saving a permission choice fails at a path where a placeholder remains. Run `claude doctor` in your terminal to list the leftover placeholder files. The [`Stale sandbox mask files left by a killed session`](</docs/en/errors#stale-sandbox-mask-files-left-by-a-killed-session>) warning names some of them and counts the rest. Delete each file with `rm` while no other Claude Code session is running in that project. Before v2.1.257, Claude Code left the same placeholders behind without flagging them.
+
+###
+
+
+
+`git` over SSH fails with the sandbox on
+
+On macOS, `git fetch`, `git pull`, and `git push` against an SSH remote fail inside the sandbox even when the host is allowed. On Linux and WSL2, they work once the host is allowed. Claude Code tunnels git’s SSH connection through the sandbox proxy, and the macOS tunnel can’t authenticate to that proxy. On Linux and WSL2, check these if the connection still fails:
+
+ * **The host is allowed on port 22** : an `allowedDomains` entry with no port, such as `"git.example.com"`, covers it
+ * **Your corporate proxy permits port 22** : if your network requires an upstream proxy, the tunnel goes through it too
+ * **The key is readable as a file** : the sandbox can block the `ssh-agent` socket, and a `denyRead` or `credentials` entry for `~/.ssh` hides your key files
+
+On macOS, switch the remote to HTTPS, which needs HTTPS credentials such as a personal access token:
+
+ git remote set-url origin https://git.example.com/example-org/example-repo.git
+
+If you have to keep the SSH remote, take git’s network commands out of the sandbox with `excludedCommands`:
+
+ {
+ "sandbox": {
+ "excludedCommands": ["git fetch *", "git pull *", "git push *"]
+ }
+ }
+
+These entries match `git push origin main`. A call that adds a `cd`, uses `git -C`, or contains a command substitution stays sandboxed. The excluded git commands can reach any host, not only the ones in `allowedDomains`. Plain `ssh`, `scp`, and `rsync` over SSH fail for the reason the database client entry gives.
+
+###
+
+
+
+A database client or other non-HTTP tool fails to reach an allowed host
+
+A tool that ignores the proxy environment variables can’t connect from inside the sandbox, even to a host in `allowedDomains`. A sandboxed command has no direct route to the network, so a tool that opens its own connection fails. Most database drivers, plain `ssh`, and tools that use UDP behave this way. The failure looks like a network or name resolution error:
+
+ * **macOS** : `Operation not permitted`, or a name resolution error such as `Could not resolve host`
+ * **Linux and WSL2** : `Network is unreachable`, or a name resolution error such as `Temporary failure in name resolution`
+
+A tool that uses the proxy fails differently when its host isn’t allowed. You get a network prompt, or the tool receives a `403` response from the proxy. To let the tool connect, run the command that needs it outside the sandbox with `excludedCommands`. This example excludes one script and adds an [ask rule](</docs/en/permissions>) so that you approve each run:
+
+ {
+ "sandbox": {
+ "excludedCommands": ["python scripts/load_orders.py *"]
+ },
+ "permissions": {
+ "ask": ["Bash(python scripts/load_orders.py *)"]
+ }
+ }
+
+The script runs with your full access, and Claude can edit a script that’s inside your working directory, so review it when the prompt appears.
+
+###
+
+
+
+A command fails to reach a server on localhost
+
+By default, a sandboxed command can’t connect directly to a server that’s running on your machine outside the sandbox, such as a dev server or a database in a container. What you can change depends on your platform:
+
+ * **macOS** : set [`network.allowLocalBinding`](</docs/en/settings-reference#sandbox-network-allowlocalbinding>) to `true`. Sandboxed commands can then listen on network ports and connect to any port on localhost, which includes every other service listening there. A localhost service that doesn’t require authentication, such as a debugger, can then act for the command outside the sandbox, and a command that listens on a non-loopback address accepts connections from other machines
+ * **Linux and WSL2** : a sandboxed command’s `localhost` is private to that command. The command can listen on a port and reach servers it started itself. A direct connection to `localhost` or `127.0.0.1` doesn’t reach servers on the host, and `allowLocalBinding` has no effect. Run the command that needs the host’s server outside the sandbox with `excludedCommands`, where it has no filesystem or network limits. For connections that go through the sandbox proxy, see Hostnames that resolve to local addresses
+
+This example turns the setting on for macOS:
+
+ {
+ "sandbox": {
+ "network": {
+ "allowLocalBinding": true
+ }
+ }
+ }
+
+An `allowedDomains` entry for `localhost` applies to connections that go through the proxy, so it doesn’t change a direct connection. Claude Code sets `NO_PROXY` for sandboxed commands so that they connect to `localhost` directly instead of through the proxy. The entry also exposes every port on your machine’s localhost to a command that does use the proxy. For a development hostname that points at `127.0.0.1`, see An allowed hostname is refused with `resolved to a loopback address`.
+
+###
+
+
+
+An allowed hostname is refused with `resolved to a loopback address`
+
+The sandbox proxy refuses an allowed hostname that resolves to a local address, which affects development names such as `myapp.test` that point at `127.0.0.1`. The command sees a `403` response whose body names the kind of address, such as `Connection to myapp.test blocked: resolved to a loopback address`. Add the IP address the name resolves to alongside the hostname in `allowedDomains`, each with the port your server listens on:
+
+ {
+ "sandbox": {
+ "network": {
+ "allowedDomains": ["myapp.test:3000", "127.0.0.1:3000"]
+ }
+ }
+ }
+
+An IP address entry with no port lets sandboxed commands reach every service listening on that address. Before v2.1.284, the proxy connected to whatever address an allowed hostname resolved to.
+
+###
+
+
+
+`/sandbox` fails with `Sandbox settings are overridden by a higher-priority configuration`
+
+`/sandbox` prints `Error: Sandbox settings are overridden by a higher-priority configuration and cannot be changed locally.` instead of opening its panel when a higher [settings level](</docs/en/settings#settings-precedence>) sets `sandbox.enabled`, `sandbox.autoAllowBashIfSandboxed`, or `sandbox.allowUnsandboxedCommands`. The panel saves your choices to `.claude/settings.local.json`, and a value saved there can’t override those levels. Managed settings and `--settings` rank above local settings. To see which of them this session loaded, run `/status` and read the `Setting sources` line:
+
+ * **`Command line arguments`** : if you started Claude Code with [`--settings`](</docs/en/settings#change-a-setting-for-one-session>), check whether the file or JSON you passed sets one of those keys. If it does, change the value there, or start Claude Code again without those keys.
+ * **`Enterprise managed settings`** : your organization’s managed settings are loaded. If they set one of those keys, you can’t change that key from `/sandbox` or from any settings file you control, so ask your administrator.
##
@@ -661,31 +981,20 @@
* **Privilege escalation via Unix sockets** : the `allowUnixSockets` configuration can inadvertently grant access to system services that could lead to sandbox bypasses. For example, allowing access to `/var/run/docker.sock` effectively grants access to the host system through the Docker socket. Consider carefully any Unix sockets that you allow through the sandbox.
* **Filesystem permission escalation** : overly broad filesystem write permissions can enable privilege escalation attacks. Allowing writes to directories containing executables in `$PATH`, system configuration directories, or user shell configuration files such as `.bashrc` or `.zshrc` can lead to code execution in different security contexts when other users or system processes access these files.
- * **Linux sandbox strength** : the Linux implementation provides strong filesystem and network isolation but includes an `enableWeakerNestedSandbox` mode that enables it to work inside Docker environments without privileged namespaces, or on Linux hosts where unprivileged user namespaces are disabled by sysctl. This option considerably weakens security and should only be used when additional isolation is otherwise enforced.
+ * **Linux sandbox strength** : the Linux implementation provides strong filesystem and network isolation but includes an `enableWeakerNestedSandbox` mode that enables it to work inside Docker environments without privileged namespaces. This option considerably weakens security and should only be used when additional isolation is otherwise enforced.
* **Apple Events on macOS** : the macOS sandbox blocks Apple Events by default. The `allowAppleEvents` setting lifts this restriction so tools such as `open` and `osascript` work, but it removes code-execution isolation: sandboxed commands can launch other applications unsandboxed with no user prompt, and can send AppleScript commands to running applications, subject to the per-app macOS automation-consent prompt (TCC). It is only honored from user, managed, or CLI settings. Project settings cannot enable it.
###
-Platform and tool compatibility
-
- * **Platform support** : supports macOS, Linux, and WSL2. WSL1 and native Windows are not supported.
- * **Performance overhead** : minimal, but some filesystem operations may be slightly slower.
- * **Tool compatibility** : some tools that require specific system access patterns may need configuration adjustments, or may need to be run outside the sandbox.
-
-###
-
-
-
Scope
-The sandbox isolates Bash subprocesses. Other tools operate under different boundaries:
-
- * **Built-in file tools** : Read, Edit, and Write use the permission system directly rather than running through the sandbox. See [permissions](</docs/en/permissions>).
+The sandbox isolates shell commands and their child processes. What runs outside the sandbox lists the tools and helper processes it doesn’t cover. Computer use and subagents relate to the sandbox as follows:
+
* **Computer use** : when Claude opens apps and controls your screen, it runs on your actual desktop rather than in an isolated environment. Per-app permission prompts gate each application. See [computer use in the CLI](</docs/en/computer-use>) or [computer use in Desktop](</docs/en/desktop#let-claude-use-your-computer>).
- * **Environment variables** : sandboxed Bash commands inherit the parent process environment by default, including any credentials set there. Use `sandbox.credentials` to unset or mask specific variables for sandboxed commands, or set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>) to strip credentials from all subprocesses.
* **Subagents** : [subagents](</docs/en/sub-agents>) run in the same process as the parent session and use the same sandbox configuration. Bash commands inside a subagent are sandboxed when sandboxing is enabled in the parent session.
+ * **Mods** : a [mod](</docs/en/plugins/mods/overview>) is a plugin that runs its own code inside Claude Code, and a process that a mod starts runs outside the sandbox. See [What a mod can reach](</docs/en/plugins/mods/overview#what-a-mod-can-reach>).
Effective sandboxing requires both filesystem and network isolation. Without network isolation, a compromised agent could exfiltrate sensitive files like SSH keys. Without filesystem isolation, whether from a permissive policy or from disabling the filesystem layer, a compromised agent could backdoor system resources to gain network access. When you widen the defaults, check that an `allowWrite` path, a broad `allowedDomains` entry, or an `excludedCommands` exception does not undo a restriction on the other side.
--- a/secure-deployment.md
+++ b/secure-deployment.md
@@ -90,7 +90,7 @@
Sandbox runtime
-For lightweight isolation without containers, [sandbox-runtime](<https://github.com/anthropic-experimental/sandbox-runtime>) enforces filesystem and network restrictions at the OS level. The main advantage is simplicity: no Docker configuration, container images, or networking setup required. The proxy and filesystem restrictions are built in. **How it works:**
+For lightweight isolation without containers, [sandbox-runtime](<https://github.com/anthropics/sandbox-runtime>) enforces filesystem and network restrictions at the OS level. The main advantage is simplicity: no Docker configuration, container images, or networking setup required. The proxy and filesystem restrictions are built in. **How it works:**
* **Filesystem** : Uses OS primitives (`bubblewrap` on Linux, `sandbox-exec` on macOS) to restrict read/write access to configured paths
* **Network** : Removes network namespace (Linux) or uses Seatbelt profiles (macOS) to route network traffic through a built-in proxy
@@ -147,7 +147,7 @@
`-v ...:/workspace:ro`| Mounts code read-only so the agent can analyze but not modify it. **Avoid mounting sensitive host directories like`~/.ssh`, `~/.aws`, or `~/.config`**
`-v .../proxy.sock:...`| Mounts a Unix socket connected to a proxy running outside the container (see below)
-**Unix socket architecture:** With `--network none`, the container has no network interfaces at all. The only way for the agent to reach the outside world is through the mounted Unix socket, which connects to a proxy running on the host. This proxy can enforce domain allowlists, inject credentials, and log all traffic. This is the same architecture used by [sandbox-runtime](<https://github.com/anthropic-experimental/sandbox-runtime>). Even if the agent is compromised via prompt injection, it cannot exfiltrate data to arbitrary servers. It can only communicate through the proxy, which controls what domains are reachable. For more details, see the [Claude Code sandboxing blog post](<https://www.anthropic.com/engineering/claude-code-sandboxing>). **Additional hardening options:**
+**Unix socket architecture:** With `--network none`, the container has no network interfaces at all. The only way for the agent to reach the outside world is through the mounted Unix socket, which connects to a proxy running on the host. This proxy can enforce domain allowlists, inject credentials, and log all traffic. This is the same architecture used by [sandbox-runtime](<https://github.com/anthropics/sandbox-runtime>). Even if the agent is compromised via prompt injection, it cannot exfiltrate data to arbitrary servers. It can only communicate through the proxy, which controls what domains are reachable. For more details, see the [Claude Code sandboxing blog post](<https://www.anthropic.com/engineering/claude-code-sandboxing>). **Additional hardening options:**
Option| Purpose
---|---
@@ -356,7 +356,7 @@
* [Claude Code security documentation](</docs/en/security>)
* [Hosting the Agent SDK](</docs/en/agent-sdk/hosting>)
* [Handling permissions](</docs/en/agent-sdk/permissions>)
- * [Sandbox runtime](<https://github.com/anthropic-experimental/sandbox-runtime>)
+ * [Sandbox runtime](<https://github.com/anthropics/sandbox-runtime>)
* [The Lethal Trifecta for AI Agents](<https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/>)
* [OWASP Top 10 for LLM Applications](<https://owasp.org/www-project-top-10-for-large-language-model-applications/>)
* [Docker Security Best Practices](<https://docs.docker.com/engine/security/>)
--- a/security.md
+++ b/security.md
@@ -18,7 +18,12 @@
Permission-based architecture
-In Manual mode, Claude Code starts with read-only permissions. When Claude Code needs to edit files, run tests, or execute commands, it asks you first, and you choose whether to approve the action once or allow it from then on. In Manual mode, Claude Code also asks before running Bash commands that can modify your system. It runs a built-in set of [read-only commands](</docs/en/permissions#read-only-commands>) such as `ls`, `cat`, and `git status` without asking. You and your organization configure these permissions directly. In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), a separate classifier model reviews actions instead of you and blocks the ones it judges unsafe. [How the classifier evaluates actions](</docs/en/permission-modes#how-the-classifier-evaluates-actions>) lists which actions Claude Code approves outright, which it sends to the classifier, and which Claude Code still asks you about. Your explicit ask and deny rules still apply, and your organization can [turn auto mode off](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>). Which permission mode a session starts in depends on your plan, the surface you start it from, and your settings and your organization’s; see [Permission modes](</docs/en/permission-modes#which-mode-a-session-starts-in>). For detailed permission configuration, see [Permissions](</docs/en/permissions>).
+A session’s permission mode sets which actions Claude can take without asking you first. Auto mode is the built-in starting permission mode for interactive terminal and VS Code sessions. [Which mode a session starts in](</docs/en/permission-modes#which-mode-a-session-starts-in>) covers earlier versions, other surfaces, and the settings that change the starting permission mode.
+
+ * **Auto mode** : A separate classifier model reviews actions instead of you and blocks the ones it judges unsafe. [How the classifier evaluates actions](</docs/en/permission-modes#how-the-classifier-evaluates-actions>) lists which actions Claude Code approves outright, which it sends to the classifier, and which Claude Code still asks you about. Your explicit ask and deny rules still apply, and your organization can [turn auto mode off](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>)
+ * **Manual mode** : Claude Code starts with read-only permissions. When it needs to edit files, run tests, or execute commands, it asks you first, and you choose whether to approve the action once or allow it from then on. It runs a built-in set of [read-only commands](</docs/en/permissions#read-only-commands>) such as `ls`, `cat`, and `git status` without asking
+
+You and your organization configure these permissions directly. For detailed permission configuration, see [Permissions](</docs/en/permissions>).
###
@@ -29,7 +34,9 @@
To mitigate risks in agentic systems:
* **Sandboxed bash tool** : [Sandbox](</docs/en/sandboxing>) bash commands with filesystem and network isolation, reducing permission prompts while maintaining security. Configure with `/sandbox` to define boundaries where Claude Code can work autonomously
- * **Working directory boundary** : In Manual mode, Claude Code can only write to the folder where it was started and its subfolders, and can’t modify files in parent directories without explicit permission. In Manual mode, Claude Code also asks you before reading paths outside this boundary with the Read, Grep, and Glob tools. Extend the boundary with [additional directories](</docs/en/permissions#working-directories>) to skip the prompt, or restrict the broader read access available to read-only Bash commands with [sandbox `denyRead` rules](</docs/en/sandboxing#filesystem-isolation>), which apply only when sandboxing is enabled
+ * **Working directory boundary** : In Manual mode, Claude Code asks you before its file tools read or write outside the folder where it was started and its subfolders. The boundary is a permission prompt, so a Bash command you approve can still write anywhere your user account can
+ * To read a folder without the prompt, add it as an [additional directory](</docs/en/permissions#working-directories>)
+ * To restrict Bash commands at the operating system level, turn on [sandboxing](</docs/en/sandboxing#filesystem-isolation>)
* **Prompt fatigue mitigation** : Support for allowlisting frequently used safe commands per-user, per-codebase, or per-organization
* **Accept Edits mode** : Auto-approves file edits and a fixed set of filesystem Bash commands like `mkdir`, `touch`, `rm`, `mv`, `cp`, and `sed` for paths in the working directory. Other Bash commands and out-of-scope paths still prompt
@@ -39,7 +46,7 @@
User responsibility
-Claude Code only has the permissions you grant it. You’re responsible for reviewing proposed code and commands for safety before approval.
+You’re responsible for reviewing proposed code and commands for safety before approval.
##
@@ -56,8 +63,6 @@
Core protections
* **Permission system** : In Manual mode, sensitive operations require explicit approval
- * **Context-aware analysis** : Detects potentially harmful instructions by analyzing the full request
- * **Input sanitization** : Prevents command injection by processing user inputs
* **Network command approval** : Commands that fetch content from the web such as `curl` and `wget` are not auto-approved by default. In Manual mode they prompt like any other non-read-only Bash command, so you can still approve once or add an explicit allow rule like `Bash(curl *)`. To stop Claude from running them, add them to [`permissions.deny`](</docs/en/permissions#tool-specific-permission-rules>). A deny rule matches the command [as written](</docs/en/permissions#bash-rule-limits>); for network enforcement that doesn’t depend on the command text, see [sandbox network isolation](</docs/en/sandboxing#network-isolation>)
###
@@ -81,14 +86,13 @@
Additional safeguards
* **Network request approval** : In Manual mode, most tools that make network requests require user approval by default
- * **Isolated context windows** : Web fetch uses a separate context window to avoid injecting potentially malicious prompts
- * **Trust verification** : First-time codebase runs and new MCP servers require trust verification
- * Note: Trust verification is disabled when running non-interactively with the `-p` flag
+ * **Web page summaries** : For most fetches, WebFetch runs a separate model call over the page, and Claude receives that call’s answer instead of the raw page. See [WebFetch tool behavior](</docs/en/tools-reference#webfetch-tool-behavior>)
+ * **Trust verification** : In an interactive session, Claude Code shows the workspace trust dialog when you start it in a folder you haven’t trusted. Servers in a project’s `.mcp.json` have their own approval prompt, and [Project scope](</docs/en/mcp#project-scope>) lists the sessions that skip it
+ * Note: A `-p` session shows neither prompt. [What runs before you trust a folder](</docs/en/permissions#what-runs-before-you-trust-a-folder>) lists what a repository’s files can run there
* Note: When you start Claude Code directly in your home directory, trust acceptance is held for the current session only and is not written to disk, so the prompt reappears on each launch. There is no setting to persist it. Start Claude Code from a project subdirectory instead, where trust acceptance is saved per directory
- * **Command injection detection** : In Manual mode, suspicious bash commands require manual approval even if previously allowlisted
+ * **Command injection detection** : In Manual mode, Claude Code asks before running a Bash command it can’t fully analyze. An allow rule for part of a command, such as `Bash(git *)`, doesn’t skip that prompt. [Sandboxed commands](</docs/en/permissions#how-permissions-interact-with-sandboxing>) can run without it
* **Fail-closed matching** : In Manual mode, unmatched commands require approval by default
- * **Natural language descriptions** : Complex bash commands include explanations for user understanding
- * **Secure credential storage** : API keys and tokens are stored in the macOS Keychain when available, and protected by file permissions on Windows and Linux. See [Credential Management](</docs/en/authentication#credential-management>)
+ * **Secure credential storage** : API keys and tokens are stored in the macOS Keychain when available. On Linux they’re stored in a file with mode `0600`, and on Windows in a file that inherits the access controls of your user profile directory. See [Credential Management](</docs/en/authentication#credential-management>)
**Windows WebDAV security risk** : When running Claude Code on Windows, we recommend against enabling WebDAV or allowing Claude Code to access paths such as `\\*` that may contain WebDAV subdirectories. [WebDAV has been deprecated by Microsoft](<https://learn.microsoft.com/en-us/windows/whats-new/deprecated-features#:~:text=The%20Webclient%20\(WebDAV\)%20service%20is%20deprecated>) due to security risks. Enabling WebDAV may allow Claude Code to trigger network requests to remote hosts, bypassing the permission system.
@@ -108,7 +112,7 @@
MCP security
-Claude Code allows users to configure Model Context Protocol (MCP) servers. The list of allowed MCP servers is configured in your source code, as part of Claude Code settings engineers check into source control. We encourage either writing your own MCP servers or using MCP servers from providers that you trust. You are able to configure Claude Code permissions for MCP servers. Anthropic reviews connectors against its [listing criteria](<https://claude.com/docs/connectors/building/review-criteria>) before adding them to the [Anthropic Directory](<https://claude.ai/directory>), but does not security-audit or manage any MCP server.
+You can connect Claude Code to Model Context Protocol (MCP) servers. Project-scoped servers are defined in `.mcp.json`, which you can check into source control. Servers at [other scopes](</docs/en/mcp#mcp-installation-scopes>) and [claude.ai connectors](</docs/en/mcp#how-connectors-reach-claude-code>) are configured outside the repository, and plugins can add servers too, so reviewing `.mcp.json` doesn’t show every server a session can load. To restrict which servers run in your organization, see [Managed MCP configuration](</docs/en/managed-mcp>). We encourage either writing your own MCP servers or using MCP servers from providers that you trust. You are able to configure Claude Code permissions for MCP servers. Anthropic reviews connectors against its [listing criteria](<https://claude.com/docs/connectors/building/review-criteria>) before adding them to the [Anthropic Directory](<https://claude.ai/directory>), but does not security-audit or manage any MCP server.
##
@@ -129,7 +133,7 @@
* **Isolated virtual machines** : Each cloud session runs in an isolated, Anthropic-managed VM
* **Network access controls** : Network access is limited by default and can be configured to be disabled or allow only specific domains
* **Credential protection** : GitHub credentials are stored encrypted on Anthropic’s servers and never enter the session VM. The VM holds a short-lived credential scoped to that session, and GitHub traffic goes through an [Anthropic proxy](</docs/en/cloud-environments#github-proxy>) that attaches the GitHub credential on the server side. See [GitHub authentication options](</docs/en/claude-code-on-the-web#github-authentication-options>) for how you grant access
- * **Branch restrictions** : Git push operations are restricted to the current working branch
+ * **Push restrictions** : The [GitHub proxy](</docs/en/cloud-environments#github-proxy>) rejects branch deletions and pushes of anything other than a branch, such as a tag. GitHub decides which branches a session can update by applying your repository’s branch protection rules and rulesets to the GitHub access you connected. A rule that access can bypass doesn’t block a session’s push
* **Audit logging** : All operations in cloud sessions are logged for compliance and audit purposes
* **Automatic cleanup** : Session VMs are reclaimed after a period of inactivity
* **Deletion** : You can [delete a session](</docs/en/claude-code-on-the-web#delete-sessions>) at any time. See [Cloud execution data flow](</docs/en/data-usage#cloud-execution-data-flow-and-dependencies>) for what Anthropic stores for a cloud session
--- a/self-hosted-environments.md
+++ b/self-hosted-environments.md
@@ -86,7 +86,7 @@
1. A runner with free capacity claims the session and holds a lease on it.
2. The runner clones the repository into its working directory and spawns a child Claude Code process.
3. The child streams events back over HTTPS while the runner keeps polling; each poll refreshes the lease and doubles as the heartbeat.
- 4. If the runner stops polling for about 60 seconds, the server requeues the session for another runner.
+ 4. If the runner stops polling, its lease lapses after about 60 seconds, and the server requeues the session for another runner within a few minutes.
The runner gives each poll request 10 seconds. When a request times out, is lost, or gets a response the runner can’t parse, the runner keeps serving its live sessions and retries after a second or two instead of waiting for the next scheduled poll. For example, an intercepting proxy that answers the poll with its own page produces a response the runner can’t parse. Each time another request fails in one of those ways, the runner doubles the gap before the next retry, up to 20 seconds, and shortens the gap whenever the lease is close to expiring.
@@ -105,7 +105,7 @@
1. The runner stops taking new work.
2. The runner releases each active session through the same release path the [`--release-idle-session-min`](</docs/en/self-hosted-environments-reference#runner-cli-flags>) flag uses, so the session resumes on a fresh runner when the user sends their next message. When the runner releases each session depends on its state:
- * The runner releases a session that’s mid-turn as soon as that turn finishes.
+ * The runner releases a session that’s mid-turn after that turn finishes. It first waits for the session’s process to report the turn’s end to Anthropic, for no longer than [`SELF_HOSTED_RUNNER_POST_TURN_SETTLE_MS`](</docs/en/self-hosted-environments-reference#environment-variable-only-settings>). Before v2.1.280, the runner released the session as soon as the turn finished.
* When a turn finishes and leaves background tasks running, the runner waits up to 60 seconds for them, then releases the session even if they’re still running. If the tasks have finished but the follow-up turn that reads their results hasn’t run yet, the runner keeps the session until that turn finishes, and waits no longer than [`SELF_HOSTED_RUNNER_BG_RESULT_GRACE_MS`](</docs/en/self-hosted-environments-reference#environment-variable-only-settings>) for that turn to start.
3. The runner exits 0 once all its sessions are released.
Show diff (129 lines)
--- a/self-hosted-environments-configuration.md
+++ b/self-hosted-environments-configuration.md
@@ -16,7 +16,7 @@
Variable| Description
---|---
-`CLAUDE_CODE_SESSION_ACCESS_TOKEN`| The session JWT, prefixed `sk-ant-cc-`. Its `act` claim identifies the session creator, with the creator’s email and upstream identity-provider subject when the creating surface recorded them. The value is the token at spawn time; refreshes arrive over the child’s stdin, so a wrapper sees only the initial value. See [Verify session identity](</docs/en/self-hosted-environments-identity>).
+`CLAUDE_CODE_SESSION_ACCESS_TOKEN`| The session JWT, prefixed `sk-ant-cc-`. Its `act` claim identifies the session creator, with the creator’s email when the creating surface recorded it. The value is the token at spawn time; refreshes arrive over the child’s stdin, so a wrapper sees only the initial value. See [Verify session identity](</docs/en/self-hosted-environments-identity>).
`CCR_SESSION_ACCOUNT_EMAIL`| The session creator’s email, pre-extracted by the runner from the token’s `act.email` claim without signature verification. Suitable for labelling, such as commit trailers. When the email gates credential issuance, verify the token and read the claim from it instead; see Provision credentials scoped to the session creator. Unset when the token carries no creator email. Treat as personally identifiable information.
`CLAUDE_RUNNER_CLIENT_PLATFORM`| The client surface that created the session, such as `web_claude_ai`, `desktop_app`, `ios`, `claude_code_cli`, or `scheduled_trigger`. Anthropic records the value once at session creation, so the wrapper and every lifecycle hook see the same value. Use it for adoption analytics and labelling only, not as an authorization signal. Unset when the session has no recorded or recognized surface, so reference it as `${CLAUDE_RUNNER_CLIENT_PLATFORM:-}` under `set -u`. Requires Claude Code v2.1.229 or later.
`CLAUDE_RUNNER_CLAUDE_BIN`| Absolute path to the runner’s own Claude Code binary. End your wrapper with `exec "$CLAUDE_RUNNER_CLAUDE_BIN" "$@"` to pass control to the pinned binary without hardcoding an install path.
@@ -49,6 +49,17 @@
+Pass the system prompt flags through
+
+The system prompt and appended system prompt that Anthropic’s control plane sends for a session reach your wrapper as file paths, not as inline text. The runner writes each prompt to a file in the session’s config directory, `CLAUDE_CONFIG_DIR`, and passes its path in the arguments your wrapper receives, as [`--system-prompt-file <path>` or `--append-system-prompt-file <path>`](</docs/en/cli-reference#system-prompt-flags>). Runners on Claude Code v2.1.281 or later deliver the prompts as files. Before v2.1.281, the runner passed them as `--system-prompt <text>` and `--append-system-prompt <text>`. In your wrapper script or `command` hook, handle these flags as follows:
+
+ * **Pass them through** : end the wrapper with `exec "$CLAUDE_RUNNER_CLAUDE_BIN" "$@"`, which forwards the file flags along with every other argument. Don’t drop or rewrite them. If a session loses a prompt file flag, it runs without the instructions the control plane sent for it.
+ * **On a runner at v2.1.281 or later, a file flag you append replaces the server’s, never adds to it** : each prompt file flag takes a single value and Claude Code keeps the last occurrence, so if you append `--append-system-prompt-file <path>` after `"$@"`, your file’s contents replace the server’s appended instructions. To add instructions on top of the server’s, put them in the runner image’s `CLAUDE.md`, which the runner seeds into every session’s user-level config.
+
+###
+
+
+
Provision credentials scoped to the session creator
Use the `decode-token` subcommand to read claims from the session JWT. It reads the token from an argument, from `CLAUDE_CODE_SESSION_ACCESS_TOKEN`, or from stdin, in that order; see [Verify the token inside the session](</docs/en/self-hosted-environments-identity#verify-the-token-inside-the-session>) for what it checks. The example below decodes the creator identity, exchanges it for short-lived AWS credentials, and execs into Claude Code:
@@ -65,7 +76,7 @@
exec "$CLAUDE_RUNNER_CLAUDE_BIN" "$@"
-Use `jq -re` rather than `jq -r` when the extracted claim gates an auth decision, so an absent claim exits non-zero instead of passing the literal string `null` downstream. Sessions created by an organization service identity, such as bot and agent sessions, carry an `agent:` subject rather than `user:`, so this example refuses them; if your environment serves those sessions, decide explicitly whether the wrapper falls back to a default credential for them instead of exiting. When your credential exchange needs the SSO subject or email instead, read `.act.attested_by.sub` or `.act.email` and handle their absence: the token carries them only when the creating surface recorded them, and a [CLI-dispatched session](</docs/en/self-hosted-environments-testing#run-the-test-loop>) can lack both. For the full claim reference and verification from services outside the runner, see [Verify session identity](</docs/en/self-hosted-environments-identity>).
+Use `jq -re` rather than `jq -r` when the extracted claim gates an auth decision, so an absent claim exits non-zero instead of passing the literal string `null` downstream. Sessions created by an organization service identity, such as bot and agent sessions, carry an `agent:` subject rather than `user:`, so this example refuses them; if your environment serves those sessions, decide explicitly whether the wrapper falls back to a default credential for them instead of exiting. When your credential exchange needs the email instead, read `.act.email` and handle its absence: the token carries it only when the creating surface recorded it, and a [CLI-dispatched session](</docs/en/self-hosted-environments-testing#run-the-test-loop>) can lack it. For the full claim reference and verification from services outside the runner, see [Verify session identity](</docs/en/self-hosted-environments-identity>).
##
@@ -81,7 +92,7 @@
checkout
-Runs once per repository, in place of the runner’s built-in clone and fetch. Use the hook to clone from a read-through mirror, seed a working tree from an archive, or apply per-session git auth. The runner sets:
+Runs once per repository, in place of the runner’s built-in clone and fetch. Use the hook to clone from a read-through mirror, seed a working tree from an archive, or apply per-session git auth. The runner sets these variables, and may set other `CLAUDE_RUNNER_` variables that the table doesn’t list:
Variable| Description
---|---
@@ -93,6 +104,7 @@
`CLAUDE_RUNNER_API_BASE_URL`| Anthropic API base URL for session-scoped calls
`CLAUDE_RUNNER_CLIENT_PLATFORM`| The client surface that created the session, such as `web_claude_ai`, `desktop_app`, or `ios`. Unset when the session has no recorded or recognized surface.
`CLAUDE_CODE_SESSION_ACCESS_TOKEN`| The session access token, for session-scoped API calls
+`GIT_CONFIG_COUNT`, `GIT_CONFIG_KEY_n`, `GIT_CONFIG_VALUE_n`| Git settings the runner fixes for the git your hook runs. Git configuration inside lifecycle hooks describes them. Requires Claude Code v2.1.280 or later.
The script must leave a working tree at `CLAUDE_RUNNER_CHECKOUT_PATH` checked out at the requested revision. Detached HEAD is fine; the runner creates the session’s working branch on top. The runner verifies the path contains a `.git` afterwards; if your hook materializes a non-git source such as Perforce or an unpacked tarball, set `CLAUDE_RUNNER_SKIP_GIT_VERIFY=1` in the runner’s environment to skip that check. Git-based flows such as working-branch creation and pushing results require a git checkout, so export outcomes from non-git trees with a `post-session` hook. The runner doesn’t pass a git credential to the hook. Instead, mint a per-session clone credential from the session’s identity: verify `CLAUDE_CODE_SESSION_ACCESS_TOKEN` with a standard JWT library against the JWKS endpoint under `CLAUDE_RUNNER_API_BASE_URL`, as described in [Verify the token from your service](</docs/en/self-hosted-environments-identity#verify-the-token-from-your-service>), then have your credential service issue a short-lived clone credential for the identity in the token’s `act` claim. `CLAUDE_RUNNER_CLAUDE_BIN` isn’t set in the checkout-hook environment, so the `decode-token` subcommand isn’t available here. Falling back to whatever git authentication the host already has, such as an SSH agent, credential helper, or `.netrc`, is also an option. When the hook exits non-zero, or exits 0 without leaving a usable checkout behind, what the runner does depends on the repository:
@@ -119,6 +131,7 @@
`CLAUDE_RUNNER_API_BASE_URL`| Anthropic API base URL for session-scoped calls
`CLAUDE_RUNNER_CLIENT_PLATFORM`| The client surface that created the session, such as `web_claude_ai`, `desktop_app`, or `ios`. Unset when the session has no recorded or recognized surface. Requires Claude Code v2.1.229 or later.
`CLAUDE_CODE_SESSION_ACCESS_TOKEN`| The session access token, for session-scoped API calls
+`GIT_CONFIG_COUNT`, `GIT_CONFIG_KEY_n`, `GIT_CONFIG_VALUE_n`| Git settings the runner fixes for the git your hook runs. Git configuration inside lifecycle hooks describes them. Requires Claude Code v2.1.280 or later.
`CLAUDE_RUNNER_EXIT_REASON` takes one of four values:
@@ -132,12 +145,13 @@
#!/usr/bin/env bash
set -u
IFS=':'
- # Pin config the session could have planted in the checkout's .git/config:
# -c overrides beat repo-local settings, blocking session-written fsmonitor,
# hook-path, and gpg-program config from executing code with the hook's
- # privileges. Repo-local credential.helper, core.sshCommand, and pushurl
- # still apply; if the hook holds credentials the session didn't, pin the
- # push URL and helper too (see the note below the script).
+ # privileges. -c commit.gpgsign=false also leaves these rescue commits
+ # unsigned under --configure-git.
+ # Repo-local credential.helper and pushurl still apply, and on a runner
+ # before v2.1.280 so does core.sshCommand; if the hook holds credentials
+ # the session didn't, see the note below the script.
g() { git -c core.fsmonitor=false -c core.hooksPath=/dev/null \
-c commit.gpgsign=false "$@"; }
for ws in $CLAUDE_RUNNER_WORKSPACE_PATHS; do
@@ -148,7 +162,7 @@
g push -q origin "HEAD:refs/heads/rescue/$CLAUDE_RUNNER_SESSION_ID" || true
done
-The hook pushes with whatever git credentials are available in its own environment on the runner host. Under the [no-credentials-in-the-image posture](</docs/en/self-hosted-environments-deploy#configure-git>), including when the built-in clone goes through the Anthropic git proxy, there are none, so mint a short-lived push credential inside the hook before pushing: exchange the session token the hook receives in `CLAUDE_CODE_SESSION_ACCESS_TOKEN` with your own token service, verifying it as [Verify session identity](</docs/en/self-hosted-environments-identity>) describes. When the hook holds a credential the session didn’t, also pin where it pushes: replace `origin` with an operator-supplied URL and pass `-c credential.helper=` plus your own helper, so repo-local config the session wrote can’t redirect the credentialed push.
+The hook pushes with whatever git credentials are available in its own environment on the runner host. Under the [no-credentials-in-the-image posture](</docs/en/self-hosted-environments-deploy#configure-git>), including when the built-in clone goes through the Anthropic git proxy, there are none, so mint a short-lived push credential inside the hook before pushing: exchange the session token the hook receives in `CLAUDE_CODE_SESSION_ACCESS_TOKEN` with your own token service, verifying it as [Verify session identity](</docs/en/self-hosted-environments-identity>) describes. When the hook holds a credential the session didn’t, replace `origin` with an operator-supplied URL and pass `-c credential.helper=` plus your own helper. Git configuration inside lifecycle hooks describes what session-written configuration can still affect.
####
@@ -162,6 +176,29 @@
* **Waiting for the user to answer a prompt, such as a permission prompt** : the runner releases the session first, then runs this hook. A user message sent while the hook runs can resume the session on another runner before the hook finishes.
This applies whenever the runner releases a session: at the idle timeout, at the [`--retire-at`](</docs/en/self-hosted-environments-reference#runner-cli-flags>) time, and, on a runner on v2.1.260 or later, at a session’s [`--kill-session-after-min`](</docs/en/self-hosted-environments-reference#runner-cli-flags>) limit. A session whose turn has ended and that holds only background tasks counts as idle here. Before v2.1.236, the runner released the session first and then ran this hook in both cases. During a `SIGTERM` drain, the runner holds the session lease until the hook finishes; see [Shutdown timing](</docs/en/self-hosted-environments-deploy#shutdown-timing>).
+
+###
+
+
+
+Git configuration inside lifecycle hooks
+
+The `checkout` and `post-session` hooks run with the session’s access token in their environment, and the git they run reads configuration files that sessions can write, such as `~/.gitconfig` and a checkout’s `.git/config`. Before either hook runs, the runner sets git settings in the hook’s environment, including the ones below, as `GIT_CONFIG_COUNT`/`GIT_CONFIG_KEY_n`/`GIT_CONFIG_VALUE_n` pairs and git environment variables. Git ranks those above every configuration file, and they apply only to the git your hooks run, not to the session’s own git. At startup, the runner prints a `[runner:git] lifecycle hooks:` line that shows the hooks path, allowed protocols, gpg programs, and signing mode in effect. Requires Claude Code v2.1.280 or later.
+
+ * **Git hooks** : unless you supply a value, `core.hooksPath` is `/dev/null`, so git skips the hooks in a repository’s `.git/hooks` and any hooks directory that `~/.gitconfig` names. To supply one, export `core.hooksPath` as a `GIT_CONFIG_KEY_n`/`GIT_CONFIG_VALUE_n` pair in the runner’s environment. The runner also reads `core.hooksPath` from the system git configuration, and uses it only when the runner’s user can’t write that file, the directory it names, or the hook files in it. When the runner ignores a value, a `[runner:warn]` line at startup names the value and the reason.
+ * **File system monitor** : `core.fsmonitor` is empty, so git in your hook doesn’t run a monitor program that a configuration file names.
+ * **Remote protocols** : `GIT_ALLOW_PROTOCOL` is `https:http:ssh`. A clone, fetch, or push that uses a local path, a `file://` URL, or a `git://` URL fails with `fatal: transport 'file' not allowed` or `fatal: transport 'git' not allowed`.
+ * **SSH command and credential prompt** : git in your hook ignores `core.sshCommand` and `core.askPass` from configuration files. To use your own SSH command, set `GIT_SSH_COMMAND` in the runner’s environment. To use a credential prompt program, set `GIT_ASKPASS` there. Sessions inherit the runner’s environment, so both variables also reach the session’s own git. Don’t put a credential in either.
+ * **gpg programs** : `gpg.program`, `gpg.openpgp.program`, `gpg.x509.program`, and `gpg.ssh.program` are paths the runner sets, never values from a configuration file.
+ * **Commit signing** : with [`--configure-git`](</docs/en/self-hosted-environments-deploy#let-the-runner-configure-git>), commits you make from a hook are signed as the session. Without the flag, `commit.gpgsign` and `tag.gpgsign` are `false`.
+
+To change one of these settings, use the runner’s environment or a `git -c` option inside the hook:
+
+ * **Configuration pairs** : a `GIT_CONFIG_KEY_n`/`GIT_CONFIG_VALUE_n` pair you export in the runner’s environment replaces the runner’s value for the same key. Number your pairs from `0` and set `GIT_CONFIG_COUNT` to how many there are. When the last pair the count announces is missing, the runner ignores all of your pairs and logs a `[runner:warn]` line at startup.
+ * **Git environment variables** : the runner leaves `GIT_ALLOW_PROTOCOL`, `GIT_SSH_COMMAND`, and `GIT_ASKPASS` as you set them in its environment.
+ * **`git -c` options**: a `git -c` option inside the hook overrides a `GIT_CONFIG_KEY_n` pair, the runner’s or yours. It doesn’t change `GIT_ALLOW_PROTOCOL`, `GIT_SSH_COMMAND`, or `GIT_ASKPASS`, which git reads ahead of any configuration.
+
+Git in your hook still reads every setting the runner doesn’t set, such as credential helpers, `url.*.insteadOf` rewrites, and filter drivers, from every configuration file, including the ones sessions can write. A credential helper or filter driver named in one of those files runs as a program with your hook’s privileges, and configuration in those files can still change where a push from your hook goes, including a push to a URL you pass on the command line. Before v2.1.280, the runner set none of these settings, and under `--configure-git` a commit made from a hook failed unless the hook passed `-c commit.gpgsign=false`.
###
@@ -397,6 +434,8 @@
* **Who authors them** : the control plane populates the scripts from fixed constants in its own deployment, never from per-session or third-party input.
* **What still governs them** : hooks delivered through `--settings` enter the ordinary merged hook configuration, not the managed tier, so your managed settings still apply. `disableAllHooks` disables them, and they are not among the categories [`allowManagedHooksOnly`](</docs/en/settings-reference#allowmanagedhooksonly>) keeps loaded.
+Outside [Claude Tag](<https://claude.com/docs/claude-tag/overview>) sessions, a session in a self-hosted environment runs with [auto memory](</docs/en/memory#auto-memory>) off by default. For instructions that should carry across sessions, use the `CLAUDE.md` in your runner image or in the repository. The runner’s snapshot of the host’s `~/.claude/` leaves out the `projects/` directory. Auto memory’s default storage location is under that directory. If you put memory files there, the runner doesn’t seed them into sessions, and they don’t turn auto memory on.
+
###
--- a/self-hosted-environments-deploy.md
+++ b/self-hosted-environments-deploy.md
@@ -136,7 +136,7 @@
* `push.negotiate = true`, so git asks your git host which commits it already has before packing a push. Requires Claude Code v2.1.257 or later.
* `core.hooksPath` pointing at a runner-managed hooks directory. Its `commit-msg` and `prepare-commit-msg` hooks add a `Co-authored-by:` trailer for the session’s creator to each commit, built from the email in [`CCR_SESSION_ACCOUNT_EMAIL`](</docs/en/self-hosted-environments-configuration#wrapper-scripts>) and omitted when that variable is unset. If your image already sets `core.hooksPath`, the runner leaves your setting in place, skips installing these hooks, and prints a `[runner:git]` warning.
-Commit signing requires git 2.34 or later; the runner checks at startup and exits with an error if your git is older. This flag doesn’t configure push credentials, which you still provide in the image.
+Commit signing requires git 2.34 or later; the runner checks at startup and exits with an error if your git is older. This flag doesn’t configure push credentials, which you still provide in the image. On a runner on v2.1.280 or later, commits you make from a `checkout` or `post-session` lifecycle hook are signed as the session too, without the `Co-authored-by:` trailer. [Git configuration inside lifecycle hooks](</docs/en/self-hosted-environments-configuration#git-configuration-inside-lifecycle-hooks>) describes the git settings the runner fixes inside those hooks.
###
@@ -401,7 +401,7 @@
Size the stop timeout
-Give your host’s stop timeout at least the sum of three parts: the `n` minutes you configure, the post-release grace, and the full drain path that Shutdown timing describes. With default settings the post-release grace is 75 seconds and the drain path is 80 seconds, so allow `n` minutes plus 155 seconds. The runner prints this sum at startup whenever `--defer-shutdown-max-min` is set. If the stop timeout runs out before the runner finishes, the host kills the runner. The sessions it still holds get no `post-session` hook. The runner doesn’t deregister, and the control plane requeues the sessions about a minute later. If you can’t give the stop timeout that sum, leave `--defer-shutdown-max-min` unset so the runner drains on the first signal instead.
+Give your host’s stop timeout at least the sum of three parts: the `n` minutes you configure, the post-release grace, and the full drain path that Shutdown timing describes. With default settings the post-release grace is 75 seconds and the drain path is 80 seconds, so allow `n` minutes plus 155 seconds. The runner prints this sum at startup whenever `--defer-shutdown-max-min` is set. If the stop timeout runs out before the runner finishes, the host kills the runner. The sessions it still holds get no `post-session` hook. The runner doesn’t deregister, and the control plane requeues the sessions within a few minutes. If you can’t give the stop timeout that sum, leave `--defer-shutdown-max-min` unset so the runner drains on the first signal instead.
###
@@ -511,8 +511,10 @@
Additional limitations
- * **Resumed sessions lose unpushed work** : when a session is released or its runner is restarted, and the user sends another message, the session resumes on a fresh runner that clones the repository again from its starting branch, so work the session hadn’t pushed is gone. Set [`--push-outcome-on-release`](</docs/en/self-hosted-environments-reference#runner-cli-flags>) to have the runner make a best-effort push of the session’s outcome branches before it releases, so the resumed session starts from those commits instead; this preserves committed work, not a dirty working tree. Before enabling it, restrict who can push to `claude/*` refs on the source remote, for example with a branch ruleset: on resume, the runner fetches the previously pushed branch without verifying who pushed it, so anyone with push access to those refs can place content into the resumed workspace. The runner also discards per-session configuration on resume, meaning the session’s Claude config directory and any shell state the session wrote; `--push-outcome-on-release` doesn’t cover those.
- * **Private repositories can’t be added mid-session** : a repository added to a session after it has started isn’t cloned with credentials on a self-hosted runner, so the add fails. Select every repository the session needs when you create it.
+ * **Resumed sessions lose unpushed work** : a fresh runner clones the repository again from its starting branch, so work the session hadn’t pushed is gone.
+ * **To keep committed work** : set [`--push-outcome-on-release`](</docs/en/self-hosted-environments-reference#runner-cli-flags>). The runner then makes a best-effort push of the session’s outcome branches before it releases, and the resumed session starts from those commits. Uncommitted changes are still lost.
+ * **Before enabling the flag** : restrict who can push to `claude/*` refs on the source remote. On resume, the runner fetches the previously pushed branch without verifying who pushed it.
+ * **A repository added mid-session can fail to clone** : Claude clones it with `git clone` over HTTPS. On a runner without `--use-anthropic-git-proxy`, the clone fails with a git authentication error if nothing on the host can read the repository. Where you can, select every repository the session needs when you create it.
* **Some connectors don’t appear in self-hosted sessions** : a connector you haven’t yet connected in claude.ai Settings isn’t listed in a self-hosted session, and the session won’t prompt you to connect it. Connect it in Settings first, then start a fresh session. Adding a connector to an already-running session also doesn’t make its tools available to Claude; start a fresh session to pick up a newly added connector.
###
--- a/self-hosted-environments-identity.md
+++ b/self-hosted-environments-identity.md
@@ -182,9 +182,9 @@
Verify the token inside the session
-[Wrapper scripts](</docs/en/self-hosted-environments-configuration#wrapper-scripts>) run inside the session, before Claude starts. Instead of calling a JWT library, they can run the runner binary’s `self-hosted-runner decode-token` subcommand. The subcommand reads the token from a positional argument, from `CLAUDE_CODE_SESSION_ACCESS_TOKEN`, or from piped stdin, in that order, then strips the prefix, verifies the signature against the JWKS endpoint, checks expiry, and prints the claims as JSON. The subcommand performs the signature and expiry checks only; it doesn’t check `iss`, `aud`, or `ccr:role`. When your wrapper’s auth decision depends on those claims, read them from the printed JSON and compare them explicitly. This command extracts the creator identity, preferring the SSO provider’s subject, then the email address, then the creator’s `act.sub` subject, `user:<id>` or `agent:<id>`:
-
- "$CLAUDE_RUNNER_CLAUDE_BIN" self-hosted-runner decode-token | jq -re '.act.attested_by.sub // .act.email // .act.sub'
+[Wrapper scripts](</docs/en/self-hosted-environments-configuration#wrapper-scripts>) run inside the session, before Claude starts. Instead of calling a JWT library, they can run the runner binary’s `self-hosted-runner decode-token` subcommand. The subcommand reads the token from a positional argument, from `CLAUDE_CODE_SESSION_ACCESS_TOKEN`, or from piped stdin, in that order, then strips the prefix, verifies the signature against the JWKS endpoint, checks expiry, and prints the claims as JSON. The subcommand performs the signature and expiry checks only; it doesn’t check `iss`, `aud`, or `ccr:role`. When your wrapper’s auth decision depends on those claims, read them from the printed JSON and compare them explicitly. This command extracts the creator identity, preferring the email address, then the creator’s `act.sub` subject, `user:<id>` or `agent:<id>`:
+
+ "$CLAUDE_RUNNER_CLAUDE_BIN" self-hosted-runner decode-token | jq -re '.act.email // .act.sub'
Wrappers receive the absolute path to the runner’s own binary in `CLAUDE_RUNNER_CLAUDE_BIN`; use that path rather than a PATH-resolved `claude` so the decode runs on the same binary the runner itself uses. Use `jq -re` rather than `jq -r` so a missing claim causes a non-zero exit. With `-r` alone, a missing claim prints the literal string `null` and exits zero, which silently passes a bad value downstream. Pass `--no-verify` to `decode-token` only for offline inspection where the JWKS endpoint is unreachable.
@@ -226,7 +226,7 @@
---|---
`act.sub`| The creating user’s Anthropic user ID, in the form `user:<id>`, or `agent:<id>` when your organization’s service identity created the session, as it does for Claude Tag channel sessions.
`act.email`| The creating user’s email address, when one was recorded at session creation. Don’t require it; key on `act.sub`.
-`act.attested_by`| The upstream identity provider’s attestation for the creating user, when available. `act.attested_by.sub` is the subject your SSO provider, such as Google or Okta, issued. Prefer this over `act.email` when mapping to identities in your own systems.
+`act.attested_by`| Reserved for the upstream identity provider’s attestation for the creating user. Expect it to be absent, and don’t depend on it. Key on `act.sub`. If you need an address, read `act.email` when it’s present.
`act.act`| The runner that spawned the session. `act.act.sub` is `ccr:runner:<runner_id>`.
`act.act.act`| The environment. `act.act.act.sub` is `ccr:pool:<pool_id>`.
`act.act.act.act`| The identity that created the environment secret the runner registered with. The chain ends here.
--- a/settings-example.md
+++ b/settings-example.md
@@ -209,7 +209,7 @@
"enabledPlugins": {
"code-formatter@acme-tools": true
},
- // Sandbox commands: writable build dir; npm and example.com pre-allowed, other hosts still prompt
+ // Sandbox commands: writable build dir; npm and example.com pre-allowed
"sandbox": {
"enabled": true,
"filesystem": {
@@ -242,7 +242,7 @@
* [`allowManagedPermissionRulesOnly`](</docs/en/settings-reference#allowmanagedpermissionrulesonly>) and [`allowManagedMcpServersOnly`](</docs/en/settings-reference#allowmanagedmcpserversonly>) make the managed permission and MCP allowlists the only ones that apply
* `allowedMcpServers` pins the MCP server by URL
* `strictKnownMarketplaces` allows one plugin marketplace
- * `sandbox` sandboxes commands with a fixed network allowlist and no unsandboxed retry
+ * `sandbox` sandboxes commands with a fixed network allowlist and no unsandboxed retry. Its `failIfUnavailable` key [stops Claude Code from starting where the sandbox can’t run](</docs/en/sandboxing#enforce-sandboxing-with-managed-settings>)
* `requiredMinimumVersion` sets a minimum Claude Code version
* `cleanupPeriodDays` shortens retention of session transcripts and other local data to seven days
* `companyAnnouncements` shows a message at startup
Show diff (564 lines)
--- a/settings-reference.md
+++ b/settings-reference.md
@@ -25,6 +25,7 @@
`alwaysThinkingEnabled`| Turn [extended thinking](</docs/en/model-config#extended-thinking>) off for every session| Model and responses| Any file
`apiKeyHelper`| Generate the [API credential](</docs/en/authentication#credential-management>) with your own command| Authentication and providers| Any file
`askUserQuestionTimeout`| Let an unanswered question [auto-continue](</docs/en/tools-reference#question-auto-continue-timeout>) after idle time| Interface and terminal| User or managed
+`appendPlugins`| Run your organization’s [mods](</docs/en/plugins/mods/admin>) after every mod a user installs| Plugins and skills| User or managed
`attribution`| Customize the attribution Claude Code adds to commits and pull requests| Git and attribution| Any file
`attribution.commit`| Change or hide the trailer Claude Code adds to commits| Git and attribution| Any file
`attribution.pr`| Change or hide the attribution line in pull request descriptions| Git and attribution| Any file
@@ -51,7 +52,7 @@
`blockedMarketplaces`| Block [plugin marketplace](</docs/en/plugins/overview>) sources for your organization| Plugins and skills| Managed
`browserExternalPageTools`| Keep Claude’s tools off external pages in the [desktop](</docs/en/desktop>) Browser pane| Tools| Managed
`channelsEnabled`| Allow [channels](</docs/en/channels#enable-channels-for-your-organization>) for your organization| Plugins and skills| Managed
-`claudeInChromeDefaultEnabled`| Turn on [Chrome integration](</docs/en/chrome>) in every interactive CLI session without passing `--chrome`| Global config settings| Global config
+`claudeInChromeDefaultEnabled`| Turn on [Chrome integration](</docs/en/chrome>) when a session starts, in the interactive CLI and the VS Code extension| Global config settings| Global config
`claudeMd`| Inject organization-wide [CLAUDE.md](</docs/en/memory#deploy-organization-wide-claude-md>) instructions from managed settings| Memory and context| Managed
`claudeMdExcludes`| Skip specific [CLAUDE.md](</docs/en/memory#exclude-specific-claude-md-files>) files when memory loads| Memory and context| Any file
`cleanupPeriodDays`| Choose how many days Claude Code keeps [transcripts](</docs/en/data-usage#data-retention>) before deleting them| Privacy and telemetry| Any file
@@ -149,6 +150,7 @@
`policyHelper.timeoutMs`| Set how long Claude Code waits for the [helper](</docs/en/managed-settings#compute-the-policy-with-a-helper-program>)| Enterprise and managed settings| Managed
`preferredNotifChannel`| Choose a [terminal bell or desktop notification](</docs/en/terminal-config#get-a-terminal-bell-or-notification>) for task completion| Remote, desktop, and notifications| Any file
`prefersReducedMotion`| [Reduce or turn off](</docs/en/accessibility#accessibility-settings>) spinner, shimmer, and flash animations| Interface and terminal| Any file
+`prependPlugins`| Run your organization’s [mods](</docs/en/plugins/mods/admin>) before every mod a user installs| Plugins and skills| User or managed
`processWrapper`| Run Claude Code’s background processes through a [corporate launcher](</docs/en/corporate-launcher>) on macOS and Linux| Agents, sessions, and worktrees| User or managed
`promptCacheTtl`| Choose the [prompt cache lifetime](</docs/en/prompt-caching#cache-lifetime>) for the main conversation| Model and responses| Any file
`promptSuggestionEnabled`| Hide the grayed-out [prompt suggestions](</docs/en/interactive-mode#prompt-suggestions>) in the input box| Interface and terminal| Any file
@@ -173,7 +175,7 @@
`sandbox.credentials.sigv4`| Choose whether streaming, presigned, or [SigV4A AWS requests](</docs/en/sandboxing#re-sign-aws-requests>) fail or pass through| Sandbox settings| User or managed
`sandbox.enabled`| Turn on [Bash sandboxing](</docs/en/sandboxing#get-started>) on macOS, Linux, and WSL2| Sandbox settings| Any file
`sandbox.enableWeakerNestedSandbox`| Run the Linux [sandbox](</docs/en/sandboxing>) inside an unprivileged container| Sandbox settings| Any file
-`sandbox.enableWeakerNetworkIsolation`| Let `gh`, `gcloud`, and `terraform` verify TLS behind a MITM proxy inside the [sandbox](</docs/en/sandboxing#troubleshooting>) on macOS| Sandbox settings| Any file
+`sandbox.enableWeakerNetworkIsolation`| Let `gh`, `gcloud`, and `terraform` verify TLS behind a MITM proxy inside the [sandbox](</docs/en/sandboxing#go-based-clis-fail-tls-verification-on-macos>) on macOS| Sandbox settings| Any file
`sandbox.excludedCommands`| Name commands Claude Code can run outside the [sandbox](</docs/en/sandboxing>)| Sandbox settings| Any file
`sandbox.failIfUnavailable`| Refuse to start when the [sandbox](</docs/en/sandboxing>) can’t, instead of running unsandboxed| Sandbox settings| Any file
`sandbox.filesystem`| Control which paths [sandboxed](</docs/en/sandboxing#filesystem-isolation>) commands can read and write| Sandbox settings| Any file
@@ -187,7 +189,7 @@
`sandbox.network`| Control which hosts, ports, and sockets [sandboxed](</docs/en/sandboxing#network-isolation>) commands reach| Sandbox settings| Any file
`sandbox.network.allowAllUnixSockets`| Let [sandboxed](</docs/en/sandboxing>) commands connect to every Unix socket| Sandbox settings| Any file
`sandbox.network.allowedDomains`| Pre-allow domains so [sandboxed](</docs/en/sandboxing>) commands don’t prompt for them| Sandbox settings| Any file
-`sandbox.network.allowLocalBinding`| Let [sandboxed](</docs/en/sandboxing>) commands bind to localhost ports on macOS| Sandbox settings| Any file
+`sandbox.network.allowLocalBinding`| Let [sandboxed](</docs/en/sandboxing>) commands listen on network ports and connect to localhost on macOS| Sandbox settings| Any file
`sandbox.network.allowMachLookup`| Let macOS [sandboxed](</docs/en/sandboxing>) tools like the iOS Simulator or Playwright reach their XPC services| Sandbox settings| Any file
`sandbox.network.allowManagedDomainsOnly`| Lock the network allowlist to [managed settings](</docs/en/sandboxing#keep-developers-from-widening-the-policy>)| Sandbox settings| Managed
`sandbox.network.allowUnixSockets`| List Unix socket paths [sandboxed](</docs/en/sandboxing>) commands can use on macOS| Sandbox settings| Any file
@@ -868,7 +870,14 @@
`allowManagedPermissionRulesOnly`
-Make managed settings the only settings source of permission rules. Claude Code then ignores `allow`, `ask`, and `deny` rules in user, project, local, and `--settings` files, ignores `--allowedTools`, hides the always-allow choices in permission prompts, and stops saving new rules. When [parent settings from an embedding host](</docs/en/managed-settings#let-an-embedding-host-add-policy>) apply, Claude Code treats them as part of the managed tier. It drops their `allow` rules and `additionalDirectories`, and keeps their `deny` and `ask` rules except `Read` and `Edit` rules whose pattern starts with `!`. A host can’t carve paths out of the managed rules with a `!` rule, whether or not you set this key. `--disallowedTools` rules and the current session’s `deny` and `ask` rules still apply, including after Claude Code reloads settings mid-session. They only restrict, so they can’t widen what the managed rules grant. Before v2.1.257, Claude Code dropped those command-line and session rules at the first settings reload. For what a `!` pattern in a `--disallowedTools` or session rule can carve out, see [Read and Edit rules](</docs/en/permissions#read-and-edit>).
+Make managed settings the only settings source of permission rules. Claude Code then ignores `allow`, `ask`, and `deny` rules in user, project, local, and `--settings` files, ignores `--allowedTools`, hides the always-allow choices in permission prompts, and stops saving new rules. When [parent settings from an embedding host](</docs/en/managed-settings#let-an-embedding-host-add-policy>) apply, Claude Code treats them as part of the managed tier. It drops their `allow` rules and `additionalDirectories`, and keeps their `deny` and `ask` rules except `Read` and `Edit` rules whose pattern starts with `!`. A host can’t carve paths out of the managed rules with a `!` rule, whether or not you set this key. `--disallowedTools` rules and the current session’s `deny` and `ask` rules still apply, including after Claude Code reloads settings mid-session. They only restrict, so they can’t widen what the managed rules grant. Before v2.1.257, Claude Code dropped those command-line and session rules at the first settings reload. For what a `!` pattern in a `--disallowedTools` or session rule can carve out, see [Read and Edit rules](</docs/en/permissions#read-and-edit>). When you set this key, Claude Code v2.1.282 or later also ignores the [`allowed-tools`](</docs/en/skills#pre-approve-tools-for-a-skill>) frontmatter in skills and `.claude/commands/` files from these sources:
+
+ * A repository’s `.claude/` directory
+ * Your `~/.claude/skills/` and `~/.claude/commands/` directories, including [skills synced from claude.ai](</docs/en/skills#where-synced-skills-load>)
+ * An `--add-dir` directory
+ * [Plugins declared with a `.claude-plugin` manifest](</docs/en/plugins/loading#plugins-shared-through-a-repository>) inside `~/.claude/skills/` or the project’s `.claude/skills/`
+
+Skills from managed settings and bundled skills keep their `allowed-tools`. A skill’s `disallowed-tools` still applies. For what a developer sees when Claude Code ignores the field, see [When only managed permission rules apply](</docs/en/skills#when-only-managed-permission-rules-apply>).
* **Scope** : `Managed`
* **Type** : Boolean
@@ -1098,7 +1107,7 @@
Give Claude file access to directories outside the one you started in, as additional [working directories](</docs/en/permissions#working-directories>). Most `.claude/` configuration is [not discovered](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) from these directories.
- * **Scope** : `Any file`
+ * **Scope** : `Any file`, with [limits on the sandbox write access](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>) that project and local entries give
* **Type** : array of directory paths
* **Default** : unset
* **Per-session overrides** : `--add-dir` and `/add-dir` add directories for one session alongside this key
@@ -1294,7 +1303,7 @@
}
}
-Claude Code takes a Boolean key’s value from the highest-precedence settings scope that sets it, so a managed `enabled` or `failIfUnavailable` overrides anything a developer sets. It merges array keys across every settings scope the session loads, so a developer can append entries; see [Keep developers from widening the policy](</docs/en/sandboxing#keep-developers-from-widening-the-policy>) for the managed-only locks. To require the sandbox for an organization, see [Enforce sandboxing with managed settings](</docs/en/sandboxing#enforce-sandboxing-with-managed-settings>).
+When managed settings set a Boolean key such as `enabled` or `failIfUnavailable`, that value overrides anything a developer sets. Claude Code merges array keys across the settings scopes the session loads, so a developer can append entries; see [Keep developers from widening the policy](</docs/en/sandboxing#keep-developers-from-widening-the-policy>) for the managed-only locks. To require the sandbox for an organization, see [Enforce sandboxing with managed settings](</docs/en/sandboxing#enforce-sandboxing-with-managed-settings>).
###
@@ -1304,7 +1313,7 @@
Turn on [sandboxing](</docs/en/sandboxing>) for Bash commands. When you pick a mode in the `/sandbox` panel, Claude Code writes this key to `.claude/settings.local.json` for the current project; set it in `~/.claude/settings.json` to sandbox every project.
- * **Scope** : `Any file`
+ * **Scope** : `Any file`, with [limits on project and local settings](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>)
* **Type** : Boolean
* `true`: Claude Code sandboxes Bash commands
* `false`: Bash commands run unsandboxed
@@ -1318,7 +1327,7 @@
}
}
-On Linux and WSL2 the sandbox needs `bubblewrap` and `socat`; see [Set up Linux and WSL2](</docs/en/sandboxing#set-up-linux-and-wsl2>). When the sandbox can’t start, Claude Code shows a warning and runs commands unsandboxed unless you also set `failIfUnavailable`.
+On Linux and WSL2 the sandbox needs `bubblewrap` and `socat`; see [Set up Linux and WSL2](</docs/en/sandboxing#set-up-linux-and-wsl2>). When the sandbox can’t start, Claude Code runs commands unsandboxed unless you also set `failIfUnavailable`.
###
@@ -1326,12 +1335,12 @@
`sandbox.failIfUnavailable`
-Make Claude Code exit with an error at startup when `sandbox.enabled` is `true` but the sandbox can’t start, because a dependency is missing or the platform is unsupported. Without it, Claude Code shows a warning and runs commands unsandboxed. Use it in managed settings when your organization requires sandboxing as a hard gate.
-
- * **Scope** : `Any file`
+Make Claude Code exit with an error at startup when `sandbox.enabled` is `true` but the sandbox can’t start, because a dependency is missing or the platform is unsupported. Without this key, Claude Code runs commands unsandboxed. Managed deployments that require sandboxing as a security gate can use this setting. On a platform the sandbox doesn’t support, Claude Code doesn’t start with this key on. See [Enforce sandboxing with managed settings](</docs/en/sandboxing#enforce-sandboxing-with-managed-settings>).
+
+ * **Scope** : `Any file`, with [limits on project and local settings](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>)
* **Type** : Boolean
* `true`: Claude Code exits with an error at startup when `sandbox.enabled` is `true` but the sandbox can’t start
- * `false`: Claude Code shows a warning and runs commands unsandboxed
+ * `false`: Claude Code runs commands unsandboxed when the sandbox can’t start
* **Default** : `false`
This makes every managed machine sandbox commands or refuse to start:
@@ -1380,9 +1389,9 @@
`sandbox.excludedCommands`
-Name commands that Claude Code runs outside the sandbox, such as tools that don’t work under it. Each entry uses the same syntax as the content of a `Bash(...)` [permission rule](</docs/en/permissions#permission-rule-syntax>): an exact command, a prefix such as `docker *`, or a wildcard pattern. Your entries take a Bash call out of the sandbox only when they cover every command in it, and some call shapes stay sandboxed even then. A `docker *` entry alone doesn’t take `npm ci && docker build .` out of the sandbox.
-
- * **Scope** : `Any file`
+Name commands that Claude Code runs outside the sandbox, such as tools that don’t work under it. Each entry uses the same syntax as the content of a `Bash(...)` [permission rule](</docs/en/permissions#permission-rule-syntax>): an exact command, a prefix such as `docker *`, or a wildcard pattern. A pattern with no wildcard is an exact match, so `docker` matches only `docker` with no arguments. Your entries take a Bash call out of the sandbox only when they cover every command in it, and some call shapes stay sandboxed even then. A `docker *` entry alone doesn’t take `npm ci && docker build .` out of the sandbox.
+
+ * **Scope** : `Any file`, with [limits on project and local settings](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>)
* **Type** : array of command patterns
* **Default** : unset, so no command is excluded
@@ -1401,8 +1410,9 @@
* A command substitution, a subshell, or a control-flow block such as `if` or `for`
* A redirection, such as `docker build . > build.log`, other than one that only duplicates a file descriptor, as `2>&1` does
* A command name that comes from a variable
-
-For example, `cd build && docker compose up` stays sandboxed under a `docker *` entry, and adding a `cd` entry doesn’t change that. Excluded commands still go through the regular permission flow. Exclusion is a convenience, not a security boundary: prefer `filesystem.allowWrite` when a tool only needs to write somewhere specific. Claude Code merges entries across every settings scope the session loads, and there is no managed-only lock for this list, so keep a managed list narrow.
+ * A `git clone`, `git init`, `git worktree add`, `git worktree move`, or `git bundle create` with a path argument that is absolute, starts with `~`, or contains a `..` segment
+
+For example, `cd build && docker compose up` stays sandboxed under a `docker *` entry, and adding a `cd` entry doesn’t change that. Under a `git *` entry, `git clone <url> vendor/lib` runs outside the sandbox, but `git clone <url> ~/tools` stays sandboxed. A clone writes a whole tree of files, possibly executable ones, wherever its destination path points. Excluded commands still go through the regular permission flow. Exclusion is a convenience, not a security boundary: when a tool only needs to write somewhere specific, `filesystem.allowWrite` keeps it sandboxed. Entries from the settings scopes the session loads combine into one list unless the sandbox is [admin-required](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>). While it is, Claude Code ignores entries in `.claude/settings.json` and `.claude/settings.local.json`, so a cloned repository can’t take commands out of the sandbox. Entries in managed settings, `--settings`, and your `~/.claude/settings.json` still apply, and no managed-only lock covers this list.
###
@@ -1410,12 +1420,12 @@
`sandbox.allowUnsandboxedCommands`
-Let Claude retry a command outside the sandbox with the `dangerouslyDisableSandbox` parameter after the sandbox blocks it. Set it to `false` so Claude Code ignores that parameter completely and every command Claude runs must be sandboxed or appear in `excludedCommands`. The `/sandbox` **Overrides** tab shows that state as **Strict sandbox mode**. Use `false` in managed settings for policies that require strict sandboxing.
-
- * **Scope** : `Any file`
+Let Claude retry a command outside the sandbox with the `dangerouslyDisableSandbox` parameter after the sandbox blocks it. When it’s `false`, Claude Code ignores that parameter. While the sandbox is running, commands Claude runs are then sandboxed unless they match an `excludedCommands` entry. The `/sandbox` **Overrides** tab shows that state as **Strict sandbox mode**. A `false` in managed settings turns on strict sandbox mode for the developers it covers.
+
+ * **Scope** : `Any file`, with [a limit on project and local settings](</docs/en/sandboxing#turn-off-the-retry-with-strict-sandbox-mode>)
* **Type** : Boolean
* `true`: Claude can retry a command outside the sandbox with the `dangerouslyDisableSandbox` parameter after the sandbox blocks it
- * `false`: Claude Code ignores that parameter, so every command Claude runs is sandboxed or appears in `excludedCommands`
+ * `false`: Claude Code ignores that parameter, so while the sandbox is running, commands Claude runs are sandboxed unless they match an `excludedCommands` entry
* **Default** : `true`
This enforces strict sandbox mode for everyone the managed settings cover:
@@ -1429,7 +1439,7 @@
}
}
-An unsandboxed retry goes through the regular permission flow, with a prompt in Manual mode. See [The unsandboxed retry escape hatch](</docs/en/sandboxing#the-unsandboxed-retry-escape-hatch>). To see when commands you type yourself at the [`!` shell-mode prompt](</docs/en/interactive-mode#shell-mode-with-prefix>) run sandboxed, see [strict sandbox mode](</docs/en/sandboxing#the-unsandboxed-retry-escape-hatch>).
+A `false` from managed settings or `--settings` also makes the sandbox [admin-required](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>). A `false` in your user settings holds against a project’s `true` but doesn’t make the sandbox admin-required. Holding against a project’s value requires Claude Code v2.1.285 or later. Who approves an unsandboxed retry depends on your permission mode and allow rules. See [The unsandboxed retry escape hatch](</docs/en/sandboxing#the-unsandboxed-retry-escape-hatch>). To see when commands you type yourself at the [`!` shell-mode prompt](</docs/en/interactive-mode#shell-mode-with-prefix>) run sandboxed, see [strict sandbox mode](</docs/en/sandboxing#turn-off-the-retry-with-strict-sandbox-mode>).
###
@@ -1456,7 +1466,7 @@
}
}
-Claude Code enforces these lists at the OS sandbox boundary, so they apply to every subprocess a sandboxed command starts, such as `kubectl`, `terraform`, or `npm`. Claude Code adds your [permission rules](</docs/en/sandboxing#permission-rules>) to the same lists: `Edit` allow and deny rules to `allowWrite` and `denyWrite`, `Read` deny rules to `denyRead`, and `WebFetch(domain:...)` allow and deny rules to the `network` domain lists. Unless a managed-only lock is set, Claude Code merges every list across the settings files the session loads. `allowManagedReadPathsOnly` limits `allowRead` to entries from managed settings, and `allowManagedDomainsOnly` does the same for allowed domains. [Configure sandboxing](</docs/en/sandboxing#configure-sandboxing>) covers sources you exclude with `--setting-sources`. When you edit a list during a session, Claude Code [applies the change to the running session](</docs/en/settings#when-edits-take-effect>).
+Claude Code enforces these lists at the OS sandbox boundary, so they apply to every subprocess a sandboxed command starts, such as `kubectl`, `terraform`, or `npm`. Claude Code adds your [permission rules](</docs/en/sandboxing#permission-rules>) to the same lists: `Edit` allow and deny rules to `allowWrite` and `denyWrite`, `Read` deny rules to `denyRead`, and `WebFetch(domain:...)` allow and deny rules to the `network` domain lists. Unless a lock applies, Claude Code merges these lists across the settings files the session loads. `allowManagedReadPathsOnly` limits `allowRead` to entries from managed settings, and `allowManagedDomainsOnly` does the same for allowed domains. [Repository locks](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>) leave out entries from a repository’s settings files. [Configure sandboxing](</docs/en/sandboxing#configure-sandboxing>) covers sources you exclude with `--setting-sources`. When you edit a list during a session, Claude Code [applies the change to the running session](</docs/en/settings#when-edits-take-effect>).
####
@@ -1485,7 +1495,7 @@
Add paths where sandboxed commands can write, beyond the working directory, the per-user temp directory, and the directories you’ve added with `--add-dir`, `/add-dir`, or `permissions.additionalDirectories`. Use it when a subprocess such as `kubectl` or a build tool needs to write outside the project.
- * **Scope** : `Any file`
+ * **Scope** : `Any file`, with [limits on project and local settings](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>)
* **Type** : array of path strings, using the sandbox path prefixes
* **Default** : unset, so sandboxed commands can write to the working directory, the per-user temp directory, directories you’ve added with `--add-dir` or `/add-dir`, and directories in `permissions.additionalDirectories`
@@ -1501,7 +1511,7 @@
}
}
-Claude Code merges `allowWrite` entries and the paths from your `Edit(...)` allow permission rules across every settings scope the session loads, leaving out the ones from repository settings while `permissions.blockReadsOutsideWorkingDirectories` is on. An `allowWrite` entry can’t lift a [protected path](</docs/en/sandboxing#protected-paths>).
+Claude Code merges `allowWrite` entries and the paths from your `Edit(...)` allow permission rules across the settings scopes the session loads, leaving out the ones from repository settings while `permissions.blockReadsOutsideWorkingDirectories` is on. [Repository locks](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>) can leave out a repository’s entries too. An `allowWrite` entry can’t lift a [protected path](</docs/en/sandboxing#protected-paths>).
###
@@ -1561,7 +1571,7 @@
Re-open reading for specific paths inside a region that `denyRead` blocks, to build workspace-only read access. An exact or wildcard `denyRead` entry stays blocked inside a broader `allowRead`, as the [overlap table](</docs/en/sandboxing#configure-sandboxing>) shows. When a wildcard `denyRead` entry such as `~/**/.env` matches a directory, Claude Code blocks reads of its contents as well. Before v2.1.236 on macOS, Claude Code re-opened the paths a wildcard `denyRead` entry matched wherever a broader `allowRead` entry covered them, and left a matched directory’s contents readable.
- * **Scope** : `Any file`
+ * **Scope** : `Any file`, with [limits on project and local settings](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>)
* **Type** : array of path strings, using the sandbox path prefixes
* **Default** : unset
@@ -1578,7 +1588,7 @@
}
}
-Claude Code resolves a `.` entry to the project root in project settings and to `~/.claude` in user settings. Claude Code merges entries across every settings file the session loads unless `allowManagedReadPathsOnly` is set, and leaves out entries from repository settings while `permissions.blockReadsOutsideWorkingDirectories` is on.
+Claude Code resolves a `.` entry to the project root in project settings and to `~/.claude` in user settings. Claude Code merges entries across the settings files the session loads unless `allowManagedReadPathsOnly` is set, and leaves out entries from repository settings while `permissions.blockReadsOutsideWorkingDirectories` is on. [Repository locks](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>) can leave out a repository’s entries too.
###
@@ -1591,7 +1601,7 @@
* **Scope** : `Managed`
* **Type** : Boolean
* `true`: Claude Code honors only the `allowRead` entries from managed settings
- * `false`: `allowRead` entries merge from every settings scope the session loads
+ * `false`: `allowRead` entries from other settings files can merge in
* **Default** : `false`
This blocks reads of the home directory, re-opens `~/work`, and stops developers from re-opening anything else:
@@ -1650,7 +1660,7 @@
Silence sandbox violation reports for paths you expect a command to probe and be refused, such as a tool that checks `/etc/hosts` on startup, so those denials don’t show up as violations or in what Claude sees. The sandbox still blocks the access; only the report is suppressed. Keys are substrings to match against the command, with `*` matching every command, and values are substrings of the violation to ignore for that command, such as a filesystem path.
- * **Scope** : `Any file`
+ * **Scope** : `Any file`, with [limits on project and local settings](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>)
* **Type** : object mapping a command substring to an array of violation substrings, usually paths
* **Default** : unset, so every violation is reported
@@ -1672,7 +1682,7 @@
Run the Linux sandbox inside an unprivileged Docker container, where bubblewrap can’t mount a fresh `/proc`. Instead the inner sandbox bind-mounts the container’s existing `/proc`, which exposes process information that a fresh mount would hide. This reduces security; use it only when the outer container already provides the isolation you need.
- * **Scope** : `Any file`
+ * **Scope** : `Any file`, with [limits on project and local settings](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>)
* **Type** : Boolean
* `true`: the inner sandbox bind-mounts the container’s existing `/proc` instead of mounting a fresh one
* `false`: the sandbox mounts a fresh `/proc`, which doesn’t work in an unprivileged Docker container
@@ -1687,7 +1697,7 @@
}
}
-Linux and WSL2 only. See [Bubblewrap fails to start inside a container](</docs/en/sandboxing#troubleshooting>).
+Linux and WSL2 only. See [Bubblewrap fails to start inside a container](</docs/en/sandboxing#bubblewrap-fails-to-start-inside-a-container>).
###
@@ -1697,7 +1707,7 @@
Let sandboxed commands on macOS reach the system TLS trust service, `com.apple.trustd.agent`. Go-based tools such as `gh`, `gcloud`, and `terraform` need it to verify TLS certificates when you use `network.httpProxyPort` with a MITM proxy and a custom CA. This reduces security by opening a potential data exfiltration path through the trust service.
- * **Scope** : `Any file`
+ * **Scope** : `Any file`, with [limits on project and local settings](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>)
* **Type** : Boolean
* `true`: sandboxed commands on macOS can reach `com.apple.trustd.agent`
* `false`: sandboxed commands on macOS can’t reach the system TLS trust service
@@ -1712,7 +1722,7 @@
}
}
-If you don’t use a MITM proxy, list the failing tools in `excludedCommands` instead; see [Go-based CLIs fail TLS verification on macOS](</docs/en/sandboxing#troubleshooting>).
+If you don’t use a MITM proxy, list the failing tools in `excludedCommands` instead; see [Go-based CLIs fail TLS verification on macOS](</docs/en/sandboxing#go-based-clis-fail-tls-verification-on-macos>).
###
@@ -1875,7 +1885,7 @@
}
}
-Paths use the same prefixes as the `sandbox.filesystem.*` settings, and Claude Code merges the arrays from every settings scope the session loads. [Protect credentials](</docs/en/sandboxing#protect-credentials>) covers what still applies from sources you exclude with `--setting-sources`. `mask` entries require Claude Code v2.1.221 or later. `mask` substitution runs only through the sandbox proxy, so set `sandbox.network.tlsTerminate`, or `allowPlaintextInject` for plain-HTTP test networks. `mask` applies to a single file, so list each credential file individually. Claude Code accepts but ignores the `mask` fields on a `deny` entry. [Mask credential files](</docs/en/sandboxing#mask-credential-files>) covers which settings sources are honored and when an entry falls back to `deny`.
+Paths use the same prefixes as the `sandbox.filesystem.*` settings, and Claude Code merges the arrays from every settings scope the session loads. [Protect credentials](</docs/en/sandboxing#protect-credentials>) covers what still applies from sources you exclude with `--setting-sources`. `mask` entries require Claude Code v2.1.221 or later. `mask` substitution runs only through the sandbox proxy, so set `sandbox.network.tlsTerminate`, or `allowPlaintextInject` for plain-HTTP test networks. `mask` applies to a single file, so list each credential file individually. Claude Code accepts but ignores the `mask` fields on a `deny` entry. [Mask credentials](</docs/en/sandboxing#mask-credentials>) covers which settings sources are honored, and [Mask credential files](</docs/en/sandboxing#mask-credential-files>) covers when an entry falls back to `deny`.
####
@@ -1942,7 +1952,7 @@
}
}
-The `name` must start with a letter or underscore and contain only letters, digits, and underscores. Claude Code merges the arrays from every settings scope the session loads, and applies `deny` when the same variable appears with both modes. [Protect credentials](</docs/en/sandboxing#protect-credentials>) covers what still applies from sources you exclude with `--setting-sources`. `mask` entries require Claude Code v2.1.199 or later. `mask` substitution runs only through the sandbox proxy, so set `sandbox.network.tlsTerminate`, or `allowPlaintextInject` for plain-HTTP test networks; see [Mask environment variables](</docs/en/sandboxing#mask-environment-variables>). Claude Code accepts but ignores the `mask` fields on a `deny` entry.
+The `name` must start with a letter or underscore and contain only letters, digits, and underscores. Claude Code merges the arrays from every settings scope the session loads, and applies `deny` when the same variable appears with both modes. [Protect credentials](</docs/en/sandboxing#protect-credentials>) covers what still applies from sources you exclude with `--setting-sources`. `mask` entries require Claude Code v2.1.199 or later. `mask` substitution runs only through the sandbox proxy, so set `sandbox.network.tlsTerminate`, or `allowPlaintextInject` for plain-HTTP test networks; see [Mask credentials](</docs/en/sandboxing#mask-credentials>). Claude Code accepts but ignores the `mask` fields on a `deny` entry.
####
@@ -2041,7 +2051,11 @@
}
}
-Each named variable must be a whole-value `mask` entry in `sandbox.credentials.envVars`, without `extract` or `decode`, and can fill only one slot across all pairs.
+Each named variable must be a whole-value `mask` entry in `sandbox.credentials.envVars`, without `extract` or `decode`, and can fill only one slot across all pairs. These rules also apply:
+
+ * The proxy re-signs requests on the hosts listed in the access key ID entry’s `injectHosts`
+ * When `sessionTokenVar` is set, the proxy sends the real token as `x-amz-security-token` on re-signed requests
+ * Naming any of the conventional variables in a pair replaces the automatic pairing
###
@@ -2083,7 +2097,7 @@
* **Scope** : `Any file`. `strictAllowlist`, `allowManagedDomainsOnly`, and `tlsTerminate` are read from fewer sources, as their entries say.
* **Type** : object with the sub-keys below
- * **Default** : unset, so no domains are pre-allowed and the sandbox prompts for each new host
+ * **Default** : unset, so no domains are pre-allowed and your permission mode decides [what happens to each new host](</docs/en/sandboxing#hosts-outside-your-allowed-domains>)
This pre-allows GitHub and npm, blocks `uploads.github.com`, and lets commands bind to localhost:
@@ -2099,7 +2113,7 @@
}
}
-Claude Code merges the array sub-keys across settings scopes and deduplicates them, so a project can add domains to your user list. `WebFetch(domain:...)` allow and deny [permission rules](</docs/en/sandboxing#permission-rules>) feed the same allow and deny lists.
+Claude Code merges the array sub-keys across settings scopes, so a project can add domains to your user list unless a [repository lock](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>) applies. `WebFetch(domain:...)` allow and deny [permission rules](</docs/en/sandboxing#permission-rules>) feed the same allow and deny lists.
###
@@ -2109,7 +2123,7 @@
List the Unix socket paths sandboxed commands can connect to on macOS. Claude Code ignores this list on Linux and WSL2, where the seccomp filter can’t inspect socket paths; use `allowAllUnixSockets` there instead.
- * **Scope** : `Any file`
+ * **Scope** : `Any file`, with [limits on project and local settings](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>)
* **Type** : array of strings, each a socket path
* **Default** : unset, so the macOS sandbox blocks every Unix socket
@@ -2133,7 +2147,7 @@
Let sandboxed commands connect to every Unix socket. On Linux and WSL2, the sandbox’s [seccomp filter](</docs/en/sandboxing#set-up-linux-and-wsl2>) blocks `socket(AF_UNIX, ...)` calls, so this is the only way to permit Unix sockets there. When the filter is missing, which `/sandbox` reports on its Dependencies tab, the sandbox doesn’t block Unix-socket calls. See [Set up Linux and WSL2](</docs/en/sandboxing#set-up-linux-and-wsl2>) for where the filter comes from.
- * **Scope** : `Any file`
+ * **Scope** : `Any file`, with [limits on project and local settings](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>)
* **Type** : Boolean
* `true`: sandboxed commands can connect to every Unix socket
* `false`: the sandbox blocks Unix-socket connections: on macOS except the paths in `allowUnixSockets`, and on Linux and WSL2 through the seccomp filter when it’s present
@@ -2157,12 +2171,12 @@
`sandbox.network.allowLocalBinding`
-Let sandboxed commands bind to localhost ports on macOS, for example to start a dev server.
-
- * **Scope** : `Any file`
- * **Type** : Boolean
- * `true`: sandboxed commands can bind to localhost ports on macOS
- * `false`: sandboxed commands on macOS can’t bind to localhost ports
+Let sandboxed commands on macOS listen on network ports, for example to start a dev server, and connect to any port on localhost. A command that listens on a non-loopback address accepts connections from other machines. The key has no effect on Linux and WSL2, where each sandboxed command has its own loopback interface. To reach a server on the host from Linux or WSL2, see [A command fails to reach a server on localhost](</docs/en/sandboxing#a-command-fails-to-reach-a-server-on-localhost>).
+
+ * **Scope** : `Any file`, with [limits on project and local settings](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>)
+ * **Type** : Boolean
+ * `true`: sandboxed commands on macOS can listen on any local address and connect to any port on localhost
+ * `false`: sandboxed commands on macOS can’t listen on a port or connect directly to servers on localhost
* **Default** : `false`
settings.json
@@ -2183,7 +2197,7 @@
List additional XPC and Mach service names the macOS sandbox may look up. Tools that communicate over XPC, such as the iOS Simulator or Playwright, need their services listed here.
- * **Scope** : `Any file`
+ * **Scope** : `Any file`, with [limits on project and local settings](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>)
* **Type** : array of strings, each a service name; a single trailing `*` matches a prefix, and `"*"` alone matches every service
* **Default** : unset
@@ -2207,9 +2221,9 @@
Pre-allow domains for outbound traffic from sandboxed commands, so the sandbox doesn’t prompt for them. Wildcards such as `*.example.com` match subdomains, and an optional `:port` suffix limits an entry to one port; an entry without a port matches every port.
- * **Scope** : `Any file`. Only managed settings when `allowManagedDomainsOnly` is set.
+ * **Scope** : `Any file`, with [limits on project and local settings](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>). Only managed settings when `allowManagedDomainsOnly` is set.
* **Type** : array of strings, each a domain, wildcard pattern, or IP literal, with an optional `:port` suffix
- * **Default** : unset, so the sandbox prompts the first time a command reaches a new host
+ * **Default** : unset, so your permission mode decides [what happens to each new host](</docs/en/sandboxing#hosts-outside-your-allowed-domains>)
This pre-allows GitHub on every port, every npm subdomain, and one API host on port 443 only:
@@ -2255,7 +2269,7 @@
`sandbox.network.strictAllowlist`
-Deny sandboxed commands access to hosts outside the allowlist instead of prompting for approval. The allowlist is `allowedDomains` plus domains from `WebFetch(domain:...)` allow rules, or only the managed settings entries when `allowManagedDomainsOnly` is set. Requires Claude Code v2.1.219 or later.
+Deny sandboxed commands access to hosts outside the allowlist instead of prompting for approval. The allowlist is `allowedDomains` plus domains from `WebFetch(domain:...)` allow rules, or only the managed settings entries when `allowManagedDomainsOnly` is set. [Locks that apply without an admin-required sandbox](</docs/en/sandboxing#locks-that-apply-without-an-admin-required-sandbox>) covers a repository’s entries. Requires Claude Code v2.1.219 or later.
* **Scope** : `User or managed`. A repository can’t turn it on or off.
* **Type** : Boolean
@@ -2286,7 +2300,7 @@
* **Scope** : `Managed`
* **Type** : Boolean
* `true`: Claude Code honors only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings and blocks a non-allowed domain instead of prompting
- * `false`: domains from user, project, local, and `--settings` settings merge into the allowlist
+ * `false`: domains from other settings files can merge into the allowlist
* **Default** : `false`
This locks the allowlist to GitHub and npm and ignores any domains developers add:
@@ -2302,7 +2316,7 @@
}
}
-Denied domains still merge from every source the session loads. See [Keep developers from widening the policy](</docs/en/sandboxing#keep-developers-from-widening-the-policy>).
+While the key is `true`, the sandbox is [admin-required](</docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox>), and only managed settings can set a proxy port. Denied domains still merge from every source the session loads. See [Keep developers from widening the policy](</docs/en/sandboxing#keep-developers-from-widening-the-policy>).
###
@@ -2310,9 +2324,9 @@
`sandbox.network.httpProxyPort`
-Point the sandbox at your own HTTP proxy instead of the one Claude Code runs. Organizations do this to inspect HTTPS traffic, apply their own filtering rules, or log every request. When unset, Claude Code starts its own proxy for HTTP traffic.
-
- * **Scope** : `Any file`
+Point the sandbox at your own HTTP proxy instead of the one Claude Code runs. Organizations do this to inspect HTTPS traffic, apply their own filtering rules, or log requests. Your proxy takes over filtering, and Claude Code stops applying its domain lists and network prompts to traffic sent there. When unset, Claude Code starts its own proxy for HTTP traffic.
+
+ * **Scope** : `Any file`, unless [other sandbox settings limit which files can set a port](</docs/en/sandboxing#custom-proxy-configuration>)
* **Type** : number, a local TCP port
* **Default** : unset, so Claude Code runs its own proxy
@@ -2334,9 +2348,9 @@
`sandbox.network.socksProxyPort`
-Point the sandbox at your own SOCKS5 proxy instead of the one Claude Code runs. When unset, Claude Code starts its own proxy for SOCKS traffic.
-
- * **Scope** : `Any file`
+Point the sandbox at your own SOCKS5 proxy instead of the one Claude Code runs. Your proxy takes over filtering, and Claude Code stops applying its domain lists and network prompts to traffic sent there. When unset, Claude Code starts its own proxy for SOCKS traffic.
+
+ * **Scope** : `Any file`, unless [other sandbox settings limit which files can set a port](</docs/en/sandboxing#custom-proxy-configuration>)
* **Type** : number, a local TCP port
* **Default** : unset, so Claude Code runs its own proxy
@@ -2585,6 +2599,7 @@
* Project and local settings can’t set variables that a checked-out repository shouldn’t control; set those in your shell, user settings, or managed settings instead. Claude Code drops each one, apart from a few values that turn telemetry off, and logs a warning you can see with `claude --debug`. They include:
* Variables that choose where Claude Code stores or writes its own files: `CLAUDE_CONFIG_DIR`, `CLAUDE_CODE_TMPDIR`, and the operating-system directory variables such as `HOME`, `TMPDIR`, `TMP`, `TEMP`, and the `XDG_*` family.
+ * Windows variables that pick the programs and machine-wide configuration for the processes Claude Code starts, such as `SystemRoot`, `ComSpec`, `ProgramData`, `LOCALAPPDATA`, `PATHEXT`, `PSModulePath`, and the `ProgramFiles` family.
* Variables that export session content: [`OTEL_LOG_RAW_API_BODIES`](</docs/en/env-vars#variables>) and the detailed beta tracing pair `ENABLE_BETA_TRACING_DETAILED` and `BETA_TRACING_ENDPOINT`.
* The [OpenTelemetry exporter](</docs/en/monitoring-usage>) variables that turn telemetry on, choose where it goes, or choose what content it captures:
* `CLAUDE_CODE_ENABLE_TELEMETRY`, plus the enhanced telemetry beta pair `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA` and `ENABLE_ENHANCED_TELEMETRY_BETA`
@@ -3865,8 +3880,8 @@
When you set it to `true`, Claude Code changes which hooks and hook-like commands load:
* **Managed and SDK hooks run** : hooks from managed settings and hooks the [Agent SDK](</docs/en/agent-sdk/overview>) registers in process
- * **Force-enabled plugin hooks run** : hooks from plugins your managed settings force-enable through `enabledPlugins`. Claude Code matches on the full `plugin@marketplace` ID, so a plugin with the same name from a different marketplace stays blocked. This lets you distribute vetted hooks through an organization marketplace while blocking everything else
- * **Everything else is blocked** : user, project, and local hooks, hooks from other plugins, and hooks declared in agent frontmatter
+ * **Force-enabled plugin hooks run** : hooks from plugins your managed settings force-enable through `enabledPlugins`. Claude Code matches on the full `plugin@marketplace` ID, so a plugin with the same name from a different marketplace stays blocked. This lets you distribute vetted hooks through an organization marketplace while blocking everything else. A [mod](</docs/en/plugins/mods/overview>) in such a plugin loads only when it [counts as your organization’s](</docs/en/plugins/mods/admin#install-your-organizations-mods>)
+ * **Everything else is blocked** : user, project, and local hooks, hooks and mods from other installed plugins, and hooks declared in agent frontmatter. [Mods built into Claude Code](</docs/en/plugins/mods/overview#mods-built-into-claude-code>) keep running. To block only users’ mods, set [`allowManagedModsOnly`](</docs/en/plugins/mods/admin#set-options-on-the-built-in-guard>) instead.
* **Command-sourced plugins are disabled** : Claude Code also disables plugins with a [`command` source](</docs/en/plugins/marketplace-reference#command-plugin-source>), including plugins force-enabled in managed `enabledPlugins`, unless you set `disableCommandPluginSources` to `false` explicitly
* **Marketplace`headersHelper` commands are blocked**: Claude Code also blocks marketplace [`headersHelper` commands](</docs/en/plugins/host-marketplace#authenticate-archive-downloads>) unless `disableCommandPluginSources` is explicitly set to `false`, except for a marketplace that managed settings themselves declare. Requires Claude Code v2.1.238 or later
* **Status line and file suggestion narrow to managed settings** : Claude Code reads [`statusLine`](</docs/en/statusline>), `fileSuggestion`, and [`subagentStatusLine`](</docs/en/statusline#subagent-status-lines>) from managed settings only, following the status line and file suggestion gates
@@ -3898,7 +3913,12 @@
* **In managed settings** : Claude Code disables every configured hook, including managed ones, and keeps running the hooks the [Agent SDK](</docs/en/agent-sdk/overview>) registers in process
* **In any other settings file** : Claude Code disables user, project, local, and plugin hooks; managed hooks, Agent SDK hooks, and hooks from plugins force-enabled in managed `enabledPlugins` keep running
-Keeping Agent SDK hooks running when managed settings set this key requires Claude Code v2.1.242 or later. The [`/goal`](</docs/en/goal>) command can’t run while hooks are disabled, and the `/hooks` menu shows a notice instead of your hooks.
+The key also stops [mods](</docs/en/plugins/mods/overview>), which are plugins whose code registers hooks:
+
+ * **In managed settings** : the mods in every installed plugin stop, your organization’s included
+ * **In any other settings file** : the mods you installed stop, and [your organization’s mods](</docs/en/plugins/mods/admin#install-your-organizations-mods>) keep running
+
+Mods built into Claude Code keep running in both cases. Each has [its own switch](</docs/en/plugins/mods/overview#mods-built-into-claude-code>). Keeping Agent SDK hooks running when managed settings set this key requires Claude Code v2.1.242 or later. The [`/goal`](</docs/en/goal>) command can’t run while hooks are disabled, and the `/hooks` menu shows a notice instead of your hooks.
####
@@ -4644,7 +4664,7 @@
* **`git`** : any git URL, with `url`
* **`url`** : a direct URL to a `marketplace.json` file, with `url` and optional `headers` and `headersHelper` for authenticated access. `headersHelper` names a command that prints headers whose values are too short-lived to list in `headers`, and requires Claude Code v2.1.238 or later
* **`file`** : a local path to a `marketplace.json` file, with `path`
- * **`directory`** : a local filesystem path, with `path`, for development only
+ * **`directory`** : a local filesystem path, with `path`. Use it for development, or for a marketplace your organization [deploys to each machine](</docs/en/plugins/mods/admin#install-your-organizations-mods>).
* **`settings`** : an inline marketplace declared directly in the settings file without a hosted repository, with `name` and `plugins`
The `git` source type works with any git hosting service, including self-hosted GitLab and Bitbucket. Claude Code clones the repository with the same authentication that `git clone` would use on that machine: configured credential helpers or SSH keys. A provider token such as `GITHUB_TOKEN` takes effect through a credential helper that reads it. See [Private repositories](</docs/en/plugins/host-marketplace#grant-access-to-a-private-marketplace>) for setup details. For `github` and `git` sources, Claude Code never downloads [Git LFS](<https://git-lfs.com>) content when it clones the marketplace repository to add or update it. LFS-tracked files are checked out as pointer files, and the add or update output reports how many. The `skipLfs` field inside the `source` object is accepted and has no effect. Before v2.1.274, Claude Code downloaded LFS content unless you set `"skipLfs": true`. For a `url` source, set `headersHelper` inside the `source` object when the credential in `headers` expires and a command has to produce a fresh one. Requires Claude Code v2.1.238 or later. For what the command must print and where Claude Code runs it, see [Write the headersHelper command](</docs/en/plugins/host-marketplace#write-the-headershelper-command>), and for the cases where Claude Code doesn’t run it, see [When Claude Code skips a headersHelper command](</docs/en/plugins/host-marketplace#when-claude-code-skips-a-headershelper-command-or-drops-its-output>). Once you set `headersHelper` on an `https://` marketplace URL, Claude Code runs the command at two points, reusing one run’s output for up to 60 seconds:
@@ -4723,6 +4743,54 @@
Built-in plugins store their options under the same key with an `@builtin` suffix. For example, the [**Project instructions**](</docs/en/memory#choose-which-instruction-files-load>) setting that controls whether Claude Code reads `AGENTS.md` files is `pluginConfigs["agents-md@builtin"].options.instructionFiles`. Claude Code ignores project and local entries because it substitutes these values into plugin hook, MCP, and LSP configurations, and a cloned repository must not be able to supply them. Before v2.1.207, project and local settings were also read.
+###
+
+
+
+`prependPlugins`
+
+List the managed plugins whose [mods](</docs/en/plugins/mods/overview>) run before every mod a user installs, in the listed order. When you set this key in managed settings, name `sec-default@builtin` in the list to keep the built-in guard. In managed settings, Claude Code skips an id whose plugin doesn’t count as your organization’s. See [Install your organization’s mods and set the order](</docs/en/plugins/mods/admin#install-your-organizations-mods>) for those conditions and for how the two ordering keys work together.
+
+ * **Scope** : `User or managed`. Claude Code reads the key from managed settings. It reads the key from user settings only on a machine with no managed settings, for a user who isn’t signed in with a Team or Enterprise plan. It ignores the key in project and local settings and in a `--settings` file.
+ * **Type** : array of `plugin-name@marketplace-name` strings
+ * **Default** : unset
+
+managed-settings.json
+
+ {
+ "extraKnownMarketplaces": {
+ "acme-tools": {
+ "source": { "source": "directory", "path": "/opt/acme/claude-plugins" }
+ }
+ },
+ "enabledPlugins": { "acme-guard@acme-tools": true },
+ "prependPlugins": ["acme-guard@acme-tools", "sec-default@builtin"]
+ }
+
+###
+
+
+
+`appendPlugins`
+
+List the managed plugins whose [mods](</docs/en/plugins/mods/overview>) run after every mod a user installs, in the listed order. An id listed in both `prependPlugins` and `appendPlugins` is prepended. In managed settings, Claude Code skips an id whose plugin doesn’t [count as your organization’s](</docs/en/plugins/mods/admin#install-your-organizations-mods>).
+
+ * **Scope** : `User or managed`. Claude Code reads the key from managed settings. It reads the key from user settings only on a machine with no managed settings, for a user who isn’t signed in with a Team or Enterprise plan. It ignores the key in project and local settings and in a `--settings` file.
+ * **Type** : array of `plugin-name@marketplace-name` strings
+ * **Default** : unset
+
+managed-settings.json
+
+ {
+ "extraKnownMarketplaces": {
+ "acme-tools": {
+ "source": { "source": "directory", "path": "/opt/acme/claude-plugins" }
+ }
+ },
+ "enabledPlugins": { "acme-audit@acme-tools": true },
+ "appendPlugins": ["acme-audit@acme-tools"]
+ }
+
##
@@ -5545,7 +5613,7 @@
* `"foundry"`: [Microsoft Foundry](</docs/en/microsoft-foundry>)
* `"anthropicAws"`: [Claude Platform on AWS](</docs/en/claude-platform-on-aws>)
* `"mantle"`: the Amazon Bedrock [Mantle endpoint](</docs/en/amazon-bedrock#use-the-mantle-endpoint>). A session that [runs Mantle alongside the Invoke API](</docs/en/amazon-bedrock#run-mantle-alongside-the-invoke-api>) uses both providers, so list `"bedrock"` and `"mantle"` together for it
- * `"customEndpoint"`: the Anthropic API or a cloud provider’s API sent to another host, such as an [LLM gateway](</docs/en/llm-gateway>) named by `ANTHROPIC_BASE_URL`, a provider’s `ANTHROPIC_*_BASE_URL` variable, or an `ANTHROPIC_FOUNDRY_RESOURCE` value that isn’t a bare resource name. Claude Code admits it only for the exact value a managed `env` block pins
+ * `"customEndpoint"`: the Anthropic API or a cloud provider’s API sent to another host, such as an [LLM gateway](</docs/en/llm-gateway>) named by `ANTHROPIC_BASE_URL` or by a provider’s endpoint variable such as `ANTHROPIC_BEDROCK_BASE_URL`. Claude Code admits it only for the exact value a managed `env` block pins
* `"gateway"`: a [Cloud gateway](</docs/en/claude-apps-gateway>) sign-in
* **Default** : unset, so any provider can be used
@@ -5608,7 +5676,7 @@
`awsAuthRefresh`
-Run your own command, such as `aws sso login`, to refresh the credentials in your `.aws` directory when the ones Claude Code has for [Amazon Bedrock](</docs/en/amazon-bedrock>) stop working. Claude Code checks the current credentials against STS first and runs the command only when that check fails, then reads the refreshed `.aws` directory.
+Run your own command, such as `aws sso login`, to refresh the credentials in your `.aws` directory when the ones Claude Code has for [Amazon Bedrock](</docs/en/amazon-bedrock>) stop working. Claude Code checks the current credentials against STS first and runs the command only when that check fails, then reads the refreshed `.aws` directory. When the check fails at the same time in several Claude Code processes that use the same command and credentials, such as separate terminals or IDE windows, one process runs the command and the rest wait for that run instead of starting their own. A process that has waited 60 seconds with a request pending runs the command itself. To turn this off, set [`CLAUDE_CODE_DISABLE_AUTH_REFRESH_LOCK`](</docs/en/env-vars>) to `1`.
* **Scope** : `Any file`
* **Type** : string, a shell command line
@@ -5733,7 +5801,7 @@
`gcpAuthRefresh`
-Run your own command to refresh Google Cloud Application Default Credentials when Claude Code finds they’ve expired or can’t be loaded, so [Google Cloud’s Agent Platform](</docs/en/google-vertex-ai>) requests keep working without you re-authenticating by hand.
+Run your own command to refresh Google Cloud Application Default Credentials when Claude Code finds they’ve expired or can’t be loaded, so [Google Cloud’s Agent Platform](</docs/en/google-vertex-ai>) requests keep working without you re-authenticating by hand. When several Claude Code processes that use the same command and credentials, such as separate terminals or IDE windows, find them expired at the same time, one process runs the command and the rest wait for that run instead of starting their own. A process that has waited 60 seconds with a request pending runs the command itself. To turn this off, set [`CLAUDE_CODE_DISABLE_AUTH_REFRESH_LOCK`](</docs/en/env-vars>) to `1`.
* **Scope** : `Any file`
* **Type** : string, a shell command line
@@ -6366,12 +6434,12 @@
`claudeInChromeDefaultEnabled`
-Start every interactive CLI session with [Chrome integration](</docs/en/chrome>) on, without passing `--chrome` each time. If you run [`claude remote-control`](</docs/en/remote-control>), a session it starts for one of your [project](</docs/en/claude-projects>) threads follows this key too, except in `bypassPermissions` mode. Running `/chrome` and selecting **Enabled by default** sets this key for you, as described in [Enable Chrome by default](</docs/en/chrome#enable-chrome-by-default>). Appears in `/config` as **Claude in Chrome enabled by default**.
+Start every interactive CLI session with [Chrome integration](</docs/en/chrome>) on, without passing `--chrome` each time. If you run [`claude remote-control`](</docs/en/remote-control>), a session it starts for one of your [project](</docs/en/claude-projects>) threads follows this key too, except in `bypassPermissions` mode. With Claude Code v2.1.287 or later, this key also applies to sessions in the [VS Code extension](</docs/en/vs-code#automate-browser-tasks-with-chrome>): see [Enable Chrome by default](</docs/en/chrome#enable-chrome-by-default>). Running `/chrome` and selecting **Enabled by default** sets this key for you. Appears in `/config` as **Claude in Chrome enabled by default**.
* **Scope** : `Global config`
* **Type** : Boolean
- * `true`: Claude Code turns on Chrome integration when an interactive CLI session starts, as it does when you pass `--chrome`
- * `false`: interactive CLI sessions start with Chrome integration off, and Claude Code stops [offering to set it up](</docs/en/chrome#install-the-extension-when-claude-asks>). Pass `--chrome` to turn it on for one interactive session
+ * `true`: Claude Code turns on Chrome integration when an interactive CLI session starts, as it does when you pass `--chrome`. In the VS Code extension, sessions connect to the browser as they start
+ * `false`: interactive CLI sessions start with Chrome integration off, and Claude Code stops [offering to set it up](</docs/en/chrome#install-the-extension-when-claude-asks>). Pass `--chrome` to turn it on for one interactive session. In the VS Code extension, a session connects when you type `@browser`, as when the key is unset
* **Default** : unset, so Chrome integration is off and Claude Code can still offer to set it up
* **Per-session overrides** : `--chrome` and [`--no-chrome`](</docs/en/cli-reference>) take precedence over this key for one interactive session
--- a/setup.md
+++ b/setup.md
@@ -89,7 +89,7 @@
WSL 2| WSL 2 enabled| Supported| Linux toolchains or sandboxed command execution
WSL 1| WSL 1 enabled| Not supported| If WSL 2 is unavailable
-**Option 1: Native Windows** Run the install command from PowerShell or CMD. You do not need to run as Administrator. Installing [Git for Windows](<https://git-scm.com/downloads/win>) is optional. It enables the [Bash tool](</docs/en/tools-reference#bash-tool-behavior>) by providing Git Bash. Whether you install from PowerShell or CMD only affects which install command you run. Your prompt shows `PS C:\Users\YourName>` in PowerShell and `C:\Users\YourName>` without the `PS` in CMD. If you’re new to the terminal, the [terminal guide](</docs/en/terminal-guide#windows>) walks through each step. After installation, launch `claude` from any terminal.
+**Option 1: Native Windows** Run the install command from PowerShell or CMD. You do not need to run as Administrator. Installing [Git for Windows](<https://git-scm.com/downloads/win>) is optional. It provides Git Bash, which the [Bash tool](</docs/en/tools-reference#bash-tool-behavior>) and the [Monitor tool](</docs/en/tools-reference#monitor-tool>) need. Whether you install from PowerShell or CMD only affects which install command you run. Your prompt shows `PS C:\Users\YourName>` in PowerShell and `C:\Users\YourName>` without the `PS` in CMD. If you’re new to the terminal, the [terminal guide](</docs/en/terminal-guide#windows>) walks through each step. After installation, launch `claude` from any terminal.
* **Without Git for Windows** , Claude Code runs shell commands via the [PowerShell tool](</docs/en/tools-reference#powershell-tool>).
* **With Git for Windows** , Claude Code uses Git Bash for the [Bash tool](</docs/en/tools-reference#bash-tool-behavior>). If Claude Code can’t find Git Bash, set the path in your [settings.json file](</docs/en/settings>):
@@ -234,7 +234,7 @@
Advanced installation options
-These options are for version pinning, Linux package managers, npm, and verifying binary integrity.
+These options are for version pinning, Linux package managers, npm, network storage, and verifying binary integrity.
###
@@ -366,13 +366,28 @@
Install with npm
-You can also install Claude Code as a global npm package. As of v2.1.198, the npm package requires [Node.js 22 or later](<https://nodejs.org/en/download>). On an older Node.js version, npm prints an `EBADENGINE` warning during install rather than failing; the install completes and `claude` still runs, since the package downloads a native binary that doesn’t use your Node.js at runtime.
+You can also install Claude Code as a global npm package. The npm package requires [Node.js 22 or later](<https://nodejs.org/en/download>). On an older Node.js version, npm prints an `EBADENGINE` warning during install rather than failing; the install completes and `claude` still runs, since the package downloads a native binary that doesn’t use your Node.js at runtime.
npm install -g @anthropic-ai/claude-code
The npm package installs the same native binary as the standalone installer. npm pulls the binary in through a per-platform optional dependency such as `@anthropic-ai/claude-code-darwin-arm64`, and a postinstall step links it into place. The installed `claude` binary does not itself invoke Node. Supported npm install platforms are `darwin-arm64`, `darwin-x64`, `linux-x64`, `linux-arm64`, `linux-x64-musl`, `linux-arm64-musl`, `win32-x64`, and `win32-arm64`. Your package manager must allow optional dependencies. See [troubleshooting](</docs/en/troubleshoot-install#native-binary-not-found-after-npm-install>) if the binary is missing after install. To upgrade an npm installation, run `npm install -g @anthropic-ai/claude-code@latest`. Avoid `npm update -g`, which respects the semver range from the original install and may not move you to the newest release.
Do NOT use `sudo npm install -g` as this can lead to permission issues and security risks. If you encounter permission errors, see [troubleshooting permission errors](</docs/en/troubleshoot-install#permission-errors-during-installation>).
+
+###
+
+
+
+Install on network storage
+
+A running session reads parts of the Claude Code executable from disk as it works, not only at startup. If the file becomes unreadable mid-session, for example because it was truncated or deleted on network storage, the session crashes. On Linux, your shell reports this as a `Bus error`. When home directories live on network storage, such as an NFS home mounted on several machines, lay out installs so that each session’s executable stays readable until the session ends:
+
+ * **Install on local disk** : put the binary on each machine’s local filesystem, for example with a Linux package manager or your own deployment tooling. A per-user npm prefix and the native installer’s default `~/.local/share/claude/versions/` directory both sit in the home directory.
+ * **Keep each version in its own directory** : upgrading an npm installation in place with `npm install -g` deletes the previous binary. On storage that several machines share, that removes the file that sessions on the other machines are still running. Install each new version next to the old ones and move users to it.
+ * **Delete an old version only when no machine can still be running it** : a machine can’t see processes running on other machines, so checking for running processes before you delete isn’t enough.
+ * **Turn off Claude Code’s own updates** : set [`DISABLE_UPDATES`](</docs/en/env-vars>) and install new versions with your own tooling. Otherwise an auto-update of an npm installation on one machine runs the same in-place upgrade and removes the binary that sessions on other machines are running. Setting `DISABLE_AUTOUPDATER` alone isn’t enough, because users can still run `claude update` and `claude install`. See Disable auto-updates.
+
+The native installer deletes old versions from `~/.local/share/claude/versions/` on its own, which matters when that directory is on shared storage. Besides the version the launcher points to and any version a session on the same machine is running, it keeps the two newest versions and deletes the rest. A session on another machine that is running a deleted version loses its binary. With a custom launcher, Claude Code keeps every installed version and leaves cleanup to you.
###
--- a/skills.md
+++ b/skills.md
@@ -240,7 +240,7 @@
asyncio.run(main())
-A `compact_boundary` message only arrives when compaction ran. With nothing to summarize, `/compact` reports the reason instead of raising. The run still ends with a `success` result and no `compact_boundary` message, and the result text carries the reason, for example `Not enough messages to compact.` after a single short exchange. A fresh one-shot `query()` call starts with empty context, so use this pattern in a session with prior turns, for example in [streaming input mode](</docs/en/agent-sdk/streaming-vs-single-mode>) or when resuming a session.
+A `compact_boundary` message only arrives when compaction ran. When a continued session has messages but nothing `/compact` can summarize, the run still ends with a `success` result rather than an error, and no `compact_boundary` message arrives. The result text then carries the reason, for example `Not enough messages to compact.` when the session holds a prompt but no reply from Claude yet. A fresh one-shot `query()` call starts with empty context, so use this pattern in a session with prior turns, for example in [streaming input mode](</docs/en/agent-sdk/streaming-vs-single-mode>) or when resuming a session.
###
@@ -339,7 +339,7 @@
Pre-approve tools for skills
-For project and personal skills, Claude Code applies the [`allowed-tools`](</docs/en/skills#pre-approve-tools-for-a-skill>) frontmatter field in SDK sessions. You can also pre-approve tools for these skills through the `allowedTools` option (`allowed_tools` in Python) in your query configuration. Skills [synced from claude.ai](</docs/en/skills#how-claude-code-handles-the-frontmatter-of-a-synced-skill>) follow their own frontmatter rules.
+In SDK sessions, you can pre-approve tools for a project or personal skill with the skill’s [`allowed-tools`](</docs/en/skills#pre-approve-tools-for-a-skill>) frontmatter or with the `allowedTools` option (`allowed_tools` in Python) in your query configuration. If your organization sets [`allowManagedPermissionRulesOnly`](</docs/en/settings-reference#allowmanagedpermissionrulesonly>) in managed settings, Claude Code ignores both. Skills [synced from claude.ai](</docs/en/skills#how-claude-code-handles-the-frontmatter-of-a-synced-skill>) follow their own frontmatter rules.
Skills run with the session’s tools. The example below pre-approves `Read`, `Grep`, and `Glob` with `allowedTools` (`allowed_tools` in Python), so Claude can inspect files while running the security-check skill without stopping for approval:
--- a/statusline.md
+++ b/statusline.md
@@ -176,7 +176,8 @@
`thinking.enabled`| Whether extended thinking is enabled for the session
`rate_limits.five_hour.used_percentage`, `rate_limits.seven_day.used_percentage`| Percentage of the 5-hour or 7-day rate limit consumed, from 0 to 100
`rate_limits.five_hour.resets_at`, `rate_limits.seven_day.resets_at`| Unix epoch seconds when the 5-hour or 7-day rate limit window resets
-`rate_limits.spend_limit.used_percentage`, `rate_limits.spend_limit.resets_at`| Behind a [Claude apps gateway](</docs/en/claude-apps-gateway-spend-limits#usage-warnings-in-claude-code>), the percentage used of the spend limit that applies to you, and the Unix epoch seconds when its period resets. The percentage runs from 0 to 100, or above 100 once you exceed the limit. Requires Claude Code v2.1.251 or later
+`rate_limits.spend_limit.used_percentage`, `rate_limits.spend_limit.resets_at`| Behind a Claude apps gateway, how much of your spend limit you have used and when its period resets. See spend limit fields. Requires Claude Code v2.1.251 or later
+`rate_limits.spend_limit.used_usd`, `rate_limits.spend_limit.limit_usd`, `rate_limits.spend_limit.period`| Your estimated spend and your limit in US dollars, and the limit’s period. These fields can be absent. See spend limit fields. Requires v2.1.284 or later on both Claude Code and the gateway
`prompt_cache`| The session’s [prompt cache](</docs/en/prompt-caching>) statistics for the main conversation: hit ratio, misses, and whether the cache is warm. See prompt cache fields for every field. Absent until the main conversation’s first API response. Requires Claude Code v2.1.251 or later
`session_id`| Unique session identifier
`session_name`| Session name. Uses the custom name set with the `--name` flag or `/rename` when one exists, otherwise the AI-generated session title. The [default display name](</docs/en/sessions#name-your-sessions>), such as `my-app-3f`, doesn’t populate this field. Absent when the session has neither a custom name nor an AI-generated title
@@ -285,7 +286,10 @@
},
"spend_limit": {
"used_percentage": 62.8,
- "resets_at": 1740787200
+ "resets_at": 1740787200,
+ "used_usd": 314.12,
+ "limit_usd": 500,
+ "period": "monthly"
}
},
"vim": {
@@ -353,6 +357,19 @@
+Spend limit fields
+
+Behind a [Claude apps gateway with spend limits](</docs/en/claude-apps-gateway-spend-limits#usage-warnings-in-claude-code>), the `rate_limits.spend_limit` object describes the spend limit that applies to you. It appears after the session’s first API response and requires Claude Code v2.1.251 or later. Your script receives its fields on separate schedules:
+
+ * `used_percentage` and `resets_at`: come with every response, so they are present whenever `spend_limit` is. `used_percentage` runs from 0 to 100, or above 100 once you exceed the limit, and `resets_at` is the Unix epoch seconds when the limit’s period resets.
+ * `used_usd`, `limit_usd`, and `period`: your estimated spend so far and your limit in US dollars, and the period the limit covers, one of `daily`, `weekly`, or `monthly`. The gateway [computes `used_usd` from token counts](</docs/en/claude-apps-gateway-spend-limits#how-requests-are-priced>), so it’s an estimate and not a billed amount. Claude Code reads them from the gateway in a separate request, about every five minutes while you send requests. The dollar amounts can be about five minutes older than `used_percentage`, so the two may briefly disagree. Requires v2.1.284 or later on both Claude Code and the gateway.
+
+Treat `used_usd`, `limit_usd`, and `period` as optional even when `spend_limit` is present. Your script receives the percentage before them, and they stay absent if you set `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`, which turns that request off. Read each with a fallback in your script, such as `jq -r '.rate_limits.spend_limit.used_usd // empty'`.
+
+###
+
+
+
Prompt cache fields
The `prompt_cache` object summarizes how the session’s main conversation is using the [prompt cache](</docs/en/prompt-caching>). Claude Code computes it from the cache token counts in the API’s responses, so it works on every provider. The object appears after the main conversation’s first API response. Claude Code doesn’t count subagent requests in these statistics. Requires Claude Code v2.1.251 or later. The table lists each field with its meaning. Timestamps are Unix epoch seconds, the same unit as `rate_limits.*.resets_at`. A short status line usually shows one or two of these; `warm` and `hit_ratio` summarize the cache state most directly.
@@ -804,7 +821,7 @@
Rate limit usage
-Display claude.ai subscription rate limit usage in the status line. The `rate_limits` object contains a rolling `five_hour` window and a weekly `seven_day` window. Each window provides `used_percentage`, from 0 to 100, and `resets_at`, the Unix epoch seconds when the window resets. Behind a Claude apps gateway with spend limits, `rate_limits` carries `spend_limit` with the same two fields for the spend limit that applies to you, except that its `used_percentage` can go above 100 once you exceed the limit. Requires Claude Code v2.1.251 or later. The `rate_limits` object is only present for claude.ai Pro and Max subscribers, or behind a Claude apps gateway with spend limits, and only after the first API response. Each script handles the absent field gracefully:
+Display claude.ai subscription rate limit usage, or your spend against a Claude apps gateway spend limit, in the status line. For subscribers, the `rate_limits` object contains a rolling `five_hour` window and a weekly `seven_day` window. Each window provides `used_percentage`, from 0 to 100, and `resets_at`, the Unix epoch seconds when the window resets. Behind a gateway, read the `spend_limit` object, described under spend limit fields. The `rate_limits` object is only present for claude.ai Pro and Max subscribers, or behind a Claude apps gateway with spend limits, and only after the first API response. Each script handles the absent fields gracefully, and behind a gateway prints `spend: $314.12 / $500`, or `spend: 63%` while the dollar fields are absent:
Bash
@@ -824,6 +841,11 @@
[ -n "$FIVE_H" ] && LIMITS="5h: $(printf '%.0f' "$FIVE_H")%"
[ -n "$WEEK" ] && LIMITS="${LIMITS:+$LIMITS }7d: $(printf '%.0f' "$WEEK")%"
+ # Behind a Claude apps gateway: dollars when the gateway reports them, else the percentage
+ SPEND_PCT=$(echo "$input" | jq -r '.rate_limits.spend_limit.used_percentage // empty')
+ SPEND_USD=$(echo "$input" | jq -r '.rate_limits.spend_limit | select(.used_usd != null) | "$\(.used_usd) / $\(.limit_usd)"')
+ [ -n "$SPEND_PCT" ] && LIMITS="${LIMITS:+$LIMITS }spend: ${SPEND_USD:-$(printf '%.0f' "$SPEND_PCT")%}"
+
[ -n "$LIMITS" ] && echo "[$MODEL] | $LIMITS" || echo "[$MODEL]"
#!/usr/bin/env python3
@@ -841,6 +863,14 @@
parts.append(f"5h: {five_h:.0f}%")
if week is not None:
parts.append(f"7d: {week:.0f}%")
+
+ # Behind a Claude apps gateway: dollars when the gateway reports them, else the percentage
+ spend = rate.get('spend_limit', {})
+ if spend.get('used_percentage') is not None:
+ if spend.get('used_usd') is not None:
+ parts.append(f"spend: ${spend['used_usd']} / ${spend['limit_usd']}")
+ else:
+ parts.append(f"spend: {spend['used_percentage']:.0f}%")
if parts:
print(f"[{model}] | {' '.join(parts)}")
@@ -860,6 +890,14 @@
if (fiveH != null) parts.push(`5h: ${Math.round(fiveH)}%`);
if (week != null) parts.push(`7d: ${Math.round(week)}%`);
+
+ // Behind a Claude apps gateway: dollars when the gateway reports them, else the percentage
+ const spend = data.rate_limits?.spend_limit;
+ if (spend?.used_percentage != null) {
+ parts.push(spend.used_usd != null
+ ? `spend: $${spend.used_usd} / $${spend.limit_usd}`
+ : `spend: ${Math.round(spend.used_percentage)}%`);
+ }
console.log(parts.length ? `[${model}] | ${parts.join(' ')}` : `[${model}]`);
});
--- a/streaming-vs-single-mode.md
+++ b/streaming-vs-single-mode.md
@@ -158,7 +158,7 @@
asyncio.run(streaming_analysis())
-When you run the example, the TypeScript version prints each response as it completes. The Python version’s `receive_response()` loop ends at the first result message, so it prints the security analysis; to read both responses, use one `query()` and `receive_response()` pair per message as shown in the [Python reference’s example of continuing a conversation](</docs/en/agent-sdk/python#example-continuing-a-conversation>).
+When you run the example, the TypeScript version prints each response as it completes. The Python version’s `receive_response()` loop ends at the first result message, so it prints the security analysis; to read both responses, use one `query()` and `receive_response()` pair per message as shown in the [Python reference’s example of continuing a conversation](</docs/en/agent-sdk/python#example-continuing-a-conversation>). If an image block’s `source` is missing or isn’t an object, the SDK doesn’t report an error. Claude Code sends Claude a text note in place of the image, such as `[Image could not be processed: image block has no source object]`, and the session continues.
In the TypeScript SDK, if your message generator throws, for example when a file it reads is missing, the stream ends with an error that reads `Claude Code process aborted by user` instead of the original error, so check the code inside your generator first when you see that message. The error may also be preceded by a long minified line of bundled SDK source, so read to the end of the output for the error text.In the Python SDK, a generator exception is logged at debug level and the session stalls without raising, so if a streaming session hangs with no output, enable debug logging and check your generator.
Show diff (129 lines)
--- a/sub-agents.md
+++ b/sub-agents.md
@@ -30,11 +30,13 @@
A fast, read-only agent optimized for searching and analyzing codebases.
- * **Model** : inherits from the main conversation, capped at Opus on the Claude API, so Explore never runs on a more expensive model than the one you already chose for the session, unless you set `CLAUDE_CODE_SUBAGENT_MODEL` and force it onto every subagent
+ * **Model** : the main conversation’s model. When the main conversation runs Fable, Explore’s model depends on how you connect:
+ * With a Claude subscription, an Anthropic Console account, or an [LLM gateway](</docs/en/llm-gateway>) reached through `ANTHROPIC_BASE_URL`, Explore runs on the Opus model that the [`opus` alias](</docs/en/model-config#model-aliases>) resolves to.
+ * On Amazon Bedrock, Google Cloud’s Agent Platform, Microsoft Foundry, [Claude Platform on AWS](</docs/en/claude-platform-on-aws>), or a [Claude apps gateway](</docs/en/claude-apps-gateway>), Explore stays on the main conversation’s model.
* **Tools** : read-only tools; Write and Edit are denied
* **Purpose** : file discovery, code search, codebase exploration
-As of v2.1.198, Explore inherits the main conversation’s model instead of always running on Haiku. On the Claude API, the inherited model is capped at Opus: a main conversation on a higher tier runs Explore on Opus, and a main conversation on Sonnet or Haiku runs Explore on that same model. On any other provider, such as [Amazon Bedrock, Google Cloud’s Agent Platform, Microsoft Foundry, or Claude Platform on AWS](</docs/en/third-party-integrations>), Explore inherits the main conversation’s model directly.A user or project subagent named `Explore` overrides the built-in and keeps its own `model` field, so define one with `model: haiku` to keep exploration on a lower-cost model.Claude delegates to Explore when it needs to search or understand a codebase without making changes. This keeps exploration results out of your main conversation context.When invoking Explore, Claude specifies a thoroughness level: **quick** for targeted lookups, **medium** for balanced exploration, or **very thorough** for comprehensive analysis.
+A user or project subagent named `Explore` overrides the built-in and keeps its own `model` field, so define one with `model: haiku` to run exploration on a lower-cost model. To force one model onto every subagent, Explore included, see Run every subagent on one model.Claude delegates to Explore when it needs to search or understand a codebase without making changes. This keeps exploration results out of your main conversation context.When invoking Explore, Claude specifies a thoroughness level: **quick** for targeted lookups, **medium** for balanced exploration, or **very thorough** for comprehensive analysis.
A research agent used during [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) to gather context before presenting a plan.
@@ -75,7 +77,7 @@
Quickstart: create your first subagent
-Subagents are Markdown files with YAML frontmatter. To create one, ask Claude to write it for you, or write the file yourself. As of v2.1.198, the `/agents` command no longer opens the interactive creation wizard; running it prints a reminder to ask Claude or edit `.claude/agents/` directly. Subagent files, frontmatter fields, and the `.claude/agents/` and `~/.claude/agents/` locations are unchanged; only the terminal wizard is removed. This walkthrough creates a user-level subagent that reviews code and suggests improvements.
+Subagents are Markdown files with YAML frontmatter. To create one, ask Claude to write it for you, or write the file yourself. This walkthrough creates a user-level subagent that reviews code and suggests improvements.
1
@@ -120,7 +122,7 @@
You now have a subagent you can use in any project on your machine to analyze codebases and suggest improvements. You can also write subagent files by hand, define them via CLI flags, or distribute them through plugins. The following sections cover all configuration options.
-On Claude Code v2.1.197 and earlier, `/agents` opens an interactive wizard with a **Running** tab that lists live subagents and a **Library** tab for creating, editing, and deleting them.
+Running `/agents` prints a reminder to ask Claude or edit `.claude/agents/` and `~/.claude/agents/` directly. On Claude Code v2.1.197 and earlier, `/agents` opens an interactive wizard with a **Running** tab that lists live subagents and a **Library** tab for creating, editing, and deleting them.
##
@@ -188,7 +190,7 @@
For what Claude Code does with a value it can’t load, and the flags and environment variable that skip that check, see [`Invalid --agents configuration`](</docs/en/errors#invalid-agents-configuration>). **Managed subagents** are deployed by organization administrators. Place markdown files in `.claude/agents/` inside the [managed settings directory](</docs/en/managed-settings#delivery-mechanisms>), using the same frontmatter format as project and user subagents. Managed definitions take precedence over project and user subagents with the same name. **Plugin subagents** come from [plugins](</docs/en/plugins/overview>) you’ve installed. They load automatically alongside your custom subagents and appear in the @-mention typeahead under their scoped name. See the [plugin components reference](</docs/en/plugins/components#agents>) for details on creating plugin subagents.
-For security reasons, plugin subagents don’t support the `hooks`, `mcpServers`, or `permissionMode` frontmatter fields. These fields are ignored when loading agents from a plugin. If you need them, copy the agent file into `.claude/agents/` or `~/.claude/agents/`. You can also add rules to [`permissions.allow`](</docs/en/settings-reference#permissions-allow>) in `settings.json` or `settings.local.json`, but these rules apply to the entire session, not only the plugin subagent.
+For security reasons, plugin subagents don’t support the `hooks`, `mcpServers`, or `permissionMode` frontmatter fields. These fields are ignored when loading agents from a plugin. If you need them, copy the agent file into `.claude/agents/` or `~/.claude/agents/`. You can also add rules to [`permissions.allow`](</docs/en/settings-reference#permissions-allow>) in `settings.json` or `settings.local.json`, but these rules apply to the entire session, not only the plugin subagent.If you’re the plugin’s author, ship the hooks in the plugin’s [`hooks/hooks.json`](</docs/en/plugins/components#hooks>) and the MCP servers in its [`.mcp.json`](</docs/en/plugins/components#mcp-servers>) instead. They apply whenever the plugin is enabled rather than only inside the subagent.
Subagent definitions from any of these scopes are also available to [agent teams](</docs/en/agent-teams#use-subagent-definitions-for-teammates>): when spawning a teammate, you can reference a subagent type, and Claude Code applies parts of that definition to the teammate. See [agent teams](</docs/en/agent-teams#use-subagent-definitions-for-teammates>) for which parts apply in each display mode.
@@ -323,7 +325,7 @@
`CLAUDE_CODE_SUBAGENT_MODEL` is a default, so a subagent’s definition or a model Claude passes still takes precedence over it. To apply one model to every subagent, [teammate](</docs/en/agent-teams#specify-teammates-and-models>), and [workflow agent](</docs/en/workflows>), also set `CLAUDE_CODE_SUBAGENT_MODEL_FORCE` to `1`. Requires Claude Code v2.1.257 or later.
* If you set both variables, subagents run on the model in `CLAUDE_CODE_SUBAGENT_MODEL`.
- * If you set only `CLAUDE_CODE_SUBAGENT_MODEL_FORCE`, subagents run on the main conversation’s model.
+ * If you set only `CLAUDE_CODE_SUBAGENT_MODEL_FORCE`, subagents run on the main conversation’s model, except that the built-in Explore subagent runs on the model listed for it under Built-in subagents.
For example, to run every subagent on Haiku, set both variables in the `env` block of a [settings file](</docs/en/settings>):
@@ -334,12 +336,10 @@
}
}
-To check that the setting took effect, run [`/tasks`](</docs/en/commands>) while a subagent is running. The subagent’s row shows the model it runs on. While `CLAUDE_CODE_SUBAGENT_MODEL_FORCE` is [on](</docs/en/env-vars>), Claude Code ignores the `model` field of every subagent definition, including the built-in Explore and Plan subagents, and Claude can’t pass a model when it starts a subagent. Two kinds of subagent still run on the main conversation’s model:
+To check that the setting took effect, run [`/tasks`](</docs/en/commands>) while a subagent is running. The subagent’s row shows the model it runs on. While `CLAUDE_CODE_SUBAGENT_MODEL_FORCE` is [on](</docs/en/env-vars>), Claude Code ignores the `model` field in subagent definitions, and Claude can’t pass a model when it starts a subagent. These subagents still run on the main conversation’s model:
* A fork
* A [skill that runs in a subagent](</docs/en/skills#run-skills-in-a-subagent>) with `model: inherit`
-
-When you set only `CLAUDE_CODE_SUBAGENT_MODEL_FORCE`, the built-in Explore subagent keeps its model cap.
###
@@ -446,7 +446,21 @@
Use the Playwright tools to navigate, screenshot, and interact with pages.
-Inline definitions use the same schema as `.mcp.json` server entries, keyed by the server name, and support the `stdio`, `http`, `sse`, and `ws` types. To keep an MCP server out of the main conversation entirely and avoid its tool descriptions consuming context there, define it inline here rather than in `.mcp.json`. The subagent gets the tools; the parent conversation doesn’t. Claude Code loads an inline server from an agent file in your project’s `.claude/agents/` directory, or in an `--add-dir` directory’s `.claude/agents/`, only after you [trust the folder the agent file came from](</docs/en/permissions#what-runs-before-you-trust-a-folder>). Before v2.1.238, Claude Code loaded these servers without checking trust.
+Inline definitions use the same schema as `.mcp.json` server entries, keyed by the server name, and support the `stdio`, `http`, `sse`, and `ws` types. To keep an MCP server out of the main conversation entirely and avoid its tool descriptions consuming context there, define it inline here rather than in `.mcp.json`. The subagent gets the tools; the parent conversation doesn’t. The MCP restrictions that apply to the main session also cover servers declared in subagent frontmatter:
+
+ * [`--strict-mcp-config`](</docs/en/cli-reference>) and [`--bare`](</docs/en/cli-reference>)
+ * [Enterprise managed MCP configuration](</docs/en/managed-mcp>)
+ * [`allowedMcpServers` and `deniedMcpServers` policies](</docs/en/managed-mcp#policy-based-control-with-allowlists-and-denylists>)
+
+When one of these blocks a server, Claude Code skips it and shows a warning naming the blocked servers. Managed-settings restrictions apply to every subagent regardless of how it is defined. `--strict-mcp-config` doesn’t filter servers you pass inline via `--agents` or the SDK `agents` option, since those are explicit caller input.
+
+####
+
+
+
+Trust required for inline MCP servers
+
+Claude Code loads an inline MCP server from an agent file in your project’s `.claude/agents/` directory, or in an `--add-dir` directory’s `.claude/agents/`, only after you [trust the folder the agent file came from](</docs/en/permissions#what-runs-before-you-trust-a-folder>). Before v2.1.238, Claude Code loaded these servers without checking trust.
* **Trust that doesn’t count** : a parent folder’s trust, and the automatic trust a `-p` or SDK session gets for [hooks in settings files](</docs/en/permissions#what-runs-before-you-trust-a-folder>)
* **Until then** : Claude Code skips every inline server in that agent file and writes the exact `projects["<path>"].hasTrustDialogAccepted` key for `~/.claude.json` to the debug log
@@ -456,14 +470,6 @@
* A name that references a server you already configured
* An inline server in an agent file from `~/.claude/agents/`, in one you pass with `--agents` or the SDK `agents` option, or in one that managed settings supplies
-
-The MCP restrictions that apply to the main session also cover servers declared in subagent frontmatter:
-
- * [`--strict-mcp-config`](</docs/en/cli-reference>) and [`--bare`](</docs/en/cli-reference>)
- * [Enterprise managed MCP configuration](</docs/en/managed-mcp>)
- * [`allowedMcpServers` and `deniedMcpServers` policies](</docs/en/managed-mcp#policy-based-control-with-allowlists-and-denylists>)
-
-When one of these blocks a server, Claude Code skips it and shows a warning naming the blocked servers. Managed-settings restrictions apply to every subagent regardless of how it is defined. `--strict-mcp-config` doesn’t filter servers you pass inline via `--agents` or the SDK `agents` option, since those are explicit caller input.
####
@@ -967,7 +973,7 @@
Continue that code review and now analyze the authorization logic
[Claude resumes the subagent with full context from previous conversation]
-When Claude sends a completed subagent a message with the `SendMessage` tool, the subagent resumes in the background without a new `Agent` invocation. The same applies to a subagent that Claude stopped with the `TaskStop` tool, once its stopped run has exited. The resumed run keeps the tool set from where the subagent first ran and can keep reading the [prompt cache the original run warmed](</docs/en/prompt-caching#subagents-and-the-cache>). A subagent that has the `SendMessage` tool can send that message too. In an interactive session, the resumed agent then reports back to the subagent that resumed it, not to your main conversation. That subagent waits for the result before finishing its own work. When a subagent messages an agent it reports to, such as its own launcher, Claude Code resumes that agent without redirecting its results. A subagent you stopped yourself, with `x` in `/tasks` or an SDK `stop_task` request, doesn’t auto-resume. If Claude sends it a message, the message is refused and Claude is told the agent was cancelled. While that subagent’s row is still in the subagent panel, type into its transcript to resume it yourself. After that, a message from Claude can auto-resume it again. Resuming starts a new run of the agent under the same ID, so a subagent that had already failed or completed shows as running again in the task list and in the Agent SDK’s task events. Before v2.1.205, it kept showing its earlier failed or completed status while the resumed run was working. As of v2.1.199, `SendMessage` checks that a name still refers to the same agent it reached earlier in the conversation. If a newer agent has taken the name, such as a re-spawned background agent that reused it, Claude Code refuses the send rather than delivering it to the wrong agent, and the error reports which agent the name now reaches so Claude can retarget. To reach the earlier agent while it’s still running, Claude addresses it by the agent ID it received when it spawned that agent. The check is scoped to the current conversation and resets on `/clear`. As of v2.1.198, a subagent treats messages from the agent that launched it as normal task direction, including mid-task course corrections, and acts on them within its own permission settings. Two limits still hold regardless of who sent the message: no message from any agent counts as your approval for a pending permission prompt, and no agent message can change a subagent’s permission settings, `CLAUDE.md`, or configuration. Only the permission system or your own messages can grant approval. You can also ask Claude for the agent ID if you want to reference it explicitly, or find IDs in the transcript files at `~/.claude/projects/{project}/{sessionId}/subagents/`. Each transcript is stored as `agent-{agentId}.jsonl`. Subagent transcripts persist independently of the main conversation:
+When Claude sends a completed subagent a message with the `SendMessage` tool, the subagent resumes in the background without a new `Agent` invocation. The same applies to a subagent that Claude stopped with the `TaskStop` tool, once its stopped run has exited. The resumed run keeps the tool set from where the subagent first ran and can keep reading the [prompt cache the original run warmed](</docs/en/prompt-caching#subagents-and-the-cache>). A subagent that has the `SendMessage` tool can send that message too. In an interactive session, the resumed agent then reports back to the subagent that resumed it, not to your main conversation. That subagent waits for the result before finishing its own work. When a subagent messages an agent it reports to, such as its own launcher, Claude Code resumes that agent without redirecting its results. A subagent you stopped yourself, with `x` in `/tasks` or an SDK `stop_task` request, doesn’t auto-resume. If Claude sends it a message, the message is refused and Claude is told the agent was cancelled. While that subagent’s row is still in the subagent panel, type into its transcript to resume it yourself. After that, a message from Claude can auto-resume it again. Resuming starts a new run of the agent under the same ID, so a subagent that had already failed or completed shows as running again in the task list and in the Agent SDK’s task events. Before v2.1.205, it kept showing its earlier failed or completed status while the resumed run was working. As of v2.1.199, `SendMessage` checks that a name still refers to the same agent it reached earlier in the conversation. If a newer agent has taken the name, such as a re-spawned background agent that reused it, Claude Code refuses the send rather than delivering it to the wrong agent, and the error reports which agent the name now reaches so Claude can retarget. To reach the earlier agent while it’s still running, Claude addresses it by the agent ID it received when it spawned that agent. The check is scoped to the current conversation and resets on `/clear`. A subagent treats messages from the agent that launched it as normal task direction, including mid-task course corrections, and acts on them within its own permission settings. Two limits hold regardless of who sent the message: no message from any agent counts as your approval for a pending permission prompt, and no agent message can change a subagent’s permission settings, `CLAUDE.md`, or configuration. Only the permission system or your own messages can grant approval. You can also ask Claude for the agent ID if you want to reference it explicitly, or find IDs in the transcript files at `~/.claude/projects/{project}/{sessionId}/subagents/`. Each transcript is stored as `agent-{agentId}.jsonl`. Subagent transcripts persist independently of the main conversation:
* **Main conversation compaction** : when the main conversation compacts, subagent transcripts are unaffected. They’re stored in separate files.
* **Session persistence** : subagent transcripts persist within their session. You can resume a subagent after restarting Claude Code by resuming the same session.
@@ -1021,7 +1027,12 @@
`x`| Stop the selected fork if it’s running, or dismiss its row if it’s no longer running. On the main session row, or on the row of the fork whose transcript you opened with `Enter`, `x` types into the prompt instead
`Esc`| Return focus to the prompt input
-With a fork’s or subagent’s transcript open, follow-up messages and [skills](</docs/en/skills>) go to that agent, but built-in commands still run in your main conversation. As of v2.1.199, typing `/model` or `/fast` in that view shows a notice that it changes the main conversation’s model or fast mode, not the viewed agent’s, instead of running it silently.
+With a fork’s or subagent’s transcript open, follow-up messages and [skills](</docs/en/skills>) go to that agent, and built-in commands go to your main conversation, with these safeguards:
+
+ * `/compact`, `/clear`, and `/rewind` act on the main conversation, so Claude Code asks you to confirm before running one of them from this view.
+ * `/model` and `/fast` set the main conversation’s model and fast mode, not the viewed agent’s, so they don’t run from this view. A notice tells you why.
+
+To have the viewed agent read your message before the work it’s waiting on finishes, send it with [`Ctrl+Enter` or `Ctrl+X Ctrl+S`](</docs/en/keybindings#chat-actions>). Any shell command or subagent the agent is waiting on that can move to the [background](</docs/en/tools-reference#background-commands>) moves there and keeps running. When the agent is writing a response, or waiting on work that can’t move to the background, it keeps going and reads your message once that finishes. Requires Claude Code v2.1.286 or later.
###
--- a/subagents.md
+++ b/subagents.md
@@ -188,7 +188,7 @@
Project CLAUDE.md (loaded via [`settingSources`](</docs/en/agent-sdk/claude-code-features#control-filesystem-settings-with-settingsources>)), unless the agent sets `omitClaudeMd`| Preloaded skill content, unless listed in `AgentDefinition.skills`
Tool definitions (inherited from parent or the subset in `tools`, [filtered for background runs](</docs/en/sub-agents#available-tools>))| The parent’s system prompt
-The parent receives the subagent’s final message as the Agent tool result, but may summarize it in its own response. To preserve subagent output verbatim in the user-facing response, include an instruction to do so in the prompt or `systemPrompt` option you pass to the main `query()` call.In v2.1.210 and later, Claude Code [scans the final message for instruction-shaped patterns](</docs/en/sub-agents#subagent-output-scanning>) before the parent reads it. The scan treats three kinds of pattern differently:
+The parent receives the subagent’s final report, but may summarize it in its own response. To preserve subagent output verbatim in the user-facing response, include an instruction to do so in the prompt or `systemPrompt` option you pass to the main `query()` call.In v2.1.210 and later, Claude Code [scans the final message for instruction-shaped patterns](</docs/en/sub-agents#subagent-output-scanning>) before the parent reads it. The scan treats three kinds of pattern differently:
* **Control-tag imitation** : Claude Code neutralizes a tag that only the harness emits, such as a `<system-reminder>` block, in place. It inserts a backslash after the opening angle bracket and deletes nothing.
* **Permission-configuration mentions** : Claude Code keeps references to the permission configuration, such as `.claude/settings.json`, `bypassPermissions`, or `--dangerously-skip-permissions`, as written.
Show diff (403 lines)
--- a/test.md
+++ b/test.md
@@ -0,0 +1,400 @@
+You can write automated tests for a mod and run them from your shell with [`claude plugin test`](</docs/en/plugins/mods/reference#commands>). A test fires the events your hooks handle and checks what the hooks did, so you catch a problem before it reaches a session. The first example tests the mod from [Create a mod](</docs/en/plugins/mods/create>).
+
+##
+
+
+
+Write a test
+
+A test loads your mod, sends events through its hooks the way Claude Code would, and checks what the hooks did, without a session, a sign-in, or a network. You run tests from your shell with `claude plugin test`, and each test file imports the test kit, a test library in the `claude-code/testing` module. Give each test file a name that ends in `.test.ts`, such as `first-mod.test.ts`, and save it anywhere in the plugin directory. Every test file needs at least one `test()`, or the run fails with `declares no test(): nothing ran`. A test file can import your mod’s own files and sibling `.ts` helpers, so you can unit test plain functions, such as a game’s rules, without the kit. This test fires two tool calls, runs the `/tally` command from [Create a mod](</docs/en/plugins/mods/create>), and checks that the reply counts both. Its first line is a stub, which answers the tool calls in Claude Code’s place. Save it as `first-mod/tests/first-mod.test.ts`:
+
+first-mod/tests/first-mod.test.ts
+
+ import { expect, test } from 'claude-code/testing'
+
+ test('/tally reports the tool calls the mod has seen', async ($, on) => {
+ // Answer each tool call in Claude Code's place, so no tool runs
+ on('tool.call', () => ({ result: 'ok' }))
+
+ // Fire two tool calls, which the mod's tool.call hook counts
+ await $.tool.call({ tool: 'Bash', command: 'ls' })
+ await $.tool.call({ tool: 'Read', file_path: 'README.md' })
+
+ // Run /tally and check the text its hook returns
+ const answer = await $.command.run({ command: 'tally', args: '' })
+ expect(answer.text).toBe('Claude has made 2 tool calls since this mod loaded')
+ })
+
+In your shell, run the tests from the `first-mod` directory:
+
+ claude plugin test
+
+The output names each test and whether it passed, with timings that vary from run to run:
+
+ tests/first-mod.test.ts:
+ (pass) /tally reports the tool calls the mod has seen [22.87ms]
+
+ 1 pass
+ 0 fail
+ Ran 1 test across 1 file. [0.19s]
+
+Each `$.tool.call` went through the mod’s [`tool.call`](</docs/en/plugins/mods/reference#tools>) hook, which added one to its count and passed the call on to the stub. No `ls` ran and no file was read. `$.command.run` then went to the mod’s [`command.run`](</docs/en/plugins/mods/reference#commands-and-configuration>) hook, and `answer` is the object that hook returned. The command exits with status 1 when a test fails, so it works in CI. If your own mods can’t load in the shell that runs it, it prints a line starting `claude plugin test: hooks modules are turned off` with the reason, and exits with status 1.
+
+###
+
+
+
+Stub what Claude Code would answer
+
+No model, store, or tool runs in a test, so wherever your mod expects Claude Code to answer, the test supplies the answer with a stub. A test function receives two arguments for that:
+
+ * **`$`** : the test’s own `$`, which acts as Claude Code. It isn’t the [mods API](</docs/en/plugins/mods/reference#mods-api-methods>) that a hook receives. Each of its methods fires the event of the same name, sends it through your mod’s hooks, and resolves to the result: `$.tool.call({ tool: 'Bash', command: 'ls' })` fires `tool.call`. `$.command.run`, `$.prompt.submit`, `$.session.start`, and `$.turn.complete` work the same way, and `$.classic.Stop` and the other `$.classic` methods fire a [settings hook event](</docs/en/plugins/mods/events#hook-the-settings-hook-events>). A test can’t fire a mods API call such as `ui.close` directly. Trigger it through your mod, for example by pressing the button that closes the pane.
+ * **`on`** : call it to register stubs, which are hooks that answer in Claude Code’s place. Name a stub for a mods API call without the `$.`, so a stub registered as `store.get` answers your mod’s `$.store.get`. When your mod calls [`$.model.complete`](</docs/en/plugins/mods/api#call-a-model>) or [`$.store.get`](</docs/en/plugins/mods/interface#keep-state>), a stub supplies the answer.
+
+This example stubs a model call. The hook belongs to a mod named `grader`, and handles a `/grade` command that sends a sentence to a model and reports whether the reply starts with `PASS`. The file holds only the hook under test, so the mod also needs a `plugin.json` and a `hooks.json`, as in [Create a mod](</docs/en/plugins/mods/create#write-a-mod-yourself>). To type `/grade` in a session, the mod also has to [register the command](</docs/en/plugins/mods/api#add-a-command>):
+
+grader/hooks/register.js
+
+ export function register(on) {
+ on('command.run', { command: 'grade' }, async ($, e) => {
+ // e.args is the text typed after /grade
+ const reply = await $.model.complete({
+ model: 'haiku',
+ system: 'Grade the sentence. Start your reply with PASS or FAIL.',
+ prompt: e.args,
+ })
+ const passed = reply.isAnswered && reply.text.startsWith('PASS')
+ return { text: passed ? 'Passed' : 'Try again' }
+ })
+ }
+
+This test stubs the model call to check what the hook does with a passing reply:
+
+grader/tests/grader.test.ts
+
+ import { expect, test } from 'claude-code/testing'
+
+ test('a passing grade is reported', async ($, on) => {
+ // Answer the mod's $.model.complete call with a fixed reply, so no model runs
+ on('model.complete', () => ({
+ value: {
+ isAnswered: true,
+ text: 'PASS\nNice sentence.',
+ usage: { input_tokens: 10, output_tokens: 5, cache_read_input_tokens: 0, cache_creation_input_tokens: 0 },
+ },
+ }))
+
+ // Run /grade, which makes the mod call the model
+ const answer = await $.command.run({ command: 'grade', args: 'The cat sat on the mat.' })
+ expect(answer.text).toBe('Passed')
+ })
+
+The test passes because the hook’s `reply` is the object under `value`, whose `text` starts with `PASS`. To check the other branch, add a second test whose stub returns a `text` that starts with `FAIL`, and expect `Try again`. A stub for a mods API call returns an object with a `value` field, which holds what the call resolves to in your mod: `{ value: 7 }` makes `$.store.get` resolve to `7`. A stub for one of Claude Code’s events, such as [`turn.step`](</docs/en/plugins/mods/reference#turns>) or `tool.call`, returns that event’s own result, such as `{ result: 'ok' }`. `$.session.send` and `$.prompt.fill` take their event’s result too, as the table shows. Look up what a stub returns shows which form each common name takes. These errors mean a stub is wrong or missing. A failed test’s output includes a block headed `the engine reported:`, and each error appears there:
+
+ * `returned neither { value } nor { deny }`: a stub for a mods API call returned a bare value
+ * `no implementation for` followed by a name: your mod made that call and no stub answers it
+
+The kit also exports in-memory mocks that answer a whole namespace for you. `mock.clock(on)` answers [`$.clock`](</docs/en/plugins/mods/api#run-work-in-the-background>), `mock.store(on, { count: 7 })` answers `$.store` from a store that starts with those entries, and `mock.env(on, { CI: 'true' })` answers `$.env.get` from those variables. `mock.clock` returns a mock clock that your test advances, so a test of a timer doesn’t wait. `mock.store` returns nothing, so to check what your mod saved, write the two `store` stubs yourself as the drawing test does.
+
+###
+
+
+
+Follow the test kit’s rules
+
+The test kit has a few rules of its own, and breaking one produces the errors new test authors hit first:
+
+ * **Register every stub before the test’s first call on`$`.** Calling `on` after that throws an error such as `on("ui.render") after the test first called $`.
+ * **[`session.start`](</docs/en/plugins/mods/reference#session>) doesn’t run by itself.** Each test starts with your module freshly loaded and none of its hooks called, so module-level variables hold their initial values. If a hook depends on what `session.start` sets up, fire it first:
+
+ // Answer the event after your hook passes it on with next(e)
+ on('session.start', () => ({ cwd: '/work' }))
+ // Answer the $.command.register call your hook makes
+ on('command.register', () => ({ value: undefined }))
+ // Fire the event, which runs your session.start hook
+ await $.session.start({ surface: 'terminal', isInteractive: true, cwd: '/work' })
+
+The second stub answers the `$.command.register` call that a `session.start` hook such as the [tutorial’s](</docs/en/plugins/mods/create#write-a-mod-yourself>) makes. Without it, that call rejects with `no implementation for command.register` and the kit skips your hook, so nothing after the call in the hook runs. The test doesn’t fail at that point. The skipped hook is listed under `the engine reported:` only if a later check fails.
+ * **A hook that returns`next(e)` needs a stub to answer.** When your [`ui.render`](</docs/en/plugins/mods/reference#interface>) hook returns `next(e)`, for example to draw nothing while Claude is idle, mounting it fails with `no implementation for ui.render`. Register a stub that returns an element as plain data:
+
+ // Stands for what Claude Code would draw at the site
+ on('ui.render', () => ({ type: 'Text', props: {}, children: ['drawn by Claude Code'] }))
+
+With the stub registered, the mount succeeds, and `ui.find({ type: 'Text' })` returns that element whenever your hook returned `next(e)`.
+ * **A stub for`turn.step` is an async generator**, and the test reads the stream to its end to get the result:
+
+ on('turn.step', async function* ($, e) {
+ // Each yield is one piece of the model's streamed reply
+ yield { kind: 'text', index: 0, text: 'ok' }
+ // The return value is the result of the whole request
+ return { turnId: e.turnId, index: e.index, answer: 'ok', toolUses: [], stopReason: 'end_turn', usage: null }
+ })
+
+ // Fire one request to the model, which runs your turn.step hook
+ const stream = $.turn.step({ turnId: 't', index: 0, model: 'claude-test', messageCount: 1 })
+ // Read every piece until the stream says it's done
+ let step = await stream.next()
+ while (step.done !== true) step = await stream.next()
+ const result = step.value
+
+When the loop ends, `result` is the object the stub returned, after your `turn.step` hook has had the chance to change it. Here `result.answer` is `'ok'`.
+ * **Fire a tool call with the tool’s name and arguments as fields** , such as `await $.tool.call({ tool: 'Bash', command: 'ls' })`, and register a `tool.call` stub that returns `{ result }`.
+
+###
+
+
+
+Look up what a stub returns
+
+Every mods API call your mod makes in a test needs a stub that answers in Claude Code’s place, except the few the kit answers itself: [`$.ui.invalidate`](</docs/en/plugins/mods/interface#redraw-when-something-changes>) and [`$.state`](</docs/en/plugins/mods/interface#keep-state>) calls. For `$.clock` calls, use `mock.clock(on)`, or your mod’s `$.clock.now()` fails with `no implementation for clock.now`. This table lists the ones mods use most. The first column is the call your mod makes or the event it passes on with `next(e)`. The second is the function to pass to `on` under that name, so the `$.store.get` row becomes `on('store.get', ($, e) => ({ value: saved.get(e.key) }))`. A `'...'` in a stub marks text for you to fill in:
+
+Your mod calls or passes on| Stub
+---|---
+`$.command.register`, `$.tool.register`, `$.ui.toast`, `$.ui.log`, `$.ui.status`, `$.ui.close`, `$.store.set`| `() => ({ value: undefined })`. For `ui.toast` and `ui.log`, the text is `e.text`.
+`$.store.get`| `($, e) => ({ value: saved.get(e.key) })`
+`$.fs.read`| `($, e) => ({ value: e.path.endsWith('notes.md') ? '# Notes' : '' })`. `e.path` arrives as an absolute path, so compare with `endsWith`.
+`$.ui.open`| `() => ({ value: { isPlaced: true } })`
+`$.ui.ask`| A `tool.call` stub, because the question reaches it as a call to the `AskUserQuestion` tool: `($, e) => ({ result: { answers: { [e.questions[0].question]: 'Run it' } } })`. Check `e.tool` first if your mod passes on other tool calls.
+`$.model.complete`| `() => ({ value: { isAnswered: true, text: '...', usage } })`
+`$.process.run`| `($, e) => ({ value: { exitCode: 0, stdout: '...', stderr: '' } })`. `e.argv` is the argument list and `e.init` holds `cwd` and `timeoutMs`.
+Any mods API call that should fail| `() => ({ deny: 'the reason' })`, which makes the call reject in your mod. A stub that throws is skipped instead.
+`session.start`| `() => ({ cwd: '/work' })`
+`turn.start`| `($, e) => ({ turnId: e.turnId })`
+`tool.call`| `() => ({ result: '...' })`
+`turn.complete`| `() => ({ text: '' })`. Fire it with `$.turn.complete({ turnId, answer, durationMs, isAborted: false, usage: null })`.
+`prompt.submit`| `($, e) => ({ text: e.text })`
+`prompt.fill`| `() => ({ isFilled: true })`
+`$.prompt.read`| `() => ({ value: { text: '...', cursor: 0 } })`
+`$.ui.copy`| `() => ({ value: { isCopied: true } })`
+`$.session.messages`| `() => ({ value: [{ role: 'assistant', text: '...', toolUses: [] }] })`
+`$.session.id`, `$.agent.list`| `() => ({ value: 'abc123' })`, `() => ({ value: [] })`
+`session.send`| `() => ({ isDelivered: true })`. `e.to` arrives as a string even when your mod passed `{ sessionId }`.
+`session.receive`| `($, e) => ({ text: e.text })`. Fire it with `$.session.receive({ origin: { kind: 'peer-send-message' }, text })`.
+`ui.render`| `() => ({ type: 'Text', props: {}, children: ['...'] })`
+
+`expect` has the assertions `toBe`, `toEqual`, `toMatch`, `toMatchObject`, `toContain`, `toBeDefined`, `toBeUndefined`, and `toThrow`, and `.not` before any of them.
+
+##
+
+
+
+Test a timer
+
+A mod that runs work on a timer needs a clock the test controls, so the test can move time forward instead of waiting. `const clock = mock.clock(on)` returns a mock clock that starts at `0` and moves only when your test moves it. To start at another time, pass it in milliseconds, as in `mock.clock(on, { now: 5000 })`. The clock has these methods:
+
+Method| What it does
+---|---
+`await clock.advance(1000)`| Moves the time forward by that many milliseconds and runs each timer that comes due
+`await clock.set(5000)`| Moves the time forward to that value, as `advance` would
+`clock.now()`| Returns the time, which is what your mod’s `$.clock.now()` resolves to
+`await clock.settle()`| Runs timers that are already due, such as a chain of zero-delay `$.clock.after` calls, without moving the time
+`await clock.sleep(2000)`| Inside a stub, makes that stub answer only once the test has advanced that far, which is how you simulate a slow model or process
+
+This hook belongs to a mod named `countdown`, and handles a `/countdown` command that takes a number of seconds, starts a one-second `$.clock.every` timer, and shows a toast at zero. As with `grader`, the file holds only the hook under test and doesn’t register the command:
+
+countdown/hooks/register.js
+
+ export function register(on) {
+ on('command.run', { command: 'countdown' }, async ($, e) => {
+ // e.args is the text typed after /countdown
+ let left = Number(e.args)
+ const timer = $.clock.every(1000, () => {
+ left -= 1
+ if (left === 0) {
+ timer.cancel()
+ $.ui.toast('Time is up')
+ }
+ })
+ // Print nothing in the transcript
+ return {}
+ })
+ }
+
+This test runs `/countdown 3` and moves the mock clock, so it checks three seconds of behavior without waiting three seconds:
+
+countdown/tests/countdown.test.ts
+
+ import { expect, mock, test } from 'claude-code/testing'
+
+ test('the countdown ends with a toast', async ($, on) => {
+ // Answer every $.clock call from a clock the test controls
+ const clock = mock.clock(on)
+ // Collect the text of each toast the mod shows
+ const toasts: string[] = []
+ on('ui.toast', ($, e) => {
+ toasts.push(e.text)
+ return { value: undefined }
+ })
+
+ await $.command.run({ command: 'countdown', args: '3' })
+ // After two seconds the timer has fired twice, and no toast is due
+ await clock.advance(2000)
+ expect(toasts).toEqual([])
+ // The third second brings the count to zero
+ await clock.advance(1000)
+ expect(toasts).toEqual(['Time is up'])
+ })
+
+The first `expect` shows that the toast doesn’t come early, and the second shows that it comes once. Each `advance` resolves after the timers that came due have run, so the check on the next line sees their effect.
+
+##
+
+
+
+Test a drawing
+
+A test can draw one of your mod’s [render sites](</docs/en/plugins/mods/reference#render-sites>), then press, type into, and find the elements it drew. `$.ui.mount` draws the site through your mod’s `ui.render` hook and returns a handle with a method for each of those. To cover several apps in one test, set `surface` to the app to draw for. This test opens the pane from [Build a pane with tabs](</docs/en/plugins/mods/interface#build-a-pane-with-tabs>), switches tabs, presses the button, and checks the count in the terminal and the Desktop app:
+
+hello-tabs/tests/hello-tabs.test.ts
+
+ import { expect, test } from 'claude-code/testing'
+
+ // What Claude Code passes to a ui.render hook for this pane, apart from the app
+ const PANE = {
+ plugin: 'hello-tabs',
+ component: 'Pane',
+ requestId: 'hello-tabs',
+ viewport: { columns: 100, rows: 30 },
+ props: {
+ title: 'Hello tabs',
+ isFocused: true,
+ bodyColumns: 60,
+ placement: 'inline',
+ scroll: { offset: 0, bodyRows: 10 },
+ view: {},
+ },
+ } as const
+
+ test('the second tab counts presses and saves the count', async ($, on) => {
+ // Stub $.store with a Map, so the test can read what the mod saved
+ const saved = new Map<string, unknown>()
+ on('store.get', ($, e) => ({ value: saved.get(e.key) }))
+ on('store.set', ($, e) => {
+ saved.set(e.key, e.value)
+ return { value: undefined }
+ })
+
+ // Draw the pane once for each app
+ for (const surface of ['terminal', 'desktop'] as const) {
+ const ui = await $.ui.mount({ ...PANE, surface })
+ // Press the buttons by the key the mod gave them
+ await ui.press({ key: 'tab-two' })
+ await ui.press({ key: 'more' })
+ // The second tab's count line is in the drawing
+ expect(await ui.find({ type: 'Text', text: /^Count: \d+$/ })).toBeDefined()
+ await ui.unmount()
+ }
+
+ // One press in each app makes two
+ expect(saved.get('count')).toBe(2)
+ })
+
+In your shell, run `claude plugin test` from the `hello-tabs` directory. The test passes when both apps draw the count line and the mod has saved `2`. The count carries over from the first app to the second because both mounts use the same loaded module. The handle that `$.ui.mount` returns has these methods, which address elements by the `key` you gave them:
+
+Method| What it does
+---|---
+`press({ key: 'more' })`| Presses the `Button` with that key
+`input({ key: 'new-note', text: 'buy milk' })`| Types the text into the `Input` with that key and presses Enter. Add `kind: 'change'` to type without submitting.
+`select({ key: 'size', value: 'large' })`| Picks the option with that value in the `Select` with that key
+`find({ key: 'more' })` or `find({ type: 'Text', text: 'Count: 2' })`| Returns the first matching element as `{ type, props, children }`, or `undefined`. `text` can be a string or a regular expression.
+`unmount()`| Removes the drawing
+
+Each method resolves after your handler has finished, so you can check the result on the next line. Set `props` to what Claude Code would pass for that site. The [render sites table](</docs/en/plugins/mods/reference#render-sites>) lists each site’s props, and [the types for your build](</docs/en/plugins/mods/create#get-the-types-for-your-build>) have their types. A drawing test checks the tree your hook returns and whether it’s valid for that app. It doesn’t check how the app paints it, so look at a new layout in a real session as well.
+
+###
+
+
+
+Test a drawing after `/clear`
+
+Each test starts with every `$.state` value at its default, which is how `/clear` leaves them. To test what your mod does next, skip `session.start`, fire `classic.SessionStart` with `source: 'clear'`, and check what your mod draws. This test checks the module from [Load a saved value again after `/clear`](</docs/en/plugins/mods/interface#load-a-saved-value-again-after-clear>). Add it to the file from Test a drawing, where `PANE` is defined. That file’s first test expects the button to save the count, as the button in [Save from more than one session](</docs/en/plugins/mods/interface#save-from-more-than-one-session>) does:
+
+hello-tabs/tests/hello-tabs.test.ts
+
+ test('the saved count comes back after /clear', async ($, on) => {
+ // The store already holds a count of 7
+ on('store.get', () => ({ value: 7 }))
+ // Answer the event after your hook passes it on with next(e)
+ on('classic.SessionStart', () => ({}))
+
+ // Fire the event that follows /clear, which runs your hook
+ await $.classic.SessionStart({ source: 'clear' })
+
+ const ui = await $.ui.mount({ ...PANE, surface: 'terminal' })
+ await ui.press({ key: 'tab-two' })
+ // The pane shows the stored count, not the default of 0
+ expect(await ui.find({ type: 'Text', text: 'Count: 7' })).toBeDefined()
+ })
+
+The test passes when your `classic.SessionStart` hook has copied the stored `7` into `$.state` before the pane draws. Without that hook in your module, the pane draws `Count: 0`, `find` returns `undefined`, and the test fails at `toBeDefined`.
+
+##
+
+
+
+Test a policy mod
+
+A mod your organization lists in [`prependPlugins`](</docs/en/plugins/mods/admin>) can refuse another mod before it loads. To test one, set your mod’s tier and give the test a second mod for yours to allow or refuse:
+
+ * **`tier`** : call it once at the top of the test file, as in `tier('prepend')`, to load your mod as `prepend`, `append`, or `builtin`, its place in the [order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>). Without it, your mod loads as `user`.
+ * **`plugins`** : pass `test` an options object ahead of the test body. Its `plugins` array holds mods you write inline, each with a `name` and a `register` function. To load one somewhere other than `user`, add `tier` to it.
+
+This test file loads the [policy mod from the admin page](</docs/en/plugins/mods/admin#enforce-a-policy-with-a-mod-of-your-own>) first. It checks that the policy mod refuses a mod that starts a process and allows one that doesn’t:
+
+acme-guard/tests/guard.test.ts
+
+ import { expect, test, tier } from 'claude-code/testing'
+
+ // Load the mod under test ahead of every other mod
+ tier('prepend')
+
+ // A second mod whose code calls $.process.run, which the policy blocks
+ const runner = {
+ name: 'runner',
+ register(on) {
+ on('tool.call', async ($, e, next) => {
+ await $.process.run(['ls'])
+ return { result: 'runner answered' }
+ })
+ },
+ }
+
+ // A second mod that calls nothing the policy blocks
+ const reader = {
+ name: 'reader',
+ register(on) {
+ on('tool.call', async ($, e, next) => {
+ return { result: 'reader answered' }
+ })
+ },
+ }
+
+ test('refuses a mod that starts a process', { plugins: [runner] }, async ($, on) => {
+ on('tool.call', () => ({ result: 'claude code answered' }))
+ let message = ''
+ try {
+ // The first call on $ loads the mods, so the refusal is thrown here
+ await $.tool.call({ tool: 'Bash', command: 'ls' })
+ } catch (error) {
+ message = error.message
+ }
+ expect(message).toBe('runner: refused by acme-guard: Acme policy: mods may not call process.run')
+ })
+
+ test('admits a mod that starts no process', { plugins: [reader] }, async ($, on) => {
+ on('tool.call', () => ({ result: 'claude code answered' }))
+ const out = await $.tool.call({ tool: 'Bash', command: 'ls' })
+ // The answer comes from reader, which shows that it loaded
+ expect(out).toEqual({ result: 'reader answered' })
+ })
+
+In your shell, run `claude plugin test` from the `acme-guard` directory. Both tests pass with the policy mod as the admin page shows it. The kit loads every mod at the test’s first call on `$`. When your mod refuses one, that call throws, and the message names the refused mod, the mod that refused it, and your reason. In the second test nothing is refused, so `reader` answers the tool call before it reaches the stub.
+
+##
+
+
+
+Next steps
+
+ * [Troubleshoot a mod](</docs/en/plugins/mods/troubleshoot>): find out why a mod does nothing in a session
+ * [Mods reference](</docs/en/plugins/mods/reference>): every event’s input and result, for writing stubs
--- a/tools-reference.md
+++ b/tools-reference.md
@@ -213,7 +213,7 @@
Foreground commands that move to the background
-When a foreground command reaches its timeout without finishing, Claude Code moves it to the background instead of stopping it, unless the command starts with `sleep`. A moved command’s time limit counts from the move, and a foreground subagent’s moved command still stops when that subagent’s run ends. Setting [`CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1`](</docs/en/env-vars#variables>) disables auto-backgrounding along with the rest of the background task functionality. The result of a command moved to the background states what happened:
+When a foreground command reaches its timeout without finishing, Claude Code moves it to the background instead of stopping it, unless the command starts with `sleep`. A moved command’s time limit counts from the move, and a foreground subagent’s moved command still stops when that subagent’s run ends. Setting [`CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1`](</docs/en/env-vars#variables>) or running in [bare mode](</docs/en/headless#start-faster-with-bare-mode>) disables auto-backgrounding along with the rest of the background task functionality, so a command that reaches its timeout stops instead. The result of a command moved to the background states what happened:
* When the timeout triggers the move, the result reports it explicitly: `Command did not complete within its 120s timeout and was moved to the background`, with the seconds matching the timeout that applied, followed by the task ID and the path of the file the output is being written to.
* A `cd`, `pushd`, `popd`, or `chdir` inside a command that is moved to the background never carries over: the result states `Session cwd remains <dir>; directory changes made by the backgrounded command do not apply to subsequent commands.`, so Claude doesn’t act on a directory change that didn’t happen.
@@ -351,7 +351,7 @@
* Track output from any long-running script you point it at
* Connect to a WebSocket feed and report each message as it arrives
-For most watches, Claude writes a small script, runs it in the background, and receives each output line as it arrives. For a server that already pushes events, Claude can open a WebSocket instead of running a script. You keep working in the same session and Claude interjects when an event arrives. Every watch Claude starts has a deadline: 5 minutes by default, at most 30 minutes, and at most 10 minutes in a [non-interactive](</docs/en/headless>) run given a single prompt with `-p`. At the deadline the watch ends. Claude gets one notice, so it can start the watch again if it’s still needed. Stop a monitor by asking Claude to cancel it or by ending the session. When you stop a [subagent](</docs/en/sub-agents>) that started monitors, for example from `/tasks`, those monitors stop with it. When Monitor runs a command, it uses the same [permission rules as Bash](</docs/en/permissions#tool-specific-permission-rules>), so `allow` and `deny` patterns you have set for Bash apply here too. While [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) is active, Claude Code sets aside allow rules that name `Monitor` itself, along with the other [broad allow rules it drops](</docs/en/permission-modes#how-the-classifier-evaluates-actions>), so the classifier reviews Monitor commands the same way it reviews Bash commands. The WebSocket source has its own approval prompt, which the classifier also decides in auto mode. The tool is not available on Amazon Bedrock, Google Cloud’s Agent Platform, or Microsoft Foundry. It is also not available when `DISABLE_TELEMETRY` or `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` is set. Plugins can declare monitors that start automatically when the plugin is active, instead of asking Claude to start them. See [plugin monitors](</docs/en/plugins/components#monitors>).
+For most watches, Claude writes a small script, runs it in the background, and receives each output line as it arrives. For a server that already pushes events, Claude can open a WebSocket instead of running a script. You keep working in the same session and Claude interjects when an event arrives. Every watch Claude starts has a deadline: 5 minutes by default, at most 30 minutes, and at most 10 minutes in a [non-interactive](</docs/en/headless>) run given a single prompt with `-p`. At the deadline the watch ends. Claude gets one notice, so it can start the watch again if it’s still needed. Stop a monitor by asking Claude to cancel it or by ending the session. When you stop a [subagent](</docs/en/sub-agents>) that started monitors, for example from `/tasks`, those monitors stop with it. When Monitor runs a command, it uses the same [permission rules as Bash](</docs/en/permissions#tool-specific-permission-rules>), so `allow` and `deny` patterns you have set for Bash apply here too. While [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) is active, Claude Code sets aside allow rules that name `Monitor` itself, along with the other [broad allow rules it drops](</docs/en/permission-modes#how-the-classifier-evaluates-actions>), so the classifier reviews Monitor commands the same way it reviews Bash commands. The WebSocket source has its own approval prompt, which the classifier also decides in auto mode. The tool is not available on Amazon Bedrock, Google Cloud’s Agent Platform, or Microsoft Foundry. It is also not available when `DISABLE_TELEMETRY` or `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` is set. On Windows, the tool is available only when [Git Bash](</docs/en/setup#set-up-on-windows>) is installed. Plugins can declare monitors that start automatically when the plugin is active, instead of asking Claude to start them. See [plugin monitors](</docs/en/plugins/components#monitors>).
###
@@ -575,7 +575,7 @@
WebFetch tool behavior
-WebFetch takes a URL and a prompt describing what to extract. It fetches the page, converts the response to Markdown when the server returns HTML, and runs the prompt against the content using a small, fast model. For most fetches, Claude receives that model’s answer, not the raw page. The conversion step is not configurable. This makes WebFetch lossy by design. The extraction prompt determines what reaches Claude, so a result that says a page doesn’t mention something may only mean the prompt didn’t ask about it. Ask Claude to fetch again with a more specific prompt, or use `curl` via Bash for the unprocessed page. A few behaviors shape the response Claude receives:
+WebFetch takes a URL and a prompt describing what to extract. It fetches the page and converts the response to Markdown when the server returns HTML. For most fetches, it then runs the prompt against the content in a separate model call, and Claude receives the result of that call rather than the raw page. The conversion step is not configurable. This makes WebFetch lossy by design. The extraction prompt determines what reaches Claude, so a result that says a page doesn’t mention something may only mean the prompt didn’t ask about it. Ask Claude to fetch again with a more specific prompt, or use `curl` via Bash for the unprocessed page. A few behaviors shape the response Claude receives:
* WebFetch refuses `localhost` and any other hostname without a dot, such as a bare intranet name, before making a request. The [error it returns](</docs/en/errors#webfetch-cannot-fetch-localhost>) tells Claude to reach local servers with `curl` through Bash instead.
* HTTP URLs are automatically upgraded to HTTPS.
@@ -591,7 +591,15 @@
* **Yes, and don’t ask again for`<domain>`**: approves the fetch and saves a `WebFetch(domain:...)` allow rule for that domain to `.claude/settings.local.json` for that repository. See [how saved approvals persist](</docs/en/permissions#permission-system>). When your organization sets [`allowManagedPermissionRulesOnly`](</docs/en/permissions#managed-only-settings>), Claude Code hides this option.
* **No, and tell Claude what to do differently** : rejects the fetch.
-To allow a domain in advance without a prompt, add an allow rule like `WebFetch(domain:example.com)`; `WebFetch(domain:*)` allows every domain. The `auto` and `bypassPermissions` [permission modes](</docs/en/permissions#permission-modes>) skip the prompt, except for a domain an explicit `ask` rule matches. An explicit `WebFetch(domain:...)` rule in `deny`, `ask`, or `allow` takes precedence over the preapproved set, so you can block a preapproved domain or require a prompt for it. WebFetch sets a `User-Agent` header beginning with `Claude-User`, and an `Accept` header that prefers Markdown over HTML so servers that support content negotiation can return Markdown directly. Sandboxed commands don’t inherit WebFetch’s built-in set of preapproved documentation domains. To let a sandboxed command reach a domain without a prompt, add the domain to [`allowedDomains`](</docs/en/settings-reference#sandbox-network-alloweddomains>) or allow it with a `WebFetch(domain:...)` rule, which the [sandbox also honors](</docs/en/sandboxing#network-isolation>). WebFetch never reads the sandbox allowlist in return, so adding a domain to a sandbox or organization network allowlist doesn’t stop WebFetch from prompting for it.
+To allow a domain in advance without a prompt, add an allow rule like `WebFetch(domain:example.com)`; `WebFetch(domain:*)` allows every domain. The `auto` and `bypassPermissions` [permission modes](</docs/en/permissions#permission-modes>) skip the prompt, except for a domain an explicit `ask` rule matches. An explicit `WebFetch(domain:...)` rule in `deny`, `ask`, or `allow` takes precedence over the preapproved set, so you can block a preapproved domain or require a prompt for it. When the URL is a claude.ai [artifact](</docs/en/artifacts>) link, Claude Code can also ask for approval to read the artifact itself. For the cases where it asks, see [Read an artifact shared with you](</docs/en/artifacts#read-an-artifact-shared-with-you>). WebFetch sets a `User-Agent` header beginning with `Claude-User`, and an `Accept` header that prefers Markdown over HTML so servers that support content negotiation can return Markdown directly. Sandboxed commands don’t inherit WebFetch’s built-in set of preapproved documentation domains. To let a sandboxed command reach a domain without a prompt, add the domain to [`allowedDomains`](</docs/en/settings-reference#sandbox-network-alloweddomains>) or allow it with a `WebFetch(domain:...)` rule, which the [sandbox also honors](</docs/en/sandboxing#network-isolation>). WebFetch never reads the sandbox allowlist in return, so adding a domain to a sandbox or organization network allowlist doesn’t stop WebFetch from prompting for it.
+
+###
+
+
+
+WebFetch availability
+
+On Claude Code v2.1.285 or later, set [`CLAUDE_CODE_DISABLE_WEB_FETCH`](</docs/en/env-vars#variables>) to `1` to turn WebFetch off. If you sign in with a Team or Enterprise claude.ai account and don’t connect through an [LLM gateway](</docs/en/llm-gateway>), WebFetch also depends on your organization’s policy, which Claude Code requests from `api.anthropic.com` when a session starts. The same goes for a session whose plan Claude Code can’t determine, such as one running under a claude.ai token that another app supplied. If WebFetch is missing from a session, run `/status` in the session. If its `Organization policy` line reports that the policy didn’t load and names web fetch among the features that wait for it, Claude Code is withholding WebFetch until it can confirm that your organization allows it. Outside a session, `claude doctor` makes its own request and prints the same line. Once a policy that allows WebFetch loads, the tool returns without a restart.
##
Show diff (304 lines)
--- a/troubleshoot.md
+++ b/troubleshoot.md
@@ -0,0 +1,301 @@
+When a mod’s module or one of its hooks fails, Claude Code skips it and the session continues, so a broken mod can look like one that does nothing. Start by checking what Claude Code read from your mod and where it reports a problem, then find the symptom or message you have.
+
+##
+
+
+
+Find out why a mod does nothing
+
+When a mod does nothing, check what Claude Code reads from the mod’s files, and the line it writes when it skips something. For the first, in your shell run [`claude plugin validate`](</docs/en/plugins/mods/create#check-what-claude-code-reads-from-your-mod>) with the mod’s directory, as in `claude plugin validate ./first-mod`. It catches a misspelled event, a bad manifest, and a module Claude Code can’t read, without starting a session. When a module doesn’t load, a hook is skipped, or another mod refuses yours, Claude Code writes one line that names your mod. Where you read that line depends on the session:
+
+ * **A session that hot-reloads a plugin directory** : a dim line in the transcript. That’s an interactive session you started with `--plugin-dir`, or one where you [enabled hot reloading](</docs/en/plugins/mods/create#ask-claude-for-a-mod>) for mods Claude wrote.
+ * **Any other interactive session, such as one that runs a mod you installed from a marketplace** : the debug log only. To get one, start the session with `claude --debug`.
+ * **A`claude -p` run with `--plugin-dir`**: stderr, in the default text output format. A refusal by another mod goes to the debug log only.
+
+##
+
+
+
+Check whether mods can load
+
+To check whether your setup lets mods load at all, without installing one, run `claude plugin test` in your shell, from a directory that doesn’t hold a mod. You don’t need a session. The message it prints tells you the state:
+
+Message includes| What it means
+---|---
+`no hooks module to load`| Mods can load. The command found no mod to test in this directory.
+`hooks modules are turned off here`| A setting is blocking your mods: `disableAllHooks` in your own settings, or your organization’s policy
+`hooks modules are turned off in this process`| Anthropic has turned installed mods off remotely. No setting on your machine turns them back on.
+
+An organization can also set `allowManagedModsOnly` to allow only its own mods, which this command doesn’t report. In that case a mod you install doesn’t load, and [a message says why](</docs/en/plugins/mods/troubleshoot#messages-from-the-built-in-guard>).
+
+##
+
+
+
+The mod doesn’t load
+
+Nothing the mod adds appears: no command, no drawing, and no change in behavior.
+
+###
+
+
+
+Your version is older than 2.1.287
+
+`claude --version` prints a version older than 2.1.287. Your version predates mods being on by default. [Update Claude Code](</docs/en/setup#update-claude-code>).
+
+###
+
+
+
+The `mods active` line doesn’t name the mod
+
+Nothing the mod adds appears, and the [`mods active` line](</docs/en/plugins/mods/overview#see-which-mods-a-session-loaded>) in `/plugin` doesn’t name it. The hooks module didn’t load. When Claude Code refused it, the debug log has a line that starts with `hooks module`, the mod’s name, and `not loaded:`, as in `hooks module first-mod@inline not loaded: disableAllHooks in managed settings` for a mod loaded with `--plugin-dir`. Read the reason after the colon. The refusal messages section lists each one. If the log has no such line, work through the other entries in this group. Some settings stop a mod and leave the rest of its plugin working. [Turn mods on or off](</docs/en/plugins/mods/overview#turn-mods-on-or-off>) names them.
+
+###
+
+
+
+A `claude -p` run prints `hooks module not loaded`
+
+The line starts with the mod’s name and goes to stderr. The hooks module was refused. A non-interactive run has no transcript, so the message goes to stderr. Read the reason after the colon. The refusal messages section lists each one.
+
+###
+
+
+
+Refusal messages
+
+Each of these follows `hooks module`, the mod’s name, and `not loaded:` in the debug log.
+
+Message starts with| What it means
+---|---
+`hooks modules are turned off for installed plugins in this process`| Anthropic has turned installed mods off remotely. No setting on your machine turns them back on.
+`disableAllHooks in managed settings`| Your organization turned off hooks from installed plugins
+`only managed plugins and built-in plugins run`| `allowManagedHooksOnly` is set, or `disableAllHooks` is set in a settings file other than managed settings
+`installed plugins that are not managed load no hooks module in this mode (--bare)`| You started Claude Code with `--bare`
+`another plugin of that name loads first`| Two plugins share a name. The managed one, or the one loaded first, is used.
+
+###
+
+
+
+Messages from the built-in guard
+
+On a machine with managed settings, or for a user signed in with a Team or Enterprise plan, the [built-in guard](</docs/en/plugins/mods/admin#know-what-happens-by-default>) can refuse a mod or one of its answers. Each message names the option your organization’s administrator sets to change the rule.
+
+Message contains| What it means| Where it appears
+---|---|---
+`mods are limited to your organization's by policy (allowManagedModsOnly)`| Your organization allows only [its own mods](</docs/en/plugins/mods/admin#install-your-organizations-mods>), so yours wasn’t loaded| The debug log, and the transcript in a session that hot-reloads a plugin directory
+`tried to lift a deny rule in your settings`| Your mod’s [`tool.check`](</docs/en/plugins/mods/reference#tools>) hook approved a call that a `deny` rule refuses. The call stays denied.| The transcript and the debug log, once for each mod in a session. In a `claude -p` run, the debug log only.
+`the deny rules in your settings could not be checked for this call, so it is refused`| The guard failed while checking a call that a mod approved, so it refused the call| The reason Claude reads for the denied call
+
+###
+
+
+
+`validate` passes and lists no `hooks` line
+
+`hooks/hooks.json` has no `modules` key, or the key is misspelled. Add `"modules": ["./register.js"]`.
+
+###
+
+
+
+`hooks module did not load`
+
+The line starts with the mod’s name, then `hooks module did not load:` and a reason, which gives the file and line when the problem is in your code. Claude Code couldn’t load the module, for example because its top-level code threw. Fix the error the reason names.
+
+###
+
+
+
+`options do not fit plugin.json userConfig`
+
+The line starts with the mod’s name, then `hooks module did not load: options do not fit plugin.json userConfig:` and a reason. An option fails validation against its [`userConfig`](</docs/en/plugins/components#user-configuration>) field, such as a number above the field’s `max`, or a required field has no value. Set or change the value. The end of the line names its `pluginConfigs` entry in `settings.json`.
+
+###
+
+
+
+No mod loads in a directory you opened for the first time
+
+You haven’t answered the trust prompt for the directory. Start an interactive session in that directory with `claude`, and accept the trust prompt it opens with.
+
+###
+
+
+
+No installed plugin loads at all
+
+You started Claude Code with `--safe-mode`. Start without the flag.
+
+##
+
+
+
+A hook is skipped or a mod is unloaded
+
+The mod loaded, and then Claude Code skipped one of its hooks or unloaded it.
+
+###
+
+
+
+`hook skipped`
+
+The line names the mod and the event, then says `hook skipped:` and a reason, as in `first-mod: tool.call hook skipped: threw Error: boom`. A hook threw, exceeded its [time limit](</docs/en/plugins/mods/reference#limits>), or returned a result of the wrong shape. The line appears once for each event and kind of failure until the mod reloads. Fix the error. The debug log has a line for every occurrence.
+
+###
+
+
+
+`no command.run hook answered it`
+
+You run a command your mod added, and the reply names the mod and the command, as in `first-mod registered /tally but no command.run hook answered it`, then tells you to add a hook. Claude Code prints that reply when the command reaches the end of the chain with no answer, which happens in two cases:
+
+ * **No hook answered the command** : the module has no `command.run` hook, the hook’s [filter](</docs/en/plugins/mods/events#filter-which-events-a-hook-handles>) names a different command, or the hook returned `next(e)`
+ * **Claude Code skipped the hook** : `hook skipped` lists the reasons. Passing `focus: false` to [`$.ui.open`](</docs/en/plugins/mods/interface#open-a-pane-at-the-right-time>) is one way to get there.
+
+If the module already has the hook the reply describes, look for a `hook skipped` line that names `command.run`, which gives the reason. A [test](</docs/en/plugins/mods/test>) that runs the command fails with the same reason.
+
+###
+
+
+
+`it crashed the hooks worker`
+
+The line starts with the mod’s name, as in `first-mod was unloaded: it crashed the hooks worker`. Installed mods share one worker thread. The worker stopped responding or crashed, and Claude Code traced that to this mod and unloaded it. A hook that blocks the thread, such as a loop that never awaits, is one cause. Fix the hook.
+
+###
+
+
+
+`mods that run in the hooks worker are off for this session`
+
+The line reads `hooks: mods that run in the hooks worker are off for this session: it crashed 3 times`. The worker stopped three times and Claude Code couldn’t trace the stops to one mod, so it unloaded every mod that isn’t built in, including mods your organization installs. This line reaches the transcript in every interactive session. Run `/reload-plugins` to load them again.
+
+##
+
+
+
+A tool call is denied
+
+The mod loaded and its hooks run, and a tool call it touched is refused.
+
+###
+
+
+
+`a hook changed this call's input after the model wrote it`
+
+In auto mode, a denied tool call gives this reason. A hook changed the tool call’s input after the [server-side classifier](</docs/en/permission-modes#server-side-classifier-review>) reviewed it, so that review doesn’t cover what would run. The hook can be a mod’s [`tool.call`](</docs/en/plugins/mods/reference#tools>) or [`turn.step`](</docs/en/plugins/mods/reference#turns>) hook, or a [`PreToolUse`](</docs/en/hooks#pretooluse>) settings hook. The message doesn’t say which. The message tells Claude to issue the call once more as recorded. If that’s denied too, the hook changes the input every time, so turn off the mod or hook, or leave auto mode and approve the call yourself.
+
+###
+
+
+
+A message about the deny rules in your settings
+
+`tried to lift a deny rule in your settings` and `the deny rules in your settings could not be checked for this call, so it is refused` both come from the built-in guard. Look them up in Messages from the built-in guard.
+
+##
+
+
+
+A drawing doesn’t appear or respond
+
+The mod loaded, and its pane, band, or controls don’t behave as you expect.
+
+###
+
+
+
+A pane or band is empty or shows Claude Code’s usual content
+
+The [tree](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) your hook returned didn’t validate. With `--plugin-dir`, the transcript says `ui.render (Pane) refused:` with the reason, as in `first-mod: ui.render (Pane) refused: Box prop "flexDirection" must be one of row, column, row-reverse, column-reverse; the engine drew its own`. The debug log has `a hook returned a tree that does not validate` with the same reason. Read the reason on that line. Common causes are a prop the element doesn’t take and an element the app doesn’t have.
+
+###
+
+
+
+`$.ui.open` runs and no pane appears
+
+The call didn’t come from something the user did, and the terminal is narrower than [the width that pane needs](</docs/en/plugins/mods/interface#when-a-pane-waits-for-a-wider-terminal>). Open the pane from a command or a button, or check the call’s `isPlaced` result. See [Open a pane at the right time](</docs/en/plugins/mods/interface#open-a-pane-at-the-right-time>).
+
+###
+
+
+
+Hotkeys do nothing
+
+Your pane doesn’t have keyboard focus. Press Ctrl+X then Tab, or click the pane. Open it with `focus: true` from a command.
+
+###
+
+
+
+A drawing works in the terminal and not in the Desktop app
+
+The site or element isn’t available there. Check the [render sites](</docs/en/plugins/mods/reference#render-sites>) and [elements](</docs/en/plugins/mods/reference#elements>) tables.
+
+##
+
+
+
+An edit or a value is lost
+
+The mod runs, and a change you made or a value it kept isn’t there.
+
+###
+
+
+
+Your edits don’t take effect
+
+You’re editing a plugin you installed. Claude Code runs the cached copy for the installed version. Develop with `--plugin-dir` pointed at your working copy, as in `claude --plugin-dir ./first-mod`, which reloads when you save.
+
+###
+
+
+
+A value resets when the module reloads
+
+Module-level variables are re-initialized on each reload. [Keep the value in `$.state` or `$.store`](</docs/en/plugins/mods/interface#keep-state>).
+
+###
+
+
+
+A value resets after `/clear`, `/resume`, or `/branch`
+
+A value resets, or a saved value is replaced by its default. Each of those commands resets `$.state` to its defaults, and `session.start` doesn’t fire again. [Load the saved value again](</docs/en/plugins/mods/interface#load-a-saved-value-again-after-clear>) in a `classic.SessionStart` hook.
+
+##
+
+
+
+Read the debug log
+
+The debug log has a line for every module Claude Code loads or refuses, every hook that fails, and every result it refuses, so it’s where to look when the transcript shows nothing. To write one, in your shell start Claude Code with `--debug`, or with `--debug-file <path>` to choose where it goes:
+
+ claude --debug-file ./mod-debug.log --plugin-dir ./first-mod
+
+In another terminal, follow the file and filter for your mod’s name:
+
+ tail -f ./mod-debug.log | grep first-mod
+
+A mod that loaded has a line that names it and lists the events it handles. A mod loaded with `--plugin-dir` appears under its name followed by `@inline`:
+
+ hooks module first-mod@inline loaded (worker, environment 2, tier user); events: session.start,tool.call,command.run,ui.render
+
+A drawing that didn’t validate counts as a refused result and gets a line too. To write your own lines in the log, call [`$.ui.log`](</docs/en/plugins/mods/api#show-something-without-starting-a-turn>) with a second argument, as in `$.ui.log('message', { to: 'debug' })`. Without the second argument, `$.ui.log` adds a dim line to the transcript. While you edit a mod loaded with `--plugin-dir`, the transcript shows a line for each reload that names the mod and lists its hooks. If a save breaks the module, the line says `reload failed, the previous version stays loaded:` with the reason, and the last working version keeps running.
+
+##
+
+
+
+Next steps
+
+ * [Test a mod](</docs/en/plugins/mods/test>): catch problems before they reach a session
+ * [Troubleshoot plugins](</docs/en/plugins/troubleshooting>): problems with installing and loading a plugin that aren’t specific to mods
--- a/troubleshoot-install.md
+++ b/troubleshoot-install.md
@@ -16,6 +16,7 @@
`curl: (23)` or `curl: (56) Failure writing output to destination`| Check connectivity or use an alternative installer
`Killed` during install on Linux, or `Installation was killed before it could finish (exit code 137)`| Free memory or add swap space
`Raw mode is not supported` during install| Rerun the installer
+`EACCES: permission denied` during install| Fix the install directory’s permissions
`TLS connect error` or `SSL/TLS secure channel`| Update CA certificates
`Failed to fetch version` or can’t reach download server| Check network and proxy settings
`irm is not recognized` or `The token '&&' is not a valid statement separator`| Use the right command for your shell
@@ -28,6 +29,7 @@
`Error loading shared library`| Wrong binary variant for your system
`Illegal instruction`| Architecture or CPU instruction set mismatch
`cannot execute binary file: Exec format error` in WSL| WSL1 native-binary regression
+`Bus error` or `oh no: Bun has crashed` while a session is running| Keep the executable readable
PowerShell installer completes but `claude` is not found or shows an old version| Add the install directory to your PATH, then open a new terminal
`dyld: Symbol not found`, `dyld: cannot load`, or `Abort trap` on macOS| Binary incompatibility
`claude update` hangs after `Checking for updates`, or `claude doctor` hangs with no output| Move the directory at a shell config path
@@ -217,7 +219,16 @@
Check directory permissions
-The installer needs write access to `~/.local/bin/` and `~/.claude/` on macOS and Linux. On Windows the install location is under `%USERPROFILE%`, which is writable by your user by default, so this section rarely applies there. Check whether the directories are writable:
+An install that fails on permissions names the path it couldn’t create or write. On Windows the install writes under `%USERPROFILE%`, which is writable by your user by default, so this section rarely applies there. On macOS and Linux the install writes to these locations:
+
+ * `~/.claude/downloads/`: where the install command puts the downloaded binary
+ * `~/.local/bin/`: the `claude` launcher
+ * `~/.local/share/claude/`: each version it downloads
+ * `~/.local/state/claude/`: its lock files
+ * `~/.cache/claude/`: staged downloads
+ * [`~/.claude.json`](</docs/en/claude-directory>): your global config file, where the installer records the install method
+
+If you set `XDG_DATA_HOME`, `XDG_STATE_HOME`, or `XDG_CACHE_HOME`, the install uses those in place of `~/.local/share`, `~/.local/state`, and `~/.cache`. If you set [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>), the global config file lives under that directory instead of your home directory. Check whether the directories are writable:
test -w ~/.local/bin && echo "writable" || echo "not writable"
test -w ~/.claude && echo "writable" || echo "not writable"
@@ -657,6 +668,14 @@
+`Bus error` while a session is running
+
+If a running session exits and your shell prints `Bus error`, one cause is that Claude Code could no longer read its own executable file from disk. For example, the file was truncated, or deleted on network storage, while the session ran. Before the shell’s message, Claude Code’s runtime can print a crash report that includes `panic(main thread): Bus error at address` and `oh no: Bun has crashed. This indicates a bug in Bun, not your code.` When the executable became unreadable, the crash comes from the unreadable file, not from a bug in Bun. The report can also be missing, if the runtime couldn’t read the code that prints it either. Start a new session to continue. If Claude Code is installed on network storage, follow [Install on network storage](</docs/en/setup#install-on-network-storage>) so upgrades don’t remove a binary that running sessions still need.
+
+###
+
+
+
`Exec format error` on WSL1
If running `claude` in WSL prints `cannot execute binary file: Exec format error`, you’re on WSL1 and hitting a known native-binary regression tracked in [issue #38788](<https://github.com/anthropics/claude-code/issues/38788>). The binary’s program headers changed in a way WSL1’s loader can’t handle. The cleanest fix is to convert your distribution to WSL2 from PowerShell:
@@ -864,7 +883,7 @@
Not logged in or token expired
-If Claude Code prompts you to log in again after a session, your OAuth token may have expired. Run `/login` to re-authenticate. If this happens frequently, check that your system clock is accurate, as token validation depends on correct timestamps. Parallel sessions on one machine share a saved login and coordinate its renewal so that only one process refreshes the token at a time. Before v2.1.211, waking the machine from sleep could cause two sessions to renew with the same token, which revoked the saved login and prompted every open session to log in again at once. On macOS, Claude Code saves credentials to the login Keychain. When the Keychain rejects the write, such as when it’s locked in an SSH session or its password is out of sync with your account password, Claude Code saves your login to the plaintext `~/.claude/.credentials.json` file instead. A Console login that creates an API key fails until the Keychain is writable again. To make the Keychain writable again and move your login back into the encrypted Keychain:
+If Claude Code prompts you to log in again after a session, your OAuth token may have expired. Run `/login` to re-authenticate. If this happens frequently, check that your system clock is accurate, as token validation depends on correct timestamps. Parallel sessions on one machine share a saved login and coordinate its renewal so that only one process refreshes the token at a time. For what the other sessions do after you sign in again in one of them, see [Not logged in](</docs/en/errors#not-logged-in>). Before v2.1.211, waking the machine from sleep could cause two sessions to renew with the same token, which revoked the saved login and prompted every open session to log in again at once. On macOS, Claude Code saves credentials to the login Keychain. When the Keychain rejects the write, such as when it’s locked in an SSH session or its password is out of sync with your account password, Claude Code saves your login to the plaintext `~/.claude/.credentials.json` file instead. A Console login that creates an API key fails until the Keychain is writable again. To make the Keychain writable again and move your login back into the encrypted Keychain:
1
Show diff (161 lines)
--- a/typescript.md
+++ b/typescript.md
@@ -717,14 +717,14 @@
`supportedModels()`| Returns available models with display info
`supportedAgents()`| Returns available subagents as `AgentInfo``[]`
`mcpServerStatus()`| Returns the status of connected MCP servers as `McpServerStatus``[]`
-`getContextUsage(opts?)`| Returns an `SDKControlGetContextUsageResponse` breaking down the session’s context window usage by category, skill, and tool. With the default `detail`, it is the same data `/context` shows in an interactive session. The `detail` option requires Agent SDK v0.3.257 or later
+`getContextUsage(opts?)`| Returns an `SDKControlGetContextUsageResponse` breaking down the session’s context window usage by category, skill, and tool. With the default `detail`, it is the same data `/context` shows in an interactive session, computed with token-counting API requests that don’t appear in the message stream; see how these requests are handled. The `detail` option requires Agent SDK v0.3.257 or later
`readFile(path, options?)`| Reads a file from the session’s filesystem. Claude Code resolves the path against `cwd`; What `readFile()` can read lists the files it serves. Pass `{ maxBytes }` to change the read cap (default 1 MB, ceiling 10 MB) and `{ encoding: 'base64' }` for binary files such as images. Resolves with an `SDKControlReadFileResponse`, or `null` on permission denial, a missing file, or a transport error. Requires TypeScript SDK v0.2.121 or later
`reloadPlugins(options?)`| Reloads plugins from disk, so plugins you install or edit mid-session reach the running session. Resolves with an `SDKControlReloadPluginsResponse` listing the session’s commands, subagents, plugins, and MCP server status. Requires Agent SDK v0.2.85 or later. The `holdOnCacheImpact` option requires Agent SDK v0.3.268 or later
`reloadSkills()`| Reloads skills from disk, so skills you add or edit mid-session become available to the running session. Resolves with an `SDKControlReloadSkillsResponse` listing the skills available after the reload. Requires Agent SDK v0.3.163 or later
`reloadOutputStyles()`| Re-reads [output styles](</docs/en/output-styles>) from disk, so a style file you add or edit mid-session becomes available to the running session. Resolves with an `SDKControlReloadOutputStylesResponse` listing the style names available after the reload. Requires Agent SDK v0.3.261 or later
`accountInfo()`| Returns account information
`reconnectMcpServer(serverName)`| Reconnect an MCP server by name. If the name also matches an entry in a settings file such as `.mcp.json` or `~/.claude.json`, Claude Code reconnects the server you configured through `mcpServers` or `setMcpServers()`, not the settings-file entry. That resolution order requires Claude Code v2.1.257 or later
-`toggleMcpServer(serverName, enabled)`| Enable or disable an MCP server by name, with the same name resolution as `reconnectMcpServer()`. Disabling a stdio, SSE, or HTTP server disconnects it and removes its tools; for a server you added mid-session with `setMcpServers()`, tool removal requires Claude Code v2.1.285 or later
+`toggleMcpServer(serverName, enabled)`| Enable or disable an MCP server by name, with the same name resolution as `reconnectMcpServer()`. Disabling a server disconnects it and removes its tools. See `toggleMcpServer()` for the Claude Code version this needs for each kind of server
`setMcpServers(servers)`| Dynamically replace the set of MCP servers for this session. Resolves with an `McpSetServersResult` naming which servers were added and removed, and any errors
`readMcpResource(serverName, uri)`| _Alpha._ Reads one MCP Apps `ui://` resource from a connected MCP server so your application can render a tool’s widget. Resolves with an `SDKControlMcpReadResourceResponse`. Requires TypeScript Agent SDK v0.3.280 or later
`streamInput(stream)`| Stream input messages to the query for multi-turn conversations
@@ -775,6 +775,17 @@
* **`"userSettings"`** : accepts `effortLevel` and saves it as the default [effort level](</docs/en/model-config#adjust-effort-level>) for the session’s current model, under [`modelSettings`](</docs/en/settings-reference#modelsettings>) in your user settings file. Passing `max` writes nothing, because `max` is session-only. The running session keeps its current effort level either way, so call `applyFlagSettings()` when you also want to change that. This source requires TypeScript SDK v0.3.277 or later, which bundles Claude Code v2.1.277.
The call rejects when the request carries any other key, when the session runs over a remote transport, and when the session’s `settingSources` exclude the source you name. Deleting a key isn’t supported.
+
+####
+
+
+
+`toggleMcpServer()`
+
+Disabling a server disconnects it and removes its tools from the session. For servers you added mid-session and for in-process servers, this depends on your Claude Code version:
+
+ * A stdio, SSE, or HTTP server you added mid-session with `setMcpServers()`: removing its tools requires Claude Code v2.1.285 or later.
+ * An in-process server you created with `createSdkMcpServer()`, whether you passed it in `mcpServers` or with `setMcpServers()`: disconnecting it and removing its tools requires Claude Code v2.1.286 or later. Disabling one also fails its tool calls that are still running, so Claude receives an error result for each of them immediately, without waiting for your handler to return.
###
@@ -889,7 +900,12 @@
`SDKControlGetContextUsageResponse`
-Return type of `getContextUsage()`. With the default `detail`, this is the same payload Claude Code renders for the `/context` command in an interactive session, so alongside the token counts it carries display fields such as `color` and `gridRows` that Claude Code uses to draw the `/context` usage grid. The method’s optional `detail` argument chooses how Claude Code counts each category. With the default, `'full'`, Claude Code counts each category with token-counting API requests. Pass `{ detail: 'summary' }` to get an answer from the last response’s usage and local estimates instead. No token-count requests go out, and the per-category numbers are approximate. The `detail` argument requires Agent SDK v0.3.257 or later. When you send `/context` as a prompt instead of calling the method, Claude Code attaches an `SDKContextUsage` payload to the `context_usage` field of the assistant message that delivers the result. That field requires Agent SDK v0.3.232 or later.
+Return type of `getContextUsage()`. With the default `detail`, this is the same payload Claude Code renders for the `/context` command in an interactive session, so alongside the token counts it carries display fields such as `color` and `gridRows` that Claude Code uses to draw the `/context` usage grid. The method’s optional `detail` argument chooses how Claude Code counts each category. The `detail` argument requires Agent SDK v0.3.257 or later.
+
+ * **`'full'`** : the default. Claude Code counts each category with [token-counting](<https://platform.claude.com/docs/en/build-with-claude/token-counting>) API requests. These requests don’t appear in the message stream, so cost tracking that reads the stream won’t see them. On the Anthropic API, token counting isn’t billed.
+ * **`'summary'`** : pass `{ detail: 'summary' }` to get an answer from the last response’s usage and local estimates instead. No token-count requests go out, and the per-category numbers are approximate.
+
+When you send `/context` as a prompt instead of calling the method, Claude Code attaches an `SDKContextUsage` payload to the `context_usage` field of the assistant message that delivers the result. That field requires Agent SDK v0.3.232 or later.
type SDKControlGetContextUsageResponse = {
categories: {
@@ -991,7 +1007,7 @@
* `memoryFiles` lists each loaded memory file with its cost.
* `skills.skillFrontmatter` attributes the skill listing’s tokens to each included skill. The per-skill counts measure each skill’s listing entry as Claude Code actually sends it, which can be shorter than the skill’s full frontmatter. Compare `skills.totalSkills` with `skills.includedSkills` to see whether every discovered skill made it into the listing.
-`totalTokens` is the session’s current context usage, and `maxTokens` is the window that usage is measured against. That window is the model’s context window, or the lower auto-compaction window when one applies. `rawMaxTokens` carries the same value as `maxTokens`, and `percentage` is `totalTokens` as a rounded percentage of that window. Claude Code leaves the optional `deferredBuiltinTools`, `systemTools`, and `systemPromptSections` diagnostics unset, so expect them to be absent even though the type declares them.
+`totalTokens` is the session’s current context usage, and `maxTokens` is the window that usage is measured against. That window is the model’s context window, or the lower auto-compaction window when one applies. `rawMaxTokens` carries the same value as `maxTokens`, and `percentage` is `totalTokens` as a rounded percentage of that window. `apiUsage` holds the usage from the latest API response, not a running total for the session. Claude Code leaves the optional `deferredBuiltinTools`, `systemTools`, and `systemPromptSections` diagnostics unset, so expect them to be absent even though the type declares them.
###
@@ -1538,16 +1554,38 @@
shouldQuery?: boolean;
client_composed?: true;
tool_use_result?: unknown;
+ priority?: "now" | "next" | "later";
origin?: SDKMessageOrigin;
inline_pastes?: string[];
};
-Set `pasted_content` to send content the user pasted into your prompt UI rather than typed, one entry per paste, each a string or an array of content blocks. Claude Code appends each entry’s text after the typed text, in order, and may wrap each paste in `<pasted_content>` tags. Blocks other than text are ignored, so send images and documents in `message.content`. Requires Agent SDK v0.3.277 or later. Set `shouldQuery` or `client_composed` to change how Claude Code handles a message you send:
+Set `pasted_content` to send content the user pasted into your prompt UI rather than typed, one entry per paste, each a string or an array of content blocks. Claude Code appends each entry’s text after the typed text, in order, and may wrap each paste in `<pasted_content>` tags. Blocks other than text are ignored, so send images and documents in `message.content`. Requires Agent SDK v0.3.277 or later. Set `inline_pastes` to tell Claude Code which parts of `message.content` the user pasted rather than typed, one string per paste. The prompt text stays where the user put it. Claude Code may wrap each listed paste in `<pasted_content>` tags where it stands, so Claude can tell pasted material from the user’s own words. Only pastes in the prompt’s last text block are wrapped. Requires TypeScript Agent SDK v0.3.280 or later. Set `shouldQuery`, `client_composed`, or `priority` to change how Claude Code handles a message you send:
* `shouldQuery`: set it to `false` to append the message to the transcript without triggering an assistant turn. The message is held and merged into the next user message that does trigger a turn. Use this to inject context, such as the output of a command you ran out of band, without spending a model call on it.
* `client_composed`: set it to `true` to have Claude Code deliver the message text as written. Claude Code then doesn’t expand `@path` or [`@server:resource`](</docs/en/mcp#use-mcp-resources>) mentions, and doesn’t run text that starts with `/` as a command. While the `verbatimPrompts` option is on, the SDK sets the field on every message. Requires TypeScript Agent SDK v0.3.280 or later and Claude Code v2.1.248 or later.
-
-On a message that carries a `tool_result` block, `tool_use_result` is the tool’s structured output object rather than the text sent to the model. Its shape depends on the tool named by the matching `tool_use` block, so the field is typed `unknown`; the built-in shapes are listed under Tool Output Types. For the `Agent` tool, `tool_use_result` is `AgentOutput`. On a `completed` result, `content` holds the subagent’s report without the agent ID and usage trailer that Claude Code appends to the `tool_result` text, so render from `tool_use_result` instead of parsing that text. For an MCP tool whose result contains `resource_link` blocks, `tool_use_result` is an object with a `resourceLinks` array of `SDKMcpResourceLink` entries. Claude receives each link as a line of text in the `tool_result` block, so read `resourceLinks` to render the files the server returned instead of parsing that text. Claude Code omits `resourceLinks` when the result has no links and on results from subagents, keeps at most 50 links per result, and stops adding links once the array reaches 64 KiB of serialized JSON. `resourceLinks` requires Agent SDK v0.3.257 or later. Set `inline_pastes` to tell Claude Code which parts of `message.content` the user pasted rather than typed, one string per paste. The prompt text stays where the user put it. Claude Code may wrap each listed paste in `<pasted_content>` tags where it stands, so Claude can tell pasted material from the user’s own words. Only pastes in the prompt’s last text block are wrapped. Requires TypeScript Agent SDK v0.3.280 or later.
+ * `priority`: controls when a message you send during a running turn reaches Claude:
+ * `'next'`, or no `priority` field: Claude reads the message in the same turn, as soon as the tool calls it is running finish. If the turn ends first, the message starts the next turn.
+ * `'later'`: Claude Code holds the message until the turn ends and sends it as a new turn.
+ * `'now'` with `origin: { kind: "human" }`: on Claude Code v2.1.286 or later, work that can continue in the background moves there, and Claude reads the message in the same turn. Work that can move includes shell commands, subagents, and MCP tool calls. On v2.1.287 or later it also includes WebFetch and WebSearch calls. When Claude is only writing a response, or the work it is running can’t move, Claude Code interrupts the turn instead and Claude reads the message next.
+ * `'now'` without that origin: Claude Code interrupts the turn and Claude reads the message next.
+
+This message, sent while a turn is running, asks Claude to change course without losing a shell command that is still running:
+
+ const message: SDKUserMessage = {
+ type: "user",
+ message: { role: "user", content: "Skip the integration tests and summarize what you have so far" },
+ parent_tool_use_id: null,
+ priority: "now",
+ origin: { kind: "human" },
+ };
+
+On a message that carries a `tool_result` block, `tool_use_result` is the tool’s structured output object rather than the text sent to the model. Its shape depends on the tool named by the matching `tool_use` block, so the field is typed `unknown`; the built-in shapes are listed under Tool Output Types. These results need handling beyond their listed shape:
+
+ * The `Agent` tool: `tool_use_result` is `AgentOutput`. Render from it rather than parsing the `tool_result` text. A `completed` result’s `content` holds the subagent’s report, or, for a subagent whose report goes through a `SubagentHandback` tool call, a short note about that hand-back in place of the report. In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) on Claude Code v2.1.271 or later, every subagent that produces a `completed` result reports that way unless it is a [fork](</docs/en/sub-agents#fork-the-current-conversation>), and Claude receives the report as a separate message from the subagent.
+ * A WebFetch or WebSearch call that Claude Code moved to the background to deliver a `'now'` message: the user message carrying that call’s `tool_result` has `tool_use_result` set to `{ detachedToolCall: true }`. The call is still running, and Claude receives its result once it finishes. No second `tool_result` for that `tool_use_id` follows, so if your application draws a row for each tool call, mark this row as moved to the background when this message arrives. Requires Claude Code v2.1.287 or later.
+ * An MCP tool whose result contains `resource_link` blocks: `tool_use_result` is an object with a `resourceLinks` array of `SDKMcpResourceLink` entries. Claude receives each link as a line of text in the `tool_result` block, so read `resourceLinks` to render the files the server returned instead of parsing that text. Claude Code omits `resourceLinks` when the result has no links and on results from subagents, keeps at most 50 links per result, and stops adding links once the array reaches 64 KiB of serialized JSON. `resourceLinks` requires Agent SDK v0.3.257 or later.
+ * An MCP tool that returns `structuredContent`: `tool_use_result` is an object whose `structuredContent` member holds what the server sent and whose `content` member holds the `McpOutput` value. Results from subagents don’t carry `structuredContent`.
+ * An MCP tool whose `structuredContent` serializes to more than 1,048,576 characters of JSON: Claude Code leaves `structuredContent` off `tool_use_result` and sets `structuredContentOmitted: true` in its place, so your application can tell a dropped object from a tool that sent none. The other members, such as `content` and `resourceLinks`, stay, and what Claude receives doesn’t change. Tools from [in-process SDK servers](</docs/en/agent-sdk/custom-tools>) and tools whose `tools/list` entry declares an MCP Apps `_meta.ui` resource are exempt and deliver the object whole. Claude Code v2.1.287 or later applies this cap.
###
@@ -1603,7 +1641,13 @@
first_content_frame_ms?: number;
first_stream_post_ms?: number;
first_stream_post_ack_ms?: number;
+ first_stream_post_queue_wait_ms?: number;
+ first_stream_post_queued_behind?: "durable_post" | "ephemeral_post" | "retry_backoff" | "hold" | "none";
first_stream_post_wall_ms?: number;
+ first_text_post_ms?: number;
+ first_text_post_queue_wait_ms?: number;
+ first_text_post_queued_behind?: "durable_post" | "ephemeral_post" | "retry_backoff" | "hold" | "none";
+ first_text_post_wall_ms?: number;
total_cost_usd: number;
usage: NonNullableUsage;
modelUsage: { [modelName: string]: ModelUsage };
@@ -1703,7 +1747,7 @@
Claude Code echoes the answered message’s `uuid` on three kinds of frame:
* **The result** : every result of a turn that answered a message you sent. Every such result carries it on Agent SDK v0.3.265 or later. Before v0.3.265, the success result of a turn that a regular message started lacked it when the turn sent no API request or ended with a deferred tool call. Before v0.3.246, error results lacked it too, and before v0.3.216 every result did.
- * **The turn’s first reply** : the first assistant message, or with `includePartialMessages` the first stream event whose `event.type` isn’t `ping`, so you can bind the reply before the result arrives. When a turn streams nothing, Claude Code sets it on the first assistant message instead. The first-reply echo requires Agent SDK v0.3.246 or later. When the message the turn is answering changes mid-turn, the first reply after the change carries the field too, on Agent SDK v0.3.265 or later; earlier versions set it on one reply frame per turn.
+ * **The turn’s first reply** : the first assistant message, and with `includePartialMessages` also the first stream event whose `event.type` isn’t `ping`, so you can bind the reply before the result arrives. The first-reply echo requires Agent SDK v0.3.246 or later. Before v0.3.269, with `includePartialMessages`, Claude Code set it on that first stream event only, or on the first assistant message when the turn streamed nothing. When the message the turn is answering changes mid-turn, the first reply after the change carries the field too, on Agent SDK v0.3.265 or later; earlier versions set it on one reply frame per turn.
* **Every`thinking_tokens` frame of the turn**: so you can attribute thinking progress to the message you sent without waiting for the turn’s first reply. Requires Agent SDK v0.3.260 or later.
Claude Code omits the field in these cases:
@@ -2012,7 +2056,7 @@
`SDKContextUsage`
-Structured form of the `/context` report, carried as `context_usage` on the `SDKAssistantMessage` that delivers a `/context` result. Agent SDK v0.3.232 and later export the type. Unlike `SDKControlGetContextUsageResponse`, it carries only the data needed to render the usage breakdown, without display fields such as `color` and `gridRows`.
+Structured form of the `/context` report, carried as `context_usage` on the `SDKAssistantMessage` that delivers a `/context` result. Agent SDK v0.3.232 and later export the type. Unlike `SDKControlGetContextUsageResponse`, it carries only the data needed to render the usage breakdown, without display fields such as `color` and `gridRows`. Claude Code computes the report with token-counting API requests that don’t appear in the message stream; see how these requests are handled.
type SDKContextUsage = {
model: string;
@@ -4845,7 +4889,7 @@
[k: string]: unknown;
};
-MCP tool results are returned as a string or an array of content blocks, depending on the server. The trailing plain-object branch in the exported type is a schema-generation artifact: the SDK doesn’t return a bare object, because a server’s structured output is serialized to a JSON string before being returned. At runtime the value may also be `undefined`, although the exported type doesn’t model this.
+MCP tool results are returned as a string or an array of content blocks, depending on the server. The trailing plain-object branch in the exported type is a schema-generation artifact. For a result that also carries `structuredContent` or resource links, see `tool_use_result`, which holds this value in its `content` member. At runtime the value may also be `undefined`, although the exported type doesn’t model this.
##
@@ -4974,7 +5018,7 @@
type SdkBeta = "context-1m-2025-08-07";
-The `context-1m-2025-08-07` beta is retired as of April 30, 2026. Passing this value with Claude Sonnet 4.5 or Sonnet 4 has no effect, and requests that exceed the standard 200k-token context window return an error. To use a 1M-token context window, migrate to [Claude Opus 5.5, Claude Opus 5, Claude Sonnet 5, Claude Sonnet 4.6, Claude Opus 4.6, Claude Opus 4.7, or Claude Opus 4.8](<https://platform.claude.com/docs/en/about-claude/models/overview>), which include 1M context at standard pricing with no beta header required.
+On the Claude API, the `context-1m-2025-08-07` beta is retired for Claude Sonnet 4.5 and Claude Sonnet 4. If you still pass it with either model, requests that exceed the standard 200K-token context window return an error, so remove it from `betas`. To run a session with a 1M-token context window, set `model` to a model that [runs with the 1M window by default](</docs/en/model-config#extended-context>), such as `claude-sonnet-5-5` or `claude-opus-5-5`. For a model that reaches 1M only through its `[1m]` variant, append the suffix to the model ID, as in `claude-opus-4-6[1m]`.
###
@@ -5017,7 +5061,7 @@
Field| Type| Description
---|---|---
`value`| `string`| Model identifier to pass in API calls
-`resolvedModel`| `string | undefined`| Canonical wire model ID that this entry’s `value` resolves to. An alias entry such as `sonnet` resolves to an explicit model ID such as `claude-sonnet-5`, so a host can match a stored explicit model ID against the alias entry that covers it. Requires Claude Code v2.1.197 or later.
+`resolvedModel`| `string | undefined`| The model ID that this entry’s `value` resolves to, such as `claude-sonnet-5-5` for the `sonnet` alias entry. Requires Claude Code v2.1.197 or later.
`displayName`| `string`| Human-readable display name
`description`| `string`| Description of the model’s capabilities
`supportsEffort`| `boolean | undefined`| Whether this model supports effort levels
--- a/ultrareview.md
+++ b/ultrareview.md
@@ -18,7 +18,7 @@
/code-review ultra
-Without arguments, ultrareview reviews the diff between your current branch and the default branch, including uncommitted and staged changes. For uncommitted changes to files named like credentials or keys, such as `.env` and `*.tfvars` files, Claude Code follows the rules for [uploading a local repository to a cloud session](</docs/en/claude-code-on-the-web#send-local-repositories-without-github>). For a branch review, Claude Code bundles the repository state and uploads it to a cloud sandbox; when you review a pull request, Claude Code uploads nothing from your machine. Before launching, Claude Code shows a confirmation dialog with the review scope, your remaining free runs, and the estimated cost; for a branch review, the scope includes the file and line count. After you confirm, the review continues in the background while you keep using your session. The command runs only when you invoke it with `/code-review ultra`; Claude doesn’t start an ultrareview on its own.
+Without arguments, ultrareview reviews the diff between your current branch and the default branch, including uncommitted and staged changes. For a branch review, Claude Code bundles the repository state and uploads it to a cloud sandbox under the rules for [uploading a local repository to a cloud session](</docs/en/claude-code-on-the-web#send-local-repositories-without-github>), which cover the size limits, the checkout requirements, and what happens to uncommitted changes in files named like credentials or keys, such as `.env` and `*.tfvars` files. When you review a pull request, Claude Code uploads nothing from your machine. Before launching, Claude Code shows a confirmation dialog with the review scope, your remaining free runs, and the estimated cost; for a branch review, the scope includes the file and line count. After you confirm, the review continues in the background while you keep using your session. The command runs only when you invoke it with `/code-review ultra`; Claude doesn’t start an ultrareview on its own.
###
@@ -119,7 +119,7 @@
Track a running review
-A review typically takes 5 to 10 minutes. The review runs as a background task, so you can keep working in your session, start other commands, or close the terminal entirely. If you chose to post the findings to the pull request, keep the session open until the review finishes; if the session ends first, Claude Code posts nothing. Use `/tasks` to see running and completed reviews, open the detail view for a review, or stop a review that is in progress. If you stop a review, Claude Code archives the cloud session and doesn’t return partial findings. Claude can also tell you that a review was stopped or that its session wasn’t found:
+A review typically takes 5 to 10 minutes. The review runs as a background task, so you can keep working in your session or start other commands. If you chose to post the findings to the pull request, keep the session open until the review finishes; if the session ends first, Claude Code posts nothing. Use `/tasks` to see running and completed reviews, open the detail view for a review, or stop a review that is in progress. If you stop a review, Claude Code archives the cloud session and doesn’t return partial findings. Claude can also tell you that a review was stopped or that its session wasn’t found:
* If the review’s cloud session is stopped or [archived](</docs/en/claude-code-on-the-web#archive-sessions>) on claude.ai before the review finishes, Claude tells you it was stopped.
* If the review’s cloud session was deleted, or you’ve signed in to a different Claude account or organization since launching it, Claude tells you the session wasn’t found.
@@ -139,7 +139,7 @@
claude ultrareview 1234
claude ultrareview origin/main
-Without arguments, the subcommand reviews the diff between your current branch and the default branch, with the same whole-repository fallback as `/code-review ultra` when no merge base exists. Pass a PR number to review a pull request, or a base branch to review against it; base-branch handling matches the interactive command. You consent to the whole-repository fallback and to the billing and terms prompt when you run the subcommand, so the run starts without waiting for input. Running it yourself is what counts as consent. When Claude runs the subcommand for you instead, for example through the Bash tool, Claude Code refuses the whole-repository review. On Claude Code v2.1.218 or later, you can also start the cloud review by running `/code-review ultra` in a non-interactive session, for example `claude -p '/code-review ultra'`. Claude Code launches the review and prints a tracking link without waiting for the findings, unlike `claude ultrareview`, which blocks until they arrive. When the review would bill usage credits, Claude Code stops before launching and points you to `claude ultrareview`, because the billing confirmation needs an interactive session. Before v2.1.218, `/code-review ultra` in a non-interactive session ran a local review. Progress messages and the live session URL go to stderr so stdout stays parseable. Use these flags to control the output, the timeout, and whether to post the findings:
+Without arguments, the subcommand reviews the diff between your current branch and the default branch, with the same whole-repository fallback as `/code-review ultra` when no merge base exists. Pass a PR number to review a pull request, or a base branch to review against it; base-branch handling matches the interactive command. You consent to the whole-repository fallback and to the billing and terms prompt when you run the subcommand, so the run starts without waiting for input. Running it yourself is what counts as consent. When Claude runs the subcommand for you instead, for example through the Bash tool, Claude Code refuses the whole-repository review. `claude -p '/code-review ultra'` doesn’t get you the findings, so use `claude ultrareview` in scripts. The `-p` run launches the cloud review and exits without waiting for it. When the review would bill usage credits, the `-p` run stops without launching it. Before v2.1.218, `/code-review ultra` in a non-interactive session ran a local review. `claude ultrareview` writes its progress messages to stderr so stdout stays parseable. Use these flags to control its output, the timeout, and whether to post the findings:
Flag| Description
---|---
@@ -154,9 +154,9 @@
* **1** : the review failed to launch or was stopped before it finished, the cloud session errored, or the timeout elapsed
* **130** : you interrupted the subcommand with Ctrl-C
-If you interrupt the subcommand, the remote review keeps running; follow the session URL printed to stderr to watch it in the browser. With `--post`, the subcommand starts the post right after printing the findings, and prints the link to stderr.
+If the subcommand exits before the findings arrive, they never reach your terminal. The review may still be running in the cloud. Running the subcommand again starts a new review rather than resuming that one, and the new review uses a free run or bills as usage credits. With `--post`, the subcommand starts the post right after printing the findings, and prints the link to stderr.
- * If the run fails, is stopped, or times out, or if you interrupt it, the subcommand posts nothing.
+ * If the run fails, is stopped, or times out, the subcommand posts nothing.
* If the review completes but the comment isn’t posted, Claude Code prints the reason to stderr, and the findings stay on stdout so you can post them by hand.
For automatic reviews on GitHub pull requests, [Code Review](</docs/en/code-review>) integrates with your repository directly and posts findings as inline PR comments without a CLI step.
Show diff (136 lines)
--- a/vs-code.md
+++ b/vs-code.md
@@ -95,7 +95,7 @@
* `/plan` with a task, such as `/plan fix the auth bug`: switches to plan mode and starts planning that task.
* `/plan open`: when you’re already in plan mode, opens the plan file in the editor.
* **Edit automatically** : Claude makes edits without asking.
- * **Model** : select **Switch model…** from the command menu to change the model mid-session. You can also click the model name at the bottom of the prompt box to open the same picker. When the current model supports [effort levels](</docs/en/model-config#adjust-effort-level>), the picker also shows an **Effort** row and the model name button shows the selected level. When you pick a level other than `max`, Claude Code saves it for the current model as your default, under [`modelSettings`](</docs/en/settings-reference#modelsettings>) in your user settings; `max` applies to the current session only. The model name button and the **Effort** row require Claude Code v2.1.257 or later. When [dynamic workflows](</docs/en/workflows>) are enabled and the current model supports it, an **Ultracode** switch appears under the **Effort** row. Turn it on to have Claude plan a [workflow](</docs/en/workflows#let-claude-decide-with-ultracode>) for each substantive task in this session, at the selected effort level. While it’s on, the model name button shows `· Ultracode` after the level. The switch requires Claude Code v2.1.284 or later.
+ * **Model** : select **Switch model…** from the command menu to change the model mid-session. You can also click the model name at the bottom of the prompt box to open the same picker. With Claude Code v2.1.284 or later, typing `/model` on its own in the prompt box opens the picker too. When the current model supports [effort levels](</docs/en/model-config#adjust-effort-level>), the picker also shows an **Effort** row and the model name button shows the selected level. When you pick a level other than `max`, Claude Code saves it for the current model as your default, under [`modelSettings`](</docs/en/settings-reference#modelsettings>) in your user settings; `max` applies to the current session only. The model name button and the **Effort** row require Claude Code v2.1.257 or later. When [dynamic workflows](</docs/en/workflows>) are enabled and the current model supports it, an **Ultracode** switch appears under the **Effort** row. Turn it on to have Claude plan a [workflow](</docs/en/workflows#let-claude-decide-with-ultracode>) for each substantive task in this session, at the selected effort level. While it’s on, the model name button shows `· Ultracode` after the level. The switch requires Claude Code v2.1.284 or later.
* **Command menu** : click `/` or type `/` to open the command menu. Options include attaching files, switching models, and toggling extended thinking. The Customize section includes entries such as MCP servers, commands, output styles, hooks, memory, instructions, permissions, and plugins. Items with a terminal icon open in the integrated terminal.
* To browse commands such as `/usage` or [`/remote-control`](</docs/en/remote-control>), select **Slash commands** in the Customize section. A dialog lists them with a filter box. Pick one to run it. Typing `/` in the prompt box still suggests commands inline. Requires Claude Code v2.1.257 or later. Typing `/skills` also opens this dialog. Each [skill](</docs/en/skills>) row shows its [visibility](</docs/en/skills#override-skill-visibility-from-settings>), such as **On** or **Name only**. Click the visibility to change it, except on rows marked **locked** , such as plugin skills. The `/skills` shortcut and the visibility controls require Claude Code v2.1.280 or later.
* Select **Output styles** in the Customize section to pick an [output style](</docs/en/output-styles>), including your custom styles. Requires Claude Code v2.1.257 or later. To create a custom style instead, select **Build a custom style** from the **Output styles** menu. Claude Code writes the [style file](</docs/en/output-styles#create-a-custom-output-style>) for you at the project or user level. Requires Claude Code v2.1.261 or later.
@@ -161,7 +161,7 @@
* **Session titles** : new sessions receive AI-generated titles based on your first message.
* **Rename and archive** : hover over a session to reveal these actions. Rename to give it a descriptive title, or archive to move it to the **Archived sessions** group at the bottom of the list.
-By default, a session with no activity for 14 days moves to **Archived sessions** automatically, unless it is open, unread, or in a group. Automatic archiving requires Claude Code v2.1.265 or later. To change the period or turn it off, open the [Archive Inactive Sessions setting](<vscode://settings/claudeCode.archiveInactiveSessions>) and select a number of days or **Never**. To restore an archived session, expand **Archived sessions** and click **Unarchive session**. To restore every archived session at once, hover over the **Archived sessions** header in the sessions list in the Activity Bar and click its unarchive icon, which requires Claude Code v2.1.277 or later. Before v2.1.257, the action was **Delete session** , which hid a session with no way to restore it. Sessions you deleted then appear under **Archived sessions** after you upgrade. When the conversation you resume ended in plan mode, Claude Code restores plan mode. Requires Claude Code v2.1.246 or later. Claude Code doesn’t restore it in two cases:
+If the conversation is open in another Claude Code process, such as `claude` in a terminal or another VS Code window, a notice appears in place of the prompt box: `This conversation is still open somewhere else. Using it in two places at once can mix up its messages.` To continue here, close the conversation in the other place and then click **Open here anyway**. If you click without closing it, the conversation is open in both places. With `claudeProcessWrapper` set, the extension skips this check and opens the conversation directly. By default, a session with no activity for 14 days moves to **Archived sessions** automatically, unless it is open, unread, or in a group. Automatic archiving requires Claude Code v2.1.265 or later. To change the period or turn it off, open the [Archive Inactive Sessions setting](<vscode://settings/claudeCode.archiveInactiveSessions>) and select a number of days or **Never**. To restore an archived session, expand **Archived sessions** and click **Unarchive session**. To restore every archived session at once, hover over the **Archived sessions** header in the sessions list in the Activity Bar and click its unarchive icon, which requires Claude Code v2.1.277 or later. Before v2.1.257, the action was **Delete session** , which hid a session with no way to restore it. Sessions you deleted then appear under **Archived sessions** after you upgrade. When the conversation you resume ended in plan mode, Claude Code restores plan mode. Requires Claude Code v2.1.246 or later. Claude Code doesn’t restore it in two cases:
* The extension [chooses the starting permission mode](</docs/en/permission-modes#switch-permission-modes>) from `claudeCode.initialPermissionMode` or a pick that carries over from an earlier conversation
* You have `claudeCode.claudeProcessWrapper` configured
@@ -233,12 +233,18 @@
Use the sidebar for your main Claude session and open additional tabs for side tasks. Claude remembers your preferred location. The Activity Bar sessions list icon is separate from the Claude panel: the sessions list is always visible in the Activity Bar, while the Claude panel icon only appears there when the panel is docked to the left sidebar.
+###
+
+
+
+Continue conversations after a reload
+
After you run **Developer: Reload Window** or restart VS Code, whether a chat comes back with its conversation depends on where it was open:
* **Editor tab** : the conversation comes back with its tab.
* **Sidebar** : the conversation comes back if you sent a message or Claude responded in it within the last 10 minutes. If it doesn’t come back, resume the conversation from Session history.
-If the reload interrupted Claude mid-step, Claude continues that step when the conversation comes back, and a notice in the chat marks the continuation. Requires Claude Code v2.1.274 or later. If the step was interrupted more than an hour ago or the session is open elsewhere, the conversation comes back idle instead. To turn continuation off, open the [Continue After Reload setting](<vscode://settings/claudeCode.continueAfterReload>) and uncheck it.
+If another Claude Code process still has the conversation open, you’re asked before it opens here, with the same **Open here anyway** notice as when you resume it from session history. If the reload interrupted Claude mid-step, Claude continues that step when the conversation comes back, and a notice in the chat marks the continuation. Requires Claude Code v2.1.274 or later. If the step was interrupted more than an hour ago or the session is open elsewhere, the conversation comes back idle instead. To turn continuation off, open the [Continue After Reload setting](<vscode://settings/claudeCode.continueAfterReload>) and uncheck it. Setting [`CLAUDE_CODE_RESUME_INTERRUPTED_TURN`](</docs/en/env-vars#variables>) or any other `CLAUDE_CODE_RESUME_` variable in VS Code’s environment or in the `environmentVariables` setting has no effect in the panel, because the extension removes those variables before it starts the panel’s sessions.
###
@@ -302,6 +308,7 @@
* **Installed plugins** appear at the top with toggle switches to enable or disable them.
* If you turn off a plugin that your project’s shared `.claude/settings.json` turns on, the extension asks first: **Disable for me** turns it off only for you, while **Disable for everyone** changes the shared file.
+ * A plugin that failed to load shows a short reason on its row. Click the reason for what you can do about it, including copying the full error message to look up in [Troubleshoot plugins](</docs/en/plugins/troubleshooting>).
* **Available plugins** from your configured marketplaces appear below
* Search to filter plugins by name or description
* Click **Install** on any available plugin
@@ -340,12 +347,19 @@
Parameter| Description
---|---
`plugin`| The plugin’s name as its marketplace lists it. Required.
-`marketplace`| Where the plugin comes from: a GitHub `owner/repo`, an `https://` URL, or a git SSH URL such as `git@github.com:owner/repo.git`. Defaults to `anthropics/claude-plugins-official` when omitted.
-
-Some values that the Marketplaces tab accepts don’t work in a link, such as a local path or an `http://` address. For those, VS Code shows an error message and the dialog doesn’t open. Two cases end at a message in the dialog instead of the scope choice:
+`marketplace`| The marketplace’s [source](</docs/en/plugins/install#add-a-marketplace>): a GitHub `owner/repo`, an `https://` URL, or a git SSH address such as `git@github.com:owner/repo.git`. Defaults to `anthropics/claude-plugins-official` when omitted.
+
+The extension checks both values before it opens anything:
+
+ * **Plugin name** : at most 100 characters, starting with an ASCII letter or digit and otherwise using only ASCII letters, digits, `.`, `_`, and `-`.
+ * **Marketplace source** : only the forms the `marketplace` parameter lists, so not a local path, an `http://` address, or the marketplace’s name, such as `claude-plugins-official`. An `https://` URL can’t contain a user name, password, or query string.
+ * **Git ref** : to pin the marketplace to a branch or tag, append the ref to the source after `%23`, the encoded form of `#`, as in `marketplace=owner/repo%23v1.0`. A link with an unencoded `#` fails. Marketplaces in the `anthropics` GitHub organization can’t be pinned in a link.
+
+Someone who opens a link that breaks these rules sees an error that starts with `Invalid plugin installation URL`. The Claude Code panel and the dialog don’t open, and nothing installs. If your plugin’s name or marketplace can’t go in a link, tell people to add the marketplace in the **Marketplaces** tab and then install the plugin from the **Plugins** tab. These cases end at a message in the dialog instead of the scope choice:
* **The marketplace doesn’t list a plugin by that name** : the dialog reports that the plugin wasn’t found. Check the `plugin` value against the marketplace’s listing.
* **The plugin is already installed** : the dialog says so, and nothing changes.
+ * **A different marketplace with the same name is already added** : the dialog says the link’s marketplace wasn’t added, and nothing installs.
GitHub READMEs, issues, and some other Markdown hosts strip links whose scheme isn’t `http` or `https`, so a `vscode://` link there renders as plain text. Put the URL in a code block on those hosts, as [The link renders as plain text instead of being clickable](</docs/en/deep-links#the-link-renders-as-plain-text-instead-of-being-clickable>) describes for `claude-cli://` links.
@@ -377,7 +391,7 @@
@browser go to localhost:3000 and check the console for errors
-You can also open the attachment menu to select specific browser tools like opening a new tab or reading page content. Claude opens new tabs for browser tasks and shares your browser’s login state, so it can access any site you’re already signed into. For setup instructions, the full list of capabilities, and troubleshooting, see [Use Claude Code with Chrome](</docs/en/chrome>).
+You can also open the attachment menu to select specific browser tools like opening a new tab or reading page content. Claude opens new tabs for browser tasks and shares your browser’s login state, so it can access any site you’re already signed into. To have each session connect to your browser as it starts, without typing `@browser`, see [Enable Chrome by default](</docs/en/chrome#enable-chrome-by-default>). For when Claude Code asks you before a browser action in a session connected that way, see [Permission prompts in VS Code sessions](</docs/en/chrome#permission-prompts-in-vs-code-sessions>). For setup instructions, the full list of capabilities, and troubleshooting, see [Use Claude Code with Chrome](</docs/en/chrome>).
##
@@ -481,6 +495,7 @@
`attachOpenFile`| `true`| Add the file that is open in the editor to your messages and show it in the prompt box. When off, only your selected text is added. Requires Claude Code v2.1.271 or later
`useCtrlEnterToSend`| `false`| Use Ctrl/Cmd+Enter instead of Enter to send prompts
`scrollToBottomOnSend`| `true`| Scroll the conversation to the bottom when you send a message. When off, the conversation stays where you left it. Requires Claude Code v2.1.275 or later
+`showMessageTimestamps`| `false`| Show when each message was sent. A date line marks where the day changes. Requires Claude Code v2.1.284 or later
`enableNewConversationShortcut`| `false`| Enable Cmd/Ctrl+N to start a new conversation
`enableReopenClosedSessionShortcut`| `true`| Use Cmd/Ctrl+Shift+T to reopen the most recently closed Claude session tab. When the last closed tab wasn’t a Claude session, the shortcut runs VS Code’s normal reopen-closed-editor command instead.
`archiveInactiveSessions`| `14`| Archive a session automatically after this many days without activity: `1`, `2`, `7`, or `14`. Set `0` to turn it off. Requires Claude Code v2.1.265 or later
@@ -489,7 +504,7 @@
`focusView`| `false`| Hide tool calls, tool results, and thinking behind expandable rows, leaving your prompts and Claude’s responses. Claude’s latest to-do list stays visible; this requires Claude Code v2.1.225 or later. You can also toggle Focus view from the command menu. Requires Claude Code v2.1.221 or later
`respectGitIgnore`| `true`| Exclude .gitignore patterns from file searches and from selection context
`usePythonEnvironment`| `true`| Activate the workspace’s Python environment when running Claude. Requires the Python extension.
-`environmentVariables`| `[]`| Set environment variables for the Claude process. Use Claude Code settings instead for shared config.
+`environmentVariables`| `[]`| Set environment variables for the Claude process. Use Claude Code settings instead for shared config. A [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>) entry applies only when its value is an absolute path; the extension doesn’t expand `~` and ignores a relative value.
`disableLoginPrompt`| `false`| Skip authentication prompts (for third-party provider setups)
`allowDangerouslySkipPermissions`| `false`| Adds Bypass permissions to the mode selector. Use it only in sandboxes with no internet access.
`claudeProcessWrapper`| -| Executable used to launch the Claude process. The bundled binary path is passed as an argument when present. Set this to a separately installed `claude` binary if the extension build doesn’t include one for your platform. In a wrapped setup, conversations start in Manual mode unless you set `initialPermissionMode` or picked Manual, Edit automatically, or Auto in an earlier conversation, because the extension skips the settings and built-in-default steps there; see [Switch permission modes](</docs/en/permission-modes#switch-permission-modes>). An “Unsupported platform” error at activation means no binary is bundled for your platform; see [which platforms have prebuilt binaries](</docs/en/troubleshoot-install#native-binary-not-found-after-npm-install>).
@@ -582,9 +597,17 @@
+Move a running command or subagent to the background
+
+When Claude is waiting on a command or a [subagent](</docs/en/sub-agents>) that is taking longer than you want, click **Run in background** below its tool call in the conversation. The action appears once a command has been running for about two seconds, or as soon as a subagent starts. Claude stops waiting and continues the turn, while the command or subagent keeps running as a [background task](</docs/en/tools-reference#background-commands>) that notifies Claude when it finishes. Requires Claude Code v2.1.287 or later. To check on the task or stop it in the meantime, type `/tasks` in the prompt box to open the agent map. A subagent keeps its place in the tree of agents there, and a command is listed below the agents with its latest output on its card. A command you move to the background this way is subject to the [time limit for background commands](</docs/en/tools-reference#time-limit-for-background-commands>).
+
+###
+
+
+
Monitor background processes
-Type `/tasks` in the prompt box to open the agent map, which lists the session’s background tasks, such as a dev server Claude left running as a background shell command. Click a task to open its card and stop it there. Requires Claude Code v2.1.277 or later.
+Type `/tasks` in the prompt box to open the agent map, which lists the session’s background tasks, such as a dev server Claude left running as a background shell command. Click a task to open its card, where you can stop it. Requires Claude Code v2.1.277 or later. For a background shell command, or a [monitor](</docs/en/tools-reference#monitor-tool>) that runs a command, the card also shows the command’s latest output and refreshes it while the command runs.
###
@@ -674,7 +697,18 @@
`mcp__ide__getDiagnostics`| Returns language-server diagnostics: the errors and warnings in VS Code’s Problems panel. Optionally scoped to one file.| Yes
`mcp__ide__executeCode`| Runs Python code in the active Jupyter notebook’s kernel. See confirmation flow below.| No
-**Jupyter execution always asks first.** `mcp__ide__executeCode` can’t run anything silently. On each call, the code is inserted as a new cell at the end of the active notebook, VS Code scrolls it into view, and a native Quick Pick asks you to **Execute** or **Cancel**. Cancelling, or dismissing the picker with `Esc`, returns an error to Claude and nothing runs. The tool also refuses outright when there’s no active notebook, when the Jupyter extension (`ms-toolsai.jupyter`) isn’t installed, or when the kernel isn’t Python.
+**Diagnostics in the chat panel.** In the chat panel, with Claude Code v2.1.285 or later, Claude reads VS Code’s Problems panel through a separate built-in server named `claude-vscode`. Claude can ask it for the current errors and warnings in one file, or in every file VS Code has diagnostics for. Hooks and permission rules see the chat panel’s diagnostics tool as `mcp__claude-vscode__getDiagnostics`. To cover diagnostics in both the CLI and the chat panel, name both `mcp__ide__getDiagnostics` and `mcp__claude-vscode__getDiagnostics` in your hook or rule. This `settings.json` example denies both tools:
+
+ {
+ "permissions": {
+ "deny": [
+ "mcp__ide__getDiagnostics",
+ "mcp__claude-vscode__getDiagnostics"
+ ]
+ }
+ }
+
+A `Read` deny rule covers neither tool, so block them by name with a [deny rule](</docs/en/permissions#mcp>) as the example does. **Jupyter execution always asks first.** `mcp__ide__executeCode` can’t run anything silently. On each call, the code is inserted as a new cell at the end of the active notebook, VS Code scrolls it into view, and a native Quick Pick asks you to **Execute** or **Cancel**. Cancelling, or dismissing the picker with `Esc`, returns an error to Claude and nothing runs. The tool also refuses outright when there’s no active notebook, when the Jupyter extension (`ms-toolsai.jupyter`) isn’t installed, or when the kernel isn’t Python.
The Quick Pick confirmation is separate from `PreToolUse` hooks. An allowlist entry for `mcp__ide__executeCode` lets Claude _propose_ running a cell; the Quick Pick inside VS Code is what lets it _actually_ run.
--- a/web-quickstart.md
+++ b/web-quickstart.md
@@ -65,7 +65,7 @@
Sign in with GitHub
-After you sign in, claude.ai/code prompts you to connect GitHub. Follow the prompt, and claude.ai/code sends you to GitHub’s authorization page. Approve the authorization request, and GitHub returns you to claude.ai/code. Cloud sessions work with existing GitHub repositories. To start a new project, [create an empty repository on GitHub](<https://github.com/new>) first.With this connection, a session can clone any public repository, but can work in a private repository only when the Claude GitHub App is installed on it. [Install the Claude GitHub App](<https://github.com/apps/claude/installations/new>) on each GitHub account or organization whose private repositories you want to use. On a GitHub organization, an organization owner may need to approve the installation. Installing it also enables [Auto-fix](</docs/en/claude-code-on-the-web#auto-fix-pull-requests>), which lets Claude respond to CI failures and review comments on pull requests in those repositories.If onboarding prompts you to install the Claude GitHub App at this point and you’d rather do it later, click **Skip**.
+After you sign in, claude.ai/code prompts you to connect GitHub. Follow the prompt, and claude.ai/code sends you to GitHub’s authorization page. Approve the authorization request, and GitHub returns you to claude.ai/code. Cloud sessions work with existing GitHub repositories. To start a new project, [create an empty repository on GitHub](<https://github.com/new>) first.With this connection, a session can clone any public repository, but can work in a private repository only when the Claude GitHub App is installed on it. [Install the Claude GitHub App](<https://github.com/apps/claude/installations/new>) on each GitHub account or organization whose private repositories you want to use. On a GitHub organization, an organization owner may need to approve the installation. Installing it also enables [Auto-fix](</docs/en/claude-code-on-the-web#auto-fix-pull-requests>), which lets Claude respond to CI failures and review comments on pull requests in those repositories.When you connect, Claude also links the GitHub accounts you own to your Claude organization, if they have the Claude GitHub App installed. On Team and Enterprise plans, admins see those accounts in the [connected GitHub accounts list](</docs/en/admin-setup#connected-github-accounts>).If onboarding prompts you to install the Claude GitHub App at this point and you’d rather do it later, click **Skip**.
3
--- a/worktrees.md
+++ b/worktrees.md
@@ -101,7 +101,7 @@
Apply the requested refactor across every affected file, then run the tests
and report the results.
-Each subagent gets a temporary worktree that Claude Code removes automatically when the subagent finishes without changes; a worktree with changes stays on disk until the periodic sweep below can remove it without losing work. Subagent worktrees use the same base branch as `--worktree`, so they branch from your repository’s default branch unless `worktree.baseRef` is set to `"head"`.
+Each subagent gets a temporary worktree that Claude Code removes automatically when the subagent finishes without changes; a worktree with changes stays on disk until the periodic sweep below can remove it without losing work. Subagent worktrees use the same base branch as `--worktree`, so they branch from your repository’s default branch unless `worktree.baseRef` is set to `"head"`. A subagent in its own worktree takes the instruction files it [starts with](</docs/en/sub-agents#what-loads-at-startup>) from your main conversation, not from its worktree. When that worktree is in the default location under `.claude/worktrees/`, the subagent also doesn’t load the `CLAUDE.md` file or `.claude/rules/` directory at the worktree’s root as it reads files there, even if those differ on the worktree’s branch.
###
@@ -138,7 +138,7 @@
* `"fresh"` (default): branch from the repository’s default branch on the remote, usually `main`, so the worktree starts from a clean tree matching the remote.
* `"head"`: branch from your current local `HEAD`, so the worktree carries your unpushed commits and feature-branch state. Use this when isolating subagents that need to operate on in-progress work. Inside a worktree, `"head"` resolves to that worktree’s `HEAD`, not the main checkout’s.
-You can’t set `worktree.baseRef` to a branch name. To start a worktree from a specific existing branch, create it with git directly. For a `"fresh"` base, Claude Code keeps `origin/HEAD` current: when the repository hasn’t been fetched in the last 24 hours, it fetches the default branch, capped at five seconds, and uses the locally cached ref if the fetch fails. If no remote is configured, or `origin/HEAD` isn’t cached locally and can’t be fetched, the worktree falls back to your current local `HEAD`. Before v2.1.208, a fresh worktree used whatever `origin/HEAD` was already cached locally. This example makes every new worktree branch from your current work:
+You can’t set `worktree.baseRef` to a branch name. To start a worktree from a specific existing branch, create it with git directly. For a `"fresh"` base, Claude Code keeps `origin/HEAD` current: when the repository hasn’t been fetched in the last 24 hours, it fetches the default branch, capped at five seconds, and uses the locally cached ref if the fetch fails. The fetch never waits for input in your terminal, so it also counts as failed when git or ssh would ask for a password, a key passphrase, or confirmation of a new SSH host. If no remote is configured, or `origin/HEAD` isn’t cached locally and can’t be fetched, the worktree falls back to your current local `HEAD`. Before v2.1.208, a fresh worktree used whatever `origin/HEAD` was already cached locally. This example makes every new worktree branch from your current work:
{
"worktree": {
@@ -162,7 +162,7 @@
* **gitlab.com** : fetches `merge-requests/<number>/head`
* **GitHub Enterprise, self-managed GitLab, or any other host** : tries `pull/<number>/head` first, then `merge-requests/<number>/head`
-Before v2.1.233, Claude Code accepted only `#<number>` and GitHub-style pull request URLs for `--worktree`, and always fetched `pull/<number>/head`.
+This fetch never waits for input in your terminal. If git or ssh would ask for a password, a key passphrase, or confirmation of a new SSH host, the fetch fails instead and Claude Code exits with an `Error creating worktree: Failed to fetch PR/MR #<number>` message. A key that `ssh-agent` holds still works, so load your key there and run `git fetch` once by hand to record a new host before you start. Before v2.1.233, Claude Code accepted only `#<number>` and GitHub-style pull request URLs for `--worktree`, and always fetched `pull/<number>/head`.
###