modified Orchestrate teams of Claude Code sessions View current →
--- a/agent-teams.md +++ b/agent-teams.md @@ -131,7 +131,7 @@ 3. [`CLAUDE_CODE_SUBAGENT_MODEL`](</docs/en/model-config#environment-variables>), when it’s set to anything other than `inherit`. 4. The lead’s current model. -[`CLAUDE_CODE_SUBAGENT_MODEL_FORCE`](</docs/en/sub-agents#choose-a-model>) applies to teammates as well as to subagents. Before v2.1.251, `CLAUDE_CODE_SUBAGENT_MODEL` came first in this order. +[`CLAUDE_CODE_SUBAGENT_MODEL_FORCE`](</docs/en/sub-agents#run-every-subagent-on-one-model>) applies to teammates as well as to subagents. Before v2.1.251, `CLAUDE_CODE_SUBAGENT_MODEL` came first in this order. `teammateDefaultModel` was removed in v2.1.234; Claude Code ignores a leftover value. Name the model in your prompt instead.
modified Claude Code changelog View current →
--- a/changelog.md +++ b/changelog.md @@ -1,4 +1,48 @@ 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.259 + +September 2, 2026 + + * Added `managedMcpServers` managed setting: organizations can provide HTTP/SSE MCP servers to every user (same entry shape as `.mcp.json`); entries that name a command to run are skipped + * Added `--permission-prompts none` for unattended headless hosts: anything that would prompt is denied automatically while the active permission mode (including auto mode) keeps deciding + * Added recognition of `glab mr create/merge/close/reopen/note/update` so GitLab merge requests show as `MR !N` in the collapsed tool summary and refresh the footer MR badge + * Added `--json` to `claude plugin validate` for a machine-readable validation report + * Fixed concurrent sessions silently reverting each other’s `~/.claude.json` changes — workspace trust no longer resets and MCP/project state is no longer lost when running many sessions at once + * Fixed a conversation whose thinking was rejected once being rejected again on every later turn + * Fixed Bash `Read()` deny rules not covering files given as option values (`--ignore-revs-file=.env`, `-f.env`, `@file`), `git diff`/`git grep` file operands, or `cd DIR && cat FILE` compounds; `grep -r`/`cp -r` over a directory holding a denied file now asks + * Fixed the prompt cache being invalidated when the OAuth token refreshed in sessions with telemetry disabled + * Fixed fullscreen mode showing a blank conversation after a long turn with hundreds of tool calls + * Fixed auto mode running a turn on a model it doesn’t support when a command or skill’s frontmatter `model:` named one; the turn now keeps the session model + * Fixed `CLAUDE_CODE_MAX_CONTEXT_TOKENS` being ignored for Vertex-style model IDs (`@YYYYMMDD` suffix) of model versions Claude Code doesn’t recognize + * Fixed the live output preview of a running shell command hiding its newest lines when an earlier line wrapped + * Fixed a background GitHub connection check that ran on every launch for claude.ai users; the result is now remembered across launches + * Fixed `--resume` failing (and `--continue` opening an empty conversation) when a saved session contains an attachment entry with no payload + * Fixed frontmatter `model:` on custom commands and skills being ignored in interactive sessions + * Fixed Artifact publishing failing once with an “unexpected parameter `note`” error in conversations continued from an older version + * Fixed managed `forceRemoteSettingsRefresh` being ignored at startup when a policy helper configured by MDM or the managed settings file had already run + * Fixed worktree isolation refusing hook-created worktrees on machines where `git rev-parse` fails with a message other than “not a git repository” + * Fixed OpenTelemetry metrics and events from cloud sessions missing the `user.email`, `organization.id`, and `user.account_uuid` attributes + * Fixed MCP servers that disconnect while their tools are being listed at startup showing as connected with no tools instead of reporting the error + * Fixed the file edit permission dialog sometimes showing a changed line cut short with no indication + * Fixed repository detection dropping a known repo identity after a transient git probe failure + * Fixed managed settings silently going unenforced when the managed-settings file, a drop-in, the MDM plist, or the HKLM value cannot be parsed: Claude Code now refuses to start and names the source + * Fixed Stop not actually stopping background agents and workflows in remote-control sessions: killed tasks now stay visible and re-stoppable until their processes exit + * Fixed resuming a workflow run while its previous stopped run was still exiting, which could run duplicate copies of its agents + * Fixed marketplace repo URLs on github.com with a trailing slash or dangling `?`/`#` producing an unusable `.git` clone URL + * Fixed blocking Stop hooks causing the turn after a block to lose the model’s reasoning from that turn and, on some models, miss the prompt cache + * Fixed remote (claude.ai) sessions taking 60 seconds to start a turn after a browser-hosted MCP server’s page had gone away + * Fixed worktree-isolated sessions refusing common Bash loops, xargs pipelines and launcher-wrapped commands that cannot reach the main checkout + * Improved terminal resize and first-render performance for long responses by reusing text measurements + * Improved `/workflows` agent detail: JSON outcomes are pretty-printed with syntax colors and real line breaks, and long outcomes fold behind an expand toggle + * Improved headless/SDK session start: the first turn begins up to 50 ms sooner when MCP servers finish connecting + * Improved `/install-github-app` to explain it is GitHub-only and point to the GitLab CI/CD docs when run inside a GitLab repository + * Improved nested background subagent results to be saved in the parent subagent’s transcript, so resumed subagents keep them and shared transcripts show the delivery + * Changed `allowedMcpServers` to govern only servers users add: a literal `managed-mcp.json` server your allowlist used to filter out now loads on upgrade; use `deniedMcpServers` to keep it off + * [VSCode] Added an Active quick filter and a status filter menu (Needs input, Working, Completed) to the session list sidebar + * Fixed remote and scheduled sessions doing nothing after a connector-tool permission prompt was approved while the session was paused ​
modified Environment variables View current →
--- a/env-vars.md +++ b/env-vars.md @@ -232,7 +232,7 @@ `CLAUDE_CODE_DISABLE_MOUSE`| Set to `1` to disable mouse tracking in [fullscreen rendering](</docs/en/fullscreen>). Keyboard scrolling with `PgUp` and `PgDn` still works. Use this to keep your terminal’s native copy-on-select behavior `CLAUDE_CODE_DISABLE_MOUSE_CLICKS`| Set to `1` to disable click, drag, and hover handling in [fullscreen rendering](</docs/en/fullscreen>) while keeping mouse-wheel scrolling. Use this when you want wheel scroll to work inside Claude Code but don’t want clicks to position the cursor, expand tool output, or open links. `CLAUDE_CODE_DISABLE_MOUSE` takes precedence when both are set. Requires Claude Code v2.1.195 or later `CLAUDE_CODE_DISABLE_MTLS_RELOAD_ON_STALE_CONNECTION`| Set to `1` to stop Claude Code from re-reading the [mTLS client certificate and key](</docs/en/network-config#mtls-authentication>) when an API request fails with a connection-level error, such as a connection reset or a TLS handshake error. With the reload disabled, Claude Code loads rotated files only when it next applies settings or at the next startup. Requires Claude Code v2.1.232 or later -`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`| Set to any non-empty value, such as `1`, to disable nonessential network traffic: auto-updates, telemetry, error reporting, the `/feedback` command, [Claude-drafted feedback](</docs/en/tools-reference#sendfeedback-tool-behavior>), release notes, [gateway model discovery](</docs/en/llm-gateway-connect#add-gateway-models-to-the-model-picker>) refreshes, and availability checks such as the [fast mode](</docs/en/fast-mode#use-fast-mode-behind-proxies-and-llm-gateways>) check. It also stops the [background runs of plugin `command` sources](</docs/en/plugin-marketplaces#when-claude-code-re-runs-the-command>), which are local commands rather than network traffic, because they can trigger dependency installs. **Setting it to`0` or `false` still disables this traffic**, unlike most on/off variables; unset the variable to allow it again. Also disables feature-flag fetching, which makes [Remote Control](</docs/en/remote-control#requirements>) and the other features that need feature-flag fetching unavailable. Official plugin marketplace auto-install isn’t covered; disable it with `CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL` +`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`| Set to any non-empty value, such as `1`, to disable nonessential network traffic: auto-updates, telemetry, error reporting, the `/feedback` command, [Claude-drafted feedback](</docs/en/tools-reference#sendfeedback-tool-behavior>), release notes, the [PR and MR status badge](</docs/en/interactive-mode#pr-review-status>) checks, [gateway model discovery](</docs/en/llm-gateway-connect#add-gateway-models-to-the-model-picker>) refreshes, and availability checks such as the [fast mode](</docs/en/fast-mode#use-fast-mode-behind-proxies-and-llm-gateways>) check. It also stops the [background runs of plugin `command` sources](</docs/en/plugin-marketplaces#when-claude-code-re-runs-the-command>), which are local commands rather than network traffic, because they can trigger dependency installs. **Setting it to`0` or `false` still disables this traffic**, unlike most on/off variables; unset the variable to allow it again. Also disables feature-flag fetching, which makes [Remote Control](</docs/en/remote-control#requirements>) and the other features that need feature-flag fetching unavailable. Official plugin marketplace auto-install isn’t covered; disable it with `CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL` `CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK`| Set to `1` to disable the non-streaming fallback when a streaming request fails mid-stream. Streaming errors propagate to the retry layer instead. Useful when a proxy or gateway causes the fallback to produce duplicate tool execution `CLAUDE_CODE_DISABLE_NOTIFICATION_PRESENCE_CHECK`| Set to `1` to send the `PushNotification` tool’s desktop notification even while you are typing in or focused on the terminal. By default the tool skips both the desktop notification and the [mobile push](</docs/en/remote-control#mobile-push-notifications>) when it detects recent keyboard activity or terminal focus. This variable disables only that local check, so the server can still suppress the mobile push when it detects that you are active. Requires Claude Code v2.1.193 or later `CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL`| Set to `1` to disable automatic registration of the official plugin marketplace. Claude Code reads the variable when it is about to register the marketplace, usually during a machine’s first interactive launch. If the variable is set at that point, Claude Code skips the registration permanently. Unsetting the variable later doesn’t undo the skip. Run `claude plugin marketplace add anthropics/claude-plugins-official` to register the marketplace at any time @@ -342,8 +342,8 @@ `CLAUDE_CODE_SKIP_PROMPT_HISTORY`| Set to `1` to skip writing prompt history and session transcripts to disk. Sessions started with this variable set do not appear in `--resume`, `--continue`, or up-arrow history. Useful for ephemeral scripted sessions `CLAUDE_CODE_SKIP_VERTEX_AUTH`| Skip Google authentication for Google Cloud’s Agent Platform (for example, when using an LLM gateway) `CLAUDE_CODE_STOP_HOOK_BLOCK_CAP`| Maximum number of consecutive times a [Stop](</docs/en/hooks#stop>) or [SubagentStop](</docs/en/hooks#subagentstop>) hook may block the turn from ending before Claude Code overrides it and ends the turn anyway (default: 8). Set to `0` to disable the cap. Raise this if your hook legitimately needs more iterations to resolve -`CLAUDE_CODE_SUBAGENT_MODEL`| The default model for [subagents](</docs/en/sub-agents#choose-a-model>), [agent team](</docs/en/agent-teams#specify-teammates-and-models>) teammates, and [workflow](</docs/en/workflows>) agents that aren’t assigned a model another way. Accepts an alias such as `haiku` or a full model name. Two sources take precedence over it: a model Claude passes when it spawns the agent, and a `model` field in the agent’s definition, including `inherit`. To change that, set [`CLAUDE_CODE_SUBAGENT_MODEL_FORCE`](</docs/en/sub-agents#choose-a-model>). See [Choose a model](</docs/en/sub-agents#choose-a-model>) for the full order. Setting it to `inherit` is the same as leaving it unset. Before v2.1.251, this variable overrode both the per-invocation model and the definition’s `model` field -`CLAUDE_CODE_SUBAGENT_MODEL_FORCE`| Set to `1` to force one model onto subagents, teammates, and workflow agents. [Choose a model](</docs/en/sub-agents#choose-a-model>) says which model that is. Requires Claude Code v2.1.257 or later +`CLAUDE_CODE_SUBAGENT_MODEL`| The default model for [subagents](</docs/en/sub-agents#choose-a-model>), [agent team](</docs/en/agent-teams#specify-teammates-and-models>) teammates, and [workflow](</docs/en/workflows>) agents that aren’t assigned a model another way. Accepts an alias such as `haiku` or a full model name. Two sources take precedence over it: a model Claude passes when it spawns the agent, and a `model` field in the agent’s definition, including `inherit`. To change that, set [`CLAUDE_CODE_SUBAGENT_MODEL_FORCE`](</docs/en/sub-agents#run-every-subagent-on-one-model>). See [Choose a model](</docs/en/sub-agents#choose-a-model>) for the full order. Setting it to `inherit` is the same as leaving it unset. Before v2.1.251, this variable overrode both the per-invocation model and the definition’s `model` field +`CLAUDE_CODE_SUBAGENT_MODEL_FORCE`| Set to `1` to force one model onto subagents, teammates, and workflow agents. [Run every subagent on one model](</docs/en/sub-agents#run-every-subagent-on-one-model>) says which model that is. Requires Claude Code v2.1.257 or later `CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL`| Set `5m` or `1h`, the only values Claude Code accepts, to choose the [prompt cache TTL](</docs/en/prompt-caching#cache-lifetime>) for requests outside the main conversation, such as [subagents](</docs/en/sub-agents>), workflows, and background work. Takes precedence over the `subagentPromptCacheTtl` setting and over `ENABLE_PROMPT_CACHING_1H`, and `FORCE_PROMPT_CACHING_5M` overrides it. The API bills 1-hour cache writes at a higher rate. Requires Claude Code v2.1.242 or later `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`| Set to `1` to strip credentials from subprocess environments (Bash tool, hooks, MCP stdio servers): Anthropic and cloud provider credentials, any other variable that Claude Code recognizes as a credential, and credentials embedded in package registry URLs. The parent Claude process keeps these credentials for API calls, but child processes cannot read them, reducing exposure to prompt injection attacks that attempt to exfiltrate secrets via shell expansion. On Linux, this also runs Bash subprocesses in an isolated PID namespace so they cannot read host process environments via `/proc`; as a side effect, `ps`, `pgrep`, and `kill` cannot see or signal host processes. `claude-code-action` sets this automatically when `allowed_non_write_users` is configured `CLAUDE_CODE_SYNC_PLUGIN_INSTALL`| Set to `1` in non-interactive mode (the `-p` flag) to wait for plugin installation to complete before the first query. Without this, plugins install in the background and may not be available on the first turn. Combine with `CLAUDE_CODE_SYNC_PLUGIN_INSTALL_TIMEOUT_MS` to bound the wait @@ -490,7 +490,6 @@ * Run [`claude import` or the `/import` command](</docs/en/cli-reference#cli-commands>) * 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 Code refresh the [PR review status badge](</docs/en/interactive-mode#pr-review-status>) less often while you’re idle; Claude Code refreshes it every 60 seconds instead * Get the [v2 MCP client runtime](</docs/en/mcp#mcp-client-runtimes>) and its protocol probe without setting `MCP_SDK_GENERATION` and `MCP_PROTOCOL_NEGOTIATION`; Claude Code uses the v1 runtime unless you set `MCP_SDK_GENERATION=v2`, and skips the probe 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
modified Interactive mode View current →
--- a/interactive-mode.md +++ b/interactive-mode.md @@ -696,14 +696,13 @@ * Red: changes requested * Gray: draft -The badge disappears once the pull request merges or closes. `Cmd+click` (macOS) or `Ctrl+click` (Windows/Linux) the link to open the pull request in your browser. How often Claude Code refreshes the status depends on your provider: - - * **Anthropic API with[feature-flag fetching](</docs/en/env-vars#features-that-need-feature-flag-fetching>) on**: about every 90 seconds while you’re active in the session, and less often while you’re idle, while your terminal is unfocused, or while Claude Code keeps finding no pull request for the branch - * **Amazon Bedrock, Google Cloud’s Agent Platform, Microsoft Foundry, Claude Platform on AWS, or feature-flag fetching off** : every 60 seconds - -On either schedule, Claude Code also refreshes as soon as a `git push`, or a `gh pr` command that changes the pull request such as `gh pr create` or `gh pr merge`, succeeds in the session. After an hour without input from you, Claude Code stops refreshing, and your next prompt starts it again. Claude Code renders the badge as a hyperlink even when it can’t detect hyperlink support in your terminal, which commonly happens over SSH or in tmux. Set [`FORCE_HYPERLINK=0`](</docs/en/env-vars>) to render the badge as plain text. - -PR status for GitHub repositories requires the `gh` CLI to be installed and authenticated with `gh auth login`. +The badge disappears once the pull request merges or closes. `Cmd+click` (macOS) or `Ctrl+click` (Windows/Linux) the link to open the pull request in your browser. The status refreshes as soon as a `git push`, or a `gh pr` command that changes the pull request, such as `gh pr create` or `gh pr merge`, succeeds in the session. Claude Code renders the badge as a hyperlink even when it can’t detect hyperlink support in your terminal, which commonly happens over SSH or in tmux. Set [`FORCE_HYPERLINK=0`](</docs/en/env-vars>) to render the badge as plain text. When you set [`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`](</docs/en/env-vars>), Claude Code doesn’t check pull request or merge request status. + +PR status for GitHub repositories needs a GitHub token. Claude Code finds one based on the remote’s host: + + * **github.com** : `GH_TOKEN` or `GITHUB_TOKEN`, or the token saved by `gh auth login`. Without one, the footer shows `install gh for PR status` when the `gh` CLI isn’t installed, or `gh auth login for PR status` when it is + * **A GitHub Enterprise host set as`GH_HOST`**: `GH_ENTERPRISE_TOKEN` or `GITHUB_ENTERPRISE_TOKEN`, or the token saved by `gh auth login --hostname <host>`. Without one, the footer shows the same hints + * **Any other GitHub host** : the token saved by `gh auth login --hostname <host>`. Without one, Claude Code shows no badge and no hint ### @@ -717,7 +716,7 @@ * Yellow: any other open state * Gray: draft -The badge disappears once the merge request merges or closes. Claude Code checks merge request status on the same schedule as the GitHub badge, and refreshes as soon as a `glab mr create` or `git push` succeeds in the session. To get the badge, you need: +The badge disappears once the merge request merges or closes. It refreshes as soon as a `glab mr create` or `git push` succeeds in the session. To get the badge, you need: * Claude Code v2.1.234 or later * A repository remote that points at your GitLab host, either gitlab.com or a self-managed instance
modified Model configuration View current →
--- a/model-config.md +++ b/model-config.md @@ -672,7 +672,7 @@ `ANTHROPIC_DEFAULT_OPUS_MODEL`| The model to use for `opus`, or for `opusplan` when Plan Mode is active. `ANTHROPIC_DEFAULT_SONNET_MODEL`| The model to use for `sonnet`, or for `opusplan` when Plan Mode is not active. `ANTHROPIC_DEFAULT_HAIKU_MODEL`| The model to use for `haiku`, or [background functionality](</docs/en/costs#background-token-usage>) -`CLAUDE_CODE_SUBAGENT_MODEL`| The default model for [subagents](</docs/en/sub-agents#choose-a-model>), [agent team](</docs/en/agent-teams#specify-teammates-and-models>) teammates, and [workflow](</docs/en/workflows>) agents that aren’t assigned a model another way. Accepts an alias such as `haiku` or a full model name. A per-invocation model or a definition’s `model` field, including `inherit`, takes precedence. To change that, set [`CLAUDE_CODE_SUBAGENT_MODEL_FORCE`](</docs/en/sub-agents#choose-a-model>) +`CLAUDE_CODE_SUBAGENT_MODEL`| The default model for [subagents](</docs/en/sub-agents#choose-a-model>), [agent team](</docs/en/agent-teams#specify-teammates-and-models>) teammates, and [workflow](</docs/en/workflows>) agents that aren’t assigned a model another way. Accepts an alias such as `haiku` or a full model name. A per-invocation model or a definition’s `model` field, including `inherit`, takes precedence. To change that, set [`CLAUDE_CODE_SUBAGENT_MODEL_FORCE`](</docs/en/sub-agents#run-every-subagent-on-one-model>) Note: `ANTHROPIC_SMALL_FAST_MODEL` is deprecated in favor of `ANTHROPIC_DEFAULT_HAIKU_MODEL`.
modified Plugins reference View current →
--- a/plugins-reference.md +++ b/plugins-reference.md @@ -1145,6 +1145,38 @@ ​ +plugin validate + +Check a plugin or a marketplace for syntax and schema errors before publishing. The command exits 0 when validation passes, 1 when it fails, and 2 when the validation run itself fails, such as when the path you pass is unreadable. + + claude plugin validate <path> [options] + +**Arguments:** + + * `<path>`: Path to a plugin directory or a marketplace directory. See [Validate a plugin or a directory without a manifest](</docs/en/plugin-marketplaces#validate-a-plugin-or-a-directory-without-a-manifest>) for which files a plugin run covers. + +**Options:** + +Option| Description| Default +---|---|--- +`--strict`| Treat warnings as errors and exit 1 on them. Use in CI to catch issues the runtime tolerates, such as unrecognized fields| +`--json`| Output the validation report as one JSON object with the same exit codes. Requires Claude Code v2.1.259 or later| +`-h, --help`| Display help for command| + +With `--json`, Claude Code writes the report to stdout as one JSON object with these top-level fields: + + * `success`: the same verdict the exit code gives + * `strict`: whether the run treated warnings as errors + * `target`: the resolved path Claude Code validated + * `manifest`: the manifest’s own result, or `null` for a [run without a manifest](</docs/en/plugin-marketplaces#validate-a-plugin-or-a-directory-without-a-manifest>) + * `contents`: per-file results, each naming its `file` and carrying `errors`, `warnings`, and `notes` arrays + +On exit 2, the command writes nothing to stdout; the error message goes to stderr. Within an interactive session, `/plugin validate <path>` runs the same checks inline. + +### + +​ + plugin tag Create a release git tag for a plugin. By default the command tags the plugin in the current directory; pass a path to tag a plugin elsewhere. See [Tag plugin releases](</docs/en/plugin-dependencies#tag-plugin-releases-for-version-resolution>).
modified How Claude Code uses prompt caching View current →
--- a/prompt-caching.md +++ b/prompt-caching.md @@ -57,6 +57,7 @@ * Enabling or disabling a plugin * Denying an entire tool * Compacting the conversation + * Accumulating many images * Upgrading Claude Code ### @@ -170,6 +171,14 @@ [Compaction](</docs/en/context-window#what-survives-compaction>) replaces your message history with a summary. By design, this invalidates the conversation layer, since the next request has a new, shorter history that doesn’t share a prefix with the old one. Claude Code reuses the system prompt layer and reloads project context from disk, which cache-hits only if CLAUDE.md and memory are unchanged since the session started. To produce the summary, Claude Code sends a separate request with the same system prompt, tools, and history as your conversation, plus a summarization instruction appended as a final user message. While the cache is warm, that request reads your prefix from the cache, so a mid-session `/compact` costs a fraction of what the context size suggests and spends most of its time generating the summary. After a break longer than the cache lifetime, there is no cache left to read, so the summarization request reprocesses the full history as uncached input. This is why `/compact` costs the most when you [resume an old session](</docs/en/sessions#resume-from-a-summary>). In both the warm and cold cases, the turn after compaction rebuilds the conversation cache for only the much shorter summary, so that turn is not the slow part. Compaction works in your favor when the context you discard is content you no longer need. To choose when its overhead happens, run `/compact` at a natural break in your work, such as between tasks, instead of waiting for auto-compaction to trigger mid-task. If you’ve gone down a path you want to abandon entirely, `/rewind` to an earlier turn instead. Rewinding truncates back to a prefix that is already cached, rather than building a new one as compaction does. + +### + +​ + +Accumulating many images + +The API limits how many images and PDFs each request can carry. For the current numbers, see [Request limits](<https://platform.claude.com/docs/en/build-with-claude/vision#request-limits>) in the API docs. Claude Code also caps the total size of the images and PDFs in a request, so large screenshots reach the limit with fewer images than small ones. When the next request would pass either limit, Claude Code removes a batch of the oldest images and PDFs from what it sends, which leaves room for more before it needs to remove any again. Claude can no longer see the removed images. If Claude needs one of them again, share it again. Removing images changes the messages that held them, so the next request reprocesses the conversation from the earliest of those messages onward. Because Claude Code removes a batch at a time, you see one slower turn per batch rather than one with each new screenshot. ### @@ -333,7 +342,11 @@ Subagents and the cache -A [subagent](</docs/en/sub-agents>) starts its own conversation with its own system prompt and tool set, separate from the parent’s. Its first request doesn’t read the parent’s cache, because the two prefixes differ, and it warms a cache of its own across its turns. Subagents fall outside the main-conversation TTL bucket, so they get five minutes even on a subscription until you choose a longer one. The parent’s cache is unaffected. From the parent’s side, the subagent’s call and result append to the conversation, leaving the parent’s prefix intact. A [fork](</docs/en/sub-agents#fork-the-current-conversation>), by contrast, inherits the parent’s system prompt, tools, and conversation history exactly, so its first request reads the parent’s cache. The compaction summarization call described in Compacting the conversation uses the same prefix-sharing approach. In a [workflow fan-out](</docs/en/workflows#prompt-caching-in-a-fan-out>) of same-prefix agents, Claude Code briefly holds all but the first so their first requests can read the prefix the first agent cached. +A [subagent](</docs/en/sub-agents>) starts its own conversation with its own system prompt and tool set, separate from the parent’s. Its first request doesn’t read the parent’s cache, because the two prefixes differ, and it warms a cache of its own across its turns. Subagents fall outside the main-conversation TTL bucket, so they get five minutes even on a subscription until you choose a longer one. The parent’s cache is unaffected. From the parent’s side, the subagent’s call and result append to the conversation, leaving the parent’s prefix intact. A [fork](</docs/en/sub-agents#fork-the-current-conversation>), by contrast, inherits the parent’s system prompt, tools, and conversation history exactly, so its first request reads the parent’s cache. Other requests can also read a prefix that an earlier request cached: + + * **Session copies** : a session you [copy with `/fork`](</docs/en/agent-view#copy-the-session-with-%2Ffork>) receives its isolation instruction as a message at the end of the copied conversation, so the cache that the original conversation built stays intact. + * **Compaction** : the summarization call described in Compacting the conversation uses the same prefix-sharing approach. + * **Workflow fan-outs** : in a [workflow fan-out](</docs/en/workflows#prompt-caching-in-a-fan-out>) of same-prefix agents, Claude Code holds all but the first for up to 5 seconds by default, so their first requests can read the prefix that the first agent cached. ##
modified Deploy self-hosted environments to production View current →
--- a/self-hosted-environments-deploy.md +++ b/self-hosted-environments-deploy.md @@ -460,7 +460,7 @@ Some sessions don’t count as idle -A session holding a background task that never finishes doesn’t count as idle, so `--release-idle-session-min` won’t release that session’s slot. A session that’s waiting on an approval requested from inside a running tool call also doesn’t count as idle. Always set `--kill-session-after-min` alongside it as a hard backstop so no session can hold a slot indefinitely. +A session holding a background task that never finishes doesn’t count as idle, so `--release-idle-session-min` won’t release that session’s slot. A session that’s waiting on an approval requested from inside a running tool call also doesn’t count as idle. Always set `--kill-session-after-min` alongside it as a hard backstop so no session can hold a slot indefinitely. `--kill-session-after-min` is a backstop for runaway sessions. The runner terminates any session that reaches the limit, even one someone is still using, so set the flag well above your longest expected session, such as `--kill-session-after-min 480` for 8 hours. To free slots from conversations that go idle, use `--release-idle-session-min` instead. ###
modified Self-hosted environments reference View current →
--- a/self-hosted-environments-reference.md +++ b/self-hosted-environments-reference.md @@ -29,7 +29,7 @@ `--git-ssh-rewrite <host>`| none| unset| Rewrite `https://<host>/...` source URLs to `git@<host>:...` before cloning, for SSH-only git hosts. Repeatable; flag only. `--health-port <port>`| `SELF_HOSTED_RUNNER_HEALTH_PORT`| `8080`| Port for the `/healthz` and `/metrics` listener. Set `0` to disable. `--hooks-dir <path>`| `SELF_HOSTED_RUNNER_HOOKS_DIR`| unset| Directory of lifecycle hook scripts. See [Lifecycle hooks](</docs/en/self-hosted-environments-configuration#lifecycle-hooks>). -`--kill-session-after-min <n>`| `SELF_HOSTED_RUNNER_MAX_LIFETIME_MS`| `0`| Terminate a session child once it has lived N minutes wall-clock, as a safety limit for stuck sessions. The runner terminates the session’s process tree, including any commands the session left running. The runner defers a kill that falls mid-turn until the turn finishes, for at most the `SELF_HOSTED_RUNNER_MAX_LIFETIME_GRACE_MS` window. `0` disables. +`--kill-session-after-min <n>`| `SELF_HOSTED_RUNNER_MAX_LIFETIME_MS`| `0`| Terminate a session child once it has lived N minutes wall-clock, as a safety limit for stuck sessions. The runner terminates the session’s process tree, including any commands the session left running. The runner defers a kill that falls mid-turn until the turn finishes, for at most the `SELF_HOSTED_RUNNER_MAX_LIFETIME_GRACE_MS` window. To choose a value, see [Some sessions don’t count as idle](</docs/en/self-hosted-environments-deploy#some-sessions-don%E2%80%99t-count-as-idle>). `0` disables. `--lock-to-account <id>`| `SELF_HOSTED_RUNNER_LOCK_TO_ACCOUNT`| unset| Pre-lock the runner to a specific account at startup instead of locking on first session. Accepts an email address or `user_...` ID in the environment’s organization. A pre-locked runner never picks up Claude Tag channel sessions, which have no account. `--log-file <path>`| `SELF_HOSTED_RUNNER_LOG_FILE`| unset| Mirror runner logs to a file in addition to stdout and stderr, created with `0600` permissions. Required for `self-hosted-runner doctor` to tail logs locally. `--log-level <level>`| none| `info`| `info` or `debug`
modified Claude Code settings reference View current →
--- a/settings-reference.md +++ b/settings-reference.md @@ -3505,11 +3505,11 @@ `prUrlTemplate` -Point the PR links Claude Code renders, in the footer badge and in tool-result summaries, at an internal code-review tool instead of `github.com`. Claude Code substitutes `{host}`, `{owner}`, `{repo}`, `{number}`, and `{url}` from the `gh`-reported PR URL. The [GitLab merge request badge](</docs/en/interactive-mode#gitlab-merge-requests>) keeps its GitLab URL. +Point the PR links Claude Code renders, in the footer badge and in tool-result summaries, at an internal code-review tool instead of `github.com`. Claude Code substitutes `{host}`, `{owner}`, `{repo}`, `{number}`, and `{url}` from the PR URL. The [GitLab merge request badge](</docs/en/interactive-mode#gitlab-merge-requests>) keeps its GitLab URL. * **Scope** : `Any file` * **Type** : string, a URL template using any of the five placeholders - * **Default** : unset, so links use the `gh`-reported URL + * **Default** : unset settings.json
modified Create custom subagents View current →
--- a/sub-agents.md +++ b/sub-agents.md @@ -30,7 +30,7 @@ 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 force `CLAUDE_CODE_SUBAGENT_MODEL` onto it + * **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 * **Tools** : read-only tools; Write and Edit are denied * **Purpose** : file discovery, code search, codebase exploration @@ -38,7 +38,7 @@ 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. - * **Model** : inherits from the main conversation, unless you force `CLAUDE_CODE_SUBAGENT_MODEL` onto it + * **Model** : inherits from the main conversation, unless you set `CLAUDE_CODE_SUBAGENT_MODEL` and force it onto every subagent * **Tools** : read-only tools; Write and Edit are denied * **Purpose** : codebase research for planning @@ -46,7 +46,7 @@ A capable agent for complex, multi-step tasks that require both exploration and action. - * **Model** : the `CLAUDE_CODE_SUBAGENT_MODEL` model if you set one and nothing assigns a model another way, otherwise the main conversation’s model; Choose a model states the full order and how to force the variable onto subagents + * **Model** : the `CLAUDE_CODE_SUBAGENT_MODEL` model if you set one and nothing assigns a model another way, otherwise the main conversation’s model; Choose a model states the full order, and Run every subagent on one model shows how to make the variable override those sources * **Tools** : every tool available to subagents * **Purpose** : complex research, multi-step operations, code modifications @@ -295,12 +295,39 @@ 3. The [`CLAUDE_CODE_SUBAGENT_MODEL`](</docs/en/model-config#environment-variables>) environment variable, when you set it to a model alias or model ID 4. The main conversation’s model -Setting `CLAUDE_CODE_SUBAGENT_MODEL` by itself doesn’t change the model the built-in Explore and Plan subagents run on. Before v2.1.251, `CLAUDE_CODE_SUBAGENT_MODEL` came first in this order and overrode both the per-invocation parameter and the frontmatter, including `model: inherit`. Setting the variable to `inherit` is the same as leaving it unset. Before v2.1.196, that value forced subagents onto the main conversation’s model and ignored the other sources. Set [`CLAUDE_CODE_SUBAGENT_MODEL_FORCE=1`](</docs/en/env-vars>) to run subagents, [teammates](</docs/en/agent-teams#specify-teammates-and-models>), and [workflow agents](</docs/en/workflows>) on `CLAUDE_CODE_SUBAGENT_MODEL` whatever model their definition or invocation names, the built-in Explore and Plan definitions included. A fork, and a [skill that runs in a subagent](</docs/en/skills#run-skills-in-a-subagent>) with `model: inherit`, still run on the main conversation’s model. When you haven’t set `CLAUDE_CODE_SUBAGENT_MODEL`, subagents, teammates, and workflow agents run on the main conversation’s model, and the built-in Explore subagent keeps its model cap. Requires Claude Code v2.1.257 or later. Claude Code checks the per-invocation parameter, frontmatter, and environment variable values against your organization’s [`availableModels`](</docs/en/model-config#restrict-model-selection>) allowlist. For a blocked value, it substitutes another model: +Setting `CLAUDE_CODE_SUBAGENT_MODEL` by itself doesn’t change the model the built-in Explore and Plan subagents run on. To change it, see Run every subagent on one model. Before v2.1.251, `CLAUDE_CODE_SUBAGENT_MODEL` came first in this order and overrode both the per-invocation parameter and the frontmatter, including `model: inherit`. Setting the variable to `inherit` is the same as leaving it unset. Before v2.1.196, that value forced subagents onto the main conversation’s model and ignored the other sources. Claude Code checks the per-invocation parameter, frontmatter, and environment variable values against your organization’s [`availableModels`](</docs/en/model-config#restrict-model-selection>) allowlist. For a blocked value, it substitutes another model: * When the blocked value is a family alias such as `opus`, Claude Code runs the subagent on the newest version of that family the allowlist permits, following the same [substitution rules and provider scope](</docs/en/model-config#restrict-model-selection>) as `/model`. Before v2.1.222, Claude Code ran the subagent on the inherited model for a blocked family alias as well. * For any other blocked value, on providers where that substitution doesn’t operate, or when the allowlist permits no version of the family, Claude Code runs the subagent on the inherited model instead. If you set `CLAUDE_CODE_SUBAGENT_MODEL`, Claude Code tries that model first, under these same rules. In interactive sessions, Claude Code shows a warning naming the requested model and the model the subagent runs on, for either substitution. To check which model a subagent is running on, run [`/tasks`](</docs/en/commands>). Claude Code names the model on the subagent’s row, and adds the [effort level](</docs/en/model-config#adjust-effort-level>) when the subagent’s definition, or the skill it forked from, sets `effort`. Requires Claude Code v2.1.242 or later. A per-invocation `model` parameter also applies when the subagent is resumed or sent a follow-up message, so the subagent stays on that model. Before v2.1.211, resuming dropped the per-invocation value and the subagent reverted to its definition’s `model` field or, without one, the main conversation’s model. As of v2.1.198, subagents also inherit the main conversation’s [extended thinking](</docs/en/model-config#extended-thinking>) configuration: if thinking is on in your session, it’s on for the subagent, and if it’s off, it stays off. There is no per-subagent thinking setting. Before v2.1.198, subagents ran with extended thinking disabled regardless of the main conversation’s setting. + +#### + +​ + +Run every subagent on one model + +`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. + +For example, to run every subagent on Haiku, set both variables in the `env` block of a [settings file](</docs/en/settings>): + + { + "env": { + "CLAUDE_CODE_SUBAGENT_MODEL": "haiku", + "CLAUDE_CODE_SUBAGENT_MODEL_FORCE": "1" + } + } + +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: + + * 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. ###