modified Changelog View current →
--- a/changelog.md +++ b/changelog.md @@ -1,4 +1,39 @@ 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.117 + +April 22, 2026 + + * Forked subagents can now be enabled on external builds by setting `CLAUDE_CODE_FORK_SUBAGENT=1` + * Agent frontmatter `mcpServers` are now loaded for main-thread agent sessions via `--agent` + * Improved `/model`: selections now persist across restarts even when the project pins a different model, and the startup header shows when the active model comes from a project or managed-settings pin + * The `/resume` command now offers to summarize stale, large sessions before re-reading them, matching the existing `--resume` behavior + * Faster startup when both local and claude.ai MCP servers are configured (concurrent connect now default) + * `plugin install` on an already-installed plugin now installs any missing dependencies instead of stopping at “already installed” + * Plugin dependency errors now say “not installed” with an install hint, and `claude plugin marketplace add` now auto-resolves missing dependencies from configured marketplaces + * Managed-settings `blockedMarketplaces` and `strictKnownMarketplaces` are now enforced on plugin install, update, refresh, and autoupdate + * Advisor Tool (experimental): dialog now carries an “experimental” label, learn-more link, and startup notification when enabled; sessions no longer get stuck with “Advisor tool result content could not be processed” errors on every prompt and `/compact` + * The `cleanupPeriodDays` retention sweep now also covers `~/.claude/tasks/`, `~/.claude/shell-snapshots/`, and `~/.claude/backups/` + * OpenTelemetry: `user_prompt` events now include `command_name` and `command_source` for slash commands; `cost.usage`, `token.usage`, `api_request`, and `api_error` now include an `effort` attribute when the model supports effort levels. Custom/MCP command names are redacted unless `OTEL_LOG_TOOL_DETAILS=1` is set + * Native builds on macOS and Linux: the `Glob` and `Grep` tools are replaced by embedded `bfs` and `ugrep` available through the Bash tool — faster searches without a separate tool round-trip (Windows and npm-installed builds unchanged) + * Windows: cached `where.exe` executable lookups per process for faster subprocess launches + * Default effort for Pro/Max subscribers on Opus 4.6 and Sonnet 4.6 is now `high` (was `medium`) + * Fixed Plain-CLI OAuth sessions dying with “Please run /login” when the access token expires mid-session — the token is now refreshed reactively on 401 + * Fixed `WebFetch` hanging on very large HTML pages by truncating input before HTML-to-markdown conversion + * Fixed a crash when a proxy returns HTTP 204 No Content — now surfaces a clear error instead of a `TypeError` + * Fixed `/login` having no effect when launched with `CLAUDE_CODE_OAUTH_TOKEN` env var and that token expires + * Fixed prompt-input undo (`Ctrl+_`) doing nothing immediately after typing, and skipping a state on each undo step + * Fixed `NO_PROXY` not being respected for remote API requests when running under Bun + * Fixed rare spurious escape/return triggers when key names arrive as coalesced text over slow connections + * Fixed SDK `reload_plugins` reconnecting all user MCP servers serially + * Fixed Bedrock application-inference-profile requests failing with 400 when backed by Opus 4.7 with thinking disabled + * Fixed MCP `elicitation/create` requests auto-cancelling in print/SDK mode when the server finishes connecting mid-turn + * Fixed subagents running a different model than the main agent incorrectly flagging file reads with a malware warning + * Fixed idle re-render loop when background tasks are present, reducing memory growth on Linux + * [VSCode] Fixed “Manage Plugins” panel breaking when multiple large marketplaces are configured + * Fixed Opus 4.7 sessions showing inflated `/context` percentages and autocompacting too early — Claude Code was computing against a 200K context window instead of Opus 4.7’s native 1M ​
modified Explore the .claude directory View current →
--- a/claude-directory.md +++ b/claude-directory.md @@ -85,45 +85,7 @@ Troubleshoot configuration -If a setting, hook, or file isn’t taking effect, scan the symptoms below. - -Symptom| Cause| Fix ----|---|--- -Hook never fires| `matcher` is a JSON array instead of a string| Use a single string with `|` to match multiple tools, for example `"Edit|Write"`. See [matcher patterns](</docs/en/hooks#matcher-patterns>). -Hook never fires| `matcher` value is lowercase, for example `"bash"`| Matching is case-sensitive. Tool names are capitalized: `Bash`, `Edit`, `Write`, `Read`. -Hook never fires| Hooks are in a standalone `.claude/hooks.json` file| There is no standalone hooks file. Define hooks under the `"hooks"` key in `settings.json`. See [hook configuration](</docs/en/hooks>). -Permissions, hooks, or env set globally are ignored| Configuration was added to `~/.claude.json`| `~/.claude.json` holds app state and UI toggles. `permissions`, `hooks`, and `env` belong in `~/.claude/settings.json`. These are two different files. -A `settings.json` value seems ignored| The same key is set in `settings.local.json`| `settings.local.json` overrides `settings.json`, and both override `~/.claude/settings.json`. See [settings precedence](</docs/en/settings#settings-precedence>). -Skill doesn’t appear in `/skills`| Skill file is at `.claude/skills/name.md` instead of in a folder| Use a folder with `SKILL.md` inside: `.claude/skills/name/SKILL.md`. -Subdirectory `CLAUDE.md` instructions seem ignored| Subdirectory files load on demand, not at session start| They load when Claude reads a file in that directory with the Read tool, not at launch and not when writing or creating files there. See [how CLAUDE.md files load](</docs/en/memory#how-claude-md-files-load>). -Subagent ignores `CLAUDE.md` instructions| Subagents don’t always inherit project memory| Put critical rules in the agent file body, which becomes the subagent’s system prompt. See [subagent configuration](</docs/en/sub-agents>). -Cleanup logic never runs at session end| No `SessionEnd` hook configured| `SessionStart` and `SessionEnd` both exist. See the [hook events list](</docs/en/hooks#hook-events>). -MCP servers in `.mcp.json` never load| File is under `.claude/` or uses Claude Desktop’s config format| Project MCP config lives at the repository root as `.mcp.json`, not inside `.claude/`. See [MCP configuration](</docs/en/mcp>). -Project MCP server added but doesn’t appear| The one-time approval prompt was dismissed| Project-scoped servers require approval. Run `/mcp` to see status and approve. -MCP server fails to start from some directories| `command` or `args` uses a relative file path| Use absolute paths for local scripts. Executables on your `PATH` like `npx` or `uvx` work as-is. -MCP server starts without expected environment variables| Variables are in `settings.json` `env`, which doesn’t propagate to MCP child processes| Set per-server `env` inside `.mcp.json` instead. -`Bash(rm *)` deny rule doesn’t block `/bin/rm` or `find -delete`| Prefix rules match the literal command string, not the underlying executable| Add explicit patterns for each variant, or use a [PreToolUse hook](</docs/en/hooks-guide>) or the [sandbox](</docs/en/sandboxing>) for a hard guarantee. - -## - -​ - -Check what loaded - -The explorer shows what files can exist. To see what actually loaded in your current session, use these commands: - -Command| Shows ----|--- -`/context`| Token usage by category: system prompt, memory files, skills, MCP tools, and messages -`/memory`| Which CLAUDE.md and rules files loaded, plus auto-memory entries -`/agents`| Configured subagents and their settings -`/hooks`| Active hook configurations -`/mcp`| Connected MCP servers and their status -`/skills`| Available skills from project, user, and plugin sources -`/permissions`| Current allow and deny rules -`/doctor`| Installation and configuration diagnostics - -Run `/context` first for the overview, then the specific command for the area you want to investigate. +If a setting, hook, or file isn’t taking effect, see [Debug your configuration](</docs/en/debug-your-config>) for the inspection commands and a symptom-first lookup table. ##
modified Common workflows View current →
--- a/common-workflows.md +++ b/common-workflows.md @@ -498,7 +498,7 @@ Use extended thinking (thinking mode) -[Extended thinking](<https://platform.claude.com/docs/en/build-with-claude/extended-thinking>) is enabled by default, giving Claude space to reason through complex problems step-by-step before responding. This reasoning is visible in verbose mode, which you can toggle on with `Ctrl+O`. During extended thinking, progress hints appear below the indicator to show that Claude is actively working. Additionally, [models that support effort](</docs/en/model-config#adjust-effort-level>) use adaptive reasoning: instead of a fixed thinking token budget, the model dynamically decides whether and how much to think based on your effort level setting and the task at hand. Adaptive reasoning lets Claude respond faster to routine prompts and reserve deeper thinking for steps that benefit from it. Extended thinking is particularly valuable for complex architectural decisions, challenging bugs, multi-step implementation planning, and evaluating tradeoffs between different approaches. +[Extended thinking](<https://platform.claude.com/docs/en/build-with-claude/extended-thinking>) is enabled by default, giving Claude space to reason through complex problems step-by-step before responding. This reasoning is visible in verbose mode, which you can toggle on with `Ctrl+O`. During extended thinking, the spinner shows inline progress hints such as “still thinking” and “almost done thinking” to indicate Claude is actively working. Additionally, [models that support effort](</docs/en/model-config#adjust-effort-level>) use adaptive reasoning: instead of a fixed thinking token budget, the model dynamically decides whether and how much to think based on your effort level setting and the task at hand. Adaptive reasoning lets Claude respond faster to routine prompts and reserve deeper thinking for steps that benefit from it. Extended thinking is particularly valuable for complex architectural decisions, challenging bugs, multi-step implementation planning, and evaluating tradeoffs between different approaches. Phrases like “think”, “think hard”, and “think more” are interpreted as regular prompt instructions and don’t allocate thinking tokens.
modified Data usage View current →
--- a/data-usage.md +++ b/data-usage.md @@ -101,7 +101,7 @@ Default behaviors by API provider -By default, error reporting, telemetry, and bug reporting are disabled when using Bedrock, Vertex, or Foundry. Session quality surveys are the exception and appear regardless of provider. You can opt out of all non-essential traffic, including surveys, at once by setting `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`. Here are the full default behaviors: +By default, error reporting, telemetry, and bug reporting are disabled when using Bedrock, Vertex, or Foundry. Session quality surveys and the WebFetch domain safety check are exceptions and run regardless of provider. You can opt out of all non-essential traffic, including surveys, at once by setting `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`. This variable does not affect the WebFetch check, which has its own opt-out. Here are the full default behaviors: Service| Claude API| Vertex API| Bedrock API| Foundry API ---|---|---|---|--- @@ -125,5 +125,18 @@ `CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY=1` to disable.| Default on. `CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY=1` to disable.| Default on. `CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY=1` to disable. +**WebFetch domain safety check**| Default on. +`skipWebFetchPreflight: true` in [settings](</docs/en/settings>) to disable.| Default on. +`skipWebFetchPreflight: true` in [settings](</docs/en/settings>) to disable.| Default on. +`skipWebFetchPreflight: true` in [settings](</docs/en/settings>) to disable.| Default on. +`skipWebFetchPreflight: true` in [settings](</docs/en/settings>) to disable. All environment variables can be checked into `settings.json` (see [settings reference](</docs/en/settings>)). + +### + +​ + +WebFetch domain safety check + +Before fetching a URL, the WebFetch tool sends the requested hostname to `api.anthropic.com` to check it against a safety blocklist maintained by Anthropic. Only the hostname is sent, not the full URL, path, or page contents. Results are cached per hostname for five minutes. This check runs regardless of which model provider you use and is not affected by `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`. If your network blocks `api.anthropic.com`, WebFetch requests fail until you either allowlist the domain or set `skipWebFetchPreflight: true` in [settings](</docs/en/settings>). Disabling the check means WebFetch attempts to retrieve any URL without consulting the blocklist, so combine it with [`WebFetch` permission rules](</docs/en/permissions#webfetch>) if you need to restrict which domains Claude can reach.
added Debug your configuration View current →
--- a/debug-your-config.md +++ b/debug-your-config.md @@ -0,0 +1,94 @@ +When Claude ignores an instruction or a feature you configured doesn’t appear, the cause is usually that the file didn’t load, it loaded from a different location than you expected, or another file overrode it. This guide shows how to inspect what Claude Code actually loaded so you can narrow down which applies. For installation, authentication, and connectivity problems, see [Troubleshooting](</docs/en/troubleshooting>) instead. + +## + +​ + +See what loaded into context + +The `/context` command shows everything occupying the context window for the current session, broken down by category: system prompt, memory files, skills, MCP tools, and conversation messages. Run it first to confirm whether your `CLAUDE.md`, rules, or skill descriptions are present at all. For detail on a specific category, follow up with the dedicated command: + +Command| Shows +---|--- +`/memory`| Which `CLAUDE.md` and rules files loaded, plus auto-memory entries +`/skills`| Available skills from project, user, and plugin sources +`/agents`| Configured subagents and their settings +`/hooks`| Active hook configurations +`/mcp`| Connected MCP servers and their status +`/permissions`| Resolved allow and deny rules currently in effect +`/doctor`| Configuration diagnostics: invalid keys, schema errors, installation health +`/status`| Active settings sources, including whether managed settings are in effect + +If a memory file is missing from `/memory`, check its location against [how CLAUDE.md files load](</docs/en/memory#how-claude-md-files-load>). Subdirectory `CLAUDE.md` files load on demand when Claude reads a file in that directory with the Read tool, not at session start. If `/memory` confirms the file loaded but Claude still isn’t following a particular instruction, the issue is likely how the instruction is written rather than whether it loaded. CLAUDE.md works well for the kinds of guidance you’d give a new teammate, such as project conventions, build commands, and where files belong. Adherence drops when an instruction is vague enough to interpret multiple ways, when two files give conflicting direction, or when the file has grown long enough that individual rules get less attention. [Write effective instructions](</docs/en/memory#write-effective-instructions>) covers the specificity, size, and structure patterns that keep adherence high. + +CLAUDE.md and permissions solve different problems. CLAUDE.md tells Claude how your project works so it makes good decisions. [Permissions](</docs/en/permissions>) and [hooks](</docs/en/hooks>) enforce limits regardless of what Claude decides. Use CLAUDE.md for “we do it this way here.” Use permissions or hooks for security boundaries and anything that must never happen, where you need a guarantee instead of guidance. + +## + +​ + +Check resolved settings + +Settings merge across managed, user, project, and local scopes. Managed settings always win when present. Among the rest, the closer scope overrides the broader one in the order local, then project, then user. Some settings can also be set by command-line flags or [environment variables](</docs/en/env-vars>), which act as another override layer. When a setting doesn’t seem to apply, the value you set is usually being overridden by another scope or an environment variable. Run `/doctor` to validate your configuration files and surface invalid keys or schema errors. Run `/status` to see which settings sources are active, including whether managed settings are in effect. To understand which scope wins for a given key, see [How scopes interact](</docs/en/settings#how-scopes-interact>). + +## + +​ + +Check MCP servers + +Run `/mcp` to see every configured server, its connection status, and whether you have approved it for the current project. A server can be defined correctly but still not provide tools for a few common reasons: + + * Project-scoped servers in `.mcp.json` require a one-time approval. If the prompt was dismissed, the server stays disabled until you approve it from `/mcp`. + * A server that fails to start shows as failed in `/mcp`. Relative file paths in `command` or `args` are a frequent cause, since they resolve against the directory you launched Claude Code from rather than the location of `.mcp.json`. + * A server that shows as connected but lists zero tools has started successfully but isn’t returning a tool list. Select **Reconnect** from `/mcp`. If the count stays at zero, run `claude --debug mcp` to see the server’s stderr output. + +For configuration locations and scope rules, see [MCP](</docs/en/mcp>). + +## + +​ + +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. The `matcher` field is a single string that uses `|` to match multiple tool names, for example `"Edit|Write"`. A misspelled tool name fails silently because the matcher never matches. An array value is a schema error: Claude Code shows a settings error notice, `/doctor` reports the validation failure, and the hook entry is dropped so it won’t appear in `/hooks`. Edits to `settings.json` take effect in the running session after a brief file-stability delay. You don’t need to restart. If `/hooks` still shows the old definition a few seconds after saving, 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 hooks` 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. + +## + +​ + +Common causes + +Most configuration surprises trace back to a small set of location and syntax rules. Check these before assuming a bug: + +Symptom| Cause| Fix +---|---|--- +Hook never fires| `matcher` is a JSON array instead of a string| Use a single string with `|` to match multiple tools, for example `"Edit|Write"`. See [matcher patterns](</docs/en/hooks#matcher-patterns>). +Hook never fires| `matcher` value is lowercase, for example `"bash"`| Matching is case-sensitive. Tool names are capitalized: `Bash`, `Edit`, `Write`, `Read`. +Hook never fires| Hooks are in a standalone `.claude/hooks.json` file| There is no standalone hooks file. Define hooks under the `"hooks"` key in `settings.json`. See [hook configuration](</docs/en/hooks>). +Permissions, hooks, or env set globally are ignored| Configuration was added to `~/.claude.json`| `~/.claude.json` holds app state and UI toggles. `permissions`, `hooks`, and `env` belong in `~/.claude/settings.json`. These are two different files. +A `settings.json` value seems ignored| The same key is set in `settings.local.json`| `settings.local.json` overrides `settings.json`, and both override `~/.claude/settings.json`. See [settings precedence](</docs/en/settings#how-scopes-interact>). +Skill doesn’t appear in `/skills`| Skill file is at `.claude/skills/name.md` instead of in a folder| Use a folder with `SKILL.md` inside: `.claude/skills/name/SKILL.md`. +Skill appears in `/skills` but Claude never invokes it| Skill has `disable-model-invocation: true` in its frontmatter, or its description doesn’t match how you phrase the request| Check the badge in `/skills`: a “user-only” label means Claude won’t trigger it on its own. See [skill invocation](</docs/en/skills>). +Subdirectory `CLAUDE.md` instructions seem ignored| Subdirectory files load on demand, not at session start| They load when Claude reads a file in that directory with the Read tool, not at launch and not when writing or creating files there. See [how CLAUDE.md files load](</docs/en/memory#how-claude-md-files-load>). +Subagent ignores `CLAUDE.md` instructions| Subagents don’t always inherit project memory| Put critical rules in the agent file body, which becomes the subagent’s system prompt. See [subagent configuration](</docs/en/sub-agents>). +Cleanup logic never runs at session end| No `SessionEnd` hook configured| `SessionStart` and `SessionEnd` both exist. See the [hook events list](</docs/en/hooks#hook-events>). +MCP servers in `.mcp.json` never load| File is under `.claude/` or uses Claude Desktop’s config format| Project MCP config goes at the repository root as `.mcp.json`, not inside `.claude/`. See [MCP configuration](</docs/en/mcp>). +Project MCP server added but doesn’t appear| The one-time approval prompt was dismissed| Project-scoped servers require approval. Run `/mcp` to see status and approve. +MCP server fails to start from some directories| `command` or `args` uses a relative file path| Use absolute paths for local scripts. Executables on your `PATH` like `npx` or `uvx` work as-is. +MCP server starts without expected environment variables| Variables are in `settings.json` `env`, which doesn’t propagate to MCP child processes| Set per-server `env` inside `.mcp.json` instead. +`Bash(rm *)` deny rule doesn’t block `/bin/rm` or `find -delete`| Prefix rules match the literal command string, not the underlying executable| Add explicit patterns for each variant, or use a [PreToolUse hook](</docs/en/hooks-guide>) or the [sandbox](</docs/en/sandboxing>) for a hard guarantee. + +## + +​ + +Related resources + +For full reference on each configuration surface, see the dedicated page: + + * **[`.claude` directory reference](</docs/en/claude-directory>)**: every config file location and what reads it + * **[Settings](</docs/en/settings>)** : precedence order and the full key list + * **[Hooks reference](</docs/en/hooks>)** : event names, payloads, and `--debug hooks` output format + * **[MCP](</docs/en/mcp>)** : server configuration, approval, and `/mcp` output + * **[Troubleshooting](</docs/en/troubleshooting>)** : `claude doctor`, platform issues, and installation problems
modified Environment variables View current →
--- a/env-vars.md +++ b/env-vars.md @@ -120,6 +120,7 @@ `CLAUDE_CODE_SHELL`| Override automatic shell detection. Useful when your login shell differs from your preferred working shell (for example, `bash` vs `zsh`) `CLAUDE_CODE_SHELL_PREFIX`| Command prefix to wrap all bash commands (for example, for logging or auditing). Example: `/path/to/logger.sh` will execute `/path/to/logger.sh <command>` `CLAUDE_CODE_SIMPLE`| Set to `1` to run with a minimal system prompt and only the Bash, file read, and file edit tools. MCP tools from `--mcp-config` are still available. Disables auto-discovery of hooks, skills, plugins, MCP servers, auto memory, and CLAUDE.md. The [`--bare`](</docs/en/headless#start-faster-with-bare-mode>) CLI flag sets this +`CLAUDE_CODE_SIMPLE_SYSTEM_PROMPT`| Set to `1` to use the minimal system prompt and collapsed tool descriptions from `CLAUDE_CODE_SIMPLE` without the other simple-mode changes. The full tool set, hooks, MCP servers, and CLAUDE.md discovery remain enabled `CLAUDE_CODE_SKIP_BEDROCK_AUTH`| Skip AWS authentication for Bedrock (for example, when using an LLM gateway) `CLAUDE_CODE_SKIP_FOUNDRY_AUTH`| Skip Azure authentication for Microsoft Foundry (for example, when using an LLM gateway) `CLAUDE_CODE_SKIP_MANTLE_AUTH`| Skip AWS authentication for Bedrock Mantle (for example, when using an LLM gateway) @@ -185,9 +186,9 @@ `MCP_TIMEOUT`| Timeout in milliseconds for MCP server startup (default: 30000, or 30 seconds) `MCP_TOOL_TIMEOUT`| Timeout in milliseconds for MCP tool execution (default: 100000000, about 28 hours) `NO_PROXY`| List of domains and IPs to which requests will be directly issued, bypassing proxy -`OTEL_LOG_RAW_API_BODIES`| Set to `1` to emit the full Anthropic Messages API request and response JSON as OpenTelemetry log events (`api_request_body`, `api_response_body`). Disabled by default; bodies include the entire conversation history. See [Monitoring](</docs/en/monitoring-usage>) +`OTEL_LOG_RAW_API_BODIES`| Emit Anthropic Messages API request and response JSON as `api_request_body` / `api_response_body` log events. Set to `1` for inline bodies truncated at 60 KB, or `file:<dir>` to write untruncated bodies to disk and emit a `body_ref` path instead. Disabled by default; bodies include the entire conversation history. See [Monitoring](</docs/en/monitoring-usage#api-request-body-event>) `OTEL_LOG_TOOL_CONTENT`| Set to `1` to include tool input and output content in OpenTelemetry span events. Disabled by default to protect sensitive data. See [Monitoring](</docs/en/monitoring-usage>) -`OTEL_LOG_TOOL_DETAILS`| Set to `1` to include tool input arguments, MCP server names, and tool details in OpenTelemetry traces and logs. Disabled by default to protect PII. See [Monitoring](</docs/en/monitoring-usage>) +`OTEL_LOG_TOOL_DETAILS`| Set to `1` to include tool input arguments, MCP server names, raw error strings on tool failures, and other tool details in OpenTelemetry traces and logs. Disabled by default to protect PII. See [Monitoring](</docs/en/monitoring-usage>) `OTEL_LOG_USER_PROMPTS`| Set to `1` to include user prompt text in OpenTelemetry traces and logs. Disabled by default (prompts are redacted). See [Monitoring](</docs/en/monitoring-usage>) `OTEL_METRICS_INCLUDE_ACCOUNT_UUID`| Set to `false` to exclude account UUID from metrics attributes (default: included). See [Monitoring](</docs/en/monitoring-usage>) `OTEL_METRICS_INCLUDE_SESSION_ID`| Set to `false` to exclude session ID from metrics attributes (default: included). See [Monitoring](</docs/en/monitoring-usage>)
modified Hooks reference View current →
Show diff (144 lines)
--- a/hooks.md +++ b/hooks.md @@ -16,6 +16,7 @@ ---|--- `SessionStart`| When a session begins or resumes `UserPromptSubmit`| When you submit a prompt, before Claude processes it +`UserPromptExpansion`| When a user-typed command expands into a prompt, before it reaches Claude. Can block the expansion `PreToolUse`| Before a tool call executes. Can block it `PermissionRequest`| When a permission dialog appears `PermissionDenied`| When a tool call is denied by the auto mode classifier. Return `{retry: true}` to tell the model it may retry the denied tool call @@ -195,6 +196,7 @@ `FileChanged`| literal filenames to watch (see FileChanged)| `.envrc|.env` `StopFailure`| error type| `rate_limit`, `authentication_failed`, `billing_error`, `invalid_request`, `server_error`, `max_output_tokens`, `unknown` `InstructionsLoaded`| load reason| `session_start`, `nested_traversal`, `path_glob_match`, `include`, `compact` +`UserPromptExpansion`| command name| your skill or command names `Elicitation`| MCP server name| your configured MCP server names `ElicitationResult`| MCP server name| same values as `Elicitation` `UserPromptSubmit`, `Stop`, `TeammateIdle`, `TaskCreated`, `TaskCompleted`, `WorktreeCreate`, `WorktreeRemove`| no matcher support| always fires on every occurrence @@ -516,7 +518,7 @@ Exit code output -The exit code from your hook command tells Claude Code whether the action should proceed, be blocked, or be ignored. **Exit 0** means success. Claude Code parses stdout for JSON output fields. JSON output is only processed on exit 0. For most events, stdout is written to the debug log but not shown in the transcript. The exceptions are `UserPromptSubmit` and `SessionStart`, where stdout is added as context that Claude can see and act on. **Exit 2** means a blocking error. Claude Code ignores stdout and any JSON in it. Instead, stderr text is fed back to Claude as an error message. The effect depends on the event: `PreToolUse` blocks the tool call, `UserPromptSubmit` rejects the prompt, and so on. See exit code 2 behavior for the full list. **Any other exit code** is a non-blocking error for most hook events. The transcript shows a `<hook name> hook error` notice followed by the first line of stderr, so you can identify the cause without `--debug`. Execution continues and the full stderr is written to the debug log. For example, a hook command script that blocks dangerous Bash commands: +The exit code from your hook command tells Claude Code whether the action should proceed, be blocked, or be ignored. **Exit 0** means success. Claude Code parses stdout for JSON output fields. JSON output is only processed on exit 0. For most events, stdout is written to the debug log but not shown in the transcript. The exceptions are `UserPromptSubmit`, `UserPromptExpansion`, and `SessionStart`, where stdout is added as context that Claude can see and act on. **Exit 2** means a blocking error. Claude Code ignores stdout and any JSON in it. Instead, stderr text is fed back to Claude as an error message. The effect depends on the event: `PreToolUse` blocks the tool call, `UserPromptSubmit` rejects the prompt, and so on. See exit code 2 behavior for the full list. **Any other exit code** is a non-blocking error for most hook events. The transcript shows a `<hook name> hook error` notice followed by the first line of stderr, so you can identify the cause without `--debug`. Execution continues and the full stderr is written to the debug log. For example, a hook command script that blocks dangerous Bash commands: #!/bin/bash # Reads JSON input from stdin, checks the command @@ -544,6 +546,7 @@ `PreToolUse`| Yes| Blocks the tool call `PermissionRequest`| Yes| Denies the permission `UserPromptSubmit`| Yes| Blocks prompt processing and erases the prompt +`UserPromptExpansion`| Yes| Blocks the expansion `Stop`| Yes| Prevents Claude from stopping, continues the conversation `SubagentStop`| Yes| Prevents the subagent from stopping `TeammateIdle`| Yes| Prevents the teammate from going idle (teammate continues working) @@ -621,7 +624,7 @@ Events| Decision pattern| Key fields ---|---|--- -UserPromptSubmit, PostToolUse, PostToolUseFailure, Stop, SubagentStop, ConfigChange, PreCompact| Top-level `decision`| `decision: "block"`, `reason` +UserPromptSubmit, UserPromptExpansion, PostToolUse, PostToolUseFailure, Stop, SubagentStop, ConfigChange, PreCompact| Top-level `decision`| `decision: "block"`, `reason` TeammateIdle, TaskCreated, TaskCompleted| Exit code or `continue: false`| Exit code 2 blocks the action with stderr feedback. JSON `{"continue": false, "stopReason": "..."}` also stops the teammate entirely, matching `Stop` hook behavior PreToolUse| `hookSpecificOutput`| `permissionDecision` (allow/deny/ask/defer), `permissionDecisionReason` PermissionRequest| `hookSpecificOutput`| `decision.behavior` (allow/deny) @@ -639,7 +642,7 @@ * PermissionRequest -Used by `UserPromptSubmit`, `PostToolUse`, `PostToolUseFailure`, `Stop`, `SubagentStop`, `ConfigChange`, and `PreCompact`. The only value is `"block"`. To allow the action to proceed, omit `decision` from your JSON, or exit 0 without any JSON at all: +Used by `UserPromptSubmit`, `UserPromptExpansion`, `PostToolUse`, `PostToolUseFailure`, `Stop`, `SubagentStop`, `ConfigChange`, and `PreCompact`. The only value is `"block"`. To allow the action to proceed, omit `decision` from your JSON, or exit 0 without any JSON at all: { "decision": "block", @@ -869,6 +872,58 @@ } The JSON format isn’t required for simple use cases. To add context, you can print plain text to stdout with exit code 0. Use JSON when you need to block prompts or want more structured control. + +### + +​ + +UserPromptExpansion + +Runs when a user-typed slash command expands into a prompt before reaching Claude. Use this to block specific commands from direct invocation, inject context for a particular skill, or log which commands users invoke. For example, a hook matching `deploy` can block `/deploy` unless an approval file is present, or a hook matching a review skill can append the team’s review checklist as `additionalContext`. This event covers the path `PreToolUse` does not: a `PreToolUse` hook matching the `Skill` tool fires only when Claude calls the tool, but typing `/skillname` directly bypasses `PreToolUse`. `UserPromptExpansion` fires on that direct path. Matches on `command_name`. Leave the matcher empty to fire on every prompt-type slash command. + +#### + +​ + +UserPromptExpansion input + +In addition to the common input fields, UserPromptExpansion hooks receive `expansion_type`, `command_name`, `command_args`, `command_source`, and the original `prompt` string. The `expansion_type` field is `slash_command` for skill and custom commands, or `mcp_prompt` for MCP server prompts. + + { + "session_id": "abc123", + "transcript_path": "/Users/.../00893aaf.jsonl", + "cwd": "/Users/...", + "permission_mode": "default", + "hook_event_name": "UserPromptExpansion", + "expansion_type": "slash_command", + "command_name": "example-skill", + "command_args": "arg1 arg2", + "command_source": "plugin", + "prompt": "/example-skill arg1 arg2" + } + +#### + +​ + +UserPromptExpansion decision control + +`UserPromptExpansion` hooks can block the expansion or add context. All JSON output fields are available. + +Field| Description +---|--- +`decision`| `"block"` prevents the slash command from expanding. Omit to allow it to proceed +`reason`| Shown to the user when `decision` is `"block"` +`additionalContext`| String added to Claude’s context alongside the expanded prompt + + { + "decision": "block", + "reason": "This slash command is not available", + "hookSpecificOutput": { + "hookEventName": "UserPromptExpansion", + "additionalContext": "Additional context for this expansion" + } + } ### @@ -1774,7 +1829,7 @@ CwdChanged -Runs when the working directory changes during a session, for example when Claude executes a `cd` command. Use this to react to directory changes: reload environment variables, activate project-specific toolchains, or run setup scripts automatically. Pairs with FileChanged for tools like [direnv](<https://direnv.net/>) that manage per-directory environment. CwdChanged hooks have access to `CLAUDE_ENV_FILE`. Variables written to that file persist into subsequent Bash commands for the session, just as in SessionStart hooks. Only `type: "command"` hooks are supported. CwdChanged does not support matchers and fires on every directory change. +Runs when the working directory changes during a session, for example when Claude executes a `cd` command. Use this to react to directory changes: reload environment variables, activate project-specific toolchains, or run setup scripts automatically. Pairs with FileChanged for tools like [direnv](<https://direnv.net/>) that manage per-directory environment. CwdChanged hooks have access to `CLAUDE_ENV_FILE`. Variables written to that file persist into subsequent Bash commands for the session, just as in SessionStart hooks. CwdChanged does not support matchers and fires on every directory change. #### @@ -1818,7 +1873,7 @@ * **Build the watch list** : the value is split on `|` and each segment is registered as a literal filename in the working directory, so `".envrc|.env"` watches exactly those two files. Regex patterns are not useful here: a value like `^\.env` would watch a file literally named `^\.env`. * **Filter which hooks run** : when a watched file changes, the same value filters which hook groups run using the standard matcher rules against the changed file’s basename. -FileChanged hooks have access to `CLAUDE_ENV_FILE`. Variables written to that file persist into subsequent Bash commands for the session, just as in SessionStart hooks. Only `type: "command"` hooks are supported. +FileChanged hooks have access to `CLAUDE_ENV_FILE`. Variables written to that file persist into subsequent Bash commands for the session, just as in SessionStart hooks. #### @@ -2192,6 +2247,7 @@ * `SubagentStop` * `TaskCompleted` * `TaskCreated` + * `UserPromptExpansion` * `UserPromptSubmit` Events that support `command` and `http` hooks but not `prompt` or `agent`: @@ -2532,4 +2588,4 @@ [DEBUG] Executing hook command: <Your command> with timeout 600000ms [DEBUG] Hook command completed with status 0: <Your stdout> -For more granular hook matching details, set `CLAUDE_CODE_DEBUG_LOG_LEVEL=verbose` to see additional log lines such as hook matcher counts and query matching. For troubleshooting common issues like hooks not firing, infinite Stop hook loops, or configuration errors, see [Limitations and troubleshooting](</docs/en/hooks-guide#limitations-and-troubleshooting>) in the guide. +For more granular hook matching details, set `CLAUDE_CODE_DEBUG_LOG_LEVEL=verbose` to see additional log lines such as hook matcher counts and query matching. For troubleshooting common issues like hooks not firing, infinite Stop hook loops, or configuration errors, see [Limitations and troubleshooting](</docs/en/hooks-guide#limitations-and-troubleshooting>) in the guide. For a broader diagnostic walkthrough covering `/context`, `/doctor`, and settings precedence, see [Debug your config](</docs/en/debug-your-config>).
modified Automate workflows with hooks View current →
--- a/hooks-guide.md +++ b/hooks-guide.md @@ -401,6 +401,7 @@ ---|--- `SessionStart`| When a session begins or resumes `UserPromptSubmit`| When you submit a prompt, before Claude processes it +`UserPromptExpansion`| When a user-typed command expands into a prompt, before it reaches Claude. Can block the expansion `PreToolUse`| Before a tool call executes. Can block it `PermissionRequest`| When a permission dialog appears `PermissionDenied`| When a tool call is denied by the auto mode classifier. Return `{retry: true}` to tell the model it may retry the denied tool call @@ -481,7 +482,7 @@ The exit code determines what happens next: - * **Exit 0** : the action proceeds. For `UserPromptSubmit` and `SessionStart` hooks, anything you write to stdout is added to Claude’s context. + * **Exit 0** : the action proceeds. For `UserPromptSubmit`, `UserPromptExpansion`, and `SessionStart` hooks, anything you write to stdout is added to Claude’s context. * **Exit 2** : the action is blocked. Write a reason to stderr, and Claude receives it as feedback so it can adjust. * **Any other exit code** : the action proceeds. The transcript shows a `<hook name> hook error` notice followed by the first line of stderr; the full stderr goes to the [debug log](</docs/en/hooks#debug-hooks>). @@ -551,6 +552,7 @@ `Elicitation`| MCP server name| your configured MCP server names `ElicitationResult`| MCP server name| same values as `Elicitation` `FileChanged`| literal filenames to watch (see [FileChanged](</docs/en/hooks#filechanged>))| `.envrc|.env` +`UserPromptExpansion`| command name| your skill or command names `UserPromptSubmit`, `Stop`, `TeammateIdle`, `TaskCreated`, `TaskCompleted`, `WorktreeCreate`, `WorktreeRemove`, `CwdChanged`| no matcher support| always fires on every occurrence A few more examples showing matchers on different event types:
modified Interactive mode View current →
--- a/interactive-mode.md +++ b/interactive-mode.md @@ -353,7 +353,7 @@ When working on complex, multi-step work, Claude creates a task list to track progress. Tasks appear in the status area of your terminal with indicators showing what’s pending, in progress, or complete. - * Press `Ctrl+T` to toggle the task list view. The display shows up to 10 tasks at a time + * Press `Ctrl+T` to toggle the task list view. The display shows up to 5 tasks at a time * To see all tasks or clear them, ask Claude directly: “show me all tasks” or “clear all tasks” * Tasks persist across context compactions, helping Claude stay organized on larger projects * To share a task list across sessions, set `CLAUDE_CODE_TASK_LIST_ID` to use a named directory in `~/.claude/tasks/`: `CLAUDE_CODE_TASK_LIST_ID=my-project claude` @@ -364,7 +364,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. To turn automatic recaps off, open `/config` and disable **Session recap**. Session recap is on by default for every plan and provider. To override the `/config` toggle, set [`CLAUDE_CODE_ENABLE_AWAY_SUMMARY`](</docs/en/env-vars>) to `0` or `1`. 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. To turn automatic recaps off, open `/config` and disable **Session recap**. Session recap is on by default for every plan and provider. The recap is always skipped in non-interactive mode. ##
modified Connect Claude Code to tools via MCP View current →
--- a/mcp.md +++ b/mcp.md @@ -695,7 +695,7 @@ Configure MCP servers in Claude.ai -Add servers at [claude.ai/settings/connectors](<https://claude.ai/settings/connectors>). On Team and Enterprise plans, only admins can add servers. +Add servers at [claude.ai/customize/connectors](<https://claude.ai/customize/connectors>). On Team and Enterprise plans, only admins can add servers. 2
modified How Claude remembers your project View current →
--- a/memory.md +++ b/memory.md @@ -428,6 +428,7 @@ Related resources + * [Debug your configuration](</docs/en/debug-your-config>): diagnose why CLAUDE.md or settings aren’t taking effect * [Skills](</docs/en/skills>): package repeatable workflows that load on demand * [Settings](</docs/en/settings>): configure Claude Code behavior with settings files * [Subagent memory](</docs/en/sub-agents#enable-persistent-memory>): let subagents maintain their own auto memory
modified Monitoring View current →
Show diff (417 lines)
--- a/monitoring-usage.md +++ b/monitoring-usage.md @@ -85,7 +85,7 @@ `OTEL_LOG_USER_PROMPTS`| Enable logging of user prompt content (default: disabled)| `1` to enable `OTEL_LOG_TOOL_DETAILS`| Enable logging of tool parameters and input arguments in tool events and trace span attributes: Bash commands, MCP server and tool names, skill names, and tool input (default: disabled)| `1` to enable `OTEL_LOG_TOOL_CONTENT`| Enable logging of tool input and output content in span events (default: disabled). Requires tracing. Content is truncated at 60 KB| `1` to enable -`OTEL_LOG_RAW_API_BODIES`| Emit the full Anthropic Messages API request and response JSON as `api_request_body` / `api_response_body` log events (default: disabled). Bodies include the entire conversation history and are truncated at 60 KB. Enabling this implies consent to everything `OTEL_LOG_USER_PROMPTS`, `OTEL_LOG_TOOL_DETAILS`, and `OTEL_LOG_TOOL_CONTENT` would reveal| `1` to enable +`OTEL_LOG_RAW_API_BODIES`| Emit the full Anthropic Messages API request and response JSON as `api_request_body` / `api_response_body` log events (default: disabled). Bodies include the entire conversation history. Enabling this implies consent to everything `OTEL_LOG_USER_PROMPTS`, `OTEL_LOG_TOOL_DETAILS`, and `OTEL_LOG_TOOL_CONTENT` would reveal| `1` for inline bodies truncated at 60 KB, or `file:<dir>` for untruncated bodies on disk with a `body_ref` pointer in the event `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE`| Metrics temporality preference (default: `delta`). Set to `cumulative` if your backend expects cumulative temporality| `delta`, `cumulative` `CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MS`| Interval for refreshing dynamic headers (default: 1740000ms / 29 minutes)| `900000` @@ -122,6 +122,108 @@ `OTEL_TRACES_EXPORT_INTERVAL`| Span batch export interval in milliseconds (default: 5000)| `1000`, `10000` Spans redact user prompt text, tool input details, and tool content by default. Set `OTEL_LOG_USER_PROMPTS=1`, `OTEL_LOG_TOOL_DETAILS=1`, and `OTEL_LOG_TOOL_CONTENT=1` to include them. When tracing is active, Bash and PowerShell subprocesses automatically inherit a `TRACEPARENT` environment variable containing the W3C trace context of the active tool execution span. This lets any subprocess that reads `TRACEPARENT` parent its own spans under the same trace, enabling end-to-end distributed tracing through scripts and commands that Claude runs. In Agent SDK and non-interactive sessions started with `-p`, Claude Code also reads `TRACEPARENT` and `TRACESTATE` from its own environment when starting each interaction span. This lets an embedding process pass its active W3C trace context into the subprocess so Claude Code’s spans appear as children of the caller’s distributed trace. Interactive sessions ignore inbound `TRACEPARENT` to avoid accidentally inheriting ambient values from CI or container environments. + +#### + +​ + +Span hierarchy + +Each user prompt starts a `claude_code.interaction` root span. API calls, tool calls, and hook executions are recorded as its children. Tool spans have two child spans of their own: one for the time spent waiting on a permission decision and one for the execution itself. When the Task tool spawns a subagent, the subagent’s API and tool spans nest under the parent’s `claude_code.tool` span. + + claude_code.interaction + ├── claude_code.llm_request + ├── claude_code.hook (requires detailed beta tracing) + └── claude_code.tool + ├── claude_code.tool.blocked_on_user + ├── claude_code.tool.execution + └── (Task tool) subagent claude_code.llm_request / claude_code.tool spans + +In Agent SDK and `claude -p` sessions, `claude_code.interaction` itself becomes a child of the caller’s span when `TRACEPARENT` is set in the environment. + +#### + +​ + +Span attributes + +Every span carries the standard attributes plus a `span.type` attribute matching its name. The tables below list the additional attributes set on each span. The `llm_request`, `tool.execution`, and `hook` spans set OpenTelemetry status `ERROR` when they record a failure; the other spans always end with status `UNSET`. **`claude_code.interaction`** + +Attribute| Description| Gated by +---|---|--- +`user_prompt`| Prompt text. Value is `<REDACTED>` unless the gate is set| `OTEL_LOG_USER_PROMPTS` +`user_prompt_length`| Prompt length in characters| +`interaction.sequence`| 1-based counter of interactions in this session| +`interaction.duration_ms`| Wall-clock duration of the turn| + +**`claude_code.llm_request`** + +Attribute| Description| Gated by +---|---|--- +`model`| Model identifier| +`gen_ai.system`| Always `anthropic`. OpenTelemetry GenAI semantic convention| +`gen_ai.request.model`| Same value as `model`. OpenTelemetry GenAI semantic convention| +`query_source`| Subsystem that issued the request, such as `repl_main_thread` or a subagent name| +`speed`| `fast` or `normal`| +`llm_request.context`| `interaction`, `tool`, or `standalone` depending on the parent span| +`duration_ms`| Wall-clock duration including retries| +`ttft_ms`| Time to first token in milliseconds| +`input_tokens`| Input token count from the API usage block| +`output_tokens`| Output token count| +`cache_read_tokens`| Tokens read from prompt cache| +`cache_creation_tokens`| Tokens written to prompt cache| +`request_id`| Anthropic API request ID from the `request-id` response header| +`gen_ai.response.id`| Same value as `request_id`. OpenTelemetry GenAI semantic convention| +`client_request_id`| Client-generated `x-client-request-id` of the final attempt| +`attempt`| Total attempts made for this request| +`success`| `true` or `false`| +`status_code`| HTTP status code when the request failed| +`error`| Error message when the request failed| +`response.has_tool_call`| `true` when the response contained tool-use blocks| + +Each retry attempt is also recorded as a `gen_ai.request.attempt` span event with `attempt` and `client_request_id` attributes. **`claude_code.tool`** + +Attribute| Description| Gated by +---|---|--- +`tool_name`| Tool name| +`duration_ms`| Wall-clock duration including permission wait and execution| +`result_tokens`| Approximate token size of the tool result| +`file_path`| Target file path for Read, Edit, and Write tools| `OTEL_LOG_TOOL_DETAILS` +`full_command`| Command string for the Bash tool| `OTEL_LOG_TOOL_DETAILS` +`skill_name`| Skill name for the Skill tool| `OTEL_LOG_TOOL_DETAILS` +`subagent_type`| Subagent type for the Task tool| `OTEL_LOG_TOOL_DETAILS` + +When `OTEL_LOG_TOOL_CONTENT=1`, this span also records a `tool.output` span event whose attributes contain the tool’s input and output bodies, truncated at 60 KB per attribute. **`claude_code.tool.blocked_on_user`** + +Attribute| Description| Gated by +---|---|--- +`duration_ms`| Time spent waiting for the permission decision| +`decision`| `accept` or `reject`| +`source`| Decision source, matching the `tool_decision` event| + +**`claude_code.tool.execution`** + +Attribute| Description| Gated by +---|---|--- +`duration_ms`| Time spent running the tool body| +`success`| `true` or `false`| +`error`| Error category string when execution failed, such as `Error:ENOENT` or `ShellError`. Contains the full error message instead when the gate is set| `OTEL_LOG_TOOL_DETAILS` + +**`claude_code.hook`** This span is emitted only when detailed beta tracing is active, which requires `ENABLE_BETA_TRACING_DETAILED=1` and `BETA_TRACING_ENDPOINT` in addition to the trace exporter configuration above. In interactive CLI sessions, this also requires your organization to be allowlisted for the feature. Agent SDK and non-interactive `-p` sessions are not gated. It is not emitted when only `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA` is set. + +Attribute| Description| Gated by +---|---|--- +`hook_event`| Hook event type, such as `PreToolUse`| +`hook_name`| Full hook name, such as `PreToolUse:Write`| +`num_hooks`| Number of matching hook commands executed| +`hook_definitions`| JSON-serialized hook configuration| `OTEL_LOG_TOOL_DETAILS` +`duration_ms`| Wall-clock duration of all matching hooks| +`num_success`| Count of hooks that completed successfully| +`num_blocking`| Count of hooks that returned a blocking decision| +`num_non_blocking_error`| Count of hooks that failed without blocking| +`num_cancelled`| Count of hooks cancelled before completion| + +Additional content-bearing attributes such as `new_context`, `system_prompt_preview`, `tool_input`, and `response.model_output` are emitted only when detailed beta tracing is active. They are not part of the stable span schema. ### @@ -317,6 +419,7 @@ Incremented at the start of each session. **Attributes** : * All standard attributes + * `start_type`: How the session was started. One of `"fresh"`, `"resume"`, or `"continue"` #### @@ -359,6 +462,8 @@ * All standard attributes * `model`: Model identifier (for example, “claude-sonnet-4-6”) + * `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 #### @@ -371,6 +476,8 @@ * All standard attributes * `type`: (`"input"`, `"output"`, `"cacheRead"`, `"cacheCreation"`) * `model`: Model identifier (for example, “claude-sonnet-4-6”) + * `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 #### @@ -451,7 +558,8 @@ * `tool_name`: Name of the tool * `success`: `"true"` or `"false"` * `duration_ms`: Execution time in milliseconds - * `error`: Error message (if failed) + * `error_type`: Error category string when the tool failed, such as `"Error:ENOENT"` or `"ShellError"` + * `error` (when `OTEL_LOG_TOOL_DETAILS=1`): Full error message when the tool failed * `decision_type`: Either `"accept"` or `"reject"` * `decision_source`: Decision source - `"config"`, `"hook"`, `"user_permanent"`, `"user_temporary"`, `"user_abort"`, or `"user_reject"` * `tool_result_size_bytes`: Size of the tool result in bytes @@ -460,6 +568,7 @@ * For Bash tool: includes `bash_command`, `full_command`, `timeout`, `description`, `dangerouslyDisableSandbox`, and `git_commit_id` (the commit SHA, when a `git commit` command succeeds) * For MCP tools: includes `mcp_server_name`, `mcp_tool_name` * For Skill tool: includes `skill_name` + * For Task tool: includes `subagent_type` * `tool_input` (when `OTEL_LOG_TOOL_DETAILS=1`): JSON-serialized tool arguments. Individual values over 512 characters are truncated, and the full payload is bounded to ~4 K characters. Applies to all tools including MCP tools. #### @@ -483,6 +592,7 @@ * `cache_creation_tokens`: Number of tokens used for cache creation * `request_id`: Anthropic API request ID from the response’s `request-id` header, such as `"req_011..."`. Present only when the API returns one. * `speed`: `"fast"` or `"normal"`, indicating whether fast mode was active + * `query_source`: Subsystem that issued the request, such as `"repl_main_thread"`, `"compact"`, or a subagent name #### @@ -503,6 +613,7 @@ * `attempt`: Total number of attempts made, including the initial request (`1` means no retries occurred) * `request_id`: Anthropic API request ID from the response’s `request-id` header, such as `"req_011..."`. Present only when the API returns one. * `speed`: `"fast"` or `"normal"`, indicating whether fast mode was active + * `query_source`: Subsystem that issued the request, such as `"repl_main_thread"`, `"compact"`, or a subagent name #### @@ -510,15 +621,16 @@ API request body event -Logged for each API request attempt when `OTEL_LOG_RAW_API_BODIES=1`. One event is emitted per attempt, so retries with adjusted parameters each produce their own event. **Event Name** : `claude_code.api_request_body` **Attributes** : +Logged for each API request attempt when `OTEL_LOG_RAW_API_BODIES` is set. One event is emitted per attempt, so retries with adjusted parameters each produce their own event. **Event Name** : `claude_code.api_request_body` **Attributes** : * All standard attributes * `event.name`: `"api_request_body"` * `event.timestamp`: ISO 8601 timestamp * `event.sequence`: monotonically increasing counter for ordering events within a session - * `body`: JSON-serialized Messages API request parameters (system prompt, messages, tools, etc.), truncated at 60 KB. Extended-thinking content in prior assistant turns is redacted. - * `body_length`: Original (pre-truncation) JSON length in characters - * `body_truncated`: `"true"` when truncation occurred (absent otherwise) + * `body`: JSON-serialized Messages API request parameters (system prompt, messages, tools, etc.), truncated at 60 KB. Extended-thinking content in prior assistant turns is redacted. Emitted only in inline mode (`OTEL_LOG_RAW_API_BODIES=1`). + * `body_ref`: Absolute path to a `<dir>/<uuid>.request.json` file containing the untruncated body. Emitted only in file mode (`OTEL_LOG_RAW_API_BODIES=file:<dir>`). + * `body_length`: Untruncated body length. UTF-8 bytes when `OTEL_LOG_RAW_API_BODIES=file:<dir>`, or UTF-16 code units when `=1` + * `body_truncated`: `"true"` when inline truncation occurred. Absent in file mode and when no truncation occurred. * `model`: Model identifier from the request parameters * `query_source`: Subsystem that issued the request (for example, `"compact"`) @@ -528,15 +640,16 @@ API response body event -Logged for each successful API response when `OTEL_LOG_RAW_API_BODIES=1`. **Event Name** : `claude_code.api_response_body` **Attributes** : +Logged for each successful API response when `OTEL_LOG_RAW_API_BODIES` is set. **Event Name** : `claude_code.api_response_body` **Attributes** : * All standard attributes * `event.name`: `"api_response_body"` * `event.timestamp`: ISO 8601 timestamp * `event.sequence`: monotonically increasing counter for ordering events within a session - * `body`: JSON-serialized Messages API response (id, content blocks, usage, stop reason), truncated at 60 KB. Extended-thinking content is redacted. - * `body_length`: Original (pre-truncation) JSON length in characters - * `body_truncated`: `"true"` when truncation occurred (absent otherwise) + * `body`: JSON-serialized Messages API response (id, content blocks, usage, stop reason), truncated at 60 KB. Extended-thinking content is redacted. Emitted only in inline mode (`OTEL_LOG_RAW_API_BODIES=1`). + * `body_ref`: Absolute path to a `<dir>/<request_id>.response.json` file containing the untruncated body. Emitted only in file mode (`OTEL_LOG_RAW_API_BODIES=file:<dir>`). + * `body_length`: Untruncated body length. UTF-8 bytes when `OTEL_LOG_RAW_API_BODIES=file:<dir>`, or UTF-16 code units when `=1` + * `body_truncated`: `"true"` when inline truncation occurred. Absent in file mode and when no truncation occurred. * `model`: Model identifier * `query_source`: Subsystem that issued the request * `request_id`: Anthropic API request ID from the response’s `request-id` header, such as `"req_011..."`. Present only when the API returns one. @@ -561,6 +674,75 @@ ​ +Permission mode changed event + +Logged when the permission mode changes, for example from `Shift+Tab` cycling, exiting plan mode, or an auto mode gate check. **Event Name** : `claude_code.permission_mode_changed` **Attributes** : + + * All standard attributes + * `event.name`: `"permission_mode_changed"` + * `event.timestamp`: ISO 8601 timestamp + * `event.sequence`: monotonically increasing counter for ordering events within a session + * `from_mode`: The previous permission mode, for example `"default"`, `"plan"`, `"acceptEdits"`, `"auto"`, or `"bypassPermissions"` + * `to_mode`: The new permission mode + * `trigger`: What caused the change. One of `"shift_tab"`, `"exit_plan_mode"`, `"auto_gate_denied"`, or `"auto_opt_in"`. Absent when the transition originates from the SDK or bridge + +#### + +​ + +Auth event + +Logged when `/login` or `/logout` completes. **Event Name** : `claude_code.auth` **Attributes** : + + * All standard attributes + * `event.name`: `"auth"` + * `event.timestamp`: ISO 8601 timestamp + * `event.sequence`: monotonically increasing counter for ordering events within a session + * `action`: `"login"` or `"logout"` + * `success`: `"true"` or `"false"` + * `auth_method`: Authentication method, such as `"oauth"` + * `error_category`: Categorical error kind when the action failed. The raw error message is never included + * `status_code`: HTTP status code as a string when the action failed with an HTTP error + +#### + +​ + +MCP server connection event + +Logged when an MCP server connects, disconnects, or fails to connect. **Event Name** : `claude_code.mcp_server_connection` **Attributes** : + + * All standard attributes + * `event.name`: `"mcp_server_connection"` + * `event.timestamp`: ISO 8601 timestamp + * `event.sequence`: monotonically increasing counter for ordering events within a session + * `status`: `"connected"`, `"failed"`, or `"disconnected"` + * `transport_type`: Server transport, such as `"stdio"`, `"sse"`, or `"http"` + * `server_scope`: Scope the server is configured at, such as `"user"`, `"project"`, or `"local"` + * `duration_ms`: Connection attempt duration in milliseconds + * `error_code`: Error code when the connection failed + * `server_name` (when `OTEL_LOG_TOOL_DETAILS=1`): Configured server name + * `error` (when `OTEL_LOG_TOOL_DETAILS=1`): Full error message when the connection failed + +#### + +​ + +Internal error event + +Logged when Claude Code catches an unexpected internal error. Only the error class name and an errno-style code are recorded. The error message and stack trace are never included. This event is not emitted when running against Bedrock, Vertex, or Foundry, or when `DISABLE_ERROR_REPORTING` is set. **Event Name** : `claude_code.internal_error` **Attributes** : + + * All standard attributes + * `event.name`: `"internal_error"` + * `event.timestamp`: ISO 8601 timestamp + * `event.sequence`: monotonically increasing counter for ordering events within a session + * `error_name`: Error class name, such as `"TypeError"` or `"SyntaxError"` + * `error_code`: Node.js errno code such as `"ENOENT"` when present on the error + +#### + +​ + Plugin installed event Logged when a plugin finishes installing, from both the `claude plugin install` CLI command and the interactive `/plugin` UI. **Event Name** : `claude_code.plugin_installed` **Attributes** : @@ -569,11 +751,11 @@ * `event.name`: `"plugin_installed"` * `event.timestamp`: ISO 8601 timestamp * `event.sequence`: monotonically increasing counter for ordering events within a session - * `plugin.name`: Name of the installed plugin - * `plugin.version`: Plugin version when declared in the marketplace entry - * `marketplace.name`: Marketplace the plugin was installed from * `marketplace.is_official`: `"true"` if the marketplace is an official Anthropic marketplace, `"false"` otherwise * `install.trigger`: `"cli"` or `"ui"` + * `plugin.name`: Name of the installed plugin. For third-party marketplaces this is included only when `OTEL_LOG_TOOL_DETAILS=1` + * `plugin.version`: Plugin version when declared in the marketplace entry. For third-party marketplaces this is included only when `OTEL_LOG_TOOL_DETAILS=1` + * `marketplace.name`: Marketplace the plugin was installed from. For third-party marketplaces this is included only when `OTEL_LOG_TOOL_DETAILS=1` #### @@ -587,10 +769,91 @@ * `event.name`: `"skill_activated"` * `event.timestamp`: ISO 8601 timestamp * `event.sequence`: monotonically increasing counter for ordering events within a session - * `skill.name`: Name of the skill + * `skill.name`: Name of the skill. For user-defined and third-party plugin skills the value is the placeholder `"custom_skill"` unless `OTEL_LOG_TOOL_DETAILS=1` * `skill.source`: Where the skill was loaded from (for example, `"bundled"`, `"userSettings"`, `"projectSettings"`, `"plugin"`) - * `plugin.name`: Name of the owning plugin when the skill is provided by a plugin - * `marketplace.name`: Marketplace the owning plugin was installed from, when the skill is provided by a plugin + * `plugin.name` (when `OTEL_LOG_TOOL_DETAILS=1` or the plugin is from an official marketplace): Name of the owning plugin when the skill is provided by a plugin + * `marketplace.name` (when `OTEL_LOG_TOOL_DETAILS=1` or the plugin is from an official marketplace): Marketplace the owning plugin was installed from, when the skill is provided by a plugin + +#### + +​ + +API retries exhausted event + +Logged once when an API request fails after more than one attempt. Emitted alongside the final `api_error` event. **Event Name** : `claude_code.api_retries_exhausted` **Attributes** : + + * All standard attributes + * `event.name`: `"api_retries_exhausted"` + * `event.timestamp`: ISO 8601 timestamp + * `event.sequence`: monotonically increasing counter for ordering events within a session + * `model`: Model used + * `error`: Final error message + * `status_code`: HTTP status code as a string + * `total_attempts`: Total number of attempts made + * `total_retry_duration_ms`: Total wall-clock time across all attempts + * `speed`: `"fast"` or `"normal"` + +#### + +​ + +Hook execution start event + +Logged when one or more hooks begin executing for a hook event. **Event Name** : `claude_code.hook_execution_start` **Attributes** : + + * All standard attributes + * `event.name`: `"hook_execution_start"` + * `event.timestamp`: ISO 8601 timestamp + * `event.sequence`: monotonically increasing counter for ordering events within a session + * `hook_event`: Hook event type, such as `"PreToolUse"` or `"PostToolUse"` + * `hook_name`: Full hook name including matcher, such as `"PreToolUse:Write"` + * `num_hooks`: Number of matching hook commands + * `managed_only`: `"true"` when only managed-policy hooks are permitted + * `hook_source`: `"policySettings"` or `"merged"` + * `hook_definitions`: JSON-serialized hook configuration. Included only when both detailed beta tracing and `OTEL_LOG_TOOL_DETAILS=1` are enabled + +#### + +​ + +Hook execution complete event + +Logged when all hooks for a hook event have finished. **Event Name** : `claude_code.hook_execution_complete` **Attributes** : + + * All standard attributes + * `event.name`: `"hook_execution_complete"` + * `event.timestamp`: ISO 8601 timestamp + * `event.sequence`: monotonically increasing counter for ordering events within a session + * `hook_event`: Hook event type + * `hook_name`: Full hook name including matcher + * `num_hooks`: Number of matching hook commands + * `num_success`: Count that completed successfully + * `num_blocking`: Count that returned a blocking decision + * `num_non_blocking_error`: Count that failed without blocking + * `num_cancelled`: Count cancelled before completion + * `total_duration_ms`: Wall-clock duration of all matching hooks + * `managed_only`: `"true"` when only managed-policy hooks are permitted + * `hook_source`: `"policySettings"` or `"merged"` + * `hook_definitions`: JSON-serialized hook configuration. Included only when both detailed beta tracing and `OTEL_LOG_TOOL_DETAILS=1` are enabled + +#### + +​ + +Compaction event + +Logged when conversation compaction completes. **Event Name** : `claude_code.compaction` **Attributes** : + + * All standard attributes + * `event.name`: `"compaction"` + * `event.timestamp`: ISO 8601 timestamp + * `event.sequence`: monotonically increasing counter for ordering events within a session + * `trigger`: `"auto"` or `"manual"` + * `success`: `"true"` or `"false"` + * `duration_ms`: Compaction duration + * `pre_tokens`: Approximate token count before compaction + * `post_tokens`: Approximate token count after compaction + * `error`: Error message when compaction failed ## @@ -740,7 +1003,7 @@ * User prompt content is not collected by default. Only prompt length is recorded. To include prompt content, set `OTEL_LOG_USER_PROMPTS=1` * Tool input arguments and parameters are not logged by default. To include them, set `OTEL_LOG_TOOL_DETAILS=1`. When enabled, `tool_result` events include a `tool_parameters` attribute with Bash commands, MCP server and tool names, and skill names, plus a `tool_input` attribute with file paths, URLs, search patterns, and other arguments. Trace spans include the same `tool_input` attribute and input-derived attributes such as `file_path`. Individual values over 512 characters are truncated and the total is bounded to ~4 K characters, but the arguments may still contain sensitive values. Configure your telemetry backend to filter or redact these attributes as needed * Tool input and output content is not logged in trace spans by default. To include it, set `OTEL_LOG_TOOL_CONTENT=1`. When enabled, span events include full tool input and output content truncated at 60 KB per span. This can include raw file contents from Read tool results and Bash command output. Configure your telemetry backend to filter or redact these attributes as needed - * Raw Anthropic Messages API request and response bodies are not logged by default. To include them, set `OTEL_LOG_RAW_API_BODIES=1`. When enabled, each API call emits `api_request_body` and `api_response_body` log events whose `body` attribute is the JSON-serialized payload, truncated at 60 KB. These bodies contain the full conversation history (system prompt, every prior user and assistant turn, tool results), so enabling this implies consent to everything the other `OTEL_LOG_*` content flags would reveal. Claude’s extended-thinking content is always redacted from these bodies regardless of other settings + * Raw Anthropic Messages API request and response bodies are not logged by default. To include them, set `OTEL_LOG_RAW_API_BODIES`. With `=1`, each API call emits `api_request_body` and `api_response_body` log events whose `body` attribute is the JSON-serialized payload, truncated at 60 KB. With `=file:<dir>`, untruncated bodies are written to `.request.json` and `.response.json` files under that directory and the events carry a `body_ref` path instead of the inline body. Ship the directory with a log collector or sidecar rather than through the telemetry stream. In both modes, bodies contain the full conversation history (system prompt, every prior user and assistant turn, tool results), so enabling this implies consent to everything the other `OTEL_LOG_*` content flags would reveal. Claude’s extended-thinking content is always redacted from these bodies regardless of other settings ##
modified Enterprise network configuration View current →
--- a/network-config.md +++ b/network-config.md @@ -104,10 +104,10 @@ * `claude.ai`: authentication for claude.ai accounts * `platform.claude.com`: authentication for Anthropic Console accounts -Ensure these URLs are allowlisted in your proxy configuration and firewall rules. This is especially important when using Claude Code in containerized or restricted network environments. The native installer and update checks also require the following URLs. Allowlist both, since the installer and auto-updater fetch from `storage.googleapis.com` while plugin downloads use `downloads.claude.ai`. If you install Claude Code through npm or manage your own binary distribution, end users may not need access: +Ensure these URLs are allowlisted in your proxy configuration and firewall rules. This is especially important when using Claude Code in containerized or restricted network environments. When using [Bedrock](</docs/en/amazon-bedrock>), [Vertex AI](</docs/en/google-vertex-ai>), or [Foundry](</docs/en/microsoft-foundry>), model traffic goes to your provider instead of `api.anthropic.com`. The WebFetch tool still calls `api.anthropic.com` for its [domain safety check](</docs/en/data-usage#webfetch-domain-safety-check>) unless you set `skipWebFetchPreflight: true` in [settings](</docs/en/settings>). The native installer and update checks also require the following URLs. Allowlist both, since clients running older Claude Code versions fetch from `storage.googleapis.com`. If you install Claude Code through npm or manage your own binary distribution, end users may not need access: - * `storage.googleapis.com`: download bucket for the Claude Code binary and auto-updater - * `downloads.claude.ai`: CDN hosting the install script, version pointers, manifests, signing keys, and plugin executables + * `downloads.claude.ai`: download host for the Claude Code binary, auto-updater, version pointers, manifests, install script, signing keys, and plugin executables + * `storage.googleapis.com`: legacy download host used by older clients The [Chrome integration](</docs/en/chrome>) connects to the browser extension over a WebSocket bridge. If you use Claude in Chrome, allowlist `bridge.claudeusercontent.com` for outbound WebSocket connections. [Claude Code on the web](</docs/en/claude-code-on-the-web>) and [Code Review](</docs/en/code-review>) connect to your repositories from Anthropic-managed infrastructure. If your GitHub Enterprise Cloud organization restricts access by IP address, enable [IP allow list inheritance for installed GitHub Apps](<https://docs.github.com/en/enterprise-cloud@latest/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/managing-allowed-ip-addresses-for-your-organization#allowing-access-by-github-apps>). The Claude GitHub App registers its IP ranges, so enabling this setting allows access without manual configuration. To [add the ranges to your allow list manually](<https://docs.github.com/en/enterprise-cloud@latest/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/managing-allowed-ip-addresses-for-your-organization#adding-an-allowed-ip-address>) instead, or to configure other firewalls, see the [Anthropic API IP addresses](<https://platform.claude.com/docs/en/api/ip-addresses>). For self-hosted [GitHub Enterprise Server](</docs/en/github-enterprise-server>) instances behind a firewall, allowlist the same [Anthropic API IP addresses](<https://platform.claude.com/docs/en/api/ip-addresses>) so Anthropic infrastructure can reach your GHES host to clone repositories and post review comments.
modified Observability with OpenTelemetry View current →
--- a/observability.md +++ b/observability.md @@ -100,11 +100,19 @@ * **`claude_code.interaction`:** wraps a single turn of the agent loop, from receiving a prompt to producing a response. * **`claude_code.llm_request`:** wraps each call to the Claude API, with model name, latency, and token counts as attributes. * **`claude_code.tool`:** wraps each tool invocation, with child spans for the permission wait (`claude_code.tool.blocked_on_user`) and the execution itself (`claude_code.tool.execution`). - * **`claude_code.hook`:** wraps each [hook](</docs/en/agent-sdk/hooks>) execution. + * **`claude_code.hook`:** wraps each [hook](</docs/en/agent-sdk/hooks>) execution. Requires detailed beta tracing (`ENABLE_BETA_TRACING_DETAILED=1` and `BETA_TRACING_ENDPOINT`) in addition to the variables above. -Spans carry a `session.id` attribute by default. When you make several `query()` calls against the same [session](</docs/en/agent-sdk/sessions>), filter on `session.id` in your backend to see them as one timeline. The attribute is omitted if `OTEL_METRICS_INCLUDE_SESSION_ID` is set to a falsy value. +The `llm_request`, `tool`, and `hook` spans are children of the enclosing `claude_code.interaction` span. When the agent spawns a subagent through the Task tool, the subagent’s `llm_request` and `tool` spans nest under the parent agent’s `claude_code.tool` span, so the full delegation chain appears as one trace. Spans carry a `session.id` attribute by default. When you make several `query()` calls against the same [session](</docs/en/agent-sdk/sessions>), filter on `session.id` in your backend to see them as one timeline. The attribute is omitted if `OTEL_METRICS_INCLUDE_SESSION_ID` is set to a falsy value. Tracing is in beta. Span names and attributes may change between releases. See [Traces (beta)](</docs/en/monitoring-usage#traces-beta>) in the Monitoring reference for the trace exporter configuration variables. + +## + +​ + +Link traces to your application + +The SDK automatically propagates W3C trace context into the CLI subprocess. When you call `query()` while an OpenTelemetry span is active in your application, the SDK injects `TRACEPARENT` and `TRACESTATE` into the child process environment, and the CLI reads them so its `claude_code.interaction` span becomes a child of your span. The agent run then appears inside your application’s trace instead of as a disconnected root. The CLI also forwards `TRACEPARENT` to every Bash and PowerShell command it runs. If a command launched through the Bash tool emits its own OpenTelemetry spans, those spans nest under the `claude_code.tool.execution` span that wraps the command. Auto-injection is skipped when you set `TRACEPARENT` explicitly in `options.env`, so you can pin a specific parent context if needed. Interactive CLI sessions ignore inbound `TRACEPARENT` entirely; only Agent SDK and `claude -p` runs honor it. See [Traces (beta)](</docs/en/monitoring-usage#traces-beta>) in the Monitoring reference for the full span and attribute reference. ## @@ -132,13 +140,14 @@ Control sensitive data in exports -Telemetry is structural by default. Durations, model names, and tool names are recorded on every span; token counts are recorded when the underlying API request returns usage data, so spans for failed or aborted requests may omit them. The content your agent reads and writes is not recorded by default. Three opt-in variables add content to the exported data: +Telemetry is structural by default. Durations, model names, and tool names are recorded on every span; token counts are recorded when the underlying API request returns usage data, so spans for failed or aborted requests may omit them. The content your agent reads and writes is not recorded by default. These opt-in variables add content to the exported data: Variable| Adds ---|--- `OTEL_LOG_USER_PROMPTS=1`| Prompt text on `claude_code.user_prompt` events and on the `claude_code.interaction` span `OTEL_LOG_TOOL_DETAILS=1`| Tool input arguments (file paths, shell commands, search patterns) on `claude_code.tool_result` events `OTEL_LOG_TOOL_CONTENT=1`| Full tool input and output bodies as span events on `claude_code.tool`, truncated at 60 KB. Requires tracing to be enabled +`OTEL_LOG_RAW_API_BODIES`| Full Anthropic Messages API request and response JSON as `claude_code.api_request_body` and `claude_code.api_response_body` log events. Set to `1` for inline bodies truncated at 60 KB, or `file:<dir>` for untruncated bodies on disk with a `body_ref` path in the event. Bodies include the entire conversation history and have extended-thinking content redacted. Enabling this implies consent to everything the three variables above would reveal Leave these unset unless your observability pipeline is approved to store the data your agent handles. See [Security and privacy](</docs/en/monitoring-usage#security-and-privacy>) in the Monitoring reference for the full list of attributes and redaction behavior.
modified Configure permissions View current →
--- a/permissions.md +++ b/permissions.md @@ -311,7 +311,7 @@ * Filesystem restrictions in the sandbox use Read and Edit deny rules, not separate sandbox configuration * Network restrictions combine WebFetch permission rules with the sandbox’s `allowedDomains` and `deniedDomains` lists -When sandboxing is enabled with `autoAllowBashIfSandboxed: true`, which is the default, sandboxed Bash commands run without prompting even if your permissions include `ask: Bash(*)`. The sandbox boundary substitutes for the per-command prompt. See [sandbox modes](</docs/en/sandboxing#sandbox-modes>) to change this behavior. +When sandboxing is enabled with `autoAllowBashIfSandboxed: true`, which is the default, sandboxed Bash commands run without prompting even if your permissions include `ask: Bash(*)`. The sandbox boundary substitutes for the per-command prompt. Explicit deny rules still apply, and `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a prompt. See [sandbox modes](</docs/en/sandboxing#sandbox-modes>) to change this behavior. ## @@ -361,7 +361,7 @@ Configure the auto mode classifier -[Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) uses a classifier model to decide whether each action is safe to run without prompting. Out of the box it trusts only the working directory and, if present, the current repo’s remotes. Actions like pushing to your company’s source control org or writing to a team cloud bucket will be blocked as potential data exfiltration. The `autoMode` settings block lets you tell the classifier which infrastructure your organization trusts. The classifier reads `autoMode` from user settings, `.claude/settings.local.json`, and managed settings. It does not read from shared project settings in `.claude/settings.json`, because a checked-in repo could otherwise inject its own allow rules. +[Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) uses a classifier model to decide whether each action is safe to run without prompting. Out of the box it trusts only the working directory and, if present, the current repo’s remotes. Actions like pushing to your company’s source control org or writing to a team cloud bucket will be blocked as potential data exfiltration. To adjust what the classifier allows or blocks, add instructions to your [CLAUDE.md](</docs/en/memory>) file. The classifier reads CLAUDE.md from trusted directories alongside the conversation, so an instruction like “never force push” steers both Claude and the classifier at the same time. Start here for project conventions and behavioral rules. For rules that apply across projects, such as trusted infrastructure or organization-wide deny rules, use the `autoMode` settings block. The classifier reads `autoMode` from user settings, `.claude/settings.local.json`, and managed settings. It does not read from shared project settings in `.claude/settings.json`, because a checked-in repo could otherwise inject its own allow rules. Scope| File| Use for ---|---|---
modified Constrain plugin dependency versions View current →
--- a/plugin-dependencies.md +++ b/plugin-dependencies.md @@ -1,4 +1,4 @@ -A plugin can depend on other plugins by listing them in `plugin.json` or in its marketplace entry. By default, a dependency tracks the latest available version, so an upstream release can change the dependency under your plugin without warning. Version constraints let you hold a dependency at a tested version range until you choose to move. When you install a plugin that declares dependencies, Claude Code resolves and installs them automatically and lists which dependencies were added at the end of the install output. This guide is for plugin authors who declare dependencies in `plugin.json` and for marketplace maintainers who tag releases. To install plugins that have dependencies, see [Discover and install plugins](</docs/en/discover-plugins>). For the full manifest schema, see the [Plugins reference](</docs/en/plugins-reference>). +A plugin can depend on other plugins by listing them in `plugin.json` or in its marketplace entry. By default, a dependency tracks the latest available version, so an upstream release can change the dependency under your plugin without warning. Version constraints let you hold a dependency at a tested version range until you choose to move. When you install a plugin that declares dependencies, Claude Code resolves and installs them automatically and lists which dependencies were added at the end of the install output. If a dependency later goes missing, `/reload-plugins` and the background plugin auto-update install it automatically, provided its marketplace is already in your configured marketplaces. Dependencies from a marketplace you have not added are left unresolved. This guide is for plugin authors who declare dependencies in `plugin.json` and for marketplace maintainers who tag releases. To install plugins that have dependencies, see [Discover and install plugins](</docs/en/discover-plugins>). For the full manifest schema, see the [Plugins reference](</docs/en/plugins-reference>). Dependency version constraints require Claude Code v2.1.110 or later. @@ -35,9 +35,36 @@ ---|---|--- `name`| string| Plugin name. Resolves within the same marketplace as the declaring plugin. Required. `version`| string| A [semver range](<https://github.com/npm/node-semver#ranges>) such as `~2.1.0`, `^2.0`, `>=1.4`, or `=2.1.0`. The dependency is fetched at the highest tagged version that satisfies this range. -`marketplace`| string| A different marketplace to resolve `name` in. Cross-marketplace dependencies are blocked unless the target marketplace is allowlisted in the root marketplace’s `marketplace.json`. +`marketplace`| string| A different marketplace to resolve `name` in. Cross-marketplace dependencies are blocked unless the target marketplace is listed in `allowCrossMarketplaceDependenciesOn` in the root marketplace’s `marketplace.json`. The `version` field accepts any expression supported by Node’s `semver` package, including caret, tilde, hyphen, and comparator ranges. Pre-release versions such as `2.0.0-beta.1` are excluded unless your range opts in with a pre-release suffix like `^2.0.0-0`. + +## + +​ + +Depend on a plugin from another marketplace + +By default, Claude Code refuses to auto-install a dependency that lives in a different marketplace than the plugin declaring it. This prevents one marketplace from silently pulling in plugins from a source you have not reviewed. To allow it, the maintainer of the root marketplace adds the target marketplace name to `allowCrossMarketplaceDependenciesOn` in `marketplace.json`. The root marketplace is the one that hosts the plugin the user is installing; only its allowlist is consulted, so trust does not chain through intermediate marketplaces. The following `marketplace.json` allows `deploy-kit` to depend on a plugin from `acme-shared`: + +.claude-plugin/marketplace.json + + { + "name": "acme-tools", + "owner": { "name": "Acme" }, + "allowCrossMarketplaceDependenciesOn": ["acme-shared"], + "plugins": [ + { + "name": "deploy-kit", + "source": "./deploy-kit", + "dependencies": [ + { "name": "audit-logger", "marketplace": "acme-shared" } + ] + } + ] + } + +If the field is missing or does not include the target marketplace, install fails with a `cross-marketplace` error naming the field to set. Users can still install the dependency manually first, which satisfies the constraint without changing the allowlist. ##
modified Create and distribute a plugin marketplace View current →
--- a/plugin-marketplaces.md +++ b/plugin-marketplaces.md @@ -179,13 +179,14 @@ ​ -Optional metadata +Optional fields Field| Type| Description ---|---|--- `metadata.description`| string| Brief marketplace description `metadata.version`| string| Marketplace version `metadata.pluginRoot`| string| Base directory prepended to relative plugin source paths (for example, `"./plugins"` lets you write `"source": "formatter"` instead of `"source": "./plugins/formatter"`) +`allowCrossMarketplaceDependenciesOn`| array| Other marketplaces that plugins in this marketplace may depend on. Dependencies from a marketplace not listed here are blocked at install. See [Depend on a plugin from another marketplace](</docs/en/plugin-dependencies#depend-on-a-plugin-from-another-marketplace>). ##
modified Plugins reference View current →
--- a/plugins-reference.md +++ b/plugins-reference.md @@ -90,6 +90,7 @@ ---|--- `SessionStart`| When a session begins or resumes `UserPromptSubmit`| When you submit a prompt, before Claude processes it +`UserPromptExpansion`| When a user-typed command expands into a prompt, before it reaches Claude. Can block the expansion `PreToolUse`| Before a tool call executes. Can block it `PermissionRequest`| When a permission dialog appears `PermissionDenied`| When a tool call is denied by the auto mode classifier. Return `{retry: true}` to tell the model it may retry the denied tool call @@ -394,17 +395,33 @@ { "userConfig": { "api_endpoint": { - "description": "Your team's API endpoint", - "sensitive": false + "type": "string", + "title": "API endpoint", + "description": "Your team's API endpoint" }, "api_token": { + "type": "string", + "title": "API token", "description": "API authentication token", "sensitive": true } } } -Keys must be valid identifiers. Each value is available for substitution as `${user_config.KEY}` in MCP and LSP server configs, hook commands, monitor commands, and (for non-sensitive values only) skill and agent content. Values are also exported to plugin subprocesses as `CLAUDE_PLUGIN_OPTION_<KEY>` environment variables. Non-sensitive values are stored in `settings.json` under `pluginConfigs[<plugin-id>].options`. Sensitive values go to the system keychain (or `~/.claude/.credentials.json` where the keychain is unavailable). Keychain storage is shared with OAuth tokens and has an approximately 2 KB total limit, so keep sensitive values small. +Keys must be valid identifiers. Each option supports these fields: + +Field| Required| Description +---|---|--- +`type`| Yes| One of `string`, `number`, `boolean`, `directory`, or `file` +`title`| Yes| Label shown in the configuration dialog +`description`| Yes| Help text shown beneath the field +`sensitive`| No| If `true`, masks input and stores the value in secure storage instead of `settings.json` +`required`| No| If `true`, validation fails when the field is empty +`default`| No| Value used when the user provides nothing +`multiple`| No| For `string` type, allow an array of strings +`min` / `max`| No| Bounds for `number` type + +Each value is available for substitution as `${user_config.KEY}` in MCP and LSP server configs, hook commands, and monitor commands. Non-sensitive values can also be substituted in skill and agent content. All values are exported to plugin subprocesses as `CLAUDE_PLUGIN_OPTION_<KEY>` environment variables. Non-sensitive values are stored in `settings.json` under `pluginConfigs[<plugin-id>].options`. Sensitive values go to the system keychain (or `~/.claude/.credentials.json` where the keychain is unavailable). Keychain storage is shared with OAuth tokens and has an approximately 2 KB total limit, so keep sensitive values small. ### @@ -419,8 +436,17 @@ { "server": "telegram", "userConfig": { - "bot_token": { "description": "Telegram bot token", "sensitive": true }, - "owner_id": { "description": "Your Telegram user ID", "sensitive": false } + "bot_token": { + "type": "string", + "title": "Bot token", + "description": "Telegram bot token", + "sensitive": true + }, + "owner_id": { + "type": "string", + "title": "Owner ID", + "description": "Your Telegram user ID" + } } } ]
modified Agent SDK reference - Python View current →
--- a/python.md +++ b/python.md @@ -900,8 +900,9 @@ plugins: list[SdkPluginConfig] = field(default_factory=list) max_thinking_tokens: int | None = None # Deprecated: use thinking instead thinking: ThinkingConfig | None = None - effort: Literal["low", "medium", "high", "xhigh", "max"] | None = None + effort: Literal["low", "medium", "high", "max"] | None = None enable_file_checkpointing: bool = False + session_store: SessionStore | None = None Property| Type| Default| Description ---|---|---|--- @@ -941,7 +942,8 @@ `setting_sources`| `list[SettingSource] | None`| `None` (CLI defaults: all sources)| Control which filesystem settings to load. Pass `[]` to disable user, project, and local settings. Managed policy settings load regardless. See [Use Claude Code features](</docs/en/agent-sdk/claude-code-features#what-settingsources-does-not-control>) `max_thinking_tokens`| `int | None`| `None`| _Deprecated_ \- Maximum tokens for thinking blocks. Use `thinking` instead `thinking`| `ThinkingConfig` ` | None`| `None`| Controls extended thinking behavior. Takes precedence over `max_thinking_tokens` -`effort`| `Literal["low", "medium", "high", "xhigh", "max"] | None`| `None`| Effort level for thinking depth +`effort`| `Literal["low", "medium", "high", "max"] | None`| `None`| Effort level for thinking depth +`session_store`| [`SessionStore`](</docs/en/agent-sdk/session-storage#the-session-store-interface>) ` | None`| `None`| Mirror session transcripts to an external backend so any host can resume them. See [Persist sessions to external storage](</docs/en/agent-sdk/session-storage>) ### @@ -1121,20 +1123,34 @@ description: str prompt: str tools: list[str] | None = None - model: Literal["sonnet", "opus", "haiku", "inherit"] | None = None + disallowedTools: list[str] | None = None + model: str | None = None skills: list[str] | None = None memory: Literal["user", "project", "local"] | None = None mcpServers: list[str | dict[str, Any]] | None = None + initialPrompt: str | None = None + maxTurns: int | None = None + background: bool | None = None + effort: Literal["low", "medium", "high", "max"] | int | None = None + permissionMode: PermissionMode | None = None Field| Required| Description ---|---|--- `description`| Yes| Natural language description of when to use this agent `prompt`| Yes| The agent’s system prompt `tools`| No| Array of allowed tool names. If omitted, inherits all tools -`model`| No| Model override for this agent. If omitted, uses the main model +`disallowedTools`| No| Array of tool names to remove from the agent’s tool set +`model`| No| Model override for this agent. Accepts an alias such as `"sonnet"`, `"opus"`, `"haiku"`, or `"inherit"`, or a full model ID. If omitted, uses the main model `skills`| No| List of skill names available to this agent `memory`| No| Memory source for this agent: `"user"`, `"project"`, or `"local"` `mcpServers`| No| MCP servers available to this agent. Each entry is a server name or an inline `{name: config}` dict +`initialPrompt`| No| Auto-submitted as the first user turn when this agent runs as the main thread agent +`maxTurns`| No| Maximum number of agentic turns before the agent stops +`background`| No| Run this agent as a non-blocking background task when invoked +`effort`| No| Reasoning effort level for this agent. Accepts a named level or an integer +`permissionMode`| No| Permission mode for tool execution within this agent. See `PermissionMode` + +`AgentDefinition` field names use camelCase, such as `disallowedTools`, `permissionMode`, and `maxTurns`. These names map directly to the wire format shared with the TypeScript SDK. This differs from `ClaudeAgentOptions`, which uses Python snake_case for the equivalent top-level fields such as `disallowed_tools` and `permission_mode`. Because `AgentDefinition` is a dataclass, passing a snake_case keyword raises a `TypeError` at construction time. ###
modified Sandboxing View current →
--- a/sandboxing.md +++ b/sandboxing.md @@ -107,7 +107,7 @@ /sandbox -This opens a menu where you can choose between sandbox modes. If required dependencies are missing (such as `bubblewrap` or `socat` on Linux), the menu displays installation instructions for your platform. By default, if the sandbox cannot start (missing dependencies, unsupported platform, or platform restrictions), Claude Code shows a warning and runs commands without sandboxing. To make this a hard failure instead, set [`sandbox.failIfUnavailable`](</docs/en/settings#sandbox-settings>) to `true`. This is intended for managed deployments that require sandboxing as a security gate. +This opens a menu where you can choose between sandbox modes. If required dependencies are missing (such as `bubblewrap` or `socat` on Linux), the menu displays installation instructions for your platform. By default, if the sandbox cannot start (missing dependencies or unsupported platform), Claude Code shows a warning and runs commands without sandboxing. To make this a hard failure instead, set [`sandbox.failIfUnavailable`](</docs/en/settings#sandbox-settings>) to `true`. This is intended for managed deployments that require sandboxing as a security gate. ### @@ -115,7 +115,7 @@ Sandbox modes -Claude Code offers two sandbox modes: **Auto-allow mode** : Bash commands will attempt to run inside the sandbox and are automatically allowed without requiring permission. Commands that cannot be sandboxed (such as those needing network access to non-allowed hosts) fall back to the regular permission flow. Explicit deny rules are always respected. Ask rules apply only to commands that fall back to the regular permission flow. **Regular permissions mode** : All bash commands go through the standard permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission. +Claude Code offers two sandbox modes: **Auto-allow mode** : Bash commands will attempt to run inside the sandbox and are automatically allowed without requiring permission. Commands that cannot be sandboxed (such as those needing network access to non-allowed hosts) fall back to the regular permission flow. Explicit deny rules are always respected, and `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a permission prompt. Ask rules apply only to commands that fall back to the regular permission flow. **Regular permissions mode** : All bash commands go through the standard permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission. Auto-allow mode works independently of your permission mode setting. Even if you’re not in “accept edits” mode, sandboxed bash commands will run automatically when auto-allow is enabled. This means bash commands that modify files within the sandbox boundaries will execute without prompting, even when file edit tools would normally require approval.
modified Work with sessions View current →
--- a/sessions.md +++ b/sessions.md @@ -203,6 +203,8 @@ If a `resume` call returns a fresh session instead of the expected history, the most common cause is a mismatched `cwd`. Sessions are stored under `~/.claude/projects/<encoded-cwd>/*.jsonl`, where `<encoded-cwd>` is the absolute working directory with every non-alphanumeric character replaced by `-` (so `/Users/me/proj` becomes `-Users-me-proj`). If your resume call runs from a different directory, the SDK looks in the wrong place. The session file also needs to exist on the current machine. +To resume sessions across machines or in serverless environments, mirror transcripts to shared storage with a [`SessionStore` adapter](</docs/en/agent-sdk/session-storage>). + ### ​
modified Claude Code settings View current →
--- a/settings.md +++ b/settings.md @@ -100,7 +100,7 @@ * **Managed settings** : For organizations that need centralized control, Claude Code supports multiple delivery mechanisms for managed settings. All use the same JSON format and cannot be overridden by user or project settings: * **Server-managed settings** : delivered from Anthropic’s servers via the Claude.ai admin console. See [server-managed settings](</docs/en/server-managed-settings>). * **MDM/OS-level policies** : delivered through native device management on macOS and Windows: - * macOS: `com.anthropic.claudecode` managed preferences domain (deployed via configuration profiles in Jamf, Iru (Kandji), or other MDM tools) + * macOS: `com.anthropic.claudecode` managed preferences domain. The plist’s top-level keys mirror `managed-settings.json`, with nested settings as dictionaries and arrays as plist arrays. Deploy via configuration profiles in Jamf, Iru (Kandji), or similar MDM tools. * Windows: `HKLM\SOFTWARE\Policies\ClaudeCode` registry key with a `Settings` value (REG_SZ or REG_EXPAND_SZ) containing JSON (deployed via Group Policy or Intune) * Windows (user-level): `HKCU\SOFTWARE\Policies\ClaudeCode` (lowest policy priority, only used when no admin-level source exists) * **File-based** : `managed-settings.json` and `managed-mcp.json` deployed to system directories: @@ -214,6 +214,7 @@ `respectGitignore`| Control whether the `@` file picker respects `.gitignore` patterns. When `true` (default), files matching `.gitignore` patterns are excluded from suggestions| `false` `showClearContextOnPlanAccept`| Show the “clear context” option on the plan accept screen. Defaults to `false`. Set to `true` to restore the option| `true` `showThinkingSummaries`| Show [extended thinking](</docs/en/common-workflows#use-extended-thinking-thinking-mode>) summaries in interactive sessions. When unset or `false` (default in interactive mode), thinking blocks are redacted by the API and shown as a collapsed stub. Redaction only changes what you see, not what the model generates: to reduce thinking spend, [lower the budget or disable thinking](</docs/en/common-workflows#use-extended-thinking-thinking-mode>) instead. Non-interactive mode (`-p`) and SDK callers always receive summaries regardless of this setting| `true` +`skipWebFetchPreflight`| Skip the [WebFetch domain safety check](</docs/en/data-usage#webfetch-domain-safety-check>) that sends each requested hostname to `api.anthropic.com` before fetching. Set to `true` in environments that block traffic to Anthropic, such as Bedrock, Vertex AI, or Foundry deployments with restrictive egress. When skipped, WebFetch attempts any URL without consulting the blocklist| `true` `spinnerTipsEnabled`| Show tips in the spinner while Claude is working. Set to `false` to disable tips (default: `true`)| `false` `spinnerTipsOverride`| Override spinner tips with custom strings. `tips`: array of tip strings. `excludeDefault`: if `true`, only show custom tips; if `false` or absent, custom tips are merged with built-in tips| `{ "excludeDefault": true, "tips": ["Use our internal tool X"] }` `spinnerVerbs`| Customize the action verbs shown in the spinner and turn duration messages. Set `mode` to `"replace"` to use only your verbs, or `"append"` to add them to the defaults| `{"mode": "append", "verbs": ["Pondering", "Crafting"]}` @@ -303,7 +304,7 @@ Keys| Description| Example ---|---|--- `enabled`| Enable bash sandboxing (macOS, Linux, and WSL2). Default: false| `true` -`failIfUnavailable`| Exit with an error at startup if `sandbox.enabled` is true but the sandbox cannot start (missing dependencies, unsupported platform, or platform restrictions). When false (default), a warning is shown and commands run unsandboxed. Intended for managed settings deployments that require sandboxing as a hard gate| `true` +`failIfUnavailable`| Exit with an error at startup if `sandbox.enabled` is true but the sandbox cannot start (missing dependencies or unsupported platform). When false (default), a warning is shown and commands run unsandboxed. Intended for managed settings deployments that require sandboxing as a hard gate| `true` `autoAllowBashIfSandboxed`| Auto-approve bash commands when sandboxed. Default: true| `true` `excludedCommands`| Commands that should run outside of the sandbox| `["docker *"]` `allowUnsandboxedCommands`| Allow commands to run outside the sandbox via the `dangerouslyDisableSandbox` parameter. When set to `false`, the `dangerouslyDisableSandbox` escape hatch is completely disabled and all commands must run sandboxed (or be in `excludedCommands`). Useful for enterprise policies that require strict sandboxing. Default: true| `false` @@ -488,7 +489,7 @@ Verify active settings -Run `/status` inside Claude Code to see which settings sources are active and where they come from. The output shows each configuration layer (managed, user, project) along with its origin, such as `Enterprise managed settings (remote)`, `Enterprise managed settings (plist)`, `Enterprise managed settings (HKLM)`, or `Enterprise managed settings (file)`. If a settings file contains errors, `/status` reports the issue so you can fix it. +Run `/status` inside Claude Code to see which settings sources are active and where they come from. The output shows each configuration layer (managed, user, project) along with its origin, such as `Enterprise managed settings (remote)`, `Enterprise managed settings (plist)`, `Enterprise managed settings (HKLM)`, `Enterprise managed settings (HKCU)`, or `Enterprise managed settings (file)`. If a settings file contains errors, `/status` reports the issue so you can fix it. ### @@ -895,4 +896,5 @@ * [Permissions](</docs/en/permissions>): permission system, rule syntax, tool-specific patterns, and managed policies * [Authentication](</docs/en/authentication>): set up user access to Claude Code - * [Troubleshooting](</docs/en/troubleshooting>): solutions for common configuration issues + * [Debug your configuration](</docs/en/debug-your-config>): diagnose why a setting, hook, or MCP server isn’t taking effect + * [Troubleshooting](</docs/en/troubleshooting>): installation, authentication, and platform issues
modified Advanced setup View current →
--- a/setup.md +++ b/setup.md @@ -323,7 +323,7 @@ Set `VERSION` to the release you want to verify. - REPO=https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases + REPO=https://downloads.claude.ai/claude-code-releases VERSION=2.1.89 curl -fsSLO "$REPO/$VERSION/manifest.json" curl -fsSLO "$REPO/$VERSION/manifest.json.sig"
modified Extend Claude with skills View current →
--- a/skills.md +++ b/skills.md @@ -190,10 +190,11 @@ `description`| Recommended| What the skill does and when to use it. Claude uses this to decide when to apply the skill. If omitted, uses the first paragraph of markdown content. Front-load the key use case: the combined `description` and `when_to_use` text is truncated at 1,536 characters in the skill listing to reduce context usage. `when_to_use`| No| Additional context for when Claude should invoke the skill, such as trigger phrases or example requests. Appended to `description` in the skill listing and counts toward the 1,536-character cap. `argument-hint`| No| Hint shown during autocomplete to indicate expected arguments. Example: `[issue-number]` or `[filename] [format]`. -`disable-model-invocation`| No| Set to `true` to prevent Claude from automatically loading this skill. Use for workflows you want to trigger manually with `/name`. Default: `false`. +`arguments`| No| Named positional arguments for `$name` substitution in the skill content. Accepts a space-separated string or a YAML list. Names map to argument positions in order. +`disable-model-invocation`| No| Set to `true` to prevent Claude from automatically loading this skill. Use for workflows you want to trigger manually with `/name`. Also prevents the skill from being [preloaded into subagents](</docs/en/sub-agents#preload-skills-into-subagents>). Default: `false`. `user-invocable`| No| Set to `false` to hide from the `/` menu. Use for background knowledge users shouldn’t invoke directly. Default: `true`. `allowed-tools`| No| Tools Claude can use without asking permission when this skill is active. Accepts a space-separated string or a YAML list. -`model`| No| Model to use when this skill is active. +`model`| No| Model to use when this skill is active. The override applies for the rest of the current turn and is not saved to settings; the session model resumes on your next prompt. Accepts the same values as [`/model`](</docs/en/model-config>), or `inherit` to keep the active model. `effort`| No| [Effort level](</docs/en/model-config#adjust-effort-level>) when this skill is active. Overrides the session effort level. Default: inherits from session. Options: `low`, `medium`, `high`, `xhigh`, `max`; available levels depend on the model. `context`| No| Set to `fork` to run in a forked subagent context. `agent`| No| Which subagent type to use when `context: fork` is set. @@ -214,6 +215,7 @@ `$ARGUMENTS`| All arguments passed when invoking the skill. If `$ARGUMENTS` is not present in the content, arguments are appended as `ARGUMENTS: <value>`. `$ARGUMENTS[N]`| Access a specific argument by 0-based index, such as `$ARGUMENTS[0]` for the first argument. `$N`| Shorthand for `$ARGUMENTS[N]`, such as `$0` for the first argument or `$1` for the second. +`$name`| Named argument declared in the `arguments` frontmatter list. Names map to positions in order, so with `arguments: [issue, branch]` the placeholder `$issue` expands to the first argument and `$branch` to the second. `${CLAUDE_SESSION_ID}`| The current session ID. Useful for logging, creating session-specific files, or correlating skill output with sessions. `${CLAUDE_SKILL_DIR}`| The directory containing the skill’s `SKILL.md` file. For plugin skills, this is the skill’s subdirectory within the plugin, not the plugin root. Use this in bash injection commands to reference scripts or files bundled with the skill, regardless of the current working directory. @@ -716,6 +718,7 @@ Related resources + * **[Debug your configuration](</docs/en/debug-your-config>)** : diagnose why a skill isn’t appearing or triggering * **[Subagents](</docs/en/sub-agents>)** : delegate tasks to specialized agents * **[Plugins](</docs/en/plugins>)** : package and distribute skills with other extensions * **[Hooks](</docs/en/hooks>)** : automate workflows around tool events
modified Create custom subagents View current →
--- a/sub-agents.md +++ b/sub-agents.md @@ -377,7 +377,7 @@ Implement API endpoints. Follow the conventions and patterns from the preloaded skills. -The full content of each skill is injected into the subagent’s context, not just made available for invocation. Subagents don’t inherit skills from the parent conversation; you must list them explicitly. +The full content of each skill is injected into the subagent’s context, not just made available for invocation. Subagents don’t inherit skills from the parent conversation; you must list them explicitly. You cannot preload skills that set [`disable-model-invocation: true`](</docs/en/skills#control-who-invokes-a-skill>), since preloading draws from the same set of skills Claude can invoke. If a listed skill is missing or disabled, Claude Code skips it and logs a warning to the debug log. This is the inverse of [running a skill in a subagent](</docs/en/skills#run-skills-in-a-subagent>). With `skills` in a subagent, the subagent controls the system prompt and loads skill content. With `context: fork` in a skill, the skill content is injected into the agent you specify. Both use the same underlying system. @@ -501,7 +501,7 @@ Define hooks directly in the subagent’s markdown file. These hooks only run while that specific subagent is active and are cleaned up when it finishes. -Frontmatter hooks fire when the agent is spawned as a subagent through the Agent tool or an @-mention. They do not fire when the agent runs as the main session via `--agent` or the `agent` setting. For session-wide hooks, configure them in [`settings.json`](</docs/en/hooks>). +Frontmatter hooks fire when the agent is spawned as a subagent through the Agent tool or an @-mention, and when the agent runs as the main session via `--agent` or the `agent` setting. In the main-session case they run alongside any hooks defined in [`settings.json`](</docs/en/hooks>). All [hook events](</docs/en/hooks#hook-events>) are supported. The most common events for subagents are: @@ -529,7 +529,7 @@ command: "./scripts/run-linter.sh" --- -`Stop` hooks in frontmatter are automatically converted to `SubagentStop` events. +When the agent is invoked as a subagent, `Stop` hooks in frontmatter are automatically converted to `SubagentStop` events. ####
modified Subagents in the SDK View current →
--- a/subagents.md +++ b/subagents.md @@ -129,10 +129,17 @@ `description`| `string`| Yes| Natural language description of when to use this agent `prompt`| `string`| Yes| The agent’s system prompt defining its role and behavior `tools`| `string[]`| No| Array of allowed tool names. If omitted, inherits all tools -`model`| `'sonnet' | 'opus' | 'haiku' | 'inherit'`| No| Model override for this agent. Defaults to main model if omitted +`disallowedTools`| `string[]`| No| Array of tool names to remove from the agent’s tool set +`model`| `string`| No| Model override for this agent. Accepts an alias such as `'sonnet'`, `'opus'`, `'haiku'`, `'inherit'`, or a full model ID. Defaults to main model if omitted `skills`| `string[]`| No| List of skill names available to this agent -`memory`| `'user' | 'project' | 'local'`| No| Memory source for this agent (Python only) +`memory`| `'user' | 'project' | 'local'`| No| Memory source for this agent `mcpServers`| `(string | object)[]`| No| MCP servers available to this agent, by name or inline config +`maxTurns`| `number`| No| Maximum number of agentic turns before the agent stops +`background`| `boolean`| No| Run this agent as a non-blocking background task when invoked +`effort`| `'low' | 'medium' | 'high' | 'xhigh' | 'max' | number`| No| Reasoning effort level for this agent +`permissionMode`| `PermissionMode`| No| Permission mode for tool execution within this agent + +In the Python SDK, these field names use camelCase to match the wire format. See the [`AgentDefinition` reference](</docs/en/agent-sdk/python#agent-definition>) for details. Subagents cannot spawn their own subagents. Don’t include `Agent` in a subagent’s `tools` array.
modified Configure your terminal for Claude Code View current →
--- a/terminal-config.md +++ b/terminal-config.md @@ -23,7 +23,7 @@ VS Code, Cursor, Windsurf, Alacritty, Zed| Run `/terminal-setup` once Windows Terminal, gnome-terminal, JetBrains IDEs such as PyCharm and Android Studio| Not available; use Ctrl+J or `\` then Enter -For VS Code, Cursor, Windsurf, Alacritty, and Zed, `/terminal-setup` writes Shift+Enter and other keybindings into the terminal’s configuration file. If it reports a conflict such as `Found existing VSCode terminal Shift+Enter key binding`, remove that entry from the terminal’s own keybindings file, for example VS Code’s `keybindings.json`, and run the command again. Run `/terminal-setup` directly in the host terminal rather than inside tmux or screen, since it needs to write to the host terminal’s configuration. If you are running inside tmux, Shift+Enter also requires the tmux configuration below even when the outer terminal supports it. To bind newline to a different key, or to swap behavior so Enter inserts a newline and Shift+Enter submits, map the `chat:newline` and `chat:submit` actions in your [keybindings file](</docs/en/keybindings>). +For VS Code, Cursor, Windsurf, Alacritty, and Zed, `/terminal-setup` writes Shift+Enter and other keybindings into the terminal’s configuration file. In VS Code, Cursor, and Windsurf it also sets `terminal.integrated.mouseWheelScrollSensitivity` in the editor settings for smoother scrolling in [fullscreen mode](</docs/en/fullscreen>). Existing bindings and settings are left in place; if you see a message such as `VSCode terminal Shift+Enter key binding already configured`, no change was made. Run `/terminal-setup` directly in the host terminal rather than inside tmux or screen, since it needs to write to the host terminal’s configuration. If you are running inside tmux, Shift+Enter also requires the tmux configuration below even when the outer terminal supports it. To bind newline to a different key, or to swap behavior so Enter inserts a newline and Shift+Enter submits, map the `chat:newline` and `chat:submit` actions in your [keybindings file](</docs/en/keybindings>). ##
modified Troubleshooting View current →
--- a/troubleshooting.md +++ b/troubleshooting.md @@ -43,13 +43,13 @@ Check network connectivity -The installer downloads from `storage.googleapis.com`. Verify you can reach it: - - curl -sI https://storage.googleapis.com +The installer downloads from `downloads.claude.ai`. Verify you can reach it: + + curl -sI https://downloads.claude.ai If this fails, your network may be blocking the connection. Common causes: - * Corporate firewalls or proxies blocking Google Cloud Storage + * Corporate firewalls or proxies blocking `downloads.claude.ai` * Regional network restrictions: try a VPN or alternative network * TLS/SSL issues: update your system’s CA certificates, or check if `HTTPS_PROXY` is configured @@ -235,9 +235,9 @@ The `curl ... | bash` command downloads the script and passes it directly to Bash for execution using a pipe (`|`). This error means the connection broke before the script finished downloading. Common causes include network interruptions, the download being blocked mid-stream, or system resource limits. **Solutions:** - 1. **Check network stability** : Claude Code binaries are hosted on Google Cloud Storage. Test that you can reach it: - - curl -fsSL https://storage.googleapis.com -o /dev/null + 1. **Check network stability** : Claude Code binaries are hosted at `downloads.claude.ai`. Test that you can reach it: + + curl -fsSL https://downloads.claude.ai -o /dev/null If the command completes silently, your connection is fine and the issue is likely intermittent. Retry the install command. If you see an error, your network may be blocking the download. 2. **Try an alternative install method** : On macOS or Linux: @@ -284,13 +284,13 @@ ​ -`Failed to fetch version from storage.googleapis.com` - -The installer couldn’t reach the download server. This typically means `storage.googleapis.com` is blocked on your network. **Solutions:** +`Failed to fetch version from downloads.claude.ai` + +The installer couldn’t reach the download server. This typically means `downloads.claude.ai` is blocked on your network. **Solutions:** 1. **Test connectivity directly** : - curl -sI https://storage.googleapis.com + curl -sI https://downloads.claude.ai 2. **If behind a proxy** , set `HTTPS_PROXY` so the installer can route through it. See [proxy configuration](</docs/en/network-config#proxy-configuration>) for details. @@ -427,7 +427,7 @@ ldd /bin/ls | head -1 If it shows `linux-vdso.so` or references to `/lib/x86_64-linux-gnu/`, you’re on glibc. If it shows `musl`, you’re on musl. - 2. **If you’re on glibc but got the musl binary** , remove the installation and reinstall. You can also manually download the correct binary from the GCS bucket at `https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/{VERSION}/manifest.json`. File a [GitHub issue](<https://github.com/anthropics/claude-code/issues>) with the output of `ldd /bin/ls` and `ls /lib/libc.musl*`. + 2. **If you’re on glibc but got the musl binary** , remove the installation and reinstall. You can also manually download the correct binary using the manifest at `https://downloads.claude.ai/claude-code-releases/{VERSION}/manifest.json`. File a [GitHub issue](<https://github.com/anthropics/claude-code/issues>) with the output of `ldd /bin/ls` and `ls /lib/libc.musl*`. 3. **If you’re actually on musl** (Alpine Linux), install the required packages: apk add libgcc libstdc++ ripgrep
modified Agent SDK reference - TypeScript View current →
--- a/typescript.md +++ b/typescript.md @@ -437,6 +437,7 @@ `resumeSessionAt`| `string`| `undefined`| Resume session at a specific message UUID `sandbox`| `SandboxSettings`| `undefined`| Configure sandbox behavior programmatically. See Sandbox settings for details `sessionId`| `string`| Auto-generated| Use a specific UUID for the session instead of auto-generating one +`sessionStore`| [`SessionStore`](</docs/en/agent-sdk/session-storage#the-session-store-interface>)| `undefined`| Mirror session transcripts to an external backend so any host can resume them. See [Persist sessions to external storage](</docs/en/agent-sdk/session-storage>) `settingSources`| `SettingSource``[]`| CLI defaults (all sources)| Control which filesystem settings to load. Pass `[]` to disable user, project, and local settings. Managed policy settings load regardless. See [Use Claude Code features](</docs/en/agent-sdk/claude-code-features#what-settingsources-does-not-control>) `spawnClaudeCodeProcess`| `(options: SpawnOptions) => SpawnedProcess`| `undefined`| Custom function to spawn the Claude Code process. Use to run Claude Code in VMs, containers, or remote environments `stderr`| `(data: string) => void`| `undefined`| Callback for stderr output @@ -560,10 +561,15 @@ tools?: string[]; disallowedTools?: string[]; prompt: string; - model?: "sonnet" | "opus" | "haiku" | "inherit"; + model?: string; mcpServers?: AgentMcpServerSpec[]; skills?: string[]; + initialPrompt?: string; maxTurns?: number; + background?: boolean; + memory?: "user" | "project" | "local"; + effort?: "low" | "medium" | "high" | "xhigh" | "max" | number; + permissionMode?: PermissionMode; criticalSystemReminder_EXPERIMENTAL?: string; }; @@ -573,10 +579,15 @@ `tools`| No| Array of allowed tool names. If omitted, inherits all tools from parent `disallowedTools`| No| Array of tool names to explicitly disallow for this agent `prompt`| Yes| The agent’s system prompt -`model`| No| Model override for this agent. If omitted or `'inherit'`, uses the main model +`model`| No| Model override for this agent. Accepts an alias such as `'sonnet'`, `'opus'`, `'haiku'`, `'inherit'`, or a full model ID. If omitted or `'inherit'`, uses the main model `mcpServers`| No| MCP server specifications for this agent `skills`| No| Array of skill names to preload into the agent context +`initialPrompt`| No| Auto-submitted as the first user turn when this agent runs as the main thread agent `maxTurns`| No| Maximum number of agentic turns (API round-trips) before stopping +`background`| No| Run this agent as a non-blocking background task when invoked +`memory`| No| Memory source for this agent: `'user'`, `'project'`, or `'local'` +`effort`| No| Reasoning effort level for this agent. Accepts a named level or an integer +`permissionMode`| No| Permission mode for tool execution within this agent. See `PermissionMode` `criticalSystemReminder_EXPERIMENTAL`| No| Experimental: Critical reminder added to the system prompt ###