Changes on
29 changes detected
--- a/agent-view.md
+++ b/agent-view.md
@@ -357,15 +357,19 @@
Permission mode, model, and effort
-A background session reads its [settings](</docs/en/settings>) from the directory it runs in, the same as if you had started `claude` there. The [permission mode](</docs/en/permissions>) depends on how you started the session. Backgrounding an existing session with `/bg` or `←` keeps the current permission mode, so a session you switched to `acceptEdits` or `auto` stays in that mode after detaching. Dispatching from the agent view input or running `claude --bg` from your shell uses the `defaultMode` from that directory’s settings, or the `permissionMode` from the dispatched [subagent’s frontmatter](</docs/en/sub-agents#supported-frontmatter-fields>). The permission mode you start a background session with persists when the supervisor later stops and restarts the session’s process. A session you launched with `claude --bg --dangerously-skip-permissions` or `claude --bg --permission-mode bypassPermissions` stays in `bypassPermissions` after that restart instead of falling back to the directory’s `defaultMode`. To set defaults for every session you dispatch from agent view, pass any of `--permission-mode`, `--model`, or `--effort` when opening it:
+A background session reads its [settings](</docs/en/settings>) from the directory it runs in, the same as if you had started `claude` there. The [permission mode](</docs/en/permissions>) depends on how you started the session. Backgrounding an existing session with `/bg` or `←` keeps the current permission mode, so a session you switched to `acceptEdits` or `auto` stays in that mode after detaching. Dispatching from the agent view input or running `claude --bg` from your shell uses the `defaultMode` from that directory’s settings, or the `permissionMode` from the dispatched [subagent’s frontmatter](</docs/en/sub-agents#supported-frontmatter-fields>). The permission mode you start a background session with persists when the supervisor later stops and restarts the session’s process. A session you launched with `claude --bg --dangerously-skip-permissions` or `claude --bg --permission-mode bypassPermissions` stays in `bypassPermissions` after that restart instead of falling back to the directory’s `defaultMode`. To set defaults for every session you dispatch from agent view, pass any of `--permission-mode`, `--model`, `--effort`, or `--agent` when opening it:
claude agents --permission-mode plan --model opus --effort high
-`claude agents` also accepts `--dangerously-skip-permissions` as shorthand for `--permission-mode bypassPermissions`, and `--allow-dangerously-skip-permissions` to make `bypassPermissions` available in each dispatched session’s `Shift+Tab` cycle without starting in that mode. Both match the [top-level CLI flags](</docs/en/cli-reference>).
-
-Passing `--permission-mode`, `--model`, `--effort`, or `--dangerously-skip-permissions` to `claude agents` requires Claude Code v2.1.142 or later. `--allow-dangerously-skip-permissions` on `claude agents` requires v2.1.143 or later. Earlier versions reject these flags with an unknown-option error.
-
-The active defaults appear in the footer below the dispatch input. Without these flags, the session uses the `defaultMode` from that directory’s settings or the `permissionMode` from the dispatched [subagent’s frontmatter](</docs/en/sub-agents#supported-frontmatter-fields>), and the model shown in the agent view header. Using `bypassPermissions` or `auto` is refused until you have accepted that mode by running `claude` with it once interactively, since those modes let a session you aren’t watching act without approval. The same applies whether you pass the mode to `claude agents` or to `claude --bg --permission-mode`.
+`--agent` sets the [subagent](</docs/en/sub-agents>) used when a dispatch prompt does not name one, either with `@name` or as the first word. It defaults to the [`agent` setting](</docs/en/settings#available-settings>) if one is set, otherwise the built-in catch-all `claude` agent. Naming a subagent in the dispatch input overrides both. `claude agents` also accepts `--dangerously-skip-permissions` as shorthand for `--permission-mode bypassPermissions`, and `--allow-dangerously-skip-permissions` to make `bypassPermissions` available in each dispatched session’s `Shift+Tab` cycle without starting in that mode. Both match the [top-level CLI flags](</docs/en/cli-reference>). These flags were added across releases. Earlier versions reject them with an unknown-option error.
+
+Flag or setting| Minimum version
+---|---
+`--permission-mode`, `--model`, `--effort`, `--dangerously-skip-permissions`| v2.1.142
+`--allow-dangerously-skip-permissions`| v2.1.143
+`--agent`, and honoring the `agent` setting for dispatched sessions| v2.1.157
+
+Before v2.1.157, agent view ignores the `agent` setting and dispatches the built-in `claude` agent. The active defaults appear in the footer below the dispatch input. Without these flags, the session uses the `defaultMode` from that directory’s settings or the `permissionMode` from the dispatched [subagent’s frontmatter](</docs/en/sub-agents#supported-frontmatter-fields>), and the model shown in the agent view header. Using `bypassPermissions` or `auto` is refused until you have accepted that mode by running `claude` with it once interactively, since those modes let a session you aren’t watching act without approval. The same applies whether you pass the mode to `claude agents` or to `claude --bg --permission-mode`.
###
--- a/changelog.md
+++ b/changelog.md
@@ -5,6 +5,54 @@
> Use this file to discover all available pages before exploring further.
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.158
+
+May 30, 2026
+
+ * Auto mode is now available on Bedrock, Vertex, and Foundry for Opus 4.7 and Opus 4.8. Opt in by setting `CLAUDE_CODE_ENABLE_AUTO_MODE=1`
+
+
+
+2.1.157
+
+May 29, 2026
+
+ * Plugins in `.claude/skills` directories are now automatically loaded, no marketplace required
+ * Added `claude plugin init <name>` to scaffold a new plugin in `.claude/skills`
+ * Added autocomplete for `/plugin` arguments: subcommands, installed plugin names, and plugins from known marketplaces
+ * `claude agents`: the `agent` field in `settings.json` is now honored for dispatched sessions, with `--agent <name>` to override it
+ * `EnterWorktree` can now switch between Claude-managed worktrees mid-session
+ * `tool_decision` telemetry events now include `tool_parameters` (bash commands, MCP/skill names) when `OTEL_LOG_TOOL_DETAILS=1`
+ * Worktrees managed by Claude are now left unlocked when the agent finishes, so `git worktree remove`/`prune` can clean them up
+ * Fixed unprocessable images (zero-byte, corrupt) attached via paste, MCP, or dialog crashing the request instead of becoming a text placeholder
+ * Fixed sandbox network permission prompts appearing in auto and bypass-permissions mode when using the desktop app, IDE extensions, or SDK
+ * Fixed `claude agents` completed sessions not retiring when an idle subagent was still parked or had leaked a backgrounded shell
+ * Fixed `claude agents` pressing Esc not cancelling a slow “opening…”, leaving the list unresponsive
+ * Fixed background agent worktrees under `.claude/worktrees/` being orphaned after the 30-day job retention sweep
+ * Fixed background sessions re-attached after a sleep/wake not telling the model the correct date
+ * Fixed copy-on-select in `claude agents` not reaching the system clipboard inside tmux with `set-clipboard on` (regression in 2.1.153)
+ * Fixed `--resume` not reporting background subagents that were running when the previous Claude Code process exited
+ * Fixed the `--resume` session picker leaving its contents on the terminal after exiting in fullscreen mode
+ * Fixed `--worktree` and `--worktree --tmux` returning to the canonical repo root instead of the current linked worktree
+ * Fixed the `/model` picker showing an incorrect “Newer version available” hint when the selected model is already the newest in its family; the pinned-model row now shows the model’s description instead of its raw ID
+ * Fixed literal markdown markers (backticks, asterisks) appearing in the in-progress message text in fullscreen mode
+ * Fixed the terminal freezing after approving the managed-settings security dialog at startup
+ * Fixed a rare duplicate line appearing in scrollback after the terminal UI redraws
+ * Fixed right-click paste duplicating the clipboard in the VS Code, Cursor, and Windsurf integrated terminals
+ * WSL: fixed image paste (`alt+v` keybinding), screenshot paste on Windows 11, and added support for dragging images from Windows Explorer
+ * Improved performance of long and resumed conversations by eliminating redundant message-rendering recomputations
+ * `/terminal-setup` now disables GPU acceleration in VS Code/Cursor/Windsurf integrated terminals to prevent garbled-text rendering
+ * The Feature of the Week credit-claim status now appears as a notification in the status area instead of a line above the prompt
+ * `claude agents`: slash-command autocomplete in the dispatch input now matches substrings
+ * Removed the “bash commands will be sandboxed” startup banner — sandbox status still shows in `/status` and when a command is blocked
+ * Removed the “/ide for …” startup hint toast
+ * [IDE] Fixed clicking Stop while a background subagent is running not actually stopping it
+ * [VSCode] Fixed the fast mode indicator not appearing on Opus 4.8
+ * Pressing backspace right after a workflow trigger keyword now dismisses the workflow request (same as alt+w) instead of deleting a character
+ * Added a “Workflow keyword trigger” setting in /config to stop the word “workflow” in a prompt from triggering a dynamic workflow
--- a/cli-reference.md
+++ b/cli-reference.md
@@ -26,7 +26,7 @@
`claude auth login`| Sign in to your Anthropic account. Use `--email` to pre-fill your email address, `--sso` to force SSO authentication, and `--console` to sign in with Anthropic Console for API usage billing instead of a Claude subscription| `claude auth login --console`
`claude auth logout`| Log out from your Anthropic account| `claude auth logout`
`claude auth status`| Show authentication status as JSON. Use `--text` for human-readable output. Exits with code 0 if logged in, 1 if not| `claude auth status`
-`claude agents`| Open [agent view](</docs/en/agent-view>) to monitor and dispatch parallel background sessions. Use `--cwd <path>` to show only sessions started under that directory, or `--json` to print live sessions as a JSON array for scripting. Pass `--permission-mode`, `--model`, or `--effort` to set [defaults for dispatched sessions](</docs/en/agent-view#permission-mode-model-and-effort>). Accepts `--settings`, `--add-dir`, `--plugin-dir`, and `--mcp-config` like the top-level `claude` command. Opening agent view requires an interactive terminal| `claude agents --json`
+`claude agents`| Open [agent view](</docs/en/agent-view>) to monitor and dispatch parallel background sessions. Use `--cwd <path>` to show only sessions started under that directory, or `--json` to print live sessions as a JSON array for scripting. Pass `--permission-mode`, `--model`, `--effort`, or `--agent` to set [defaults for dispatched sessions](</docs/en/agent-view#permission-mode-model-and-effort>). Accepts `--settings`, `--add-dir`, `--plugin-dir`, and `--mcp-config` like the top-level `claude` command. Opening agent view requires an interactive terminal| `claude agents --json`
`claude attach <id>`| Attach to a [background session](</docs/en/agent-view#manage-sessions-from-the-shell>) in this terminal| `claude attach 7c5dcf5d`
`claude auto-mode defaults`| Print the built-in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) classifier rules as JSON. Use `claude auto-mode config` to see your effective config with settings applied| `claude auto-mode defaults > rules.json`
`claude daemon status`| Print the background-session [supervisor’s](</docs/en/agent-view#the-supervisor-process>) state, version, socket directory, and worker count for diagnostics. Exits 1 if the supervisor isn’t running| `claude daemon status`
--- a/desktop.md
+++ b/desktop.md
@@ -348,7 +348,7 @@
Watch background tasks
-The tasks pane shows the background work running inside the current session: subagents, background shell commands, and dynamic workflows. Open it from the **Views** menu or drag it into your layout. Click any entry to see its output in the subagent pane or stop it. To see what other sessions are doing, use the sidebar.
+The tasks pane shows the background work running inside the current session: subagents, background shell commands, and [dynamic workflows](</docs/en/workflows>). Open it from the **Views** menu or drag it into your layout. Click any entry to see its output in the subagent pane or stop it. To see what other sessions are doing, use the sidebar.
###
@@ -794,7 +794,7 @@
* **Third-party providers** : Desktop connects to Anthropic’s API by default. Enterprise deployments can configure Vertex AI and gateway providers via [managed settings](<https://support.claude.com/en/articles/12622667-enterprise-configuration>). For Bedrock or Foundry, use the [CLI](</docs/en/quickstart>).
* **Linux** : the desktop app is available on macOS and Windows only. On Linux, use the [CLI](</docs/en/quickstart>).
* **Inline code suggestions** : Desktop does not provide autocomplete-style suggestions. It works through conversational prompts and explicit code changes.
- * **Agent teams** : multi-agent orchestration is available via the [CLI](</docs/en/agent-teams>) and [Agent SDK](</docs/en/headless>), not in Desktop.
+ * **Agent teams** : parallel Claude Code sessions that message each other are available in the [CLI](</docs/en/agent-teams>), not in Desktop. For multi-agent work inside one session, use [dynamic workflows](</docs/en/workflows>), which run in Desktop.
* **Terminal-dialog commands** : built-in commands that open an interactive panel in the terminal, such as `/permissions`, `/config`, `/agents`, and `/doctor`, are not available in the Code tab and reply with `isn't available in this environment`. Edit [settings files](</docs/en/settings>) directly to manage permission rules and configuration, or run the command from the standalone CLI.
##
--- a/env-vars.md
+++ b/env-vars.md
@@ -173,7 +173,7 @@
`CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK`| Set to `1` to disable the non-streaming fallback when a streaming request fails mid-stream. Streaming errors propagate to the retry layer instead. Useful when a proxy or gateway causes the fallback to produce duplicate tool execution
`CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL`| Set to `1` to skip automatic addition of the official plugin marketplace on first run
`CLAUDE_CODE_DISABLE_POLICY_SKILLS`| Set to `1` to skip loading skills from the system-wide managed skills directory. Useful for container or CI sessions that should not load operator-provisioned skills
-`CLAUDE_CODE_DISABLE_TERMINAL_TITLE`| Set to `1` to disable automatic terminal title updates based on conversation context
+`CLAUDE_CODE_DISABLE_TERMINAL_TITLE`| Set to `1` to disable automatic terminal title updates based on conversation context. In Agent SDK and `claude -p` sessions, this also skips the background Haiku request that generates the session title
`CLAUDE_CODE_DISABLE_THINKING`| Set to `1` to force-disable [extended thinking](<https://platform.claude.com/docs/en/build-with-claude/extended-thinking>) regardless of model support or other settings. More direct than `MAX_THINKING_TOKENS=0`
`CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL`| Set to `1` to disable virtual scrolling in [fullscreen rendering](</docs/en/fullscreen>) and render every message in the transcript. Use this if scrolling in fullscreen mode shows blank regions where messages should appear
`CLAUDE_CODE_DISABLE_WORKFLOWS`| Set to `1` to disable [workflows](</docs/en/workflows#turn-workflows-off>). Equivalent to the [`disableWorkflows`](</docs/en/settings#available-settings>) setting
@@ -266,7 +266,7 @@
`CLAUDE_CODE_USE_POWERSHELL_TOOL`| Controls the PowerShell tool. On Windows without Git Bash, the tool is enabled automatically; set to `0` to disable it. On Windows with Git Bash installed, the tool is rolling out progressively: set to `1` to opt in or `0` to opt out. On Linux, macOS, and WSL, set to `1` to enable it, which requires `pwsh` on your `PATH`. When enabled on Windows, Claude can run PowerShell commands natively instead of routing through Git Bash. See [PowerShell tool](</docs/en/tools-reference#powershell-tool>)
`CLAUDE_CODE_USE_VERTEX`| Use [Vertex](</docs/en/google-vertex-ai>)
`CLAUDE_CONFIG_DIR`| Override the configuration directory (default: `~/.claude`). All settings, credentials, session history, and plugins are stored under this path. Useful for running multiple accounts side by side: for example, `alias claude-work='CLAUDE_CONFIG_DIR=~/.claude-work claude'`
-`CLAUDE_EFFORT`| Set automatically in Bash tool subprocesses and hook commands to the active [effort level](</docs/en/model-config#adjust-effort-level>) for the turn: `low`, `medium`, `high`, `xhigh`, `max`, or `ultra`. The `ultra` value corresponds to ultracode in `/effort`; the variable reports the stored value, not the display label. Matches the `effort.level` field passed to [hooks](</docs/en/hooks>). Only set when the current model supports the effort parameter
+`CLAUDE_EFFORT`| Set automatically in Bash tool subprocesses and hook commands to the active [effort level](</docs/en/model-config#adjust-effort-level>) for the turn: `low`, `medium`, `high`, `xhigh`, or `max`. Ultracode is not a distinct level and reports as `xhigh`. Matches the `effort.level` field passed to [hooks](</docs/en/hooks>). Only set when the current model supports the effort parameter
`CLAUDE_ENABLE_BYTE_WATCHDOG`| Set to `1` to force-enable the byte-level streaming idle watchdog, or set to `0` to force-disable it. When unset, the watchdog is enabled by default for Anthropic API connections. The byte watchdog aborts a connection when no bytes arrive on the wire for the duration set by `CLAUDE_STREAM_IDLE_TIMEOUT_MS`, with a minimum of 5 minutes, independent of the event-level watchdog
`CLAUDE_ENABLE_BYTE_WATCHDOG_BEDROCK`| Set to `1` to enable the byte-level streaming idle watchdog on Amazon Bedrock `vnd.amazon.eventstream` responses. Off by default. Configure the timeout with `CLAUDE_STREAM_IDLE_TIMEOUT_MS`
`CLAUDE_ENABLE_STREAM_WATCHDOG`| Set to `1` to enable the event-level streaming idle watchdog. Off by default. Applies to all providers, including Bedrock. For Vertex and Foundry, this is the only idle watchdog available. On Bedrock, you can also enable the independent byte-level watchdog with `CLAUDE_ENABLE_BYTE_WATCHDOG_BEDROCK`; the two run together when both are set. Configure the timeout with `CLAUDE_STREAM_IDLE_TIMEOUT_MS`
--- a/errors.md
+++ b/errors.md
@@ -640,6 +640,7 @@
All three variants mean the same thing: the sequence of `tool_use`, `tool_result`, and `thinking` blocks in history no longer matches what the API expects. **What to do:**
+ * If you are using Opus 4.7 or Opus 4.8, run `claude update` first. Versions before v2.1.156 can trigger this error during normal tool use, and `/rewind` does not clear it.
* Run `/rewind`, or press Esc twice, to step back to a checkpoint before the corrupted turn and continue from there. See [Checkpointing](</docs/en/checkpointing>) for how checkpoints are created and restored.
###
--- a/hooks.md
+++ b/hooks.md
@@ -563,7 +563,7 @@
`transcript_path`| Path to conversation JSON
`cwd`| Current working directory when the hook is invoked
`permission_mode`| Current [permission mode](</docs/en/permissions#permission-modes>): `"default"`, `"plan"`, `"acceptEdits"`, `"auto"`, `"dontAsk"`, or `"bypassPermissions"`. Not all events receive this field: see each event’s JSON example below to check
-`effort`| Object with a `level` field holding the active [effort level](</docs/en/model-config#adjust-effort-level>) for the turn: `"low"`, `"medium"`, `"high"`, `"xhigh"`, `"max"`, or `"ultra"`. If the requested model effort exceeds what the current model supports, this is the downgraded level the model actually used. `"ultra"` is the stored value for ultracode and is reported here even though the model receives `xhigh`. The object matches the [status line](</docs/en/statusline#available-data>) `effort` field. Present for events that fire within a tool-use context, such as `PreToolUse`, `PostToolUse`, `Stop`, and `SubagentStop`, when the current model supports the effort parameter. The level is also available to hook commands and the Bash tool as the `$CLAUDE_EFFORT` environment variable.
+`effort`| Object with a `level` field holding the active [effort level](</docs/en/model-config#adjust-effort-level>) for the turn: `"low"`, `"medium"`, `"high"`, `"xhigh"`, or `"max"`. If the requested model effort exceeds what the current model supports, this is the downgraded level the model actually used. Ultracode is not a distinct level and reports as `"xhigh"`. The object matches the [status line](</docs/en/statusline#available-data>) `effort` field. Present for events that fire within a tool-use context, such as `PreToolUse`, `PostToolUse`, `Stop`, and `SubagentStop`, when the current model supports the effort parameter. The level is also available to hook commands and the Bash tool as the `$CLAUDE_EFFORT` environment variable.
`hook_event_name`| Name of the event that fired
When running with `--agent` or inside a subagent, two additional fields are included:
Show diff (490 lines)
--- a/hosting.md
+++ b/hosting.md
@@ -4,186 +4,304 @@
>
> Use this file to discover all available pages before exploring further.
-The Claude Agent SDK differs from traditional stateless LLM APIs in that it maintains conversational state and executes commands in a persistent environment. This guide covers the architecture, hosting considerations, and best practices for deploying SDK-based agents in production.
-
-For security hardening beyond basic sandboxing (including network controls, credential management, and isolation options), see [Secure Deployment](</docs/en/agent-sdk/secure-deployment>).
-
-##
-
-
-
-Hosting Requirements
-
-###
-
-
-
-Container-Based Sandboxing
-
-For security and isolation, the SDK should run inside a sandboxed container environment. This provides process isolation, resource limits, network control, and ephemeral filesystems. The SDK also supports [programmatic sandbox configuration](</docs/en/agent-sdk/typescript#sandboxsettings>) for command execution.
-
-###
-
-
-
-System Requirements
-
-Each SDK instance requires:
-
- * **Runtime dependencies**
- * Python 3.10+ for the Python SDK, or Node.js 18+ for the TypeScript SDK
- * Both SDK packages bundle a native Claude Code binary for the host platform, so no separate Claude Code or Node.js install is needed for the spawned CLI
- * **Resource allocation**
- * Recommended: 1GiB RAM, 5GiB of disk, and 1 CPU (vary this based on your task as needed)
- * **Network access**
- * Outbound HTTPS to `api.anthropic.com`
- * Optional: Access to MCP servers or external tools
-
-##
-
-
-
-Understanding the SDK Architecture
-
-Unlike stateless API calls, the Claude Agent SDK operates as a **long-running process** that:
-
- * **Executes commands** in a persistent shell environment
- * **Manages file operations** within a working directory
- * **Handles tool execution** with context from previous interactions
-
-##
-
-
-
-Sandbox Provider Options
-
-Several providers specialize in secure container environments for AI code execution:
-
- * **[Modal Sandbox](<https://modal.com/docs/guide/sandbox>)** \- [demo implementation](<https://modal.com/docs/examples/claude-slack-gif-creator>)
- * **[Cloudflare Sandboxes](<https://github.com/cloudflare/sandbox-sdk>)**
- * **[Daytona](<https://www.daytona.io/>)**
- * **[E2B](<https://e2b.dev/>)**
- * **[Fly Machines](<https://fly.io/docs/machines/>)**
- * **[Vercel Sandbox](<https://vercel.com/docs/functions/sandbox>)**
-
-For self-hosted options (Docker, gVisor, Firecracker) and detailed isolation configuration, see [Isolation Technologies](</docs/en/agent-sdk/secure-deployment#isolation-technologies>).
-
-##
-
-
-
-Production Deployment Patterns
-
-###
-
-
-
-Pattern 1: Ephemeral Sessions
-
-Create a new container for each user task, then destroy it when complete. Best for one-off tasks, the user may still interact with the AI while the task is completing, but once completed the container is destroyed. **Examples:**
-
- * Bug Investigation & Fix: Debug and resolve a specific issue with relevant context
- * Invoice Processing: Extract and structure data from receipts/invoices for accounting systems
- * Translation Tasks: Translate documents or content batches between languages
- * Image/Video Processing: Apply transformations, optimizations, or extract metadata from media files
-
-###
-
-
-
-Pattern 2: Long-Running Sessions
-
-Maintain persistent container instances for long running tasks. Often times running _multiple_ Claude Agent processes inside of the container based on demand. Best for proactive agents that take action without the users input, agents that serve content or agents that process high amounts of messages. **Examples:**
-
- * Email Agent: Monitors incoming emails and autonomously triages, responds, or takes actions based on content
- * Site Builder: Hosts custom websites per user with live editing capabilities served through container ports
- * High-Frequency Chat Bots: Handles continuous message streams from platforms like Slack where rapid response times are critical
-
-###
-
-
-
-Pattern 3: Hybrid Sessions
-
-Ephemeral containers that are hydrated with history and state, possibly from a database or from the SDK’s session resumption features. Best for containers with intermittent interaction from the user that kicks off work and spins down when the work is completed but can be continued. **Examples:**
-
- * Personal Project Manager: Helps manage ongoing projects with intermittent check-ins, maintains context of tasks, decisions, and progress
- * Deep Research: Conducts multi-hour research tasks, saves findings and resumes investigation when user returns
- * Customer Support Agent: Handles support tickets that span multiple interactions, loads ticket history and customer context
-
-###
-
-
-
-Pattern 4: Single Containers
-
-Run multiple Claude Agent SDK processes in one global container. Best for agents that must collaborate closely together. This is likely the least popular pattern because you will have to prevent agents from overwriting each other. **Examples:**
-
- * **Simulations** : Agents that interact with each other in simulations such as video games.
-
-##
-
-
-
-FAQ
-
-###
-
-
-
-How do I communicate with my sandboxes?
-
-When hosting in containers, expose ports to communicate with your SDK instances. Your application can expose HTTP/WebSocket endpoints for external clients while the SDK runs internally within the container.
-
-###
-
-
-
-What is the cost of hosting a container?
-
-The dominant cost of serving agents is the tokens; containers vary based on what you provision, but a minimum cost is roughly 5 cents per hour running.
-
-###
-
-
-
-When should I shut down idle containers vs. keeping them warm?
-
-This is likely provider dependent, different sandbox providers will let you set different criteria for idle timeouts after which a sandbox might spin down. You will want to tune this timeout based on how frequent you think user response might be.
-
-###
-
-
-
-How often should I update the Claude Code CLI?
-
-The Claude Code CLI is versioned with semver, so any breaking changes will be versioned.
-
-###
-
-
-
-How do I monitor container health and agent performance?
-
-Since containers are just servers the same logging infrastructure you use for the backend will work for containers.
-
-###
-
-
-
-How long can an agent session run before timing out?
-
-An agent session will not timeout, but consider setting a ‘maxTurns’ property to prevent Claude from getting stuck in a loop.
-
-##
-
-
-
-Next Steps
-
- * [Secure Deployment](</docs/en/agent-sdk/secure-deployment>) \- Network controls, credential management, and isolation hardening
- * [TypeScript SDK - Sandbox Settings](</docs/en/agent-sdk/typescript#sandboxsettings>) \- Configure sandbox programmatically
- * [Sessions Guide](</docs/en/agent-sdk/sessions>) \- Learn about session management
- * [Permissions](</docs/en/agent-sdk/permissions>) \- Configure tool permissions
- * [Cost Tracking](</docs/en/agent-sdk/cost-tracking>) \- Monitor API usage
- * [MCP Integration](</docs/en/agent-sdk/mcp>) \- Extend with custom tools
+The Agent SDK spawns and supervises a `claude` CLI subprocess that owns a shell, a working directory, and session files on disk. Hosting it is not like hosting a stateless API wrapper. Every running agent is a long-lived process tied to local state, which shapes how you allocate resources, persist sessions, and scale across tenants. This page covers self-hosting on your own infrastructure: understand the subprocess model, choose a session pattern, provision the container, and handle production concerns like persistence, observability, auth, and multi-tenant isolation. For deployable Dockerfiles and Kubernetes manifests, see the [hosting cookbook](<https://github.com/anthropics/claude-cookbooks/tree/main/claude_agent_sdk/hosting>). If you do not need infrastructure control, custom isolation, or your own data plane, consider [Managed Agents](<https://platform.claude.com/docs/en/managed-agents/overview>) instead: a hosted REST API where Anthropic runs the agent and the sandbox, so your application sends events and streams back results with no hosting infrastructure to operate.
+
+For security hardening beyond basic sandboxing, including network controls, credential management, and isolation options, see [Secure Deployment](</docs/en/agent-sdk/secure-deployment>).
+
+##
+
+
+
+The subprocess model
+
+Every hosting decision on this page follows from how the SDK runs the agent. When your code calls `query()`, the SDK spawns a separate `claude` CLI process and talks to it over stdio. That subprocess owns the shell, the working directory, and the JSONL session transcripts on local disk. One agent session maps to one subprocess. Running N concurrent sessions means N subprocesses, each with its own process tree and transcript file. By default they all inherit your application’s working directory, so pass `cwd` on each `query()` call when sessions need separate filesystems:
+
+TypeScript
+
+Python
+
+ query({ prompt, options: { cwd: "/work/session-a" } })
+
+###
+
+
+
+State that lives on local disk
+
+Three kinds of agent state live on the container’s filesystem by default. None of them survive a container restart, a scale-down, or a move to a different node.
+
+State| Default location
+---|---
+Session transcripts| `~/.claude/projects/`, or the `projects/` directory under `CLAUDE_CONFIG_DIR` if set
+`CLAUDE.md` memory files| `~/.claude/CLAUDE.md` for the user tier and the session’s working directory for the project tier
+Working-directory artifacts| The session’s working directory
+
+To persist transcripts across hosts, configure a [`SessionStore` adapter](</docs/en/agent-sdk/session-storage>). Memory files and other working-directory artifacts need their own storage strategy, such as a mounted volume or an object-store sync. For how sessions, resumption, and forking work at the API level, see [Sessions](</docs/en/agent-sdk/sessions>).
+
+##
+
+
+
+Choose a session pattern
+
+These four patterns cover session lifecycle: how long a container lives relative to the sessions it serves. For where the container runs, the [hosting cookbook](<https://github.com/anthropics/claude-cookbooks/blob/main/claude_agent_sdk/07_Hosting_the_agent.ipynb>) has [deployable code](<https://github.com/anthropics/claude-cookbooks/tree/main/claude_agent_sdk/hosting>) for local Docker, Modal, and Kubernetes. Choose a session pattern here and a deployment target from the cookbook.
+
+###
+
+
+
+Ephemeral sessions
+
+Create a container for each user task and destroy it when the task completes. Best for one-off tasks. The user may still interact with the AI while the task is completing, but once completed the container is destroyed. Example workloads include bug investigation and fix, invoice and receipt extraction, document translation, and media transformation. The container runs a one-shot entrypoint that calls the SDK and exits. The example below shows a minimal TypeScript version. Save it as `entrypoint.mts` or set `"type": "module"` in `package.json` so top-level `await` is available.
+
+ import { query } from "@anthropic-ai/claude-agent-sdk";
+
+ const prompt = process.env.TASK_PROMPT!;
+ for await (const message of query({ prompt, options: { maxTurns: 20 } })) {
+ console.log(message);
+ }
+
+###
+
+
+
+Long-running sessions
+
+Run persistent container instances, often hosting multiple SDK processes per container, to serve ongoing work. Best for agents that take autonomous action, serve content, or handle high-volume message streams. Example workloads include an email agent that triages and responds to incoming mail, a site builder that hosts a per-user editable site through container ports, and a chat bot that handles continuous traffic from a platform like Slack. The container exposes an HTTP or WebSocket endpoint and maps each active session to a long-lived query and the subprocess behind it. In TypeScript, use [`streamInput()`](</docs/en/agent-sdk/typescript#query-object>) to add turns to an active session and [`startup()`](</docs/en/agent-sdk/typescript#startup>) to pre-warm subprocesses ahead of incoming traffic. In Python, use [`ClaudeSDKClient`](</docs/en/agent-sdk/python#claudesdkclient>) to hold a session open across turns. Size the container so it can hold the maximum number of concurrent sessions in memory.
+
+###
+
+
+
+Hybrid sessions
+
+Ephemeral containers that hydrate from a [`SessionStore`](</docs/en/agent-sdk/session-storage>) on startup and persist updates back. Best for sessions that span many interactions but sit idle between them. The container spins down during idle periods and spins back up when the user returns. Example workloads include a personal project manager with intermittent check-ins, deep research that pauses and resumes over hours, and a customer support agent that loads ticket history across interactions. Tune your provider’s idle timeout to how frequently you expect users to return. Shutting a container down without a `SessionStore` configured loses the transcript with it, so the store is required for this pattern, not optional. The pattern hinges on resuming a session by ID with a shared store attached:
+
+TypeScript
+
+Python
+
+ import { query, type SessionStore } from "@anthropic-ai/claude-agent-sdk";
+
+ declare const userInput: string;
+ declare const sessionId: string; // looked up from your database by user
+ declare const sessionStore: SessionStore; // S3, Redis, Postgres, or your own adapter
+
+ for await (const message of query({
+ prompt: userInput,
+ options: { resume: sessionId, sessionStore },
+ })) {
+ // ...
+ }
+
+See [Session storage](</docs/en/agent-sdk/session-storage>) for the full `SessionStore` interface and reference adapters.
+
+###
+
+
+
+Multi-agent container
+
+Run multiple SDK subprocesses inside one container. Best for agents that must collaborate closely, for example multi-agent simulations where the agents interact with each other in a shared environment. Give each agent its own working directory so they do not overwrite each other’s files, and isolate settings loading so per-agent `CLAUDE.md` files do not leak across agents. See Multi-tenant isolation for the specific options.
+
+##
+
+
+
+Provision the container
+
+###
+
+
+
+Container-based sandboxing
+
+Run the SDK inside a sandboxed container for process isolation, resource limits, network control, and an ephemeral filesystem. Several providers specialize in sandboxed container environments that fit the Agent SDK’s model. Questions to answer when choosing a provider:
+
+ * **Who runs the sandbox** : a sandbox-as-a-service provider operates the infrastructure for you, while self-hosted options give you software to run on your own.
+ * **Cold-start latency** : how long from “create a sandbox” to “ready to accept the first request.” Ephemeral patterns need sub-second starts. Long-running patterns tolerate more.
+ * **Persistent storage** : whether the provider offers durable volumes or only ephemeral disk. The hybrid pattern needs durable storage somewhere, whether in the sandbox or alongside it.
+ * **Pricing model** : per-second, per-request, or flat hourly billing. Per-second pricing suits bursty ephemeral workloads. Hourly suits long-running sessions.
+ * **Networking** : support for custom egress rules, outbound proxies, and private VPC peering for regulated environments.
+
+Providers to evaluate:
+
+ * [Modal Sandbox](<https://modal.com/docs/guide/sandbox>), with a [demo implementation](<https://modal.com/docs/examples/claude-slack-gif-creator>)
+ * [Cloudflare Sandboxes](<https://github.com/cloudflare/sandbox-sdk>)
+ * [Daytona](<https://www.daytona.io/>)
+ * [E2B](<https://e2b.dev/>)
+ * [Fly Machines](<https://fly.io/docs/machines/>)
+ * [Vercel Sandbox](<https://vercel.com/docs/functions/sandbox>)
+
+For self-hosted options such as Docker, gVisor, and Firecracker, and detailed isolation configuration, see [Isolation Technologies](</docs/en/agent-sdk/secure-deployment#isolation-technologies>).
+
+###
+
+
+
+Runtime dependencies
+
+The container needs only your SDK’s language runtime:
+
+ * Python 3.10+ for the Python SDK, or Node.js 18+ for the TypeScript SDK
+ * Both SDK packages bundle a native Claude Code binary for the host platform, so no separate Claude Code or Node.js install is needed for the spawned CLI
+
+The bundled binary is pinned to the SDK package version, so updating the SDK is how you update the CLI. The SDK follows semver: take patch releases continuously and review the [TypeScript](<https://github.com/anthropics/claude-agent-sdk-typescript/blob/main/CHANGELOG.md>) or [Python](<https://github.com/anthropics/claude-agent-sdk-python/blob/main/CHANGELOG.md>) changelog before taking a minor.
+
+###
+
+
+
+Resources
+
+1 GiB RAM, 5 GiB disk, and 1 CPU per agent is a reasonable starting point for a freshly started instance. Memory usage grows with session length and tool activity, so size for the session lengths and concurrency you actually need rather than the idle baseline. See Scaling and concurrency for how to work out agents per host.
+
+###
+
+
+
+Network
+
+The SDK needs outbound HTTPS to `api.anthropic.com`, or to your provider’s regional endpoint when running on Bedrock or Vertex. If your agents use [MCP servers](</docs/en/agent-sdk/mcp>) or external tools, they need outbound access to those endpoints as well. For production, route outbound traffic through an egress proxy that enforces domain allowlists, injects credentials, and logs requests. See [Secure Deployment](</docs/en/agent-sdk/secure-deployment>) for the full pattern. For inbound traffic, expose an HTTP or WebSocket port on the container. Your application handles client requests on that port and calls the SDK internally; the subprocess itself does not listen on the network.
+
+##
+
+
+
+Handle production concerns
+
+Work through these decisions before shipping a self-hosted agent.
+
+###
+
+
+
+Session and state persistence
+
+Default local disk is lost on restart, scale-down, or a move to a different node. For any session a user expects to resume, mirror the transcript to durable storage with a [`SessionStore` adapter](</docs/en/agent-sdk/session-storage>). See [Reference implementations](</docs/en/agent-sdk/session-storage#reference-implementations>) for S3, Redis, and Postgres adapters and a conformance suite for your own. Three things to know about how `SessionStore` behaves:
+
+ * **Transcripts only** : `SessionStore` mirrors transcripts, not `CLAUDE.md` memory files or other working-directory artifacts. Mount a shared volume or sync those separately.
+ * **Mirror, not replacement** : the subprocess writes to local disk first, and the store receives a copy of each batch. Local writes remain authoritative.
+ * **`mirror_error` messages**: if the store rejects or times out, the SDK emits a `{ type: "system", subtype: "mirror_error" }` message and continues the query without retry. Alert on these if store durability matters.
+
+###
+
+
+
+Observability
+
+Agent SDK agents are long-lived processes that spawn tool calls across many API round-trips. Without telemetry you cannot see which tools ran, how long they took, or where a session stalled. The SDK inherits OpenTelemetry configuration from the environment. Set the OTEL environment variables at the container or orchestrator level so every `query()` call exports spans, metrics, and log events to your collector. The example below enables OTLP export for all three signals. `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA` is required only for traces; omit it if you export metrics and logs alone.
+
+.env
+
+ CLAUDE_CODE_ENABLE_TELEMETRY=1
+ CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1
+ OTEL_TRACES_EXPORTER=otlp
+ OTEL_METRICS_EXPORTER=otlp
+ OTEL_LOGS_EXPORTER=otlp
+ OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
+ OTEL_EXPORTER_OTLP_ENDPOINT=http://collector.example.com:4318
+
+Prompt text and tool inputs are not included in exports by default. See [Control sensitive data in exports](</docs/en/agent-sdk/observability#control-sensitive-data-in-exports>) for the opt-in flags, and [Observability](</docs/en/agent-sdk/observability>) for the full signal catalog.
+
+###
+
+
+
+Auth and secrets
+
+Three auth concerns matter at hosting time:
+
+ * **Anthropic API** : the subprocess reads `ANTHROPIC_API_KEY` from its environment. Supply it from your secret manager, or set `ANTHROPIC_BASE_URL` to route model calls through a proxy that injects the key outside the container. See [Credential management](</docs/en/agent-sdk/secure-deployment#credential-management>) for the proxy pattern and the [SDK overview](</docs/en/agent-sdk/overview#get-started>) for supported authentication methods.
+ * **Inbound** : put authentication at a gateway in front of the agent container. The agent should receive pre-authenticated requests and should not be the component that validates user tokens.
+ * **Outbound tools** : keep tool credentials out of the agent environment. Route outbound calls through a proxy that injects API keys after the request leaves the container. The agent makes the call; the proxy adds the credential.
+
+###
+
+
+
+Scaling and concurrency
+
+Each session runs in its own subprocess, so concurrency on a host is bounded by how many subprocesses its RAM can hold. Size each host with this formula:
+
+ agents per host = (host RAM - overhead) / (per-session RAM ceiling)
+
+Measure the per-session ceiling by running a representative session to your target length under your expected tool load and recording peak RSS. The 1 GiB starting point in Resources is a floor, not the ceiling. Horizontal-scale routing depends on your pattern. For long-running sessions, where containers hold many sessions, run a pool of containers behind a load balancer and pin each session to one container using consistent hashing on `sessionId`. A pinned session keeps hitting the same container, and therefore the same running subprocess, until it is evicted or the container restarts. Large fanouts of concurrent [subagents](</docs/en/agent-sdk/subagents>) from a single session can hit API rate limits. Break the work into smaller batches rather than issuing one wide dispatch.
+
+###
+
+
+
+Cost
+
+Anthropic token cost typically dominates container infrastructure cost by an order of magnitude or more. A minimally provisioned container runs roughly $0.05 per hour, while a single long agent session can spend dollars in tokens. See [Cost tracking](</docs/en/agent-sdk/cost-tracking>) for per-session token accounting.
+
+###
+
+
+
+Multi-tenant isolation
+
+Default SDK behavior reads settings and `CLAUDE.md` memory files from the filesystem. In a shared container that serves multiple tenants, those files can leak one tenant’s context into another tenant’s session. To isolate tenants inside a shared container:
+
+ * Pass `settingSources: []` in TypeScript or `setting_sources=[]` in Python so no filesystem settings load.
+ * Set `CLAUDE_CODE_DISABLE_AUTO_MEMORY=1` in `env`. [Auto memory](</docs/en/memory#auto-memory>) at `~/.claude/projects/<project>/memory/` loads into the system prompt regardless of `settingSources`. See [What settingSources does not control](</docs/en/agent-sdk/claude-code-features#what-settingsources-does-not-control>) for the other inputs that load unconditionally.
+ * Point `CLAUDE_CONFIG_DIR` at a per-tenant directory so tenants do not share the `~/.claude.json` global config.
+ * Use a per-tenant working directory. Pass `cwd` explicitly on every `query()` call.
+ * Apply per-tenant egress rules at your proxy, such as distinct outbound IPs, credentials, or domain allowlists, so a compromised tenant cannot exfiltrate data via another tenant’s outbound policy.
+
+The example below applies the four SDK-level options together. Construct `tenantDir` and `configDir` so each tenant gets a path no other tenant can read. In TypeScript, `env` replaces the subprocess environment, so spread `...process.env` to keep inherited variables like `PATH` and `ANTHROPIC_API_KEY`. In Python, `env` is merged on top of the inherited environment.
+
+TypeScript
+
+Python
+
+ import { query } from "@anthropic-ai/claude-agent-sdk";
+
+ declare const prompt: string;
+ declare const tenantDir: string;
+ declare const configDir: string;
+
+ for await (const message of query({
+ prompt,
+ options: {
+ cwd: tenantDir,
+ settingSources: [],
+ env: {
+ ...process.env,
+ CLAUDE_CONFIG_DIR: configDir,
+ CLAUDE_CODE_DISABLE_AUTO_MEMORY: "1",
+ },
+ },
+ })) {
+ // ...
+ }
+
+For per-tenant network controls, see [Secure Deployment](</docs/en/agent-sdk/secure-deployment>).
+
+##
+
+
+
+Known limitations
+
+Plan around these in your deployment design.
+
+Limitation| What to do
+---|---
+No top-level session timeout| A session does not time out on its own. Set `maxTurns` in `Options` to bound how many tool-use round trips the agent takes before stopping.
+Memory growth over long sessions| Cap session length or recycle subprocesses periodically. See Scaling and concurrency.
+Large parallel-subagent fanouts can hit rate limits| Break work into smaller batches rather than issuing one wide dispatch.
+No per-subagent wall-clock deadline| Cap each [subagent](</docs/en/agent-sdk/subagents>) with `maxTurns` in its `AgentDefinition`. For background subagents only, `CLAUDE_ASYNC_AGENT_STALL_TIMEOUT_MS` sets a stall watchdog that fires when a `run_in_background` subagent stops producing output; it is not a total-runtime deadline.
+
+##
+
+
+
+Next steps
+
+ * [Hosting cookbook](<https://github.com/anthropics/claude-cookbooks/blob/main/claude_agent_sdk/07_Hosting_the_agent.ipynb>): notebook walkthrough with [deployable code](<https://github.com/anthropics/claude-cookbooks/tree/main/claude_agent_sdk/hosting>) for Docker, Modal, and Kubernetes.
+ * [Session storage](</docs/en/agent-sdk/session-storage>): persist transcripts across hosts with a `SessionStore` adapter.
+ * [Observability](</docs/en/agent-sdk/observability>): export OTEL traces, metrics, and logs to your collector.
+ * [Secure deployment](</docs/en/agent-sdk/secure-deployment>): network controls, credential management, and isolation hardening.
+ * [Cost tracking](</docs/en/agent-sdk/cost-tracking>): per-session token and cost accounting.
--- a/interactive-mode.md
+++ b/interactive-mode.md
@@ -33,7 +33,7 @@
`Ctrl+L`| Redraw screen| Forces a full terminal redraw. Input and conversation history are kept. Use this to recover if the display becomes garbled or partially blank
`Ctrl+O`| Toggle transcript viewer| Shows detailed tool usage and execution. Also expands MCP calls, which collapse to a single line like “Called slack 3 times” by default
`Ctrl+R`| Reverse search command history| Search through previous commands interactively
-`Ctrl+V` or `Cmd+V` (iTerm2) or `Alt+V` (Windows)| Paste image from clipboard| Inserts an `[Image #N]` chip at the cursor so you can reference it positionally in your prompt
+`Ctrl+V` or `Cmd+V` (iTerm2) or `Alt+V` (Windows and WSL)| Paste image from clipboard| Inserts an `[Image #N]` chip at the cursor so you can reference it positionally in your prompt. On WSL, both `Ctrl+V` and `Alt+V` are bound; use `Alt+V` if your terminal intercepts `Ctrl+V`
`Ctrl+B`| Background running tasks| Backgrounds bash commands and agents. Tmux users press twice
`Ctrl+T`| Toggle task list| Show or hide the task list in the terminal status area
`Left/Right arrows`| Cycle through dialog tabs| Navigate between tabs in permission dialogs and menus
--- a/keybindings.md
+++ b/keybindings.md
@@ -132,7 +132,7 @@
`chat:undo`| Ctrl+_, Ctrl+Shift+-| Undo last action
`chat:externalEditor`| Ctrl+G, Ctrl+X Ctrl+E| Open in external editor
`chat:stash`| Ctrl+S| Stash current prompt
-`chat:imagePaste`| Ctrl+V (Alt+V on Windows)| Paste image
+`chat:imagePaste`| Ctrl+V (Alt+V on Windows and WSL)| Paste image from clipboard. On WSL, both shortcuts are bound by default
*On Windows without VT mode (Node <24.2.0/<22.17.0, Bun <1.2.23), defaults to Meta+M.
--- a/mcp.md
+++ b/mcp.md
@@ -57,7 +57,7 @@
Installing MCP servers
-MCP servers can be configured in three different ways depending on your needs:
+MCP servers can be configured in several ways depending on your needs:
###
@@ -118,6 +118,19 @@
* `claude mcp add --transport stdio --env KEY=value myserver -- python server.py --port 8080` → runs `python server.py --port 8080` with `KEY=value` in environment
This prevents conflicts between Claude’s flags and the server’s flags.
+
+###
+
+
+
+Option 4: Add a remote WebSocket server
+
+WebSocket servers hold a persistent bidirectional connection, which suits remote MCP servers that push events to Claude unprompted. Use HTTP instead when your server only responds to requests, since HTTP supports OAuth and the `claude mcp add --transport` flag, while WebSocket supports neither. Configure WebSocket servers in `.mcp.json` or with `claude mcp add-json`:
+
+ claude mcp add-json events-server \
+ '{"type":"ws","url":"wss://mcp.example.com/socket","headers":{"Authorization":"Bearer YOUR_TOKEN"}}'
+
+The `type: "ws"` entry accepts the same `url`, `headers`, `headersHelper`, `timeout`, and `alwaysLoad` fields as `http`. Authentication is header-only, so pass a static token in `headers` or generate one at connect time with `headersHelper`. The `claude mcp add --transport` flag does not accept `ws`.
###
@@ -223,7 +236,7 @@
* **Automatic lifecycle** : At session startup, servers for enabled plugins connect automatically. If you enable or disable a plugin during a session, run `/reload-plugins` to connect or disconnect its MCP servers
* **Environment variables** : use `${CLAUDE_PLUGIN_ROOT}` for bundled plugin files, `${CLAUDE_PLUGIN_DATA}` for [persistent state](</docs/en/plugins-reference#persistent-data-directory>) that survives plugin updates, and `${CLAUDE_PROJECT_DIR}` for the stable project root
* **User environment access** : Access to same environment variables as manually configured servers
- * **Multiple transport types** : Support stdio, SSE, and HTTP transports (transport support may vary by server)
+ * **Multiple transport types** : Support stdio, SSE, HTTP, and WebSocket transports (transport support may vary by server)
**Viewing plugin MCP servers** :
@@ -438,7 +451,7 @@
Authenticate with remote MCP servers
-Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` or `403 Forbidden`. Either status code flags the server in `/mcp` so you can complete the OAuth flow. A custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server.
+Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` or `403 Forbidden`. Either status code flags the server in `/mcp` so you can complete the OAuth flow. A custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server. If you configured `headers.Authorization` for the server and the server rejects that header, Claude Code reports the connection as failed instead of falling back to OAuth. Check that the token is valid for the MCP endpoint, or remove the header to use the OAuth flow.
1
--- a/memory.md
+++ b/memory.md
@@ -351,13 +351,13 @@
Storage location
-Each project gets its own memory directory at `~/.claude/projects/<project>/memory/`. The `<project>` path is derived from the git repository, so all worktrees and subdirectories within the same repo share one auto memory directory. Outside a git repo, the project root is used instead. To store auto memory in a different location, set `autoMemoryDirectory` in your user settings at `~/.claude/settings.json`:
+Each project gets its own memory directory at `~/.claude/projects/<project>/memory/`. The `<project>` path is derived from the git repository, so all worktrees and subdirectories within the same repo share one auto memory directory. Outside a git repo, the project root is used instead. To store auto memory in a different location, set `autoMemoryDirectory` in your `settings.json`. It is read from any [settings scope](</docs/en/settings#settings-precedence>): user, project, local, policy, or `--settings`.
{
"autoMemoryDirectory": "~/my-custom-memory-dir"
}
-The value must be an absolute path or start with `~/`. This setting is accepted from policy and user settings, and from the `--settings` flag. It is not accepted from project or local settings, since both files live inside the project directory and a cloned repository could supply either to redirect auto memory writes to sensitive locations. The directory contains a `MEMORY.md` entrypoint and optional topic files:
+The value must be an absolute path or start with `~/`. When set in a project’s `.claude/settings.json` or `.claude/settings.local.json`, the value is honored only after you accept the workspace trust dialog for that folder, the same gate that governs hooks. The directory contains a `MEMORY.md` entrypoint and optional topic files:
~/.claude/projects/<project>/memory/
├── MEMORY.md # Concise index, loaded into every session
--- a/monitoring-usage.md
+++ b/monitoring-usage.md
@@ -151,7 +151,7 @@
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.
+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 Agent tool, or legacy 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
@@ -159,7 +159,7 @@
└── claude_code.tool
├── claude_code.tool.blocked_on_user
├── claude_code.tool.execution
- └── (Task tool) subagent claude_code.llm_request / claude_code.tool spans
+ └── (Agent 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.
@@ -219,7 +219,7 @@
`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`
+`subagent_type`| Subagent type for the Agent tool or legacy 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`**
@@ -616,9 +616,10 @@
* `mcp_server_scope`: MCP server scope identifier (for MCP tools)
* `tool_parameters` (when `OTEL_LOG_TOOL_DETAILS=1`): JSON string containing tool-specific parameters:
* 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 WorkspaceBash tool: includes `bash_command`, `full_command`, `timeout`
* For MCP tools: includes `mcp_server_name`, `mcp_tool_name`
* For Skill tool: includes `skill_name`
- * For Task tool: includes `subagent_type`
+ * For Agent tool or legacy 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.
####
@@ -730,6 +731,12 @@
* `"user_temporary"`: Emitted when the user chose “Yes” at a permission prompt for a one-time approval, or chose one of the ”… during this session” options on a file edit or read prompt. In the interactive CLI this is emitted only for the choice itself; later calls allowed by that session-scoped grant emit `"config"` instead. In Agent SDK or non-interactive `-p` sessions, both the choice and later matches emit `"user_temporary"`. Treated as an accept.
* `"user_abort"`: Emitted when the user dismissed the permission prompt without answering. Treated as a reject.
* `"user_reject"`: Emitted when the user chose “No” when prompted. In the interactive CLI this is emitted only for that choice itself; calls that match a deny rule in the user’s personal settings emit `"config"` instead. In Agent SDK or non-interactive `-p` sessions, calls that match a deny rule in personal settings emit `"user_reject"`. Treated as a reject.
+ * `tool_parameters` (when `OTEL_LOG_TOOL_DETAILS=1`): JSON string containing tool-specific parameters. Same shape as the Tool result event, minus post-execution fields such as `git_commit_id`. Values may differ from `tool_result` for an accepted call if the permission decision rewrites the tool input via `updatedInput`. Use this attribute to see which command was rejected when `decision` is `"reject"`.
+ * For Bash tool: includes `bash_command`, `full_command`, `timeout`, `description`, `dangerouslyDisableSandbox`
+ * For WorkspaceBash tool: includes `bash_command`, `full_command`, `timeout`
+ * For MCP tools: includes `mcp_server_name`, `mcp_tool_name`
+ * For Skill tool: includes `skill_name`
+ * For Agent tool or legacy Task tool: includes `subagent_type`
####
@@ -1112,9 +1119,13 @@
---|---
`mcp_server_connection`| Server connect, disconnect, and connection failure with `server_name`, `transport_type`, `server_scope`, and error detail
`tool_result`| Each MCP tool call with `tool_name` and `mcp_server_scope`, a `tool_parameters` payload containing `mcp_server_name` and `mcp_tool_name`, and a `tool_input` payload containing the call arguments
-`tool_decision`| Whether the call was allowed or denied, and whether the decision came from config, a hook, or the user
-
-Without `OTEL_LOG_TOOL_DETAILS`, `tool_result` events still carry `tool_name` and `mcp_server_scope` but omit the `mcp_server_name`/`mcp_tool_name` breakdown and the arguments, and `mcp_server_connection` events omit `server_name` and the error message.
+`tool_decision`| Whether the call was allowed or denied, whether the decision came from config, a hook, or the user, and a `tool_parameters` payload containing `mcp_server_name` and `mcp_tool_name`
+
+Without `OTEL_LOG_TOOL_DETAILS`, these events drop the identifying detail:
+
+ * `tool_result`: keeps `tool_name` and `mcp_server_scope`, omits `mcp_server_name`, `mcp_tool_name`, and arguments
+ * `tool_decision`: keeps `tool_name`, omits `tool_parameters`
+ * `mcp_server_connection`: omits `server_name` and the error message
###
@@ -1126,13 +1137,13 @@
Signal| Event| Key attributes
---|---|---
-Tool call allowed or denied, and by what| `tool_decision`| `decision`, `source`, `tool_name`
+Tool call allowed or denied, and by what| `tool_decision`| `decision`, `source`, `tool_name`, `tool_parameters`
Permission mode escalation| `permission_mode_changed`| `from_mode`, `to_mode`, `trigger`
Policy hook blocked an action| `hook_execution_complete`| `hook_event`, `num_blocking`
Login, logout, and authentication failure| `auth`| `action`, `success`, `error_category`
MCP server connect or failure| `mcp_server_connection`| `status`, `server_name`, `error_code`
Plugin installed and its source| `plugin_installed`| `plugin.name`, `marketplace.name`, `marketplace.is_official`
-Commands run and files touched| `tool_result` with `OTEL_LOG_TOOL_DETAILS=1`| `tool_parameters`, `tool_input`
+Commands run and files touched| `tool_result` (executed) or `tool_decision` (rejected) with `OTEL_LOG_TOOL_DETAILS=1`| `tool_parameters`; `tool_input` (`tool_result` only)
Claude Code emits the raw event stream only. Anomaly detection, baselining, correlation across sessions, and alerting are the responsibility of your SIEM or observability backend.
@@ -1230,7 +1241,11 @@
* Raw file contents and code snippets are not included in metrics or events. Trace spans are a separate data path: see the `OTEL_LOG_TOOL_CONTENT` bullet below
* When authenticated via OAuth, `user.email` is included in telemetry attributes. If this is a concern for your organization, work with your telemetry backend to filter or redact this field
* 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. `user_prompt` events include the verbatim `command_name` for custom, plugin, and MCP commands. 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 arguments and parameters are not logged by default. To include them, set `OTEL_LOG_TOOL_DETAILS=1`. This data is sent only to the OTEL endpoint you configure, never to Anthropic. Arguments may still contain sensitive values, so configure your telemetry backend to filter or redact these attributes as needed. When enabled:
+ * `tool_result` and `tool_decision` events include a `tool_parameters` attribute with Bash commands, MCP server and tool names, and skill names. Fields such as `full_command` are emitted untruncated
+ * `tool_result` events additionally include a `tool_input` attribute with file paths, URLs, search patterns, and other arguments. Individual values over 512 characters are truncated and the total is bounded to ~4 K characters
+ * `user_prompt` events include the verbatim `command_name` for custom, plugin, and MCP commands
+ * Trace spans include the same `tool_input` attribute and input-derived attributes such as `file_path`, with the same truncation as `tool_input`
* 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`. 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
--- a/permission-modes.md
+++ b/permission-modes.md
@@ -274,6 +274,7 @@
* `.vscode`
* `.idea`
* `.husky`
+ * `.cargo`
* `.claude`, except for `.claude/commands`, `.claude/agents`, `.claude/skills`, and `.claude/worktrees` where Claude routinely creates content
Protected files:
--- a/permissions.md
+++ b/permissions.md
@@ -53,7 +53,7 @@
`dontAsk`| Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules
`bypassPermissions`| Skips all permission prompts. Root and home directory removals such as `rm -rf /` still prompt as a circuit breaker
-`bypassPermissions` mode skips all permission prompts, including writes to `.git`, `.claude`, `.vscode`, `.idea`, and `.husky`. Removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, still prompt as a circuit breaker against model error. Only use this mode in isolated environments like containers or VMs where Claude Code cannot cause damage. Administrators can prevent this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in managed settings.
+`bypassPermissions` mode skips all permission prompts, including writes to `.git`, `.claude`, `.vscode`, `.idea`, `.husky`, and `.cargo`. Removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, still prompt as a circuit breaker against model error. Only use this mode in isolated environments like containers or VMs where Claude Code cannot cause damage. Administrators can prevent this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in managed settings.
To prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `permissions.disableAutoMode` to `"disable"` in any [settings file](</docs/en/settings#settings-files>). These are most useful in managed settings where they cannot be overridden.
--- a/plugin-marketplaces.md
+++ b/plugin-marketplaces.md
@@ -166,7 +166,7 @@
Field| Type| Description| Example
---|---|---|---
-`name`| string| Marketplace identifier (kebab-case, no spaces). This is public-facing: users see it when installing plugins (for example, `/plugin install my-tool@your-marketplace`).| `"acme-tools"`
+`name`| string| Marketplace identifier (kebab-case, no spaces). This is public-facing: users see it when installing plugins (for example, `/plugin install my-tool@your-marketplace`). Each user can register only one marketplace per name: adding a second marketplace with the same name replaces the first. To publish multiple plugins under one marketplace name, list them all in a single `marketplace.json`.| `"acme-tools"`
`owner`| object| Marketplace maintainer information (see fields below)|
`plugins`| array| List of available plugins| See below
--- a/plugins.md
+++ b/plugins.md
@@ -162,6 +162,18 @@
* **Skill arguments** (`$ARGUMENTS`): captures user input for dynamic behavior
The `--plugin-dir` flag is useful for development and testing. When you’re ready to share your plugin with others, see [Create and distribute a plugin marketplace](</docs/en/plugin-marketplaces>).
+
+##
+
+
+
+Develop a plugin in your skills directory
+
+Instead of passing `--plugin-dir` on every launch, you can keep a plugin in your skills directory and have Claude Code load it automatically. `claude plugin init` scaffolds one:
+
+ claude plugin init my-tool
+
+This creates `~/.claude/skills/my-tool/` with a `.claude-plugin/plugin.json` manifest and a starter `SKILL.md`. On the next session it loads as `my-tool@skills-dir` with no marketplace or install step. For the auto-load rules, personal vs. project scope, the workspace-trust requirement, and how to update or remove one, see [Skills-directory plugins](</docs/en/plugins-reference#skills-directory-plugins>).
##
Show diff (111 lines)
--- a/plugins-reference.md
+++ b/plugins-reference.md
@@ -320,6 +320,53 @@
`managed`| [Managed settings](</docs/en/settings#settings-files>)| Managed plugins (read-only, update only)
Plugins use the same scope system as other Claude Code configurations. For installation instructions and scope flags, see [Install plugins](</docs/en/discover-plugins#install-plugins>). For a complete explanation of scopes, see [Configuration scopes](</docs/en/settings#configuration-scopes>).
+
+* * *
+
+##
+
+
+
+Skills-directory plugins
+
+Any folder under a skills directory that contains a `.claude-plugin/plugin.json` manifest is loaded as a plugin named `<name>@skills-dir` on the next session, with no marketplace and no install step. Scaffold one with `plugin init`. Unlike a marketplace install, the plugin is discovered in place rather than copied into the plugin cache. A skills directory tree supports three distinct things:
+
+What you have| What it is
+---|---
+`<skills-dir>/foo/SKILL.md` with no manifest| A plain [skill](</docs/en/skills>) named `foo`
+`<skills-dir>/foo/.claude-plugin/plugin.json`| A plugin `foo@skills-dir`, which can bundle its own skills, agents, hooks, and more
+`<plugin>/skills/bar/SKILL.md`| A skill `bar` packaged inside a plugin
+
+###
+
+
+
+Choose where the plugin loads from
+
+Skills directory| Scope| Loads
+---|---|---
+`~/.claude/skills/`| personal| In every project, since the location is yours alone
+`<cwd>/.claude/skills/`| project| Only after you accept the workspace [trust dialog](</docs/en/settings>) for that folder
+
+A project-scope plugin is checked into the repository and reaches every collaborator who clones it. Because that content comes from the repository rather than from you, it loads only after the same trust gate that governs `.claude/settings.json`, and components that run code are restricted further:
+
+ * MCP servers it declares go through the [same per-server approval](</docs/en/mcp>) as a project `.mcp.json`
+ * LSP servers start only after you trust the workspace
+ * Background monitors do not load
+
+Personal-scope plugins have none of these restrictions.
+
+Project-scope `@skills-dir` plugins load only from the `.claude/skills/` of the directory where you start Claude Code. They do not [walk up to the repository root](</docs/en/skills#automatic-discovery-from-parent-and-nested-directories>) the way plain skills and commands do, so launching from a subdirectory misses a plugin that lives at the repo root. Launch from the repository root, or run `/reload-plugins` after changing directories.
+
+###
+
+
+
+Edit, reload, and disable a skills-directory plugin
+
+Changes you make to a skill’s `SKILL.md` take effect immediately in the current session. Changes to the plugin’s other components, such as `hooks/`, `.mcp.json`, `agents/`, and `output-styles/`, do not. Run `/reload-plugins` or restart Claude Code to pick those up. See [Live change detection](</docs/en/skills#live-change-detection>). To stop loading a skills-directory plugin, delete its folder or disable it by name. There is no `uninstall` step because nothing was installed from a marketplace.
+
+ claude plugin disable my-tool@skills-dir
* * *
@@ -750,6 +797,54 @@
+plugin init
+
+Scaffold a new plugin at `~/.claude/skills/<name>/`. On the next Claude Code session it loads automatically as `<name>@skills-dir` and appears in `/plugin` and `claude plugin list` with no install step. See Skills-directory plugins for scope and trust requirements.
+
+ claude plugin init <name> [options]
+
+**Arguments:**
+
+ * `<name>`: Plugin name. Becomes the skill namespace and the directory name under `~/.claude/skills/`, so it cannot contain spaces or path separators.
+
+**Options:**
+
+Option| Description| Default
+---|---|---
+`--description <text>`| Manifest description|
+`--author <name>`| Author name| `git config user.name`
+`--author-email <email>`| Author email| `git config user.email`
+`--with <components...>`| Also scaffold component folders. Valid values: `skills`, `agents`, `hooks`, `mcp`, `lsp`, `output-style`, `channel`|
+`-f, --force`| Overwrite an existing `.claude-plugin/` at the target|
+`-h, --help`| Display help for command|
+
+**Aliases:** `new` Each `--with` value adds a starter file for that component, ready to edit:
+
+Component| What it scaffolds
+---|---
+`skills`| An extra namespaced `<name>:example` skill alongside the default one
+`agents`| An `agents/` subagent definition
+`hooks`| A `hooks/hooks.json` with a sample event handler
+`mcp`| A `.mcp.json` with HTTP and stdio server examples
+`lsp`| A `.lsp.json` language-server example
+`output-style`| An `output-styles/<name>.md` that applies automatically while the plugin is enabled
+`channel`| An MCP-based [channel](</docs/en/channels>): a stdio server (`server.ts`), its `.mcp.json`, and a `package.json`
+
+The scaffolded plugin uses the `@skills-dir` source rather than a marketplace. Admins can block this source with `strictKnownMarketplaces` or by adding `{"source": "skills-dir"}` to `blockedMarketplaces` in [managed settings](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>). When blocked, `plugin init` fails before writing. **Examples:**
+
+ # Scaffold a minimal plugin
+ claude plugin init my-helper
+
+ # Scaffold with skill and hook folders
+ claude plugin init my-helper --with skills hooks
+
+ # Overwrite an existing scaffold
+ claude plugin init my-helper --force
+
+###
+
+
+
plugin install
Install a plugin from available marketplaces.
--- a/settings.md
+++ b/settings.md
@@ -178,7 +178,7 @@
Key| Description| Example
---|---|---
-`agent`| Run the main thread as a named subagent. Applies that subagent’s system prompt, tool restrictions, and model. See [Invoke subagents explicitly](</docs/en/sub-agents#invoke-subagents-explicitly>)| `"code-reviewer"`
+`agent`| Run the main thread as a named subagent, and set the default agent for sessions dispatched from `claude agents`. Applies that subagent’s system prompt, tool restrictions, and model. See [Invoke subagents explicitly](</docs/en/sub-agents#invoke-subagents-explicitly>)| `"code-reviewer"`
`allowAllClaudeAiMcps`| (Managed settings only) Load claude.ai connectors alongside a deployed `managed-mcp.json`, which otherwise takes exclusive control and suppresses them. See [Managed MCP configuration](</docs/en/managed-mcp>)| `true`
`allowedChannelPlugins`| (Managed settings only) Allowlist of channel plugins that may push messages. Replaces the default Anthropic allowlist when set. Undefined = fall back to the default, empty array = block all channel plugins. Requires `channelsEnabled: true`. See [Restrict which channel plugins can run](</docs/en/channels#restrict-which-channel-plugins-can-run>)| `[{ "marketplace": "claude-plugins-official", "plugin": "telegram" }]`
`allowedHttpHookUrls`| Allowlist of URL patterns that HTTP hooks may target. Supports `*` as a wildcard. When set, hooks with non-matching URLs are blocked. Undefined = no restriction, empty array = block all HTTP hooks. Arrays merge across settings sources. See Hook configuration| `["https://hooks.example.com/*"]`
@@ -189,7 +189,7 @@
`alwaysThinkingEnabled`| Enable [extended thinking](</docs/en/model-config#extended-thinking>) by default for all sessions. Typically configured via the `/config` command rather than editing directly. To force thinking off regardless of this setting, set [`CLAUDE_CODE_DISABLE_THINKING`](</docs/en/env-vars>) in `env`| `true`
`apiKeyHelper`| Custom script, to be executed in `/bin/sh`, to generate an auth value. This value will be sent as `X-Api-Key` and `Authorization: Bearer` headers for model requests. Set the refresh interval with [`CLAUDE_CODE_API_KEY_HELPER_TTL_MS`](</docs/en/env-vars>)| `/bin/generate_temp_api_key.sh`
`attribution`| Customize attribution for git commits and pull requests. See Attribution settings| `{"commit": "🤖 Generated with Claude Code", "pr": ""}`
-`autoMemoryDirectory`| Custom directory for [auto memory](</docs/en/memory#storage-location>) storage. Accepts an absolute path or a `~/`-prefixed path. Accepted from policy and user settings, and from the `--settings` flag. Not accepted from project or local settings, since a cloned repository could supply either file to redirect memory writes to sensitive locations| `"~/my-memory-dir"`
+`autoMemoryDirectory`| Custom directory for [auto memory](</docs/en/memory#storage-location>) storage. Accepts an absolute path or a `~/`-prefixed path. From project or local settings, this is honored only after you accept the workspace trust dialog, since a cloned repository can supply this file| `"~/my-memory-dir"`
`autoMemoryEnabled`| Enable [auto memory](</docs/en/memory#enable-or-disable-auto-memory>). When `false`, Claude does not read from or write to the auto memory directory. Default: `true`. You can also toggle this with `/memory` during a session. To disable via environment variable, set [`CLAUDE_CODE_DISABLE_AUTO_MEMORY`](</docs/en/env-vars>) in `env`| `false`
`autoMode`| Customize what the [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) classifier blocks and allows. Contains `environment`, `allow`, `soft_deny`, and `hard_deny` arrays of prose rules. Include the literal string `"$defaults"` in an array to inherit the built-in rules at that position. See [Configure auto mode](</docs/en/auto-mode-config>). Not read from shared project settings| `{"soft_deny": ["$defaults", "Never run terraform apply"]}`
`autoScrollEnabled`| In [fullscreen rendering](</docs/en/fullscreen>), follow new output to the bottom of the conversation. Default: `true`. Appears in `/config` as **Auto-scroll**. Permission prompts still scroll into view when this is off| `false`
@@ -269,6 +269,7 @@
`viewMode`| Default transcript view mode on startup: `"default"`, `"verbose"`, or `"focus"`. Overrides the sticky `/focus` selection when set. The `--verbose` flag overrides this for one session| `"verbose"`
`voice`| [Voice dictation](</docs/en/voice-dictation>) settings: `enabled` turns dictation on, `mode` selects `"hold"` or `"tap"`, and `autoSubmit` sends the prompt on key release in hold mode. Written automatically when you run `/voice`. Requires a Claude.ai account| `{ "enabled": true, "mode": "tap" }`
`voiceEnabled`| Legacy alias for `voice.enabled`. Prefer the `voice` object| `true`
+`workflowKeywordTriggerEnabled`| Whether the word `workflow` in a prompt triggers a [dynamic workflow](</docs/en/workflows#ask-for-a-workflow-in-your-prompt>). Set to `false` to type the word without triggering one. Ultracode, `/workflows`, and saved workflow commands are unaffected. Default: `true`. Appears in `/config` as **Workflow keyword trigger**| `false`
`wslInheritsWindowsSettings`| (Windows managed settings only) When `true`, Claude Code on WSL reads managed settings from the Windows policy chain in addition to `/etc/claude-code`, with Windows sources taking priority. Only honored when set in the HKLM registry key or `C:\Program Files\ClaudeCode\managed-settings.json`, both of which require Windows admin to write. For HKCU policy to also apply on WSL, the flag must additionally be set in HKCU itself. Has no effect on native Windows| `true`
###
--- a/skills.md
+++ b/skills.md
@@ -107,6 +107,8 @@
When skills share the same name across levels, enterprise overrides personal, and personal overrides project. Plugin skills use a `plugin-name:skill-name` namespace, so they cannot conflict with other levels. If you have files in `.claude/commands/`, those work the same way, but if a skill and a command share the same name, the skill takes precedence.
+Add a `.claude-plugin/plugin.json` to a skill folder and it loads as a [plugin](</docs/en/plugins-reference#skills-directory-plugins>) named `<name>@skills-dir`, so it can bundle agents, hooks, and MCP servers. In a project’s `.claude/skills/`, this requires accepting the workspace trust dialog first.
+
####
@@ -114,6 +116,8 @@
Live change detection
Claude Code watches skill directories for file changes. Adding, editing, or removing a skill under `~/.claude/skills/`, the project `.claude/skills/`, or a `.claude/skills/` inside an `--add-dir` directory takes effect within the current session without restarting. Creating a top-level skills directory that did not exist when the session started requires restarting Claude Code so the new directory can be watched.
+
+Live change detection covers `SKILL.md` text only. For a skill folder that is also a [plugin](</docs/en/plugins-reference#skills-directory-plugins>), changes to `hooks/`, `.mcp.json`, `agents/`, and `output-styles/` need `/reload-plugins` to take effect.
####
@@ -257,7 +261,7 @@
`$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_EFFORT}`| The current effort level: `low`, `medium`, `high`, `xhigh`, `max`, or `ultra`. The `ultra` value is the stored value for ultracode. Use this to adapt skill instructions to the active effort setting.
+`${CLAUDE_EFFORT}`| The current effort level: `low`, `medium`, `high`, `xhigh`, or `max`. Ultracode is not a distinct level and reports as `xhigh`. Use this to adapt skill instructions to the active effort setting.
`${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.
Indexed arguments use shell-style quoting, so wrap multi-word values in quotes to pass them as a single argument. For example, `/my-skill "hello world" second` makes `$0` expand to `hello world` and `$1` to `second`. The `$ARGUMENTS` placeholder always expands to the full argument string as typed. **Example using substitutions:**
--- a/statusline.md
+++ b/statusline.md
@@ -164,7 +164,7 @@
`context_window.remaining_percentage`| Pre-calculated percentage of context window remaining
`context_window.current_usage`| Token counts from the last API call, described in context window fields
`exceeds_200k_tokens`| Whether the total token count (input, cache, and output tokens combined) from the most recent API response exceeds 200k. This is a fixed threshold regardless of actual context window size.
-`effort.level`| Current reasoning effort (`low`, `medium`, `high`, `xhigh`, `max`, or `ultra`). The `ultra` value corresponds to ultracode in `/effort`; the field reports the stored value, not the display label. Reflects the live session value, including mid-session `/effort` changes. Absent when the current model does not support the effort parameter
+`effort.level`| Current reasoning effort (`low`, `medium`, `high`, `xhigh`, or `max`). Reflects the live session value, including mid-session `/effort` changes. Ultracode is not a distinct level and reports as `xhigh`. Absent when the current model does not support the effort parameter
`thinking.enabled`| Whether extended thinking is enabled for the session
`rate_limits.five_hour.used_percentage`, `rate_limits.seven_day.used_percentage`| Percentage of the 5-hour or 7-day rate limit consumed, from 0 to 100
`rate_limits.five_hour.resets_at`, `rate_limits.seven_day.resets_at`| Unix epoch seconds when the 5-hour or 7-day rate limit window resets
--- a/sub-agents.md
+++ b/sub-agents.md
@@ -411,7 +411,7 @@
`bypassPermissions`| Skip permission prompts
`plan`| Plan mode (read-only exploration)
-Use `bypassPermissions` with caution. It skips all permission prompts, allowing the subagent to execute operations without approval, including writes to `.git`, `.claude`, `.vscode`, `.idea`, and `.husky`. Root and home directory removals such as `rm -rf /` still prompt as a circuit breaker. See [permission modes](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) for details.
+Use `bypassPermissions` with caution. It skips all permission prompts, allowing the subagent to execute operations without approval, including writes to `.git`, `.claude`, `.vscode`, `.idea`, `.husky`, and `.cargo`. Root and home directory removals such as `rm -rf /` still prompt as a circuit breaker. See [permission modes](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) for details.
If the parent uses `bypassPermissions` or `acceptEdits`, this takes precedence and cannot be overridden. If the parent uses [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), the subagent inherits auto mode and any `permissionMode` in its frontmatter is ignored: the classifier evaluates the subagent’s tool calls with the same block and allow rules as the parent session.
--- a/subagents.md
+++ b/subagents.md
@@ -423,6 +423,14 @@
+Scale up with dynamic workflows
+
+Subagents work well for a few delegated tasks per turn. For runs that coordinate dozens to hundreds of agents, use the `Workflow` tool, which moves the orchestration into a script the runtime executes outside the conversation context. See [dynamic workflows](</docs/en/workflows>) for how workflows differ from turn-by-turn subagent delegation. The `Workflow` tool is available in the TypeScript Agent SDK v0.3.149 and later. Include `Workflow` in `allowedTools` to auto-approve workflow runs. The tool input and output schemas are listed in the [TypeScript reference](</docs/en/agent-sdk/typescript#workflow>).
+
+##
+
+
+
Troubleshooting
###
@@ -460,4 +468,5 @@
Related documentation
* [Claude Code subagents](</docs/en/sub-agents>): comprehensive subagent documentation including filesystem-based definitions
+ * [Dynamic workflows](</docs/en/workflows>): orchestrate many subagents from a script for jobs too large for one conversation
* [SDK overview](</docs/en/agent-sdk/overview>): getting started with the Claude Agent SDK
--- a/terminal-config.md
+++ b/terminal-config.md
@@ -29,7 +29,7 @@
VS Code, Cursor, Windsurf, Alacritty, Zed| Run `/terminal-setup` once
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. 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>).
+For VS Code, Cursor, Windsurf, Alacritty, and Zed, `/terminal-setup` writes Shift+Enter and other keybindings into the terminal’s configuration file. Existing bindings 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. In VS Code, Cursor, and Windsurf, `/terminal-setup` also updates two editor settings: it sets `terminal.integrated.gpuAcceleration` to `"off"` to prevent garbled text in the integrated terminal, and it sets `terminal.integrated.mouseWheelScrollSensitivity` for smoother scrolling in [fullscreen mode](</docs/en/fullscreen>). To undo the GPU acceleration change, set it back to `"auto"` and reload the editor window. 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>).
##
--- a/tools-reference.md
+++ b/tools-reference.md
@@ -16,7 +16,7 @@
`CronList`| Lists all scheduled tasks in the session| No
`Edit`| Makes targeted edits to specific files. See Edit tool behavior| Yes
`EnterPlanMode`| Switches to plan mode to design an approach before coding| No
-`EnterWorktree`| Creates an isolated [git worktree](</docs/en/worktrees>) and switches into it. Pass a `path` to switch into an existing worktree of the current repository instead of creating a new one. Not available to subagents that already run in their own working directory, such as with [`isolation: worktree`](</docs/en/sub-agents#supported-frontmatter-fields>)| No
+`EnterWorktree`| Creates an isolated [git worktree](</docs/en/worktrees>) and switches into it. Pass a `path` to switch into an existing worktree of the current repository instead of creating a new one. From within a worktree session, or from a subagent with a pinned working directory such as [`isolation: worktree`](</docs/en/sub-agents#supported-frontmatter-fields>), only the `path` form is available and the target must be under `.claude/worktrees/`| No
`ExitPlanMode`| Presents a plan for approval and exits plan mode| Yes
`ExitWorktree`| Exits a worktree session and returns to the original directory. Not available to subagents that already run in their own working directory, such as with [`isolation: worktree`](</docs/en/sub-agents#supported-frontmatter-fields>)| No
`Glob`| Finds files based on pattern matching. See Glob tool behavior| No
@@ -47,6 +47,7 @@
`WaitForMcpServers`| Waits for one or more [MCP servers](</docs/en/mcp>) that are still connecting in the background, so a request can use their tools without restarting the session. Claude calls it when a needed server is not connected yet. Only appears when [tool search](</docs/en/mcp#scale-with-mcp-tool-search>) is disabled, since `ToolSearch` handles the wait when it’s enabled| No
`WebFetch`| Fetches content from a specified URL. See WebFetch tool behavior| Yes
`WebSearch`| Performs web searches. See WebSearch tool behavior| Yes
+`Workflow`| Runs a [dynamic workflow](</docs/en/workflows>): a script that orchestrates many subagents in the background and returns one consolidated result| Yes
`Write`| Creates or overwrites files. See Write tool behavior| Yes
##
Show diff (120 lines)
--- a/typescript.md
+++ b/typescript.md
@@ -642,7 +642,12 @@
`applyFlagSettings()`
-Changes any [setting](</docs/en/settings>) on a running session without restarting the query. Use it when a setting that has no dedicated setter needs to change mid-session, such as tightening `permissions` after the agent reads untrusted input. `setModel()` and `setPermissionMode()` are dedicated setters for those two keys; `applyFlagSettings()` is the general form that accepts any subset of the settings keys, and passing `model` here behaves the same as `setModel()`. The values are written to the flag-settings layer, the same layer the inline `settings` option of `query()` populates at startup. Flag settings sit near the top of the [settings precedence order](</docs/en/settings#settings-precedence>): they override user, project, and local settings, and only managed policy settings can override them. This is the same tier the on-page precedence section calls programmatic options. Successive calls shallow-merge top-level keys. A second call with `{ permissions: {...} }` replaces the entire `permissions` object from the prior call rather than deep-merging into it. To clear a key from the flag layer and fall back to lower-precedence sources, pass `null` for that key. Passing `undefined` has no effect because JSON serialization drops it. Only available in streaming input mode, the same constraint as `setModel()` and `setPermissionMode()`. The example below switches the active model mid-session, then clears the override so the model falls back to whatever the user or project settings specify.
+Changes [settings](</docs/en/settings>) on a running session without restarting the query. Use it when a setting that has no dedicated setter needs to change mid-session, such as tightening `permissions` after the agent reads untrusted input. `setModel()` and `setPermissionMode()` are dedicated setters for those two keys; `applyFlagSettings()` is the general form that accepts any subset of the settings keys, and passing `model` here behaves the same as `setModel()`. Only some keys take effect mid-session:
+
+ * **Applied on the next turn** : `model`, `effortLevel`, `ultracode`, `permissions`, `hooks`, `skillOverrides`, `fastMode`, `awaySummaryEnabled`
+ * **No effect mid-session** : `agent` and the system prompt options. These are resolved once at startup, so the running session keeps the original value even though the call succeeds. To change them, start a new session.
+
+The values are written to the flag-settings layer, the same layer the inline `settings` option of `query()` populates at startup. Flag settings sit near the top of the [settings precedence order](</docs/en/settings#settings-precedence>): they override user, project, and local settings, and only managed policy settings can override them. This is the same tier the on-page precedence section calls programmatic options. Successive calls shallow-merge top-level keys. A second call with `{ permissions: {...} }` replaces the entire `permissions` object from the prior call rather than deep-merging into it. To clear a key from the flag layer and fall back to lower-precedence sources, pass `null` for that key. Passing `undefined` has no effect because JSON serialization drops it. Only available in streaming input mode, the same constraint as `setModel()` and `setPermissionMode()`. The example below switches the active model mid-session, then clears the override so the model falls back to whatever the user or project settings specify.
const q = query({ prompt: messageStream });
@@ -1918,7 +1923,8 @@
| UnsubscribeMcpResourceInput
| UnsubscribePollingInput
| WebFetchInput
- | WebSearchInput;
+ | WebSearchInput
+ | WorkflowInput;
###
@@ -2168,6 +2174,32 @@
};
Searches the web and returns formatted results.
+
+###
+
+
+
+Workflow
+
+**Tool name:** `Workflow`
+
+ type WorkflowInput = {
+ script?: string;
+ name?: string;
+ scriptPath?: string;
+ args?: unknown;
+ resumeFromRunId?: string;
+ };
+
+Runs a [dynamic workflow](</docs/en/workflows>): a script that orchestrates many subagents in the background and returns one consolidated result. The `Workflow` tool is available in Agent SDK v0.3.149 and later. At least one of `script`, `name`, or `scriptPath` is required.
+
+Field| Type| Description
+---|---|---
+`script`| `string`| Inline workflow script. Must begin with `export const meta = { name, description, phases }` as a literal, followed by the script body using `agent()`, `parallel()`, `pipeline()`, and `phase()`
+`name`| `string`| Name of a built-in workflow or one saved in `.claude/workflows/`. Resolved to a script
+`scriptPath`| `string`| Path to a workflow script file on disk. Takes precedence over `script` and `name`. Every invocation persists its script and returns the path in the result, so you can edit that file and re-invoke with the same `scriptPath` to iterate
+`args`| `unknown`| Input value exposed to the script as the global `args`, for parameterized named workflows such as a research question or a list of file paths. Pass arrays and objects as actual JSON values, not as a JSON-encoded string
+`resumeFromRunId`| `string`| Run ID of a prior `Workflow` invocation to resume. Completed `agent()` calls with unchanged inputs return cached results; only changed or new calls run live. Same session only
###
@@ -2353,7 +2385,8 @@
| TaskUpdateOutput
| TodoWriteOutput
| WebFetchOutput
- | WebSearchOutput;
+ | WebSearchOutput
+ | WorkflowOutput;
###
@@ -2420,9 +2453,10 @@
multiSelect: boolean;
}>;
answers: Record<string, string>;
- };
-
-Returns the questions asked and the user’s answers.
+ response?: string;
+ };
+
+Returns the questions asked and the user’s answers. `response` is set when the user typed a freeform reply instead of answering the structured questions; when present, Claude receives “The user responded: …” instead of the per-question answer list.
###
@@ -2713,6 +2747,36 @@
+Workflow
+
+**Tool name:** `Workflow`
+
+ type WorkflowOutput = {
+ status: "async_launched";
+ taskId: string;
+ runId?: string;
+ summary?: string;
+ transcriptDir?: string;
+ scriptPath?: string;
+ error?: string;
+ };
+
+Returns immediately after the tool accepts the invocation. The final result arrives later as a task completion. Check `error` before treating the run as started: a script that fails its syntax check returns `status: "async_launched"` with `error` set, and never runs.
+
+Field| Type| Description
+---|---|---
+`status`| `"async_launched"`| The tool accepted the invocation. This is the only value the field takes
+`taskId`| `string`| Background task identifier for the run
+`runId`| `string`| Workflow run identifier to pass as `resumeFromRunId` on a later invocation
+`summary`| `string`| One-line description of what the workflow does
+`transcriptDir`| `string`| Directory where subagent transcripts are written during execution
+`scriptPath`| `string`| Path to the persisted workflow script for this run. Edit it and pass back as `scriptPath` to rerun without resending the script
+`error`| `string`| Set when the script fails its syntax check. When present, the run did not start despite the `async_launched` status
+
+###
+
+
+
TodoWrite
**Tool name:** `TodoWrite`
--- a/user-input.md
+++ b/user-input.md
@@ -447,8 +447,9 @@
---|---
`questions`| Pass through the original questions array (required for tool processing)
`answers`| Object where keys are question text and values are selected labels
-
-For multi-select questions, pass an array of labels or join them with `", "`. For free-text input, use the user’s custom text directly.
+`response`| Optional freeform reply the user typed instead of answering the structured questions
+
+For multi-select questions, pass an array of labels or join them with `", "`. For per-question free text such as an “Other” option, put the user’s text in `answers[question]` as shown in Support free-text input. Set `response` only when your UI lets the user dismiss the question card and type a general reply that isn’t an answer to any specific question. When `response` is set, Claude receives “The user responded: …” instead of the per-question answer list.
{
"questions": [
--- a/workflows.md
+++ b/workflows.md
@@ -132,7 +132,7 @@
Run a workflow to audit every API endpoint under src/routes/ for missing auth checks
-Claude Code highlights the word in your input and Claude writes a workflow script for the task instead of working through it turn by turn. If the run does what you wanted, you can save it as a command afterward. If Claude Code highlights the word when you didn’t mean to trigger one, press `alt+w` to ignore it for this prompt.
+Claude Code highlights the word in your input and Claude writes a workflow script for the task instead of working through it turn by turn. If the run does what you wanted, you can save it as a command afterward. If Claude Code highlights the word when you didn’t mean to trigger one, press `alt+w` to ignore it for this prompt, or press backspace while the cursor is right after the highlighted word. To stop the word from triggering at all, turn off Workflow keyword trigger in `/config`.
###
--- a/worktrees.md
+++ b/worktrees.md
@@ -24,7 +24,7 @@
claude --worktree
-You can also ask Claude to “work in a worktree” during a session, and it will create one with the [`EnterWorktree`](</docs/en/tools-reference>) tool. Before using `--worktree` in a directory for the first time, accept the workspace trust dialog by running `claude` once in that directory. If trust has not yet been accepted, `--worktree` exits with an error and prompts you to run `claude` in the directory first, including when combined with `-p`.
+You can also ask Claude to “work in a worktree” during a session, and it will create one with the [`EnterWorktree`](</docs/en/tools-reference>) tool. Once in a worktree, Claude can switch directly to another one under `.claude/worktrees/` by calling `EnterWorktree` with the target path. The previous worktree stays on disk untouched. Before using `--worktree` in a directory for the first time, accept the workspace trust dialog by running `claude` once in that directory. If trust has not yet been accepted, `--worktree` exits with an error and prompts you to run `claude` in the directory first, including when combined with `-p`.
Add `.claude/worktrees/` to your `.gitignore` so worktree contents don’t appear as untracked files in your main checkout.
@@ -84,7 +84,7 @@
* **Uncommitted changes, untracked files, or new commits exist** : Claude prompts you to keep or remove the worktree. Keeping preserves the directory and branch so you can return later. Removing deletes the worktree directory and its branch, discarding any uncommitted changes, untracked files, and commits
* **Non-interactive runs** : worktrees created with `--worktree` alongside `-p` are not cleaned up automatically since there is no exit prompt. Remove them with `git worktree remove`
-Subagent worktrees orphaned by a crash or interrupted run are removed at startup once they are older than your [`cleanupPeriodDays`](</docs/en/settings#available-settings>) setting, provided they have no uncommitted changes, no untracked files, and no unpushed commits. Worktrees you create with `--worktree` are never removed by this sweep.
+Worktrees that Claude created for subagents and [background sessions](</docs/en/agent-view#how-file-edits-are-isolated>) are removed automatically once they are older than your [`cleanupPeriodDays`](</docs/en/settings#available-settings>) setting, provided they have no uncommitted changes, no untracked files, and no unpushed commits. Worktrees you create with `--worktree` are never removed by this sweep.
##