modified Set up Claude Code for your organization View current →
--- a/admin-setup.md +++ b/admin-setup.md @@ -71,6 +71,7 @@ [MCP server control](</docs/en/mcp#managed-mcp-configuration>)| Restrict which MCP servers users can add or connect to| `allowedMcpServers`, `deniedMcpServers`, `allowManagedMcpServersOnly` [Plugin marketplace control](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>)| Restrict which marketplace sources users can add and install from| `strictKnownMarketplaces`, `blockedMarketplaces` [Hook restrictions](</docs/en/settings#hook-configuration>)| Only managed hooks load; restrict HTTP hook URLs| `allowManagedHooksOnly`, `allowedHttpHookUrls` +[Disable agent view](</docs/en/agent-view#how-background-sessions-are-hosted>)| Turn off `claude agents`, `--bg`, `/background`, and the on-demand supervisor| `disableAgentView` [Version floor](</docs/en/settings>)| Prevent auto-update from installing below an org-wide minimum| `minimumVersion` Permission rules and sandboxing cover different layers. Denying WebFetch blocks Claude’s fetch tool, but if Bash is allowed, `curl` and `wget` can still reach any URL. Sandboxing closes that gap with a network domain allowlist enforced at the OS level. For the threat model these controls defend against, see [Security](</docs/en/security>).
modified How the agent loop works View current →
--- a/agent-loop.md +++ b/agent-loop.md @@ -230,7 +230,7 @@ ---|---|--- **System prompt**| Every request| Small fixed cost, always present **CLAUDE.md files**| Session start, via [`settingSources`](</docs/en/agent-sdk/claude-code-features>)| Full content in every request (but prompt-cached, so only the first request pays full cost) -**Tool definitions**| Every request| Each tool adds its schema; use [MCP tool search](</docs/en/agent-sdk/mcp#mcp-tool-search>) to load tools on-demand instead of all at once +**Tool definitions**| Every request; MCP schemas deferred by default| Built-in tool schemas load every request. [Tool search](</docs/en/agent-sdk/mcp#mcp-tool-search>) defers MCP tool schemas by default, falling back to upfront loading on Vertex AI or a non-first-party `ANTHROPIC_BASE_URL`. See [Configure tool search](</docs/en/agent-sdk/tool-search#configure-tool-search>) for the full matrix **Conversation history**| Accumulates over turns| Grows with each turn: prompts, responses, tool inputs, tool outputs **Skill descriptions**| Session start, via setting sources| Short summaries; full content loads only when invoked @@ -271,8 +271,8 @@ A few strategies for long-running agents: * **Use subagents for subtasks.** Each subagent starts with a fresh conversation (no prior message history, though it does load its own system prompt and project-level context like CLAUDE.md). It does not see the parent’s turns, and only its final response returns to the parent as a tool result. The main agent’s context grows by that summary, not by the full subtask transcript. See [What subagents inherit](</docs/en/agent-sdk/subagents#what-subagents-inherit>) for details. - * **Be selective with tools.** Every tool definition takes context space. Use the `tools` field on [`AgentDefinition`](</docs/en/agent-sdk/subagents#agentdefinition-configuration>) to scope subagents to the minimum set they need, and use [MCP tool search](</docs/en/agent-sdk/mcp#mcp-tool-search>) to load tools on demand instead of preloading all of them. - * **Watch MCP server costs.** Each MCP server adds all its tool schemas to every request. A few servers with many tools can consume significant context before the agent does any work. The `ToolSearch` tool can help by loading tools on-demand instead of preloading all of them. See [MCP tool search](</docs/en/agent-sdk/mcp#mcp-tool-search>) for configuration. + * **Be selective with tools.** Every tool definition takes context space. Use the `tools` field on [`AgentDefinition`](</docs/en/agent-sdk/subagents#agentdefinition-configuration>) to scope subagents to the minimum set they need. + * **Watch MCP server costs.** [MCP tool search](</docs/en/agent-sdk/mcp#mcp-tool-search>) defers MCP tool schemas by default and loads them on demand. When tool search is off, on Vertex AI, or behind a non-first-party `ANTHROPIC_BASE_URL`, each MCP server adds all its tool schemas to every request, so a few servers with many tools can consume significant context before the agent does any work. * **Use lower effort for routine tasks.** Set effort to `"low"` for agents that only need to read files or list directories. This reduces token usage and cost. For a detailed breakdown of per-feature context costs, see [Understand context costs](</docs/en/features-overview#understand-context-costs>).
added Manage multiple agents with agent view View current →
Show diff (346 lines)
--- a/agent-view.md +++ b/agent-view.md @@ -0,0 +1,343 @@ +> ## Documentation Index +> +> Fetch the complete documentation index at: <https://code.claude.com/docs/llms.txt> +> +> Use this file to discover all available pages before exploring further. + +Agent view, opened with `claude agents`, is one screen for all your background sessions: what’s running, what needs your input, and what’s done. Dispatch new sessions, watch their state at a glance instead of scrolling through transcripts, and step in only when one needs you. Sessions keep running in the background without a terminal attached. Use agent view when you have several independent tasks Claude can work on at once, such as fixing a bug, reviewing a pull request, or investigating a log. When you want to work through a problem together, attach to a session and use Claude Code interactively as usual. Sessions in agent view run independently and report only to you. To compare with subagents, agent teams, and worktrees, see [Run agents in parallel](</docs/en/agents>). + +Agent view is a research preview and requires Claude Code v2.1.139 or later. Check your version with `claude --version`. The interface and keyboard shortcuts may change as the feature evolves, and administrators can disable agent view for an organization with the `disableAgentView` managed setting. + +This page covers: + + * Quick start + * Monitor sessions with agent view, including state icons, peeking and replying, attaching, organizing, and keyboard shortcuts + * Dispatch new agents from agent view, from inside a session, or from the shell + * Manage sessions from the shell + * How background sessions are hosted by the supervisor process + +## + +​ + +Quick start + +This walkthrough opens agent view, dispatches a session, replies from the peek panel, and attaches for the full conversation. + +1 + +Open agent view + +From your shell, run: + + claude agents + +Agent view opens with an input at the bottom and a table that fills in as sessions start. Press `Esc` at any time to exit. Your sessions keep running. + +2 + +Dispatch a session + +Type a prompt in the input and press `Enter`. A new session starts and appears as a row showing whether it’s working, waiting on you, or done. Repeat to run several sessions in parallel. Each one uses your subscription quota independently, so see Limitations before dispatching many at once. + +3 + +Peek and reply + +Select a row with the arrow keys and press `Space` to see what the session is doing or what it needs from you. Type a reply and press `Enter` to send it without leaving agent view. + +4 + +Attach and detach + +Press `Enter` or `→` on a row to attach when you want the full conversation. The session takes over the terminal exactly as if you had run `claude`. Press `←` on an empty prompt to detach and return to the table. + +To bring an existing interactive session into agent view, run `/bg` inside it, or press `←` on an empty prompt to background the session and open agent view in one step. The session keeps running in the background and appears as a row. To start a new background session directly from the shell, run `claude --bg "<prompt>"`. You can use `claude agents` as your primary entry point instead of `claude`: dispatch every task from agent view, attach when you want the full conversation, and press `←` to return to the table. + +## + +​ + +Monitor sessions with agent view + +Run `claude agents` to open agent view. It takes over the full terminal and lists every session grouped by state, with pinned sessions and the ones that need you at the top. Each row shows the session’s name, current activity, and how long ago it last changed. The list covers every background session under your config directory, regardless of which project or worktree it’s working in, so a session started in one repository and another started in a different worktree both appear together. Interactive sessions you have open in other terminals don’t appear until you background them, and [subagents](</docs/en/sub-agents>) running inside a session aren’t listed as separate rows. + + Pinned + ✽ clawd walk cycle Write assets/sprites/clawd-walk.png 3m + + Ready for review + ∙ jump physics github.com/anthropics/example/pull/2048 2h + + Needs input + ✻ power-up design needs input: double jump or wall climb? 1m + + Working + ✽ collision detection Edit src/physics/CollisionSystem.ts 2m + ✢ playtest level 3 run 12 · all checkpoints cleared in 4m + + Completed + ✻ title screen result: menu, options, and credits done 9m + ∙ sound effects result: 14 SFX exported to assets/audio 4h + … 6 more + +Each row’s icon carries two signals. The indicator tells you the session’s state, and the icon’s shape tells you whether the underlying process is still running. The states are: + +Indicator| State| What it means +---|---|--- +Animated| Working| Claude is actively running tools or generating a response +Yellow| Needs input| Claude is waiting for your input, usually a permission decision or an answer +Dimmed| Idle| The session is waiting for input but isn’t blocked on a specific question +Green| Completed| The task finished successfully +Red| Failed| The task ended with an error +Grey| Stopped| The session was stopped with `Ctrl+X` or `claude stop` + +The icon’s shape tells you whether the underlying process is still running. A `✻`, or an animated `✽` while Claude is working, means the session is alive and you can reply to it immediately. A `∙` means the process has exited, but you can still peek, reply, or attach: Claude restarts the session from where it left off. A `✢` is a [`/loop`](</docs/en/commands>) session sleeping between iterations, with the row showing its run count and a countdown to the next iteration. Background sessions don’t need any terminal open to keep working. A separate supervisor process runs them, so you can close agent view, close your shell, or start a new interactive session and your dispatched work keeps going. Sessions persist on disk: closing your terminal or an auto-update doesn’t lose them, and reopening `claude agents` shows them all. If your machine sleeps or shuts down, running sessions stop; restart them with `claude respawn --all`. The one-line summary in each row is generated by your configured [Haiku-class model](</docs/en/model-config>) so the row can tell you what the session is doing, what it needs, or what it produced without opening the transcript. While a session is actively working, the summary refreshes at most once every 15 seconds, plus once when each turn ends. Each refresh is one short Haiku-class request through your normal provider, billed and handled under the same [data usage terms](</docs/en/data-usage>) as the session itself. When a session opens a pull request, the row shows the PR link and a status indicator for its CI checks. For most tasks this row is where you pick up the result: review and merge the pull request when its checks pass. + +### + +​ + +Peek and reply + +Press `Space` on a selected row to open the peek panel. It shows what the session needs from you, its most recent output, and any pull requests it opened. Most of the time this is enough, and you never need to open the full transcript. Type a reply in the peek panel and press `Enter` to send it to that session. When the session is asking a multiple-choice question, the peek panel shows the options and you can press a number key to pick one. For other blocked sessions, press `Tab` to fill the input with a suggested reply you can edit before sending. Prefix a reply with `!` to send a Bash command instead. Use `↑` and `↓` to peek at adjacent sessions without closing the panel, or `→` to attach. + +### + +​ + +Attach to a session + +Press `Enter` or `→` on a selected row to attach, or press `Alt+1` through `Alt+9` to attach directly to the Nth session in the focused group. Agent view is replaced by the full interactive session, exactly as if you had run `claude` in that directory. When you attach, Claude posts a short recap of what happened while you were away. While attached, the session behaves like any other Claude Code session: every [command](</docs/en/commands>), keyboard shortcut, and feature works. Press `←` on an empty prompt to detach and return to agent view. If a dialog has focus and isn’t responding to `←`, press `Ctrl+Z` to detach immediately. Detaching never stops a background session: `←`, `Ctrl+C`, `Ctrl+D`, `Ctrl+Z`, and `/exit` all leave it running. To end a session from inside it, run `/stop`. After you’ve dispatched or backgrounded a session, pressing `←` on an empty prompt works from any Claude Code session, not only ones you attached to from agent view. It backgrounds the current session and opens agent view with that session pre-selected, so you can switch sessions without leaving the terminal. You can turn this shortcut off in `/config`. + +### + +​ + +Organize the list + +Agent view groups sessions by state, with sessions that need input above sessions that are working or done. Press `Ctrl+S` to switch to grouping by directory instead. Your choice is saved across runs. Within a group, pin a session to the top with `Ctrl+T`, reorder with `Shift+↑` and `Shift+↓`, or press `Enter` on a group header to collapse it. To remove a session, press `Ctrl+X` to stop it and `Ctrl+X` again within two seconds to delete it. Pressing `Ctrl+X` on a group header deletes every session in that group after confirmation. Older completed sessions fold into a ”… N more” row to keep the list short. Failures and sessions with an open pull request always stay visible. + +### + +​ + +Filter the list + +Type in the dispatch input to filter instead of dispatching: + +Filter| Shows +---|--- +`a:<name>`| Sessions running the named agent +`s:<state>`| Sessions in the given state, such as `s:blocked` for sessions that need you +`#<number>` or a PR URL| The session working on that pull request + +### + +​ + +Keyboard shortcuts + +Press `?` in agent view to see every shortcut. The most common ones: + +Shortcut| Action +---|--- +`↑` / `↓`| Move between rows +`Enter`| Attach to the selected session, or dispatch if there’s text in the input +`Space`| Open or close the peek panel for the selected session +`Shift+Enter`| Dispatch and attach immediately +`→`| Attach to the selected session +`Alt+1`..`Alt+9`| Attach to the Nth session in the focused group +`Tab`| Browse all subagents, or apply the highlighted suggestion +`Ctrl+S`| Switch grouping between state and directory +`Ctrl+T`| Pin or unpin the selected session +`Ctrl+R`| Rename the selected session +`Ctrl+G`| Open the dispatch prompt in your `$EDITOR` +`Ctrl+X`| Stop the session; press again within two seconds to delete it +`Shift+↑` / `Shift+↓`| Reorder the selected session +`Esc`| Close the peek panel, clear the input, or exit +`Ctrl+C`| Clear the input; press twice to exit +`?`| Show all shortcuts + +## + +​ + +Dispatch new agents + +You can dispatch new background sessions from agent view, send an existing interactive session to the background, or start one directly from the shell. + +### + +​ + +From agent view + +Type a prompt in the input at the bottom of agent view and press `Enter` to start a new background session. The session is named automatically from the prompt. You can rename it later with `Ctrl+R`. Paste an image into the prompt to include a screenshot or diagram with the task. Prefix or mention parts of the prompt to control how the session starts: + +Input| Effect +---|--- +`<agent-name> <prompt>`| If the first word matches a custom [subagent](</docs/en/sub-agents>) name, that subagent runs as the session’s main agent with the configuration from its frontmatter +`@<agent-name>`| Mention a custom subagent anywhere in the prompt to run it as the main agent +`@<repo>`| Mention a repository under the directory you opened agent view from to run the session there +`/<skill>`| Suggest [skills](</docs/en/skills>) to dispatch as the prompt +`#<number>` or a pull request URL| If a session is already working on that PR, select it instead of dispatching +`Shift+Enter`| Dispatch and immediately attach to the new session + +Type `/` to dispatch a [skill](</docs/en/skills>). Packaging a recurring task as a skill lets you start the same workflow many times from agent view without retyping the prompt. Press `Tab` on an empty input to browse every dispatchable subagent, or to apply the highlighted suggestion when suggestions are showing. When the same `@name` matches both a subagent and a sibling repository, the subagent takes precedence. The first-word form without `@` also applies to any subagent name, so a prompt that begins with a word matching one of your subagent names dispatches that subagent. Use the `@` form when you want to be explicit. + +#### + +​ + +Dispatch to a specific directory + +A new session runs in the directory you opened agent view from. To target a different directory: + + * Open `claude agents` in that directory. + * Open `claude agents` in a parent directory that holds several repositories and mention one with `@<repo>` in the prompt to run the session there. + * From the shell, `cd` into the directory and run `claude --bg "<prompt>"`. + +When agent view is grouped by directory, the highlighted row’s directory becomes the dispatch target, so you can scroll to a group and dispatch into it without retyping the path. + +### + +​ + +From inside a session + +Run `/background` or its alias `/bg` to detach the current conversation and keep it running. Pass a prompt such as `/bg run the test suite and fix any failures` to send one more instruction before detaching. + +### + +​ + +From the shell + +Pass `--bg` to start a session that goes straight to the background: + + claude --bg "investigate the flaky SettingsChangeDetector test" + +To run a specific subagent as the session’s main agent, combine `--bg` with `--agent`: + + claude --agent code-reviewer --bg "address review comments on PR 1234" + +After backgrounding, Claude prints the session’s short ID and the commands for managing it: + + backgrounded · 7c5dcf5d + claude agents list sessions + claude attach 7c5dcf5d open in this terminal + claude logs 7c5dcf5d show recent output + claude stop 7c5dcf5d stop this session + +### + +​ + +How file edits are isolated + +Every background session, whether started from agent view, `/bg`, or `claude --bg`, starts in your working directory but is blocked from writing files there. When the session needs to edit files, Claude moves it into an isolated [git worktree](</docs/en/worktrees>) under `.claude/worktrees/` automatically, so parallel sessions can read the same checkout but each writes to its own. The block doesn’t apply when the session is already inside a worktree, when the working directory isn’t a git repository, or to writes outside the working directory. The worktree is removed when you delete the session, so merge or push the changes you want to keep before you delete. To find a session’s worktree path, peek the session or attach and check its working directory. To make a subagent always run in its own worktree regardless of how it was started, set [`isolation: worktree`](</docs/en/sub-agents#supported-frontmatter-fields>) in its frontmatter. + +### + +​ + +Permission mode and settings + +A dispatched session reads its [settings](</docs/en/settings>) and [permission mode](</docs/en/permissions>) from the directory it runs in, the same as if you had started `claude` there. Dispatching from the agent view input doesn’t pass a permission mode, so 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>). To set the mode from the shell, pass `--permission-mode` with `claude --bg`. Using `bypassPermissions` or `auto` this way 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. + +## + +​ + +Manage sessions from the shell + +Every background session has a short ID you can use from the shell. These commands are useful for scripting or when you don’t want to open agent view. + +Command| Purpose +---|--- +`claude agents`| Open agent view +`claude attach <id>`| Attach to a session in this terminal +`claude logs <id>`| Print the session’s recent output +`claude stop <id>`| Stop a session. Also accepts `claude kill` +`claude respawn <id>`| Restart a stopped session with its conversation intact +`claude respawn --all`| Restart every stopped session +`claude rm <id>`| Remove a session from the list + +## + +​ + +How background sessions are hosted + +Background sessions are hosted by a per-user supervisor process, separate from your terminal and from agent view. It starts automatically the first time you background a session or open agent view, and you don’t manage it directly. The supervisor and its sessions authenticate with the same credentials as your interactive sessions and make no additional network connections beyond the model API. Each background session is its own Claude Code process, parented to the supervisor rather than to your terminal. A session that’s actively working, waiting for your input, or has a terminal attached keeps its process running. Once a session finishes and sits unattached for about an hour, the supervisor stops its process to free resources. The transcript and state stay on disk, and the next time you attach, peek, or reply, the supervisor starts a fresh process from where it left off. When every session has finished and no terminal is connected, the supervisor itself exits and starts again the next time you background a session or open agent view. The supervisor watches the installed Claude Code binary on disk and restarts into the new version after the regular [auto-updater](</docs/en/setup#auto-updates>) replaces it. This is a local file watch, not a network check. Background sessions are detached processes, so they keep running through the restart and the new supervisor reconnects to them. Session state is stored under your Claude Code config directory. If you set [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>), the supervisor uses that directory instead of `~/.claude` and runs as a separate instance with its own sessions. + +Path| Contents +---|--- +`~/.claude/daemon.log`| Supervisor log +`~/.claude/daemon/roster.json`| List of running background sessions, used to reconnect after a restart +`~/.claude/jobs/<id>/state.json`| Per-session state shown in agent view + +To turn off background agents and agent view entirely, set the `disableAgentView` [setting](</docs/en/settings>) to `true` or set the `CLAUDE_CODE_DISABLE_AGENT_VIEW` environment variable. Administrators can enforce this through [managed settings](</docs/en/permissions#managed-settings>). + +## + +​ + +Troubleshooting + +### + +​ + +Agent view opens with no sessions + +Agent view is empty until you dispatch your first session. Type a prompt in the input at the bottom and press `Enter`. + +### + +​ + +Sessions show as stopped after waking your machine + +Background sessions don’t survive sleep or shutdown. Attach, peek, or reply to any stopped session and it restarts from where it left off. To restart all of them at once, run `claude respawn --all`. + +### + +​ + +A session is slow to respond after attaching + +Once a session has finished and sat unattached for about an hour, the supervisor stops its process to free resources. Attaching starts a fresh process from where it left off, which takes a moment. Sessions that are working or waiting on you are never stopped this way. + +### + +​ + +`.claude/worktrees/` is filling up + +Worktrees are removed when you delete the session that created them. If a session ended without cleaning up, list leftover entries with `git worktree list` in the project directory and remove each with `git worktree remove <path>`. See [Clean up worktrees](</docs/en/worktrees#clean-up-worktrees>). + +## + +​ + +Limitations + +Agent view is a research preview. Current limitations to be aware of: + + * **Rate limits apply** : background sessions consume your subscription usage the same as interactive sessions, so running ten agents in parallel uses quota roughly ten times as fast as running one. + * **Sessions are local** : background sessions run on your machine and stop if it sleeps or shuts down. + * **Worktrees are deleted with the session** : merge or push changes before deleting a session that edited files in its own worktree. + +## + +​ + +Next steps + +Now that you understand agent view, explore these related features: + + * [Run agents in parallel](</docs/en/agents>): compare agent view with subagents, agent teams, and worktrees + * [Subagents](</docs/en/sub-agents>): define reusable agent configurations with custom prompts, tools, and isolation + * [Agent teams](</docs/en/agent-teams>): coordinate multiple sessions that message each other + * [Claude Code on the web](</docs/en/claude-code-on-the-web>): run sessions in a managed cloud environment instead of locally
added Run agents in parallel View current →
--- a/agents.md +++ b/agents.md @@ -0,0 +1,58 @@ +> ## Documentation Index +> +> Fetch the complete documentation index at: <https://code.claude.com/docs/llms.txt> +> +> Use this file to discover all available pages before exploring further. + +[Subagents](</docs/en/sub-agents>), [agent view](</docs/en/agent-view>), [agent teams](</docs/en/agent-teams>), and [worktrees](</docs/en/worktrees>) each parallelize work in a different way. The right one depends on whether you want to stay in each conversation yourself, hand tasks off and check back later, or have Claude coordinate a group of workers for you. + +Approach| What it gives you| Use it when +---|---|--- +[Subagents](</docs/en/sub-agents>)| Delegated workers inside one session that do a side task in their own context and return a summary| A side task would flood your main conversation with search results, logs, or file contents you won’t reference again +[Agent view](</docs/en/agent-view>)| One screen to dispatch and monitor sessions running in the background, opened with `claude agents`. Research preview| You have several independent tasks and want to hand them off, check status at a glance, and step in only when one needs you +[Agent teams](</docs/en/agent-teams>)| Multiple coordinated sessions with a shared task list and inter-agent messaging, managed by a lead. Experimental and disabled by default| You want Claude to split a project into pieces, assign them, and keep the workers in sync +[Worktrees](</docs/en/worktrees>)| Separate git checkouts so parallel sessions never touch each other’s files| You’re running several sessions yourself, or your subagents edit overlapping files +[`/batch`](</docs/en/commands>)| A planned split of one large change into 5 to 30 worktree-isolated subagents that each open a pull request| A repo-wide migration or mechanical refactor you can describe in one instruction + +In every approach the workers are Claude sessions. To involve a different tool, expose it to Claude as an [MCP server](</docs/en/mcp>). You can combine these approaches. Agent view automatically moves each dispatched session into its own worktree when it needs to edit files, and a session you’re working in can spawn subagents that each get their own worktree. + +Running several sessions or subagents at once multiplies token usage. See [Costs](</docs/en/costs>) for usage and rate-limit details. + +## + +​ + +Choose an approach + +The right approach depends on who coordinates the work, whether the workers need to communicate, and whether they edit the same files: + + * **Who coordinates the work?** If you want Claude to delegate and collect results inside one conversation, use [subagents](</docs/en/sub-agents>). If you’re handing off independent tasks and checking back on them, use [agent view](</docs/en/agent-view>). If you want Claude to plan, assign, and supervise a group of workers, use [agent teams](</docs/en/agent-teams>), which are experimental and disabled by default. + * **Do the workers need to talk to each other?** Subagents report results back to the conversation that spawned them, and agent view sessions report only to you. Teammates in an agent team share a task list and message each other directly. + * **Do the tasks touch the same files?** Isolate the work with [worktrees](</docs/en/worktrees>). Subagents and sessions you run yourself can each use a separate worktree. Agent teams don’t isolate teammates in worktrees, so [partition the work](</docs/en/agent-teams#avoid-file-conflicts>) so each teammate owns a different set of files. + +## + +​ + +Check on running work + +The command for checking on running work depends on which approach you used: + + * For background sessions, `claude agents` opens [agent view](</docs/en/agent-view>): one screen showing every session, its state, and which ones need your input. + * For subagents in the current session, `/agents` opens a panel with a **Running** tab listing live subagents and a **Library** tab where you [create and edit custom subagents](</docs/en/sub-agents#use-the-%2Fagents-command>). Despite the similar name, this is separate from `claude agents`. + * For anything running in the background of the current session, `/tasks` lists each item and lets you check on, attach to, or stop it. + +For a desktop view of all your sessions, see [parallel sessions in the desktop app](</docs/en/desktop#work-in-parallel-with-sessions>). + +## + +​ + +Learn more + +Each guide below covers setup and configuration for one approach: + + * [Create custom subagents](</docs/en/sub-agents>): define reusable specialists and control which tools they can use. + * [Manage agents with agent view](</docs/en/agent-view>): dispatch sessions, watch their state, and attach when one needs you. + * [Orchestrate agent teams](</docs/en/agent-teams>): set up a lead and teammates, assign tasks, and review their work. + * [Run parallel sessions with worktrees](</docs/en/worktrees>): start Claude in an isolated checkout, control what gets copied in, and clean up afterward.
modified Changelog View current →
--- a/changelog.md +++ b/changelog.md @@ -5,6 +5,63 @@ > 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.139 + +May 11, 2026 + + * Added agent view (Research Preview): a single list of every Claude Code session — running, blocked on you, or done. Run `claude agents` to get started. See <https://code.claude.com/docs/en/agent-view> + * Added `/goal` command: set a completion condition and Claude keeps working across turns until it’s met. Works in interactive, `-p`, and Remote Control. Shows live elapsed/turns/tokens as an overlay panel + * Added `/scroll-speed` command to tune mouse wheel scroll speed with a live preview + * Added `claude plugin details <name>` to show a plugin’s component inventory and projected per-session token cost + * Added transcript view navigation: `?` for keyboard shortcuts, `{`/`}` to jump between user prompts, `v` to toggle shortcut panel + * Added hook `args: string[]` field (exec form) that spawns the command directly without a shell, so path placeholders never need quoting + * Added hook `continueOnBlock` config option for `PostToolUse` — set to `true` to feed the hook’s rejection reason back to Claude and continue the turn + * MCP stdio servers now receive `CLAUDE_PROJECT_DIR` in their environment, matching hooks. Plugin configs can reference `${CLAUDE_PROJECT_DIR}` in commands + * Compaction prompt now asks the model to preserve sensitive user instructions + * `/mcp` Reconnect now picks up `.mcp.json` edits without a restart, and shows the HTTP status and URL when reconnecting fails + * `/context all` per-skill token estimates now account for the model’s tokenizer and show rounded values + * `claude plugin install <name>@<marketplace>` now auto-refreshes the marketplace and retries before reporting a plugin as not found + * `/plugin` installed-plugin details now show hook event names and MCP server names cleanly + * `/context` now shows the providing plugin’s name for plugin-sourced skills + * Remote MCP server reconnect retry on transient failures is now enabled for all users + * API requests from subagents now carry `x-claude-code-agent-id` / `x-claude-code-parent-agent-id` headers, and `claude_code.llm_request` OTEL spans include `agent_id` / `parent_agent_id` attributes + * Remote Control, `/schedule`, claude.ai MCP connectors, and notification preferences are now disabled when `ANTHROPIC_API_KEY` / `apiKeyHelper` / `ANTHROPIC_AUTH_TOKEN` is set, even if a Claude.ai login also exists. Unset the API key to use these features + * Fixed a deadlock where expired credentials and the `forceRemoteSettingsRefresh` policy setting blocked `claude auth login`/`logout`/`status` with no way to recover + * Fixed `autoAllowBashIfSandboxed` not auto-approving commands with shell expansions like `$VAR` and `$(cmd)` + * Fixed a bug where a hook writing to the terminal could corrupt an on-screen interactive prompt; hooks now run without terminal access + * Fixed unbounded memory growth when an HTTP/SSE MCP server streams non-protocol data — response bodies now capped at 16 MB per SSE frame + * Fixed `Skill(name *)` permission rules — the wildcard form now works as a prefix match, matching `Bash(ls *)` behavior + * Fixed settings hot-reload not detecting edits to symlinked `~/.claude/settings.json` + * Fixed plugin details failing to load when the marketplace key differs from the manifest name + * Fixed `/model` picker “Default” row not reflecting `ANTHROPIC_DEFAULT_OPUS_MODEL`/`ANTHROPIC_DEFAULT_SONNET_MODEL` overrides + * Fixed spurious “stream idle timeout” 5 minutes after a response completed, caused by the watchdog timer not being cleared on stream cancellation + * Fixed silent `exit 1` when 10+ MCP servers are configured and the cache directory is unwritable — the error message now includes the underlying cause + * Fixed a typing cursor blinking on tab names, list pointers, and select rows in dialogs + * Fixed transcript view letter shortcuts not working after mouse click + * Fixed Bash-mode up-arrow history repeating the first entry and clobbering the in-progress draft + * Fixed pasting or dropping multiple images only inserting the last one + * Fixed hyperlinks using unreadable dark navy on dark themes — they now adapt to the active theme + * Fixed model picker showing a redundant “Current model” row for third-party users whose model is set to the `opus` alias + * Fixed legacy Opus picker entry on PAYG 3P providers resolving to the same model as the default entry + * Fixed mouse wheel scrolling speed in Cursor and VS Code 1.92–1.104; the trackpad now scrolls at a steady rate and the mouse wheel keeps ~3 lines per notch + * Fixed scroll behavior in Windows Terminal and VS Code when attached to background sessions + * Fixed MCP resources from disconnected servers lingering in `@server:` autocomplete + * Fixed two-file diff snippets over-reporting the number of truncated lines by one + * Fixed Grep results not relativizing Windows drive-letter paths and count mode reporting wrong totals for single-file paths + * Fixed border-embedded text overflowing on CJK/emoji due to visual cell width miscalculation + * Fixed fuzzy-match highlighting splitting emoji and astral-plane characters mid-pair + * Fixed skill argument names containing regex metacharacters breaking argument substitution + * Fixed ProgressBar rendering a full block for an almost-full fractional cell + * Fixed task polling and `fs.watch` being resurrected when the last subscriber leaves while a fetch is in flight + * Fixed plugin dependency resolution leaving a stale count when the manifest name differs from the source identifier + * Fixed Insights Time-of-Day chart skewing when a session has an unparseable timestamp + * Fixed keybindings using only the cmd/super/win modifier being flagged as unparseable + * Fixed `claude_code.active_time.total` OpenTelemetry metric not being emitted in `--print` mode + * Fixed `claude plugin update` not preserving cross-plugin symlinks inside a marketplace + * [VSCode] Press Cmd/Ctrl+Shift+T to reopen the most recently closed session tab, configurable via `claudeCode.enableReopenClosedSessionShortcut` ​
modified Push events into a running session with channels View current →
--- a/channels.md +++ b/channels.md @@ -245,7 +245,7 @@ The message arrives in your Claude Code session as a `<channel source="fakechat">` event. Claude reads it, does the work, and calls fakechat’s `reply` tool. The answer shows up in the chat UI. -If Claude hits a permission prompt while you’re away from the terminal, the session pauses until you respond. Channel servers that declare the [permission relay capability](</docs/en/channels-reference#relay-permission-prompts>) can forward these prompts to you so you can approve or deny remotely. For unattended use, [`--dangerously-skip-permissions`](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) bypasses prompts entirely, but only use it in environments you trust. +If Claude hits a permission prompt while you’re away from the terminal, the session pauses until you respond. Channel servers that declare the [permission relay capability](</docs/en/channels-reference#relay-permission-prompts>) can forward these prompts to you so you can approve or deny remotely. For unattended use, [`--dangerously-skip-permissions`](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) bypasses prompts entirely, but only use it in environments you trust. When you run channels in non-interactive mode with `-p`, tools that need terminal input, such as multiple-choice questions and plan mode approval, are disabled so the session never stalls waiting for input. ##
modified Channels reference View current →
--- a/channels-reference.md +++ b/channels-reference.md @@ -12,7 +12,7 @@ * What you need: requirements and general steps * Example: build a webhook receiver: a minimal one-way walkthrough * Server options: the constructor fields - * Notification format: the event payload + * Notification format: the event payload and delivery behavior * Expose a reply tool: let Claude send messages back * Gate inbound messages: sender checks to prevent prompt injection * Relay permission prompts: forward tool approval prompts to remote channels @@ -231,6 +231,8 @@ build failed on main: https://ci.example.com/run/1234 </channel> +Notifications are not acknowledged. The `await` on `mcp.notification()` resolves when the message is written to the transport, not when Claude has processed it. If the session hasn’t loaded your server as a channel, or the organization policy blocks it, events are dropped silently with no error returned to your server. If you need delivery confirmation, track event state in your server and expose a reply tool that Claude can call to report status back. Events queue into the session and are processed in order. If several notifications arrive while Claude is busy, they’re delivered together on the next turn and Claude handles them as a group. To process independent event streams concurrently, run separate sessions. + ## ​
modified Explore the .claude directory View current →
--- a/claude-directory.md +++ b/claude-directory.md @@ -113,6 +113,7 @@ Path under `~/.claude/`| Contents ---|--- `projects/<project>/<session>.jsonl`| Full conversation transcript: every message, tool call, and tool result +`projects/<project>/<session>/subagents/`| [Subagent](</docs/en/sub-agents>) conversation transcripts, removed with the parent session transcript when it ages out `projects/<project>/<session>/tool-results/`| Large tool outputs spilled to separate files `file-history/<session>/`| Pre-edit snapshots of files Claude changed, used for [checkpoint restore](</docs/en/checkpointing>) `plans/`| Plan files written during [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) @@ -135,6 +136,7 @@ ---|--- `history.jsonl`| Every prompt you’ve typed, with timestamp and project path. Used for up-arrow recall. `stats-cache.json`| Aggregated token and cost counts shown by `/usage` +`remote-settings.json`| Cached copy of [server-managed settings](</docs/en/server-managed-settings>) for your organization. Only present when your organization has configured them. Refreshed on each launch. `todos/`| Legacy per-session task lists. No longer written by current versions; safe to delete. Other small cache and lock files appear depending on which features you use and are safe to delete. @@ -184,6 +186,7 @@ `~/.claude/history.jsonl`| Up-arrow prompt recall `~/.claude/file-history/`| Checkpoint restore for past sessions `~/.claude/stats-cache.json`| Historical totals shown by `/usage` +`~/.claude/remote-settings.json`| Nothing. Re-fetched on next launch. `~/.claude/debug/`, `~/.claude/plans/`, `~/.claude/paste-cache/`, `~/.claude/image-cache/`, `~/.claude/session-env/`, `~/.claude/tasks/`, `~/.claude/shell-snapshots/`, `~/.claude/backups/`| Nothing user-facing `~/.claude/todos/`| Nothing. Legacy directory not written by current versions.
added Claude Code on Claude Platform on AWS View current →
Show diff (166 lines)
--- a/claude-platform-on-aws.md +++ b/claude-platform-on-aws.md @@ -0,0 +1,163 @@ +> ## Documentation Index +> +> Fetch the complete documentation index at: <https://code.claude.com/docs/llms.txt> +> +> Use this file to discover all available pages before exploring further. + +Claude Platform on AWS is the Anthropic-operated Claude API with AWS authentication, IAM access control, and AWS Marketplace billing. Requests reach Anthropic’s API directly, so you get the same models and features as the [Claude API](<https://platform.claude.com/docs>) on the same release schedule. You authenticate with AWS credentials or a workspace API key, and you pay through AWS Marketplace. Use this guide to point Claude Code at a workspace you’ve already provisioned through Claude Platform on AWS. For the AWS subscription and workspace setup that comes before this, see the [Claude Platform on AWS documentation](<https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws>). + +Subscribing through AWS Marketplace provisions a new Anthropic organization tied to your AWS account. This organization is separate from any organization you already have with Anthropic, and credentials don’t transfer between them. Use the workspace ID and API keys from the AWS-linked organization, not from a pre-existing Claude Console account. + +## + +​ + +Prerequisites + +Before configuring Claude Code, you need: + + * An active Claude Platform on AWS subscription through AWS Marketplace + * A workspace in your AWS-linked Anthropic organization, with its workspace ID + * An IAM principal with permission to invoke the Anthropic service, or an API key scoped to the workspace + * AWS credentials in your environment, in `~/.aws/credentials`, or from an attached IAM role if you want SigV4 authentication. The AWS CLI is required only for the SSO login flow. + +## + +​ + +Setup + +### + +​ + +1\. Configure AWS credentials + +Claude Code supports two authentication methods for Claude Platform on AWS. Choose the method that fits how your team manages access. **Option A: AWS credentials with SigV4** Claude Code signs requests with SigV4 using the standard AWS credential chain: environment variables, shared credentials in `~/.aws/credentials`, IAM roles, AWS SSO sessions, and any other sources the AWS SDK supports. For local use, log in with the AWS CLI before starting Claude Code. The example below uses an SSO profile, but any method that produces credentials in the standard locations works. + + aws sso login --profile my-profile + export AWS_PROFILE=my-profile + +For CI and automation, give the runner an IAM role with permission to invoke the Anthropic service and set `AWS_REGION`. The credential chain picks the role up automatically. If your SSO credentials expire mid-session, configure [`awsAuthRefresh`](</docs/en/amazon-bedrock#advanced-credential-configuration>) so Claude Code re-runs your login command and retries instead of failing. Add the command to your `settings.json`: + + { + "awsAuthRefresh": "aws sso login --profile my-profile" + } + +**Option B: Workspace API key** A workspace API key is a long-lived secret, useful when you don’t want to manage federated AWS credentials. Generate one in the AWS Console under **Claude Platform on AWS → API keys** and set it as `ANTHROPIC_AWS_API_KEY`: + + export ANTHROPIC_AWS_API_KEY=sk-ant-xxxxx + +The key is sent as `x-api-key` and takes precedence over SigV4, so any AWS credentials in your environment are ignored. API keys from a separate Claude Console organization won’t work here. Treat workspace API keys like any other production credential. The [user settings file](</docs/en/settings>) `env` block is a convenient way to scope the key to your machine without exporting it globally. + +The `/login` and `/logout` commands don’t change Claude Platform on AWS authentication. Authentication runs through your AWS credentials or workspace API key, not through a Claude.ai subscription. + +### + +​ + +2\. Configure Claude Code + +Set the environment variables that route Claude Code through Claude Platform on AWS instead of the default Anthropic API. + + export CLAUDE_CODE_USE_ANTHROPIC_AWS=1 + export ANTHROPIC_AWS_WORKSPACE_ID=wrkspc_01ABCDEFGHIJKLMN + export AWS_REGION=us-east-1 + +`ANTHROPIC_AWS_WORKSPACE_ID` is required and is sent on every request as the `anthropic-workspace-id` header. The base URL is computed from `AWS_REGION` as `https://aws-external-anthropic.{region}.api.aws`. To override the URL directly, set `ANTHROPIC_AWS_BASE_URL`. Claude Platform on AWS is opt-in even when AWS credentials are present in your environment. Bedrock and Foundry take precedence in provider routing, so unset `CLAUDE_CODE_USE_BEDROCK` and `CLAUDE_CODE_USE_FOUNDRY` if they’re set. + +### + +​ + +3\. Pin model versions + +Claude Platform on AWS uses the same model IDs as the direct Claude API. The default aliases `opus`, `sonnet`, and `haiku` resolve to the latest versions available in your workspace. If you deploy Claude Code to a team, pin the model IDs explicitly so a new release doesn’t move everyone at once: + + export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-4-7 + export ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-4-6 + export ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-4-5 + +For the full list of model IDs and aliases, see [Models overview](<https://platform.claude.com/docs/en/about-claude/models/overview>). For other model-related variables, see [Model configuration](</docs/en/model-config>). [Prompt caching](<https://platform.claude.com/docs/en/build-with-claude/prompt-caching>) is enabled automatically. 1-hour cache writes are billed at a higher rate than 5-minute writes. To request a 1-hour cache TTL instead of the 5-minute default, set `ENABLE_PROMPT_CACHING_1H=1`. + +## + +​ + +Use the Agent SDK + +The [Agent SDK](</docs/en/agent-sdk/overview>) reads the same environment variables as the CLI, so any program that spawns the Claude Code subprocess can target Claude Platform on AWS by exporting `CLAUDE_CODE_USE_ANTHROPIC_AWS`, `ANTHROPIC_AWS_WORKSPACE_ID`, and either `ANTHROPIC_AWS_API_KEY` or AWS credentials before the call. + + import { query } from "@anthropic-ai/claude-agent-sdk"; + + process.env.CLAUDE_CODE_USE_ANTHROPIC_AWS = "1"; + process.env.ANTHROPIC_AWS_WORKSPACE_ID = "wrkspc_01ABCDEFGHIJKLMN"; + process.env.AWS_REGION = "us-east-1"; + + for await (const msg of query({ prompt: "What's in this repo?" })) { + console.log(msg); + } + +This example relies on the ambient AWS credential chain for SigV4. To authenticate with a workspace API key instead, set `ANTHROPIC_AWS_API_KEY` the same way. For the broader Agent SDK surface, see [Agent SDK overview](</docs/en/agent-sdk/overview>). + +## + +​ + +Route through a corporate proxy + +To route traffic through a proxy or [LLM gateway](</docs/en/llm-gateway>), set `ANTHROPIC_AWS_BASE_URL` to the proxy’s address. Claude Code sends requests to that URL with the same workspace and authentication headers, so any gateway that forwards them unchanged works. + + export CLAUDE_CODE_USE_ANTHROPIC_AWS=1 + export ANTHROPIC_AWS_WORKSPACE_ID=wrkspc_01ABCDEFGHIJKLMN + export ANTHROPIC_AWS_BASE_URL=https://anthropic-proxy.example.com + +If your gateway signs requests itself, set `CLAUDE_CODE_SKIP_ANTHROPIC_AWS_AUTH=1` so Claude Code sends unsigned requests and lets the gateway add SigV4 headers before forwarding to AWS. If the gateway requires its own token, set it in `ANTHROPIC_AUTH_TOKEN`. + + export CLAUDE_CODE_USE_ANTHROPIC_AWS=1 + export CLAUDE_CODE_SKIP_ANTHROPIC_AWS_AUTH=1 + export ANTHROPIC_AWS_WORKSPACE_ID=wrkspc_01ABCDEFGHIJKLMN + export ANTHROPIC_AWS_BASE_URL=https://anthropic-proxy.example.com + +## + +​ + +Troubleshooting + +Run `/status` to see the resolved provider and any explicitly configured workspace ID, region, base URL override, and auth-skip setting. This is the fastest way to confirm Claude Code is targeting Claude Platform on AWS at all. + +### + +​ + +`403 Forbidden` or `AccessDenied` on every request + +The IAM principal Claude Code resolved likely lacks permission to invoke the Anthropic service in your workspace. Check the role attached to your AWS profile or the runner that started Claude Code, and verify it has the `aws-external-anthropic` actions documented in the [IAM action reference](<https://platform.claude.com/docs/en/api/claude-platform-on-aws-iam-actions>). If you set `ANTHROPIC_AWS_API_KEY`, the key takes precedence over SigV4 and a stale key produces the same error. Regenerate the key in the AWS Console under **Claude Platform on AWS → API keys** or unset the variable to fall back to your AWS credentials. + +### + +​ + +Requests fail with a missing-workspace error + +`ANTHROPIC_AWS_WORKSPACE_ID` is likely unset or empty. Every Claude Platform on AWS request must include the workspace ID. It is not implied by your AWS credentials. Find the ID under **Workspaces** on the AWS Console service page and export it before starting Claude Code. + +### + +​ + +Requests still go to `api.anthropic.com` + +`CLAUDE_CODE_USE_ANTHROPIC_AWS` is likely unset or set to a value that doesn’t parse as truthy. Set it to `1` and run `/status` to confirm the resolved provider. If `CLAUDE_CODE_USE_BEDROCK` or `CLAUDE_CODE_USE_FOUNDRY` is also set, those take precedence over Claude Platform on AWS. + +## + +​ + +Additional resources + +The Claude Platform on AWS subscription, workspace, and IAM setup that comes before configuring Claude Code is covered in the platform documentation: + + * [Claude Platform on AWS overview](<https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws>): subscription, workspace setup, and product reference + * [IAM action reference](<https://platform.claude.com/docs/en/api/claude-platform-on-aws-iam-actions>): permissions and managed policies
modified CLI reference View current →
--- a/cli-reference.md +++ b/cli-reference.md @@ -26,13 +26,18 @@ `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`| List all configured [subagents](</docs/en/sub-agents>), grouped by source| `claude agents` +`claude agents`| Open [agent view](</docs/en/agent-view>) to monitor and dispatch parallel background sessions. When output is piped, lists configured [subagents](</docs/en/sub-agents>) instead| `claude agents` +`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 logs <id>`| Print recent output from a [background session](</docs/en/agent-view#manage-sessions-from-the-shell>)| `claude logs 7c5dcf5d` `claude mcp`| Configure Model Context Protocol (MCP) servers| See the [Claude Code MCP documentation](</docs/en/mcp>). `claude plugin`| Manage Claude Code [plugins](</docs/en/plugins>). Alias: `claude plugins`. See [plugin reference](</docs/en/plugins-reference#cli-commands-reference>) for subcommands| `claude plugin install code-review@claude-plugins-official` `claude project purge [path]`| Delete all local Claude Code state for a project: transcripts, task lists, debug logs, file-edit history, prompt history lines, and the project’s entry in `~/.claude.json`. Omit `[path]` to pick from an interactive list. Flags: `--dry-run` to preview, `-y`/`--yes` to skip confirmation, `-i`/`--interactive` to confirm each item, `--all` for every project. See [Clear local data](</docs/en/claude-directory#clear-local-data>)| `claude project purge ~/work/repo --dry-run` `claude remote-control`| Start a [Remote Control](</docs/en/remote-control>) server to control Claude Code from Claude.ai or the Claude app. Runs in server mode (no local interactive session). See [Server mode flags](</docs/en/remote-control#start-a-remote-control-session>)| `claude remote-control --name "My Project"` +`claude respawn <id>`| Restart a stopped [background session](</docs/en/agent-view#manage-sessions-from-the-shell>) with its conversation intact. Use `--all` to restart every stopped session| `claude respawn 7c5dcf5d` +`claude rm <id>`| Remove a [background session](</docs/en/agent-view#manage-sessions-from-the-shell>) from the list| `claude rm 7c5dcf5d` `claude setup-token`| Generate a long-lived OAuth token for CI and scripts. Prints the token to the terminal without saving it. Requires a Claude subscription. See [Generate a long-lived token](</docs/en/authentication#generate-a-long-lived-token>)| `claude setup-token` +`claude stop <id>`| Stop a [background session](</docs/en/agent-view#manage-sessions-from-the-shell>). Also accepts `claude kill`| `claude stop 7c5dcf5d` `claude ultrareview [target]`| Run [ultrareview](</docs/en/ultrareview#run-ultrareview-non-interactively>) non-interactively. Prints findings to stdout and exits 0 on success or 1 on failure. Use `--json` for the raw payload and `--timeout <minutes>` to override the 30-minute default| `claude ultrareview 1234 --json` If you mistype a subcommand, Claude Code suggests the closest match and exits without starting a session. For example, `claude udpate` prints `Did you mean claude update?`. @@ -56,6 +61,7 @@ `--append-system-prompt-file`| Load additional system prompt text from a file and append to the default prompt| `claude --append-system-prompt-file ./extra-rules.txt` `--bare`| Minimal mode: skip auto-discovery of hooks, skills, plugins, MCP servers, auto memory, and CLAUDE.md so scripted calls start faster. Claude has access to Bash, file read, and file edit tools. Sets [`CLAUDE_CODE_SIMPLE`](</docs/en/env-vars>). See [bare mode](</docs/en/headless#start-faster-with-bare-mode>)| `claude --bare -p "query"` `--betas`| Beta headers to include in API requests (API key users only)| `claude --betas interleaved-thinking` +`--bg`| Start the session as a [background agent](</docs/en/agent-view>) and return immediately. Prints the session ID and management commands. Combine with `--agent` to run a specific subagent| `claude --bg "investigate the flaky test"` `--channels`| (Research preview) MCP servers whose [channel](</docs/en/channels>) notifications Claude should listen for in this session. Space-separated list of `plugin:<name>@<marketplace>` entries. Requires Claude.ai authentication| `claude --channels plugin:my-notifier@my-marketplace` `--chrome`| Enable [Chrome browser integration](</docs/en/chrome>) for web automation and testing| `claude --chrome` `--continue`, `-c`| Load the most recent conversation in the current directory. Includes sessions that added this directory with `/add-dir`| `claude --continue`
modified Commands View current →
--- a/commands.md +++ b/commands.md @@ -12,7 +12,7 @@ Commands across a typical workflow -Most commands are useful at a specific point in a session, from setting up a project to shipping a change. **First session in a repo.** Run `/init` to generate a starter `CLAUDE.md`, then `/memory` to refine it. Use `/mcp` and `/agents` to set up any servers or subagents the project needs, and `/permissions` to set the approval rules you want. **During a task.** `/plan` switches into plan mode before a large change. `/model` and `/effort` adjust how much reasoning you’re spending. When the conversation gets long, `/context` shows where the window is going and `/compact` summarizes it down; use `/btw` for a quick aside that shouldn’t bloat history. **Before you ship.** `/diff` shows what changed, `/simplify` reviews recent files and applies quality and efficiency fixes, and `/review` or `/security-review` give a deeper read-only pass. **Between sessions.** `/clear` starts fresh on a new task while keeping project memory. `/resume` and `/branch` let you return to or fork an earlier conversation. `/teleport` pulls a web session into this terminal, and `/remote-control` lets you continue this local session from another device. **When something is wrong.** `/rewind` rolls code and conversation back to a checkpoint. `/doctor` and `/debug` diagnose install and runtime issues, and `/feedback` reports a bug with session context attached. +Most commands are useful at a specific point in a session, from setting up a project to shipping a change. **First session in a repo.** Run `/init` to generate a starter `CLAUDE.md`, then `/memory` to refine it. Use `/mcp` and `/agents` to set up any servers or subagents the project needs, and `/permissions` to set the approval rules you want. **During a task.** `/plan` switches into plan mode before a large change. `/model` and `/effort` adjust how much reasoning you’re spending. When the conversation gets long, `/context` shows where the window is going and `/compact` summarizes it down; use `/btw` for a quick aside that shouldn’t bloat history. **Running work in parallel.** `/agents` opens the manager for the [subagents](</docs/en/sub-agents>) Claude can delegate side tasks to, and `/tasks` lists what’s running in the background of the current session. `/background` detaches the whole session to keep running as a [background agent](</docs/en/agent-view>) and frees your terminal. For a large change that spans the codebase, `/batch` decomposes it into independent units and runs each in its own [worktree](</docs/en/worktrees>). See [Run agents in parallel](</docs/en/agents>) for how these approaches relate. **Before you ship.** `/diff` shows what changed, `/simplify` reviews recent files and applies quality and efficiency fixes, and `/review` or `/security-review` give a deeper read-only pass. **Between sessions.** `/clear` starts fresh on a new task while keeping project memory. `/resume` and `/branch` let you return to or fork an earlier conversation. `/teleport` pulls a web session into this terminal, and `/remote-control` lets you continue this local session from another device. **When something is wrong.** `/rewind` rolls code and conversation back to a checkpoint. `/doctor` and `/debug` diagnose install and runtime issues, and `/feedback` reports a bug with session context attached. ## @@ -29,7 +29,8 @@ `/add-dir <path>`| Add a working directory for file access during the current session. Most `.claude/` configuration is [not discovered](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) from the added directory. You can later resume the session from the added directory with `--continue` or `--resume` `/agents`| Manage [agent](</docs/en/sub-agents>) configurations `/autofix-pr [prompt]`| Spawn a [Claude Code on the web](</docs/en/claude-code-on-the-web#auto-fix-pull-requests>) session that watches the current branch’s PR and pushes fixes when CI fails or reviewers leave comments. Detects the open PR from your checked-out branch with `gh pr view`; to watch a different PR, check out its branch first. By default the remote session is told to fix every CI failure and review comment; pass a prompt to give it different instructions, for example `/autofix-pr only fix lint and type errors`. Requires the `gh` CLI and access to [Claude Code on the web](</docs/en/claude-code-on-the-web#who-can-use-claude-code-on-the-web>) -`/batch <instruction>`| **[Skill](</docs/en/skills#bundled-skills>).** Orchestrate large-scale changes across a codebase in parallel. Researches the codebase, decomposes the work into 5 to 30 independent units, and presents a plan. Once approved, spawns one background agent per unit in an isolated [git worktree](</docs/en/worktrees>). Each agent implements its unit, runs tests, and opens a pull request. Requires a git repository. Example: `/batch migrate src/ from Solid to React` +`/background [prompt]`| Detach the current session to run as a [background agent](</docs/en/agent-view>) and free this terminal. Pass a prompt to send one more instruction before detaching. Monitor the session with `claude agents`. Alias: `/bg` +`/batch <instruction>`| **[Skill](</docs/en/skills#bundled-skills>).** Orchestrate large-scale changes across a codebase in parallel. Researches the codebase, decomposes the work into 5 to 30 independent units, and presents a plan. Once approved, spawns one [background subagent](</docs/en/sub-agents#run-subagents-in-foreground-or-background>) per unit in an isolated [git worktree](</docs/en/worktrees>). Each subagent implements its unit, runs tests, and opens a pull request. Requires a git repository. Example: `/batch migrate src/ from Solid to React` `/branch [name]`| Create a branch of the current conversation at this point. Switches you into the branch and preserves the original, which you can return to with `/resume`. Alias: `/fork`. When [`CLAUDE_CODE_FORK_SUBAGENT`](</docs/en/env-vars>) is set, `/fork` instead spawns a [forked subagent](</docs/en/sub-agents#fork-the-current-conversation>) and is no longer an alias for this command `/btw <question>`| Ask a quick [side question](</docs/en/interactive-mode#side-questions-with-%2Fbtw>) without adding to the conversation `/chrome`| Configure [Claude in Chrome](</docs/en/chrome>) settings @@ -53,6 +54,7 @@ `/feedback [report]`| Submit feedback about Claude Code. Alias: `/bug` `/fewer-permission-prompts`| **[Skill](</docs/en/skills#bundled-skills>).** Scan your transcripts for common read-only Bash and MCP tool calls, then add a prioritized allowlist to project `.claude/settings.json` to reduce permission prompts `/focus`| Toggle the focus view, which shows only your last prompt, a one-line tool-call summary with edit diffstats, and the final response. The selection persists across sessions; set [`viewMode`](</docs/en/settings#available-settings>) in settings to override it. Only available in [fullscreen rendering](</docs/en/fullscreen>) +`/goal [condition|clear]`| Set a [goal](</docs/en/goal>): Claude keeps working across turns until the condition is met. With no argument, shows the current or most recently achieved goal. `clear`, `stop`, `off`, `reset`, `none`, or `cancel` removes an active goal early `/heapdump`| Write a JavaScript heap snapshot and a memory breakdown to `~/Desktop`, or your home directory on Linux without a Desktop folder, for diagnosing high memory usage. See [troubleshooting](</docs/en/troubleshooting#high-cpu-or-memory-usage>) `/help`| Show help and available commands `/hooks`| View [hook](</docs/en/hooks>) configurations for tool events @@ -88,6 +90,7 @@ `/rewind`| Rewind the conversation and/or code to a previous point, or summarize from a selected message. See [checkpointing](</docs/en/checkpointing>). Aliases: `/checkpoint`, `/undo` `/sandbox`| Toggle [sandbox mode](</docs/en/sandboxing>). Available on supported platforms only `/schedule [description]`| Create, update, list, or run [routines](</docs/en/routines>), which execute on Anthropic-managed cloud infrastructure. Claude walks you through the setup conversationally. Alias: `/routines` +`/scroll-speed`| Adjust mouse wheel [scroll speed](</docs/en/fullscreen#mouse-wheel-scrolling>) interactively, with a ruler you can scroll while the dialog is open to preview the change. Available in [fullscreen rendering](</docs/en/fullscreen>) only and not in the JetBrains IDE terminal `/security-review`| Analyze pending changes on the current branch for security vulnerabilities. Reviews the git diff and identifies risks like injection, auth issues, and data exposure `/setup-bedrock`| Configure [Amazon Bedrock](</docs/en/amazon-bedrock>) authentication, region, and model pins through an interactive wizard. Only visible when `CLAUDE_CODE_USE_BEDROCK=1` is set. First-time Bedrock users can also access this wizard from the login screen `/setup-vertex`| Configure [Google Vertex AI](</docs/en/google-vertex-ai>) authentication, project, region, and model pins through an interactive wizard. Only visible when `CLAUDE_CODE_USE_VERTEX=1` is set. First-time Vertex AI users can also access this wizard from the login screen @@ -97,6 +100,7 @@ `/status`| Open the Settings interface (Status tab) showing version, model, account, and connectivity. Works while Claude is responding, without waiting for the current response to finish `/statusline`| Configure Claude Code’s [status line](</docs/en/statusline>). Describe what you want, or run without arguments to auto-configure from your shell prompt `/stickers`| Order Claude Code stickers +`/stop`| Stop the current [background session](</docs/en/agent-view>). Only available while attached to a background session; the transcript and any worktree are kept. To detach without stopping, use `/exit` or press `←` `/tasks`| List and manage background tasks. Also available as `/bashes` `/team-onboarding`| Generate a team onboarding guide from your Claude Code usage history. Claude analyzes your sessions, commands, and MCP server usage from the past 30 days and produces a markdown guide a teammate can paste as a first message to get set up quickly. For claude.ai subscribers on Pro, Max, Team, and Enterprise plans, also returns a share link teammates can open directly in Claude Code `/teleport`| Pull a [Claude Code on the web](</docs/en/claude-code-on-the-web#from-web-to-terminal>) session into this terminal: opens a picker, then fetches the branch and conversation. Also available as `/tp`. Requires a claude.ai subscription
modified Common workflows View current →
--- a/common-workflows.md +++ b/common-workflows.md @@ -465,7 +465,7 @@ claude --worktree feature-auth -Run the same command with a different name in a second terminal to start an isolated parallel session. See [Worktrees](</docs/en/worktrees>) for cleanup, `.worktreeinclude`, and non-git VCS support. +Run the same command with a different name in a second terminal to start an isolated parallel session. See [Worktrees](</docs/en/worktrees>) for cleanup, `.worktreeinclude`, and non-git VCS support. To monitor parallel sessions from one screen instead of separate terminals, see [background agents](</docs/en/agent-view>). ##
modified Data usage View current →
--- a/data-usage.md +++ b/data-usage.md @@ -122,31 +122,36 @@ Default behaviors by API provider -By default, error reporting, telemetry, and bug reporting are disabled when using Bedrock, Vertex, or Foundry. Session quality surveys and the WebFetch domain safety check are exceptions and run regardless of provider. You can opt out of all non-essential traffic, including surveys, at once by setting `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`. This variable does not affect the WebFetch check, which has its own opt-out. Here are the full default behaviors: +By default, error reporting, telemetry, and bug reporting are disabled when using Bedrock, Vertex, Foundry, or Claude Platform on AWS. Session quality surveys and the WebFetch domain safety check are exceptions and run regardless of provider. You can opt out of all non-essential traffic, including surveys, at once by setting `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`. This variable does not affect the WebFetch check, which has its own opt-out. Here are the full default behaviors: -Service| Claude API| Vertex API| Bedrock API| Foundry API ----|---|---|---|--- +Service| Claude API| Vertex API| Bedrock API| Foundry API| Claude Platform on AWS +---|---|---|---|---|--- **Anthropic (Metrics)**| Default on. `DISABLE_TELEMETRY=1` to disable.| Default off. `CLAUDE_CODE_USE_VERTEX` must be 1.| Default off. `CLAUDE_CODE_USE_BEDROCK` must be 1.| Default off. -`CLAUDE_CODE_USE_FOUNDRY` must be 1. +`CLAUDE_CODE_USE_FOUNDRY` must be 1.| Default off. +`CLAUDE_CODE_USE_ANTHROPIC_AWS` must be 1. **Sentry (Errors)**| Default on. `DISABLE_ERROR_REPORTING=1` to disable.| Default off. `CLAUDE_CODE_USE_VERTEX` must be 1.| Default off. `CLAUDE_CODE_USE_BEDROCK` must be 1.| Default off. -`CLAUDE_CODE_USE_FOUNDRY` must be 1. +`CLAUDE_CODE_USE_FOUNDRY` must be 1.| Default off. +`CLAUDE_CODE_USE_ANTHROPIC_AWS` must be 1. **Claude API (`/feedback` reports)**| Default on. `DISABLE_FEEDBACK_COMMAND=1` to disable.| Default off. `CLAUDE_CODE_USE_VERTEX` must be 1.| Default off. `CLAUDE_CODE_USE_BEDROCK` must be 1.| Default off. -`CLAUDE_CODE_USE_FOUNDRY` must be 1. +`CLAUDE_CODE_USE_FOUNDRY` must be 1.| Default off. +`CLAUDE_CODE_USE_ANTHROPIC_AWS` must be 1. **Session quality surveys**| Default on. +`CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY=1` to disable.| Default on. `CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY=1` to disable.| Default on. `CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY=1` to disable.| Default on. `CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY=1` to disable.| Default on. `CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY=1` to disable. **WebFetch domain safety check**| Default on. +`skipWebFetchPreflight: true` in [settings](</docs/en/settings>) to disable.| Default on. `skipWebFetchPreflight: true` in [settings](</docs/en/settings>) to disable.| Default on. `skipWebFetchPreflight: true` in [settings](</docs/en/settings>) to disable.| Default on. `skipWebFetchPreflight: true` in [settings](</docs/en/settings>) to disable.| Default on.
modified Debug your configuration View current →
--- a/debug-your-config.md +++ b/debug-your-config.md @@ -90,7 +90,7 @@ ---|---|--- Hook never fires| `matcher` is a JSON array instead of a string| Use a single string with `|` to match multiple tools, for example `"Edit|Write"`. See [matcher patterns](</docs/en/hooks#matcher-patterns>). Hook never fires| `matcher` value is lowercase, for example `"bash"`| Matching is case-sensitive. Tool names are capitalized: `Bash`, `Edit`, `Write`, `Read`. -Hook never fires| Hooks are in a standalone `.claude/hooks.json` file| There is no standalone hooks file. Define hooks under the `"hooks"` key in `settings.json`. See [hook configuration](</docs/en/hooks>). +Hook never fires| Hooks are defined in a standalone file instead of `settings.json`| There is no standalone hooks file for project or user config. Define hooks under the `"hooks"` key in `settings.json`. Only [plugins](</docs/en/plugins-reference#hooks>) load a separate `hooks/hooks.json`. See [hook configuration](</docs/en/hooks>). Permissions, hooks, or env set globally are ignored| Configuration was added to `~/.claude.json`| `~/.claude.json` holds app state and UI toggles. `permissions`, `hooks`, and `env` belong in `~/.claude/settings.json`. These are two different files. A `settings.json` value seems ignored| The same key is set in `settings.local.json`| `settings.local.json` overrides `settings.json`, and both override `~/.claude/settings.json`. See [settings precedence](</docs/en/settings#how-scopes-interact>). Skill doesn’t appear in `/skills`| Skill file is at `.claude/skills/name.md` instead of in a folder| Use a folder with `SKILL.md` inside: `.claude/skills/name/SKILL.md`.
modified Environment variables View current →
--- a/env-vars.md +++ b/env-vars.md @@ -10,6 +10,9 @@ ---|--- `ANTHROPIC_API_KEY`| API key sent as `X-Api-Key` header. When set, this key is used instead of your Claude Pro, Max, Team, or Enterprise subscription even if you are logged in. In non-interactive mode (`-p`), the key is always used when present. In interactive mode, you are prompted to approve the key once before it overrides your subscription. To use your subscription instead, run `unset ANTHROPIC_API_KEY` `ANTHROPIC_AUTH_TOKEN`| Custom value for the `Authorization` header (the value you set here will be prefixed with `Bearer `) +`ANTHROPIC_AWS_API_KEY`| Workspace API key for [Claude Platform on AWS](</docs/en/claude-platform-on-aws>), generated in the AWS Console. Sent as `x-api-key` and takes precedence over AWS SigV4 +`ANTHROPIC_AWS_BASE_URL`| Override the [Claude Platform on AWS](</docs/en/claude-platform-on-aws>) endpoint URL. Use for custom regions or when routing through an [LLM gateway](</docs/en/llm-gateway>). Defaults to `https://aws-external-anthropic.{AWS_REGION}.api.aws` +`ANTHROPIC_AWS_WORKSPACE_ID`| Required for [Claude Platform on AWS](</docs/en/claude-platform-on-aws>). Sent on every request as the `anthropic-workspace-id` header `ANTHROPIC_BASE_URL`| Override the API endpoint to route requests through a proxy or gateway. When set to a non-first-party host, [MCP tool search](</docs/en/mcp#scale-with-mcp-tool-search>) is disabled by default. Set `ENABLE_TOOL_SEARCH=true` if your proxy forwards `tool_reference` blocks `ANTHROPIC_BEDROCK_BASE_URL`| Override the Bedrock endpoint URL. Use for custom Bedrock endpoints or when routing through an [LLM gateway](</docs/en/llm-gateway>). See [Amazon Bedrock](</docs/en/amazon-bedrock>) `ANTHROPIC_BEDROCK_MANTLE_BASE_URL`| Override the Bedrock Mantle endpoint URL. See [Mantle endpoint](</docs/en/amazon-bedrock#use-the-mantle-endpoint>) @@ -43,7 +46,7 @@ `API_TIMEOUT_MS`| Timeout for API requests in milliseconds (default: 600000, or 10 minutes; maximum: 2147483647). Increase this when requests time out on slow networks or when routing through a proxy. Values above the maximum overflow the underlying timer and cause requests to fail immediately `AWS_BEARER_TOKEN_BEDROCK`| Bedrock API key for authentication (see [Bedrock API keys](<https://aws.amazon.com/blogs/machine-learning/accelerate-ai-development-with-amazon-bedrock-api-keys/>)) `BASH_DEFAULT_TIMEOUT_MS`| Default timeout for long-running bash commands (default: 120000, or 2 minutes) -`BASH_MAX_OUTPUT_LENGTH`| Maximum number of characters in bash outputs before they are middle-truncated +`BASH_MAX_OUTPUT_LENGTH`| Maximum number of characters in bash outputs before the full output is saved to a file and Claude receives the path plus a short preview. See [Bash tool behavior](</docs/en/tools-reference#bash-tool-behavior>) `BASH_MAX_TIMEOUT_MS`| Maximum timeout the model can set for long-running bash commands (default: 600000, or 10 minutes) `CCR_FORCE_BUNDLE`| Set to `1` to force [`claude --remote`](</docs/en/claude-code-on-the-web#send-local-repositories-without-github>) to bundle and upload your local repository even when GitHub access is available `CLAUDECODE`| Set to `1` in shell environments Claude Code spawns (Bash tool, tmux sessions). Not set in [hooks](</docs/en/hooks>) or [status line](</docs/en/statusline>) commands. Use to detect when a script is running inside a shell spawned by Claude Code @@ -67,6 +70,7 @@ `CLAUDE_CODE_DEBUG_LOG_LEVEL`| Minimum log level written to the debug log file. Values: `verbose`, `debug` (default), `info`, `warn`, `error`. Set to `verbose` to include high-volume diagnostics like full status line command output, or raise to `error` to reduce noise `CLAUDE_CODE_DISABLE_1M_CONTEXT`| Set to `1` to disable [1M context window](</docs/en/model-config#extended-context>) support. When set, 1M model variants are unavailable in the model picker. Useful for enterprise environments with compliance requirements `CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING`| Set to `1` to disable [adaptive reasoning](</docs/en/model-config#adjust-effort-level>) on Opus 4.6 and Sonnet 4.6 and fall back to the fixed thinking budget controlled by `MAX_THINKING_TOKENS`. Has no effect on Opus 4.7, which always uses adaptive reasoning +`CLAUDE_CODE_DISABLE_AGENT_VIEW`| Set to `1` to turn off [background agents and agent view](</docs/en/agent-view>): `claude agents`, `--bg`, `/background`, and the on-demand supervisor. Equivalent to the [`disableAgentView`](</docs/en/settings#available-settings>) setting `CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN`| Set to `1` to disable [fullscreen rendering](</docs/en/fullscreen>) and use the classic main-screen renderer. The conversation stays in your terminal’s native scrollback so `Cmd+f` and tmux copy mode work as usual. Takes precedence over `CLAUDE_CODE_NO_FLICKER` and the [`tui`](</docs/en/settings#available-settings>) setting. You can also switch with `/tui default` `CLAUDE_CODE_DISABLE_ATTACHMENTS`| Set to `1` to disable attachment processing. File mentions with `@` syntax are sent as plain text instead of being expanded into file content `CLAUDE_CODE_DISABLE_AUTO_MEMORY`| Set to `1` to disable [auto memory](</docs/en/memory#auto-memory>). Set to `0` to force auto memory on even when `--bare` mode or [`autoMemoryEnabled: false`](</docs/en/settings#available-settings>) would otherwise disable it. When disabled, Claude does not create or load auto memory files @@ -102,8 +106,8 @@ `CLAUDE_CODE_FORCE_SYNC_OUTPUT`| Set to `1` to force-enable DEC private mode 2026 [synchronized output](<https://gist.github.com/christianparpart/d8a62cc1ab659194337d73e399004036>) when your terminal supports it but is not auto-detected. Useful for emulators such as Emacs `eat` that implement BSU/ESU but do not reply to the capability probe. Has no effect under tmux `CLAUDE_CODE_FORK_SUBAGENT`| Set to `1` to enable [forked subagents](</docs/en/sub-agents#fork-the-current-conversation>). A forked subagent inherits the full conversation context from the main session instead of starting fresh. When enabled, `/fork` spawns a forked subagent rather than acting as an alias for [`/branch`](</docs/en/commands>), and all subagent spawns run in the background. Works in interactive mode and via the SDK or `claude -p` `CLAUDE_CODE_GIT_BASH_PATH`| Windows only: path to the Git Bash executable (`bash.exe`). Use when Git Bash is installed but not in your PATH. See [Windows setup](</docs/en/setup#set-up-on-windows>) -`CLAUDE_CODE_GLOB_HIDDEN`| Set to `false` to exclude dotfiles from results when Claude invokes the [Glob tool](</docs/en/tools-reference>). Included by default. Does not affect `@` file autocomplete, `ls`, Grep, or Read -`CLAUDE_CODE_GLOB_NO_IGNORE`| Set to `false` to make the [Glob tool](</docs/en/tools-reference>) respect `.gitignore` patterns. By default, Glob returns all matching files including gitignored ones. Does not affect `@` file autocomplete, which has its own [`respectGitignore` setting](</docs/en/settings#available-settings>) +`CLAUDE_CODE_GLOB_HIDDEN`| Set to `false` to exclude dotfiles from results when Claude invokes the [Glob tool](</docs/en/tools-reference#glob-tool-behavior>). Included by default. Does not affect `@` file autocomplete, `ls`, Grep, or Read +`CLAUDE_CODE_GLOB_NO_IGNORE`| Set to `false` to make the [Glob tool](</docs/en/tools-reference#glob-tool-behavior>) respect `.gitignore` patterns. By default, Glob returns all matching files including gitignored ones. Does not affect `@` file autocomplete, which has its own [`respectGitignore` setting](</docs/en/settings#available-settings>) `CLAUDE_CODE_GLOB_TIMEOUT_SECONDS`| Timeout in seconds for Glob tool file discovery. Defaults to 20 seconds on most platforms and 60 seconds on WSL `CLAUDE_CODE_HIDE_CWD`| Set to `1` to hide the working directory in the startup logo. Useful for screenshares or recordings where the path exposes your OS username `CLAUDE_CODE_IDE_HOST_OVERRIDE`| Override the host address used to connect to the IDE extension. By default Claude Code auto-detects the correct address, including WSL-to-Windows routing @@ -113,6 +117,7 @@ `CLAUDE_CODE_MAX_OUTPUT_TOKENS`| Set the maximum number of output tokens for most requests. Defaults and caps vary by model; see [max output tokens](<https://platform.claude.com/docs/en/about-claude/models/overview#latest-models-comparison>). Increasing this value reduces the effective context window available before [auto-compaction](</docs/en/costs#reduce-token-usage>) triggers. `CLAUDE_CODE_MAX_RETRIES`| Override the number of times to retry failed API requests (default: 10) `CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY`| Maximum number of read-only tools and subagents that can execute in parallel (default: 10). Higher values increase parallelism but consume more resources +`CLAUDE_CODE_MAX_TURNS`| Cap the number of agentic turns when no explicit limit is passed. Equivalent to passing [`--max-turns`](</docs/en/cli-reference#cli-flags>), which takes precedence when both are set. A value that is not a positive integer is rejected at startup with an error rather than treated as no cap `CLAUDE_CODE_MCP_ALLOWLIST_ENV`| Set to `1` to spawn stdio MCP servers with only a safe baseline environment plus the server’s configured `env`, instead of inheriting your shell environment `CLAUDE_CODE_NATIVE_CURSOR`| Set to `1` to show the terminal’s own cursor at the input caret instead of a drawn block. The cursor respects the terminal’s blink, shape, and focus settings `CLAUDE_CODE_NEW_INIT`| Set to `1` to make `/init` run an interactive setup flow. The flow asks which files to generate, including CLAUDE.md, skills, and hooks, before exploring the codebase and writing them. Without this variable, `/init` generates a CLAUDE.md automatically without prompting. @@ -142,6 +147,7 @@ `CLAUDE_CODE_SHELL_PREFIX`| Command prefix that wraps shell commands Claude Code spawns: Bash tool calls, [hook](</docs/en/hooks>) commands, and stdio [MCP server](</docs/en/mcp>) startup commands. Useful for logging or auditing. Example: setting `/path/to/logger.sh` runs each command as `/path/to/logger.sh <command>` `CLAUDE_CODE_SIMPLE`| Set to `1` to run with a minimal system prompt and only the Bash, file read, and file edit tools. MCP tools from `--mcp-config` are still available. Disables auto-discovery of hooks, skills, plugins, MCP servers, auto memory, and CLAUDE.md. The [`--bare`](</docs/en/headless#start-faster-with-bare-mode>) CLI flag sets this `CLAUDE_CODE_SIMPLE_SYSTEM_PROMPT`| Set to `1` to use a shorter system prompt and abbreviated tool descriptions on Opus 4.7. Has no effect on other models. The full tool set, hooks, MCP servers, and CLAUDE.md discovery remain enabled +`CLAUDE_CODE_SKIP_ANTHROPIC_AWS_AUTH`| Skip client-side authentication for [Claude Platform on AWS](</docs/en/claude-platform-on-aws>), for gateways that sign requests themselves `CLAUDE_CODE_SKIP_BEDROCK_AUTH`| Skip AWS authentication for Bedrock (for example, when using an LLM gateway) `CLAUDE_CODE_SKIP_FOUNDRY_AUTH`| Skip Azure authentication for Microsoft Foundry (for example, when using an LLM gateway) `CLAUDE_CODE_SKIP_MANTLE_AUTH`| Skip AWS authentication for Bedrock Mantle (for example, when using an LLM gateway) @@ -156,6 +162,7 @@ `CLAUDE_CODE_TEAM_NAME`| Name of the agent team this teammate belongs to. Set automatically on [agent team](</docs/en/agent-teams>) members `CLAUDE_CODE_TMPDIR`| Override the temp directory used for internal temp files. Claude Code appends `/claude-{uid}/` (Unix) or `/claude/` (Windows) to this path. Default: `/tmp` on macOS, `os.tmpdir()` on Linux/Windows `CLAUDE_CODE_TMUX_TRUECOLOR`| Set to `1` to allow 24-bit truecolor output inside tmux. By default, Claude Code clamps to 256 colors when `$TMUX` is set because tmux does not pass through truecolor escape sequences unless configured to. Set this after adding `set -ga terminal-overrides ',*:Tc'` to your `~/.tmux.conf`. See [Terminal configuration](</docs/en/terminal-config>) for other tmux settings +`CLAUDE_CODE_USE_ANTHROPIC_AWS`| Use [Claude Platform on AWS](</docs/en/claude-platform-on-aws>) `CLAUDE_CODE_USE_BEDROCK`| Use [Bedrock](</docs/en/amazon-bedrock>) `CLAUDE_CODE_USE_FOUNDRY`| Use [Microsoft Foundry](</docs/en/microsoft-foundry>) `CLAUDE_CODE_USE_MANTLE`| Use the Bedrock [Mantle endpoint](</docs/en/amazon-bedrock#use-the-mantle-endpoint>) @@ -192,9 +199,9 @@ `DISABLE_UPGRADE_COMMAND`| Set to `1` to hide the `/upgrade` command `DO_NOT_TRACK`| Set to `1` to opt out of telemetry. Equivalent to setting `DISABLE_TELEMETRY`. Honored as the [standard cross-tool convention](<https://consoledonottrack.com/>) `ENABLE_CLAUDEAI_MCP_SERVERS`| Set to `false` to disable [claude.ai MCP servers](</docs/en/mcp#use-mcp-servers-from-claude-ai>) in Claude Code. Enabled by default for logged-in users -`ENABLE_PROMPT_CACHING_1H`| Set to `1` to request a 1-hour prompt cache TTL instead of the default 5 minutes. Intended for API key, [Bedrock](</docs/en/amazon-bedrock>), [Vertex](</docs/en/google-vertex-ai>), and [Foundry](</docs/en/microsoft-foundry>) users. Subscription users receive 1-hour TTL automatically. 1-hour cache writes are billed at a higher rate +`ENABLE_PROMPT_CACHING_1H`| Set to `1` to request a 1-hour prompt cache TTL instead of the default 5 minutes. Intended for API key, [Bedrock](</docs/en/amazon-bedrock>), [Vertex](</docs/en/google-vertex-ai>), [Foundry](</docs/en/microsoft-foundry>), and [Claude Platform on AWS](</docs/en/claude-platform-on-aws>) users. Subscription users receive 1-hour TTL automatically. 1-hour cache writes are billed at a higher rate `ENABLE_PROMPT_CACHING_1H_BEDROCK`| Deprecated. Use `ENABLE_PROMPT_CACHING_1H` instead -`ENABLE_TOOL_SEARCH`| Controls [MCP tool search](</docs/en/mcp#scale-with-mcp-tool-search>). Unset: all MCP tools deferred by default, but loaded upfront on Vertex AI or when `ANTHROPIC_BASE_URL` points to a non-first-party host. Values: `true` (always defer including proxies and Vertex AI), `auto` (threshold mode: load upfront if tools fit within 10% of context), `auto:N` (custom threshold, e.g., `auto:5` for 5%), `false` (load all upfront) +`ENABLE_TOOL_SEARCH`| Controls [MCP tool search](</docs/en/mcp#scale-with-mcp-tool-search>). Unset: all MCP tools deferred by default, but loaded upfront on Vertex AI or when `ANTHROPIC_BASE_URL` points to a non-first-party host. Values: `true` (always defer and send the beta header, requests fail on Vertex AI or proxies that do not support `tool_reference`), `auto` (threshold mode: load upfront if tools fit within 10% of context), `auto:N` (custom threshold, e.g., `auto:5` for 5%), `false` (load all upfront) `FALLBACK_FOR_ALL_PRIMARY_MODELS`| Set to any non-empty value to trigger fallback to [`--fallback-model`](</docs/en/cli-reference#cli-flags>) after repeated overload errors on any primary model. By default, only Opus models trigger the fallback `FORCE_AUTOUPDATE_PLUGINS`| Set to `1` to force plugin auto-updates even when the main auto-updater is disabled via `DISABLE_AUTOUPDATER` `FORCE_PROMPT_CACHING_5M`| Set to `1` to force the 5-minute prompt cache TTL even when 1-hour TTL would otherwise apply. Overrides `ENABLE_PROMPT_CACHING_1H`
modified Fullscreen rendering View current →
--- a/fullscreen.md +++ b/fullscreen.md @@ -89,7 +89,7 @@ export CLAUDE_CODE_SCROLL_SPEED=3 -A value of `3` matches the default in `vim` and similar applications. The setting accepts values from 1 to 20. +A value of `3` matches the default in `vim` and similar applications. The setting accepts values from 1 to 20. To adjust scroll speed interactively, run `/scroll-speed`. The dialog shows a ruler you can scroll while it is open so you can feel the change immediately. Press `←` and `→` to adjust, `r` to reset to the auto-detected default, and `Enter` to save. The command writes the same value the `CLAUDE_CODE_SCROLL_SPEED` environment variable sets, persisted to `~/.claude/settings.json`. The command is not available in the JetBrains IDE terminal. ###
modified Glossary View current →
--- a/glossary.md +++ b/glossary.md @@ -256,7 +256,7 @@ Output style -A configuration that modifies Claude’s system prompt to change response behavior, tone, or format. Output styles turn off the software-engineering-specific parts of the default system prompt, unlike CLAUDE.md which is delivered as a user message following the system prompt. Built-in styles include Default, Explanatory, and Learning. Learn more: [Output styles](</docs/en/output-styles>) +A configuration that modifies Claude’s system prompt to change response behavior, tone, or format. Output styles turn off the software-engineering-specific parts of the default system prompt, unlike CLAUDE.md which is delivered as a user message following the system prompt. Built-in styles include Default, Proactive, Explanatory, and Learning. Learn more: [Output styles](</docs/en/output-styles>) ## @@ -409,6 +409,14 @@ Tool An action Claude can take: read a file, edit code, run a shell command, search the web, spawn a subagent. Tools are what make Claude Code agentic. Without them, Claude can only respond with text. Each tool use returns a result that informs Claude’s next decision in the agentic loop. Learn more: [Tools available to Claude](</docs/en/tools-reference>) + +### + +​ + +Turn + +One complete response from Claude within a session. A turn begins when you send a message and ends when Claude finishes responding, with any number of tool calls in between. Stop hooks fire at the end of each turn. A session consists of many turns, and the agentic loop describes what happens inside one. Learn more: [How Claude Code works](</docs/en/how-claude-code-works#the-agentic-loop>) ##
added Keep Claude working toward a goal View current →
Show diff (157 lines)
--- a/goal.md +++ b/goal.md @@ -0,0 +1,154 @@ +> ## Documentation Index +> +> Fetch the complete documentation index at: <https://code.claude.com/docs/llms.txt> +> +> Use this file to discover all available pages before exploring further. + +The `/goal` command sets a completion condition and Claude keeps working toward it without you prompting each step. After each turn, a small fast model checks whether the condition holds. If not, Claude starts another turn instead of returning control to you. The goal clears automatically once the condition is met. Use a goal for substantial work with a verifiable end state: + + * Migrating a module to a new API until every call site compiles and tests pass + * Implementing a design doc until all acceptance criteria hold + * Splitting a large file into focused modules until each is under a size budget + * Working through a labeled issue backlog until the queue is empty + +This page covers how to: + + * Compare autonomous workflow approaches: `/loop`, Stop hooks, and auto mode + * Set a goal and write an effective condition + * Check status, clear early, and run non-interactively + * See how evaluation works and requirements + +## + +​ + +Compare to other autonomous workflows + +Three approaches keep the current session running between prompts. Pick based on what should start the next turn: + +Approach| Next turn starts when| Stops when +---|---|--- +`/goal`| The previous turn finishes| A model confirms the condition is met +[`/loop`](</docs/en/scheduled-tasks#run-a-prompt-repeatedly-with-%2Floop>)| A time interval elapses| You stop it, or Claude decides the work is done +[Stop hook](</docs/en/hooks-guide#prompt-based-hooks>)| The previous turn finishes| Your own script or prompt decides + +`/goal` and a Stop hook both fire after every turn. `/goal` is a session-scoped shortcut: you type a condition and it’s active for the current session only. A Stop hook lives in your settings file, applies to every session in its scope, and can run a script for deterministic checks or a prompt for model-evaluated ones. [Auto mode](</docs/en/auto-mode-config>) on its own approves tool calls within a single turn but doesn’t start a new one. Claude stops when it judges the work done. `/goal` adds a separate evaluator that checks your condition after every turn, so completion is decided by a fresh model rather than the one doing the work. The two are complementary: auto mode removes per-tool prompts, and `/goal` removes per-turn prompts. + +The approaches above keep the current session running. You can also schedule work that runs independent of any open session, such as nightly tests or morning triage. See [scheduling options](</docs/en/scheduled-tasks#compare-scheduling-options>) for cloud routines and desktop scheduled tasks. + +## + +​ + +Use `/goal` + +One goal can be active per session. The same command sets, checks, and clears it depending on the argument. + +### + +​ + +Set a goal + +Run `/goal` followed by the condition you want satisfied. If a goal is already active, the new one replaces it. + + /goal all tests in test/auth pass and the lint step is clean + +Setting a goal starts a turn immediately, with the condition itself as the directive. You don’t need to send a separate prompt. While the goal is active, a `◎ /goal active` indicator shows how long the goal has been running. After each turn, the evaluator returns a short reason explaining why the condition is or isn’t met. The most recent reason appears in the status view and in the transcript so you can see what Claude is working toward next. + +A goal keeps running until the condition is met or you run `/goal clear`. Run `/goal` with no argument to see turns and tokens spent so far. + +### + +​ + +Write an effective condition + +The evaluator judges your condition against what Claude has surfaced in the conversation. It doesn’t run commands or read files independently, so write the condition as something Claude’s own output can demonstrate. “All tests in `test/auth` pass” works because Claude runs the tests and the result lands in the transcript for the evaluator to read. A condition that holds up across many turns usually has: + + * **One measurable end state** : a test result, a build exit code, a file count, an empty queue + * **A stated check** : how Claude should prove it, such as “`npm test` exits 0” or “`git status` is clean” + * **Constraints that matter** : anything that must not change on the way there, such as “no other test file is modified” + +The condition can be up to 4,000 characters. To bound how long a goal runs, include a turn or time clause in the condition, such as `or stop after 20 turns`. Claude reports progress against that clause each turn and the evaluator judges it from the conversation. + +### + +​ + +Check status + +Run `/goal` with no arguments to see the current state. + + /goal + +If a goal is active, the status shows: + + * The condition + * How long it has been running + * How many turns have been evaluated + * The current token spend + * The evaluator’s most recent reason + +If no goal is active but one was achieved earlier in the session, the status shows the achieved condition along with its duration, turn count, and token spend. + +### + +​ + +Clear a goal + +Run `/goal clear` to remove an active goal before its condition is met. + + /goal clear + +`stop`, `off`, `reset`, `none`, and `cancel` are accepted as aliases for `clear`. Running `/clear` to start a new conversation also removes any active goal. + +### + +​ + +Resume with an active goal + +A goal that was still active when a session ended is restored when you resume that session with `--resume` or `--continue`. The condition carries over, but the turn count, timer, and token-spend baseline all reset on resume. A goal that was already achieved or cleared is not restored. + +### + +​ + +Run non-interactively + +`/goal` works in [non-interactive mode](</docs/en/headless>) and through [Remote Control](</docs/en/remote-control>). Setting a goal with `-p` runs the loop to completion in a single invocation: + + claude -p "/goal CHANGELOG.md has an entry for every PR merged this week" + +Interrupt the process with Ctrl+C to stop a non-interactive goal before the condition is met. + +## + +​ + +How evaluation works + +`/goal` is a wrapper around a session-scoped [prompt-based Stop hook](</docs/en/hooks#prompt-based-hooks>). Each time Claude finishes a turn, the condition and the conversation so far are sent to your configured [small fast model](</docs/en/model-config>), which defaults to Haiku. The model returns a yes-or-no decision and a short reason. A “no” tells Claude to keep working and includes the reason as guidance for the next turn. A “yes” clears the goal and records an achieved entry in the transcript. The evaluator runs on whichever provider your session is configured for. It does not call tools, so it can only judge what Claude has already surfaced in the conversation. + +Evaluation tokens are billed on the small fast model configured for your provider and are typically negligible compared to main-turn spend. + +## + +​ + +Requirements + +`/goal` runs only in workspaces where you have accepted the trust dialog, because the evaluator is part of the hooks system. If [`disableAllHooks`](</docs/en/hooks#disable-or-remove-hooks>) is set in managed policy settings, `/goal` is unavailable. In both cases, the command tells you why instead of silently doing nothing. + +## + +​ + +See also + + * [Run a prompt repeatedly with `/loop`](</docs/en/scheduled-tasks#run-a-prompt-repeatedly-with-%2Floop>): re-run on a time interval instead of until a condition holds + * [Prompt-based hooks](</docs/en/hooks-guide#prompt-based-hooks>): write your own Stop hook when you need custom evaluation logic + * [Auto mode](</docs/en/auto-mode-config>): approve tool calls automatically so each goal turn runs unattended + * [Scheduling comparison](</docs/en/scheduled-tasks#compare-scheduling-options>): run work on a schedule independent of any open session
modified Claude Code on Google Vertex AI View current →
--- a/google-vertex-ai.md +++ b/google-vertex-ai.md @@ -148,7 +148,7 @@ export VERTEX_REGION_CLAUDE_HAIKU_4_5=us-east5 export VERTEX_REGION_CLAUDE_4_6_SONNET=europe-west1 -Most model versions have a corresponding `VERTEX_REGION_CLAUDE_*` variable. See the [Environment variables reference](</docs/en/env-vars>) for the full list. Check [Vertex Model Garden](<https://console.cloud.google.com/vertex-ai/model-garden>) to determine which models support global endpoints versus regional only. [Prompt caching](<https://platform.claude.com/docs/en/build-with-claude/prompt-caching>) is enabled automatically. To disable it, set `DISABLE_PROMPT_CACHING=1`. To request a 1-hour cache TTL instead of the 5-minute default, set `ENABLE_PROMPT_CACHING_1H=1`; cache writes with a 1-hour TTL are billed at a higher rate. For heightened rate limits, contact Google Cloud support. When using Vertex AI, the `/login` and `/logout` commands are disabled since authentication is handled through Google Cloud credentials. [MCP tool search](</docs/en/mcp#scale-with-mcp-tool-search>) is disabled by default on Vertex AI because the endpoint does not accept the required beta header. All MCP tool definitions load upfront instead. To opt in, set `ENABLE_TOOL_SEARCH=true`. +Most model versions have a corresponding `VERTEX_REGION_CLAUDE_*` variable. See the [Environment variables reference](</docs/en/env-vars>) for the full list. Check [Vertex Model Garden](<https://console.cloud.google.com/vertex-ai/model-garden>) to determine which models support global endpoints versus regional only. [Prompt caching](<https://platform.claude.com/docs/en/build-with-claude/prompt-caching>) is enabled automatically. To disable it, set `DISABLE_PROMPT_CACHING=1`. To request a 1-hour cache TTL instead of the 5-minute default, set `ENABLE_PROMPT_CACHING_1H=1`; cache writes with a 1-hour TTL are billed at a higher rate. For heightened rate limits, contact Google Cloud support. When using Vertex AI, the `/login` and `/logout` commands are disabled since authentication is handled through Google Cloud credentials. [MCP tool search](</docs/en/mcp#scale-with-mcp-tool-search>) is disabled by default on Vertex AI because the endpoint does not accept the required beta header. All MCP tool definitions load upfront instead. Setting `ENABLE_TOOL_SEARCH=true` forces Claude Code to send the header anyway, which causes Vertex AI to reject requests. ###
modified Hooks reference View current →
Show diff (217 lines)
--- a/hooks.md +++ b/hooks.md @@ -67,7 +67,8 @@ { "type": "command", "if": "Bash(rm *)", - "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-rm.sh" + "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/block-rm.sh", + "args": [] } ] } @@ -316,10 +317,36 @@ Field| Required| Description ---|---|--- -`command`| yes| Shell command to execute +`command`| yes| Shell command to execute. With `args`, the executable to spawn directly. See Exec form and shell form +`args`| no| Argument list. When present, `command` is resolved as an executable and spawned directly with `args` as the argument vector, with no shell involved. See Exec form and shell form `async`| no| If `true`, runs in the background without blocking. See Run hooks in the background `asyncRewake`| no| If `true`, runs in the background and wakes Claude on exit code 2. Implies `async`. The hook’s stderr, or stdout if stderr is empty, is shown to Claude as a system reminder so it can react to a long-running background failure -`shell`| no| Shell to use for this hook. Accepts `"bash"` (default) or `"powershell"`. Setting `"powershell"` runs the command via PowerShell on Windows. Does not require `CLAUDE_CODE_USE_POWERSHELL_TOOL` since hooks spawn PowerShell directly +`shell`| no| Shell to use for this hook. Accepts `"bash"` (default) or `"powershell"`. Setting `"powershell"` runs the command via PowerShell on Windows. Does not require `CLAUDE_CODE_USE_POWERSHELL_TOOL` since hooks spawn PowerShell directly. Ignored when `args` is set + +##### Exec form and shell form + +A command hook runs as exec form when `args` is set, and shell form when `args` is omitted. Set `args` whenever the hook references a path placeholder, since each element is passed as one argument with no quoting. Omit `args` when you need shell features like pipes or `&&`, or when neither concern applies. **Exec form** runs when `args` is present. Claude Code resolves `command` as an executable on `PATH` and spawns it directly with `args` as the argument vector. There is no shell, so each `args` element is one argument exactly as written, and path placeholders like `${CLAUDE_PLUGIN_ROOT}` are substituted into `command` and into each `args` element as plain strings. Special characters such as apostrophes, `$`, and backticks pass through verbatim because there is no shell to interpret them. No shell tokenization happens on any platform. **Shell form** runs when `args` is absent. The `command` string is passed to a shell: `sh -c` on macOS and Linux, Git Bash on Windows, or PowerShell when Git Bash isn’t installed. Set the `shell` field to choose explicitly. The shell tokenizes the string, expands variables, and interprets pipes, `&&`, redirects, and globs. + +On Windows, exec form requires `command` to resolve to a real executable such as a `.exe`. The `.cmd` and `.bat` shims that npm, npx, eslint, and other tools install in `node_modules/.bin` are not executables and cannot be spawned without a shell. To run them in exec form, invoke the underlying script with `node` directly, for example `"command": "node", "args": ["${CLAUDE_PLUGIN_ROOT}/node_modules/eslint/bin/eslint.js"]`. The `node` plus script-path pattern works on every platform because `node.exe` is a real binary. To run a `.cmd` or `.bat` shim by name, use shell form. + +This example runs a Node script bundled with a plugin. Exec form passes the resolved script path as one argument with no quoting: + + { + "type": "command", + "command": "node", + "args": ["${CLAUDE_PLUGIN_ROOT}/scripts/format.js", "--fix"] + } + +The equivalent shell form needs quoting to handle paths with spaces or special characters: + + { + "type": "command", + "command": "node \"${CLAUDE_PLUGIN_ROOT}\"/scripts/format.js --fix" + } + +Both forms support the same path placeholders, and both export them as the environment variables `CLAUDE_PROJECT_DIR`, `CLAUDE_PLUGIN_ROOT`, and `CLAUDE_PLUGIN_DATA` on the spawned process, so a script can read `process.env.CLAUDE_PLUGIN_ROOT` regardless of how it was launched. Plugin hooks additionally substitute `${user_config.*}` values; see [User configuration](</docs/en/plugins-reference#user-configuration>). + +In exec form, `command` is the executable name or path only. If `command` is a bare name with no path separator and contains whitespace alongside `args`, Claude Code logs a warning because the spawn will fail: there is no executable named `node script.js`. Move the extra tokens into `args`. Absolute paths with spaces, such as `C:\Program Files\nodejs\node.exe`, are a single valid executable and do not trigger the warning. #### @@ -405,7 +432,7 @@ `prompt`| yes| Prompt text to send to the model. Use `$ARGUMENTS` as a placeholder for the hook input JSON `model`| no| Model to use for evaluation. Defaults to a fast model -All matching hooks run in parallel, and identical handlers are deduplicated automatically. Command hooks are deduplicated by command string, and HTTP hooks are deduplicated by URL. Handlers run in the current directory with Claude Code’s environment. The `$CLAUDE_CODE_REMOTE` environment variable is set to `"true"` in remote web environments and not set in the local CLI. +All matching hooks run in parallel, and identical handlers are deduplicated automatically. Command hooks are deduplicated by command string and `args`, and HTTP hooks are deduplicated by URL. Handlers run in the current directory with Claude Code’s environment. The `$CLAUDE_CODE_REMOTE` environment variable is set to `"true"` in remote web environments and not set in the local CLI. ### @@ -413,17 +440,19 @@ Reference scripts by path -Use environment variables to reference hook scripts relative to the project or plugin root, regardless of the working directory when the hook runs: - - * `$CLAUDE_PROJECT_DIR`: the project root. Wrap in quotes to handle paths with spaces. +Use these placeholders to reference hook scripts relative to the project or plugin root, regardless of the working directory when the hook runs: + + * `${CLAUDE_PROJECT_DIR}`: the project root. * `${CLAUDE_PLUGIN_ROOT}`: the plugin’s installation directory, for scripts bundled with a [plugin](</docs/en/plugins>). Changes on each plugin update. * `${CLAUDE_PLUGIN_DATA}`: the plugin’s [persistent data directory](</docs/en/plugins-reference#persistent-data-directory>), for dependencies and state that should survive plugin updates. +Prefer exec form for any hook that references a path placeholder. Exec form passes each `args` element as one argument with no shell tokenization, so paths with spaces or special characters need no quoting. In shell form, wrap each placeholder in double quotes. + * Project scripts * Plugin scripts -This example uses `$CLAUDE_PROJECT_DIR` to run a style checker from the project’s `.claude/hooks/` directory after any `Write` or `Edit` tool call: +This example uses `${CLAUDE_PROJECT_DIR}` to run a style checker from the project’s `.claude/hooks/` directory after any `Write` or `Edit` tool call: { "hooks": { @@ -433,7 +462,8 @@ "hooks": [ { "type": "command", - "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/check-style.sh" + "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/check-style.sh", + "args": [] } ] } @@ -453,6 +483,7 @@ { "type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/scripts/format.sh", + "args": [], "timeout": 30 } ] @@ -539,9 +570,9 @@ Field| Description ---|--- `agent_id`| Unique identifier for the subagent. Present only when the hook fires inside a subagent call. Use this to distinguish subagent hook calls from main-thread calls. -`agent_type`| Agent name (for example, `"Explore"` or `"security-reviewer"`). Present when the session uses `--agent` or the hook fires inside a subagent. For subagents, the subagent’s type takes precedence over the session’s `--agent` value. - -For example, a `PreToolUse` hook for a Bash command receives this on stdin: +`agent_type`| Agent name (for example, `"Explore"` or `"security-reviewer"`). Present when the session uses `--agent` or the hook fires inside a subagent. For subagents, the subagent’s type takes precedence over the session’s `--agent` value. For [custom subagents](</docs/en/sub-agents>), this is the `name` field from the agent’s frontmatter, not the filename. + +Only `SessionStart` hooks receive a `model` field. There is no `$CLAUDE_MODEL` environment variable. A hook process inherits the parent environment, so it can read `$ANTHROPIC_MODEL` if you set it in your shell, but that value does not change when you switch models with `/model` during a session. For example, a `PreToolUse` hook for a Bash command receives this on stdin: { "session_id": "abc123", @@ -1173,6 +1204,18 @@ `questions`| array| `[{"question": "Which framework?", "header": "Framework", "options": [{"label": "React"}], "multiSelect": false}]`| Questions to present, each with a `question` string, short `header`, `options` array, and optional `multiSelect` flag `answers`| object| `{"Which framework?": "React"}`| Optional. Maps question text to the selected option label. Multi-select answers join labels with commas. Claude does not set this field; supply it via `updatedInput` to answer programmatically +##### ExitPlanMode + +Presents a plan and asks the user to approve it before Claude leaves [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>). Claude writes the plan to a file on disk before calling the tool, so the literal `tool_input` from the model only carries `allowedPrompts`. Claude Code injects the plan content and file path before passing the input to hooks. + +Field| Type| Example| Description +---|---|---|--- +`plan`| string| `"## Refactor auth\n1. Extract..."`| Plan content in Markdown. Injected from the plan file on disk +`planFilePath`| string| `"/Users/.../plans/refactor-auth.md"`| Path to the plan file. Injected +`allowedPrompts`| array| `[{"tool": "Bash", "prompt": "run tests"}]`| Optional. Prompt-based permissions Claude is requesting to implement the plan, each with a `tool` name and a `prompt` describing the category of action + +In `PostToolUse`, `tool_response` is an object with `plan` and `filePath` fields holding the approved plan, plus internal status flags. Read `tool_response.plan` for the plan content rather than re-reading the file from disk. + #### ​ @@ -1641,7 +1684,7 @@ SubagentStart -Runs when a Claude Code subagent is spawned via the Agent tool. Supports matchers to filter by agent type name (built-in agents like `general-purpose`, `Explore`, `Plan`, or custom agent names from `.claude/agents/`). +Runs when a Claude Code subagent is spawned via the Agent tool. Supports matchers to filter by agent type name. For built-in agents, this is the agent name like `general-purpose`, `Explore`, or `Plan`. For [custom subagents](</docs/en/sub-agents>), this is the `name` field from the agent’s frontmatter, not the filename. #### @@ -1702,7 +1745,7 @@ "last_assistant_message": "Analysis complete. Found 3 potential issues..." } -SubagentStop hooks use the same decision control format as Stop hooks. +SubagentStop hooks use the same decision control format as Stop hooks. They do not support `additionalContext`. Returning `decision: "block"` with a `reason` keeps the subagent running and delivers `reason` to the subagent as its next instruction. To inject context into the parent session after a subagent returns, use a `PostToolUse` hook on the `Agent` tool instead. ### @@ -1835,6 +1878,8 @@ Runs when the main Claude Code agent has finished responding. Does not run if the stoppage occurred due to a user interrupt. API errors fire StopFailure instead. +The [`/goal`](</docs/en/goal>) command is a built-in shortcut for a session-scoped prompt-based Stop hook. Use it when you want Claude to keep working until a condition holds without writing hook configuration. + #### ​ @@ -1983,7 +2028,8 @@ "hooks": [ { "type": "command", - "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/audit-config-change.sh" + "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/audit-config-change.sh", + "args": [] } ] } @@ -2518,6 +2564,7 @@ `prompt`| yes| The prompt text to send to the LLM. Use `$ARGUMENTS` as a placeholder for the hook input JSON. If `$ARGUMENTS` is not present, input JSON is appended to the prompt `model`| no| Model to use for evaluation. Defaults to a fast model `timeout`| no| Timeout in seconds. Default: 30 +`continueOnBlock`| no| When the prompt returns `ok: false`, feed the reason back to Claude and continue the turn instead of stopping. Default: `false`. Implemented as `continue: true` on the resulting `decision: "block"`. See Response schema for per-event behavior ### @@ -2534,14 +2581,15 @@ Field| Description ---|--- -`ok`| `true` to allow, `false` to block. See the per-event behavior below -`reason`| Required when `ok` is `false`. Explanation for the decision +`ok`| `true` to allow. `false` produces a `decision: "block"`. See the per-event behavior below +`reason`| Required when `ok` is `false`. Used as the block reason What happens on `ok: false` depends on the event: * `Stop` and `SubagentStop`: the reason is fed back to Claude as its next instruction and the turn continues * `PreToolUse`: the tool call is denied and the reason is returned to Claude as the tool error, equivalent to a command hook’s `permissionDecision: "deny"` - * `PostToolUse`, `PostToolBatch`, `UserPromptSubmit`, and `UserPromptExpansion`: the turn ends and the reason appears in the chat as a warning line, equivalent to returning `"continue": false` from a command hook + * `PostToolUse`: by default the turn ends and the reason appears in the chat as a warning line. Set `continueOnBlock: true` to feed the reason back to Claude and continue the turn instead + * `PostToolBatch`, `UserPromptSubmit`, and `UserPromptExpansion`: the turn ends and the reason appears as a warning line. These events end the turn on `decision: "block"` regardless of `continue` * `PostToolUseFailure`, `TaskCreated`, and `TaskCompleted`: the reason is returned to Claude as a tool error, similar to `PreToolUse` * `PermissionRequest`: `ok: false` has no effect. To deny an approval from a hook, use a command hook returning `hookSpecificOutput.decision.behavior: "deny"` @@ -2713,7 +2761,8 @@ "hooks": [ { "type": "command", - "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/run-tests-async.sh", + "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/run-tests-async.sh", + "args": [], "async": true, "timeout": 300 } @@ -2763,7 +2812,7 @@ * **Validate and sanitize inputs** : never trust input data blindly * **Always quote shell variables** : use `"$VAR"` not `$VAR` * **Block path traversal** : check for `..` in file paths - * **Use absolute paths** : specify full paths for scripts, using `"$CLAUDE_PROJECT_DIR"` for the project root + * **Use absolute paths** : specify full paths for scripts. In exec form, use `${CLAUDE_PROJECT_DIR}` and the path needs no quoting. In shell form, wrap it in double quotes * **Skip sensitive files** : avoid `.env`, `.git/`, keys, etc. ##
modified Automate workflows with hooks View current →
--- a/hooks-guide.md +++ b/hooks-guide.md @@ -867,7 +867,7 @@ echo '{"tool_name":"Bash","tool_input":{"command":"ls"}}' | ./my-hook.sh echo $? # Check the exit code - * If you see “command not found”, use absolute paths or `$CLAUDE_PROJECT_DIR` to reference scripts + * If you see “command not found”, use absolute paths or `${CLAUDE_PROJECT_DIR}` to reference scripts. To avoid shell quoting entirely, add `"args": []` to switch to [exec form](</docs/en/hooks#exec-form-and-shell-form>), which spawns the script directly without a shell * If you see “jq: command not found”, install `jq` or use Python/Node.js for JSON parsing * If the script isn’t running at all, make it executable: `chmod +x ./my-hook.sh` @@ -904,7 +904,7 @@ JSON validation failed -Claude Code shows a JSON parsing error even though your hook script outputs valid JSON. When Claude Code runs a hook, it spawns a shell that sources your profile (`~/.zshrc` or `~/.bashrc`). If your profile contains unconditional `echo` statements, that output gets prepended to your hook’s JSON: +Claude Code shows a JSON parsing error even though your hook script outputs valid JSON. When Claude Code runs a shell-form command hook (one without `args`), it spawns `sh -c` on macOS and Linux or Git Bash on Windows by default. This shell is non-interactive, but Git Bash and some configurations (such as `BASH_ENV` pointing at `~/.bashrc`) still source your profile. If that profile contains unconditional `echo` statements, the output gets prepended to your hook’s JSON: Shell ready on arm64 {"decision": "block", "reason": "Not allowed"}
modified Interactive mode View current →
--- a/interactive-mode.md +++ b/interactive-mode.md @@ -10,7 +10,7 @@ Keyboard shortcuts -Keyboard shortcuts may vary by platform and terminal. Press `?` to see available shortcuts for your environment.**macOS users** : Option/Alt key shortcuts (`Alt+B`, `Alt+F`, `Alt+Y`, `Alt+M`, `Alt+P`) require configuring Option as Meta in your terminal: +Keyboard shortcuts may vary by platform and terminal. In [fullscreen rendering](</docs/en/fullscreen>), press `?` in the transcript viewer to see available shortcuts there.**macOS users** : Option/Alt key shortcuts (`Alt+B`, `Alt+F`, `Alt+Y`, `Alt+M`, `Alt+P`) require configuring Option as Meta in your terminal: * **iTerm2** : Settings → Profiles → Keys → General → set Left/Right Option key to “Esc+” * **Apple Terminal** : Settings → Profiles → Keyboard → check “Use Option as Meta Key” @@ -27,7 +27,7 @@ Shortcut| Description| Context ---|---|--- `Ctrl+C`| Cancel current input or generation| Standard interrupt -`Ctrl+X Ctrl+K`| Kill all background agents. Press twice within 3 seconds to confirm| Background agent control +`Ctrl+X Ctrl+K`| Kill all running [background subagents](</docs/en/sub-agents#run-subagents-in-foreground-or-background>) in this session. Press twice within 3 seconds to confirm| Subagent control `Ctrl+D`| Exit Claude Code session| EOF signal `Ctrl+G` or `Ctrl+X Ctrl+E`| Open in default text editor| Edit your prompt or custom response in your default text editor. `Ctrl+X Ctrl+E` is the readline-native binding. Turn on Show last response in external editor in `/config` to prepend Claude’s previous reply as `#`-commented context above your prompt; the comment block is stripped when you save `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 @@ -38,6 +38,7 @@ `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 `Up/Down arrows` or `Ctrl+P`/`Ctrl+N`| Move cursor or navigate command history| In multiline input, first moves the cursor within the prompt. Once the cursor is already on the top or bottom edge, pressing again navigates command history +`Esc`| Interrupt Claude| Stop the current response or tool call mid-turn so you can redirect. Claude keeps the work done so far `Esc` \+ `Esc`| Rewind or summarize| Restore code and/or conversation to a previous point, or summarize from a selected message `Shift+Tab` or `Alt+M` (some configurations)| Cycle permission modes| Cycle through `default`, `acceptEdits`, `plan`, and any modes you have enabled, such as `auto` or `bypassPermissions`. See [permission modes](</docs/en/permission-modes>). `Option+P` (macOS) or `Alt+P` (Windows/Linux)| Switch model| Switch models without clearing your prompt @@ -106,10 +107,12 @@ Transcript viewer -When the transcript viewer is open (toggled with `Ctrl+O`), these shortcuts are available. `Ctrl+E` can be rebound via [`transcript:toggleShowAll`](</docs/en/keybindings>). +When the transcript viewer is open (toggled with `Ctrl+O`), these shortcuts are available. In [fullscreen rendering](</docs/en/fullscreen>), press `?` to show the full shortcut reference panel inside the viewer. `Ctrl+E` can be rebound via [`transcript:toggleShowAll`](</docs/en/keybindings>). Shortcut| Description ---|--- +`?`| Toggle the keyboard shortcut help panel. Requires [fullscreen rendering](</docs/en/fullscreen>) +`{` / `}`| Jump to the previous or next user prompt, like vim paragraph motion. Requires [fullscreen rendering](</docs/en/fullscreen>) `Ctrl+E`| Toggle show all content `[`| Write the full conversation to your terminal’s native scrollback so `Cmd+F`, tmux copy mode, and other native tools can search it. Requires [fullscreen rendering](</docs/en/fullscreen#search-and-review-the-conversation>) `v`| Write the conversation to a temporary file and open it in `$VISUAL` or `$EDITOR`. Requires [fullscreen rendering](</docs/en/fullscreen>)
modified Customize keyboard shortcuts View current →
--- a/keybindings.md +++ b/keybindings.md @@ -122,7 +122,7 @@ `chat:cancel`| Escape| Cancel current input `chat:clearInput`| Ctrl+L| Force a full screen redraw, preserving input. In [fullscreen rendering](</docs/en/fullscreen#clear-the-conversation>), press twice within two seconds to run `/clear` `chat:clearScreen`| Cmd+K| In [fullscreen rendering](</docs/en/fullscreen#clear-the-conversation>), press twice within two seconds to run `/clear` -`chat:killAgents`| Ctrl+X Ctrl+K| Kill all background agents +`chat:killAgents`| Ctrl+X Ctrl+K| Kill all running [background subagents](</docs/en/sub-agents#run-subagents-in-foreground-or-background>) in this session `chat:cycleMode`| Shift+Tab*| Cycle permission modes `chat:modelPicker`| Meta+P| Open model picker `chat:fastMode`| Meta+O| Toggle fast mode
modified LLM gateway configuration View current →
--- a/llm-gateway.md +++ b/llm-gateway.md @@ -31,13 +31,15 @@ Claude Code determines which features to enable based on the API format. When using the Anthropic Messages format with Bedrock or Vertex, you may need to set environment variable `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`. -**Request headers** Claude Code includes the following headers on every API request: +**Request headers** Claude Code includes the following headers on API requests: Header| Description ---|--- `X-Claude-Code-Session-Id`| A unique identifier for the current Claude Code session. Proxies can use this to aggregate all API requests from a single session without parsing the request body. - -Claude Code also prepends a short attribution block to the system prompt containing the client version and a fingerprint derived from the conversation. The Anthropic API strips this block before processing, so it does not affect first-party prompt caching. If your gateway implements its own prompt cache keyed on the full request body, set [`CLAUDE_CODE_ATTRIBUTION_HEADER=0`](</docs/en/env-vars>) to omit it. +`X-Claude-Code-Agent-Id`| Identifier of the subagent or teammate that issued the request. Your proxy can use this to attribute API cost to individual parallel subagents within a session, without parsing the request body. Present only for requests made by an in-process subagent or teammate. +`X-Claude-Code-Parent-Agent-Id`| Identifier of the agent that spawned the agent making the request. Use this with `X-Claude-Code-Agent-Id` to attribute API costs across nested agents in your proxy. Present only when the requesting agent was itself spawned by another agent. + +Both agent ID headers are ephemeral per-spawn identifiers, not persistent user or device IDs. Claude Code also prepends a short attribution block to the system prompt containing the client version and a fingerprint derived from the conversation. The Anthropic API strips this block before processing, so it does not affect first-party prompt caching. If your gateway implements its own prompt cache keyed on the full request body, set [`CLAUDE_CODE_ATTRIBUTION_HEADER=0`](</docs/en/env-vars>) to omit it. ## @@ -184,6 +186,15 @@ export CLAUDE_CODE_USE_VERTEX=1 export CLOUD_ML_REGION=us-east5 +##### Claude Platform on AWS through a gateway + +Route to a gateway that forwards to the [Claude Platform on AWS](</docs/en/claude-platform-on-aws>) endpoint: + + export ANTHROPIC_AWS_BASE_URL=https://litellm-server:4000/anthropic-aws + export ANTHROPIC_AWS_WORKSPACE_ID=wrkspc_01ABCDEFGHIJKLMN + export CLAUDE_CODE_SKIP_ANTHROPIC_AWS_AUTH=1 + export CLAUDE_CODE_USE_ANTHROPIC_AWS=1 + For more detailed information, refer to the [LiteLLM documentation](<https://docs.litellm.ai/>). ##
modified Connect Claude Code to tools via MCP View current →
--- a/mcp.md +++ b/mcp.md @@ -85,7 +85,7 @@ Option 3: Add a local stdio server -Stdio servers run as local processes on your machine. They’re ideal for tools that need direct system access or custom scripts. +Stdio servers run as local processes on your machine. They’re ideal for tools that need direct system access or custom scripts. Claude Code sets `CLAUDE_PROJECT_DIR` in the spawned server’s environment to the project root, so your server can resolve project-relative paths without depending on the working directory. This is the same directory hooks receive in their `CLAUDE_PROJECT_DIR` variable. Read it from inside your server process, for example `process.env.CLAUDE_PROJECT_DIR` in Node or `os.environ["CLAUDE_PROJECT_DIR"]` in Python. Your server can also call the MCP `roots/list` request, which returns the directory Claude Code was launched from. This variable is set in the server’s environment, not in Claude Code’s own environment, so referencing it via `${VAR}` expansion in a project- or user-scoped `.mcp.json` `command` or `args` requires a default such as `${CLAUDE_PROJECT_DIR:-.}`. Plugin-provided MCP configurations substitute `${CLAUDE_PROJECT_DIR}` directly and don’t need the default. # Basic syntax claude mcp add [options] <name> -- <command> [args...] @@ -200,7 +200,7 @@ **Plugin MCP features** : * **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 and `${CLAUDE_PLUGIN_DATA}` for [persistent state](</docs/en/plugins-reference#persistent-data-directory>) that survives plugin updates + * **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) @@ -417,7 +417,7 @@ Authenticate with remote MCP servers -Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. +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` and a `WWW-Authenticate` header pointing to its authorization server. Any custom server that returns that response gets the same `/mcp` authentication flow as any other remote server. 1 @@ -906,12 +906,12 @@ Configure tool search -Tool search is enabled by default: MCP tools are deferred and discovered on demand. It is disabled by default on Vertex AI, which does not accept the tool search beta header, and when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies do not forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly to opt in. This feature requires models that support `tool_reference` blocks: Sonnet 4 and later, or Opus 4 and later. Haiku models do not support tool search. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable: +Tool search is enabled by default: MCP tools are deferred and discovered on demand. It is disabled by default on Vertex AI, which does not accept the tool search beta header, and when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies do not forward `tool_reference` blocks. If your proxy forwards `tool_reference` blocks, set `ENABLE_TOOL_SEARCH` explicitly to override the fallback. This feature requires models that support `tool_reference` blocks: Sonnet 4 and later, or Opus 4 and later. Haiku models do not support tool search. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable: Value| Behavior ---|--- (unset)| All MCP tools deferred and loaded on demand. Falls back to loading upfront on Vertex AI or when `ANTHROPIC_BASE_URL` is a non-first-party host -`true`| All MCP tools deferred, including on Vertex AI and for non-first-party `ANTHROPIC_BASE_URL` +`true`| All MCP tools deferred. Claude Code sends the beta header even on Vertex AI and through proxies. Requests fail if the backend does not support `tool_reference` blocks `auto`| Threshold mode: tools load upfront if they fit within 10% of the context window, deferred otherwise `auto:<N>`| Threshold mode with a custom percentage, where `<N>` is 0-100 (e.g., `auto:5` for 5%) `false`| All MCP tools loaded upfront, no deferral
modified How Claude remembers your project View current →
--- a/memory.md +++ b/memory.md @@ -28,7 +28,7 @@ ---|---|--- **Who writes it**| You| Claude **What it contains**| Instructions and rules| Learnings and patterns -**Scope**| Project, user, or org| Per working tree +**Scope**| Project, user, or org| Per repository, shared across worktrees **Loaded into**| Every session| Every session (first 200 lines or 25KB) **Use for**| Coding standards, workflows, project architecture| Build commands, debugging insights, preferences Claude discovers @@ -283,6 +283,12 @@ Deploy with your configuration management system Use MDM, Group Policy, Ansible, or similar tools to distribute the file across developer machines. See [managed settings](</docs/en/permissions#managed-settings>) for other organization-wide configuration options. + +The `claudeMd` key lets you put managed CLAUDE.md content directly inside `managed-settings.json` instead of deploying a separate file. **Scope** : every Claude Code session on the machine, in every repository. For repository-specific guidance, commit a project CLAUDE.md instead. **Precedence** : same as a managed CLAUDE.md file. Loads before user and project CLAUDE.md. **Where it’s honored** : managed and policy settings only. Setting `claudeMd` in user, project, or local settings has no effect. The example below adds behavioral instructions directly in a managed settings file: + + { + "claudeMd": "Always run `make lint` before committing.\nNever push directly to main." + } A managed CLAUDE.md and [managed settings](</docs/en/settings#settings-files>) serve different purposes. Use settings for technical enforcement and CLAUDE.md for behavioral guidance:
modified Model configuration View current →
--- a/model-config.md +++ b/model-config.md @@ -40,7 +40,7 @@ **`opus[1m]`**| Uses Opus with a [1 million token context window](<https://platform.claude.com/docs/en/build-with-claude/context-windows#1m-token-context-window>) for long sessions **`opusplan`**| Special mode that uses `opus` during plan mode, then switches to `sonnet` for execution -On the Anthropic API, `opus` resolves to Opus 4.7 and `sonnet` resolves to Sonnet 4.6. On Bedrock, Vertex, and Foundry, `opus` resolves to Opus 4.6 and `sonnet` resolves to Sonnet 4.5; newer models are available on those providers by selecting the full model name explicitly or setting `ANTHROPIC_DEFAULT_OPUS_MODEL` or `ANTHROPIC_DEFAULT_SONNET_MODEL`. Aliases point to the recommended version for your provider and update over time. To pin to a specific version, use the full model name (for example, `claude-opus-4-7`) or set the corresponding environment variable like `ANTHROPIC_DEFAULT_OPUS_MODEL`. +On the Anthropic API and [Claude Platform on AWS](</docs/en/claude-platform-on-aws>), `opus` resolves to Opus 4.7 and `sonnet` resolves to Sonnet 4.6. On Bedrock, Vertex, and Foundry, `opus` resolves to Opus 4.6 and `sonnet` resolves to Sonnet 4.5; newer models are available on those providers by selecting the full model name explicitly or setting `ANTHROPIC_DEFAULT_OPUS_MODEL` or `ANTHROPIC_DEFAULT_SONNET_MODEL`. Aliases point to the recommended version for your provider and update over time. To pin to a specific version, use the full model name (for example, `claude-opus-4-7`) or set the corresponding environment variable like `ANTHROPIC_DEFAULT_OPUS_MODEL`. Opus 4.7 requires Claude Code v2.1.111 or later. Run `claude update` to upgrade. @@ -57,7 +57,7 @@ 3. **Environment variable** \- Set `ANTHROPIC_MODEL=<alias|name>` 4. **Settings** \- Configure permanently in your settings file using the `model` field. -Your `/model` selection is saved to user settings and persists across restarts. As of v2.1.117, if the project’s `.claude/settings.json` pins a different model, Claude Code also writes your choice to `.claude/settings.local.json` so it continues to apply in that project after a restart. Managed settings take precedence and reapply on the next launch. When the active model at startup comes from project or managed settings rather than your own selection, the startup header shows which settings file set it. Run `/model` to override for the current session. Example usage: +Your `/model` selection is saved to user settings and persists across restarts. As of v2.1.117, if the project’s `.claude/settings.json` pins a different model, Claude Code also writes your choice to `.claude/settings.local.json` so it continues to apply in that project after a restart. Managed settings take precedence and reapply on the next launch. The `--model` flag and `ANTHROPIC_MODEL` environment variable apply only to the session you launch with them and are not saved. To run different models in different terminals at the same time, launch each one with its own `--model` flag rather than switching with `/model`. When the active model at startup comes from project or managed settings rather than your own selection, the startup header shows which settings file set it. Run `/model` to override for the current session. Example usage: # Start with Opus claude --model opus @@ -322,7 +322,7 @@ Pin models for third-party deployments -When deploying Claude Code through [Bedrock](</docs/en/amazon-bedrock>), [Vertex AI](</docs/en/google-vertex-ai>), or [Foundry](</docs/en/microsoft-foundry>), pin model versions before rolling out to users. Without pinning, Claude Code uses model aliases (`sonnet`, `opus`, `haiku`) that resolve to the latest version. When Anthropic releases a new model that isn’t yet enabled in a user’s account, Bedrock and Vertex AI users see a notice and fall back to the previous version for that session, while Foundry users see errors because Foundry has no equivalent startup check. +When deploying Claude Code through [Bedrock](</docs/en/amazon-bedrock>), [Vertex AI](</docs/en/google-vertex-ai>), [Foundry](</docs/en/microsoft-foundry>), or [Claude Platform on AWS](</docs/en/claude-platform-on-aws>), pin model versions before rolling out to users. Without pinning, Claude Code uses model aliases (`sonnet`, `opus`, `haiku`) that resolve to the latest version. When Anthropic releases a new model that isn’t yet enabled in a user’s account, Bedrock and Vertex AI users see a notice and fall back to the previous version for that session, while Foundry users see errors because Foundry has no equivalent startup check. Set all three model environment variables to specific version IDs as part of your initial setup. Pinning lets you control when your users move to a new model.
modified Modifying system prompts View current →
--- a/modifying-system-prompts.md +++ b/modifying-system-prompts.md @@ -194,9 +194,9 @@ Once created, activate output styles via: - * **CLI** : `/output-style [style-name]` - * **Settings** : `.claude/settings.local.json` - * **Create new** : `/output-style:new [description]` + * **CLI** : `/config`, then select Output style + * **Settings** : set `outputStyle` in `.claude/settings.local.json` + * **Create new** : add a Markdown file at `~/.claude/output-styles/` or `.claude/output-styles/`; see [Create a custom output style](</docs/en/output-styles#create-a-custom-output-style>) for the format **Note for SDK users:** Output styles are loaded when you include `settingSources: ['user']` or `settingSources: ['project']` (TypeScript) / `setting_sources=["user"]` or `setting_sources=["project"]` (Python) in your options. @@ -417,7 +417,7 @@ import { query } from "@anthropic-ai/claude-agent-sdk"; - // Assuming "Code Reviewer" output style is active (via /output-style) + // Assuming "Code Reviewer" output style is active (via /config or settings) // Add session-specific focus areas const messages = [];
modified Monitoring View current →
Show diff (104 lines)
--- a/monitoring-usage.md +++ b/monitoring-usage.md @@ -185,6 +185,8 @@ `gen_ai.system`| Always `anthropic`. OpenTelemetry GenAI semantic convention| `gen_ai.request.model`| Same value as `model`. OpenTelemetry GenAI semantic convention| `query_source`| Subsystem that issued the request, such as `repl_main_thread` or a subagent name| +`agent_id`| Identifier of the subagent or teammate that issued the request. Absent on the main session| +`parent_agent_id`| Identifier of the agent that spawned this one. Absent for the main session and for agents spawned directly from it| `speed`| `fast` or `normal`| `llm_request.context`| `interaction`, `tool`, or `standalone` depending on the parent span| `duration_ms`| Wall-clock duration including retries| @@ -488,6 +490,10 @@ * `query_source`: Category of the subsystem that issued the request. One of `"main"`, `"subagent"`, or `"auxiliary"` * `speed`: `"fast"` when the request used fast mode. Absent otherwise * `effort`: [Effort level](</docs/en/model-config#adjust-effort-level>) applied to the request: `"low"`, `"medium"`, `"high"`, `"xhigh"`, or `"max"`. Absent when the model does not support effort. + * `agent.name`: Subagent type that issued the request. Built-in agent names and agents from official-marketplace plugins appear verbatim. Other user-defined agent names are replaced with `"custom"`. Absent when the request was not issued by a named subagent type. + * `skill.name`: Skill active for the request, set by the Skill tool, a `/` command, or inherited by a spawned subagent. Built-in, bundled, user-defined, and official-marketplace plugin skill names appear verbatim. Third-party plugin skill names are replaced with `"third-party"`. Absent when no skill is active. + * `plugin.name`: Owning plugin when the active skill or subagent is provided by a plugin. Official-marketplace plugin names appear verbatim. Third-party plugin names are replaced with `"third-party"`. Absent when neither the skill nor the subagent has an owning plugin. + * `marketplace.name`: Marketplace the owning plugin was installed from. Only emitted for official-marketplace plugins. Absent otherwise. #### @@ -503,6 +509,7 @@ * `query_source`: Category of the subsystem that issued the request. One of `"main"`, `"subagent"`, or `"auxiliary"` * `speed`: `"fast"` when the request used fast mode. Absent otherwise * `effort`: [Effort level](</docs/en/model-config#adjust-effort-level>) applied to the request. See Cost counter for details. + * `agent.name`, `skill.name`, `plugin.name`, `marketplace.name`: Skill, plugin, and agent attribution for the request. See Cost counter for definitions and redaction behavior. #### @@ -799,6 +806,30 @@ ​ +Plugin loaded event + +Logged once per enabled plugin at session start. Use this event to inventory which plugins are active across your fleet, as a complement to `plugin_installed` which records the install action itself. **Event Name** : `claude_code.plugin_loaded` **Attributes** : + + * All standard attributes + * `event.name`: `"plugin_loaded"` + * `event.timestamp`: ISO 8601 timestamp + * `event.sequence`: monotonically increasing counter for ordering events within a session + * `plugin.name`: name of the plugin. For plugins outside the official marketplace and built-in bundle the value is `"third-party"` unless `OTEL_LOG_TOOL_DETAILS=1` + * `marketplace.name`: marketplace the plugin was installed from, when known. Redacted to `"third-party"` under the same condition as `plugin.name` + * `plugin.version`: version from the plugin manifest. Included only when the name is not redacted and the manifest declares a version + * `plugin.scope`: provenance category for the plugin: `"official"`, `"org"`, `"user-local"`, or `"default-bundle"` + * `enabled_via`: how the plugin came to be enabled: `"default-enable"`, `"org-policy"`, `"seed-mount"`, or `"user-install"` + * `plugin_id_hash`: deterministic hash of the plugin name and marketplace, sent only to your configured exporter. Lets you count how many distinct third-party plugins are loaded across your fleet without recording their names + * `has_hooks`: whether the plugin contributes hooks + * `has_mcp`: whether the plugin contributes MCP servers + * `skill_path_count`: number of skill directories the plugin declares + * `command_path_count`: number of command directories the plugin declares + * `agent_path_count`: number of agent directories the plugin declares + +#### + +​ + Skill activated event Logged when a skill is invoked, whether Claude calls it through the Skill tool or you run it as a `/` command. **Event Name** : `claude_code.skill_activated` **Attributes** : @@ -846,6 +877,25 @@ * `total_attempts`: Total number of attempts made * `total_retry_duration_ms`: Total wall-clock time across all attempts * `speed`: `"fast"` or `"normal"` + +#### + +​ + +Hook registered event + +Logged once per configured hook at session start. Use this event to inventory which hooks are active across your fleet, as a complement to the per-execution `hook_execution_start` and `hook_execution_complete` events. **Event Name** : `claude_code.hook_registered` **Attributes** : + + * All standard attributes + * `event.name`: `"hook_registered"` + * `event.timestamp`: ISO 8601 timestamp + * `event.sequence`: monotonically increasing counter for ordering events within a session + * `hook_event`: hook event type, such as `"PreToolUse"` or `"PostToolUse"` + * `hook_type`: hook implementation type: `"command"`, `"prompt"`, `"mcp_tool"`, `"http"`, or `"agent"` + * `hook_source`: where the hook is defined: `"userSettings"`, `"projectSettings"`, `"localSettings"`, `"flagSettings"`, `"policySettings"`, or `"pluginHook"` + * `hook_matcher` (when `OTEL_LOG_TOOL_DETAILS=1`): the matcher string from the hook configuration, when one is set + * `plugin.name` (when `hook_source` is `"pluginHook"`): name of the contributing plugin. For plugins outside the official marketplace and built-in bundle the value is `"third-party"` unless `OTEL_LOG_TOOL_DETAILS=1` + * `plugin_id_hash` (when `hook_source` is `"pluginHook"`): deterministic hash of the plugin name and marketplace, sent only to your configured exporter. Lets you count distinct contributing plugins without recording their names #### @@ -925,7 +975,7 @@ Metric| Analysis Opportunity ---|--- -`claude_code.token.usage`| Break down by `type` (input/output), user, team, or model +`claude_code.token.usage`| Break down by `type` (input/output), user, team, model, `skill.name`, `plugin.name`, or `agent.name` `claude_code.session.count`| Track adoption and engagement over time `claude_code.lines_of_code.count`| Measure productivity by tracking code additions/removals `claude_code.commit.count` & `claude_code.pull_request.count`| Understand impact on development workflows @@ -940,6 +990,7 @@ * Tracking usage trends across teams or individuals * Identifying high-usage sessions for optimization + * Attributing spend to specific skills, plugins, or subagent types via the `skill.name`, `plugin.name`, and `agent.name` attributes Cost metrics are approximations. For official billing data, refer to your API provider (Claude Console, Amazon Bedrock, or Google Cloud Vertex).
modified Output styles View current →
--- a/output-styles.md +++ b/output-styles.md @@ -12,8 +12,9 @@ Built-in output styles -Claude Code’s **Default** output style is the existing system prompt, designed to help you complete software engineering tasks efficiently. There are two additional built-in output styles focused on teaching you the codebase and how Claude operates: +Claude Code’s **Default** output style is the existing system prompt, designed to help you complete software engineering tasks efficiently. There are three additional built-in output styles: + * **Proactive** : Claude executes immediately, makes reasonable assumptions instead of pausing for routine decisions, and prefers action over planning. This applies the same guidance as [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) without changing your permission mode, so you still see permission prompts before tools run. * **Explanatory** : Provides educational “Insights” in between helping you complete software engineering tasks. Helps you understand implementation choices and codebase patterns. * **Learning** : Collaborative, learn-by-doing mode where Claude will not only share “Insights” while coding, but also ask you to contribute small, strategic pieces of code yourself. Claude Code will add `TODO(human)` markers in your code for you to implement.
modified Claude Code overview View current →
--- a/overview.md +++ b/overview.md @@ -122,7 +122,7 @@ Run agent teams and build custom agents -Spawn [multiple Claude Code agents](</docs/en/sub-agents>) that work on different parts of a task simultaneously. A lead agent coordinates the work, assigns subtasks, and merges results.For fully custom workflows, the [Agent SDK](</docs/en/agent-sdk/overview>) lets you build your own agents powered by Claude Code’s tools and capabilities, with full control over orchestration, tool access, and permissions. +Spawn [multiple Claude Code agents](</docs/en/sub-agents>) that work on different parts of a task simultaneously. A lead agent coordinates the work, assigns subtasks, and merges results.To run several full sessions in parallel and watch them from one screen, use [background agents](</docs/en/agent-view>). For fully custom workflows, the [Agent SDK](</docs/en/agent-sdk/overview>) lets you build your own agents powered by Claude Code’s tools and capabilities, with full control over orchestration, tool access, and permissions. Pipe, script, and automate with the CLI
modified Choose a permission mode View current →
--- a/permission-modes.md +++ b/permission-modes.md @@ -124,7 +124,7 @@ * Keep planning with feedback * Refine with [Ultraplan](</docs/en/ultraplan>) for browser-based review -Press `Ctrl+G` to open the proposed plan in your default text editor and edit it directly before Claude proceeds. When [`showClearContextOnPlanAccept`](</docs/en/settings#available-settings>) is enabled, each approve option also offers to clear the planning context first. Accepting a plan also names the session from the plan content automatically, unless you’ve already set a name with `--name` or `/rename`. +Approving a plan exits plan mode and switches the session to the permission mode each approve option describes, so Claude starts editing. To plan again, cycle back to plan mode with `Shift+Tab`, or prefix your next prompt with `/plan`. Press `Ctrl+G` to open the proposed plan in your default text editor and edit it directly before Claude proceeds. When [`showClearContextOnPlanAccept`](</docs/en/settings#available-settings>) is enabled, each approve option also offers to clear the planning context first. Accepting a plan also names the session from the plan content automatically, unless you’ve already set a name with `--name` or `/rename`. ### @@ -148,7 +148,7 @@ Auto mode requires Claude Code v2.1.83 or later. -Auto mode lets Claude execute without permission prompts. A separate classifier model reviews actions before they run, blocking anything that escalates beyond your request, targets unrecognized infrastructure, or appears driven by hostile content Claude read. +Auto mode lets Claude execute without permission prompts. A separate classifier model reviews actions before they run, blocking anything that escalates beyond your request, targets unrecognized infrastructure, or appears driven by hostile content Claude read. Auto mode also instructs Claude to execute immediately and minimize clarifying questions. To get that behavior while keeping permission prompts, set the [Proactive output style](</docs/en/output-styles>) instead. Auto mode is a research preview. It reduces prompts but does not guarantee safety. Use it for tasks where you trust the general direction, not as a replacement for review on sensitive operations. @@ -254,7 +254,11 @@ claude --permission-mode bypassPermissions -The `--dangerously-skip-permissions` flag is equivalent. +The `--dangerously-skip-permissions` flag is equivalent. On Linux and macOS, Claude Code refuses to start in this mode when running as root or under `sudo`: + + --dangerously-skip-permissions cannot be used with root/sudo privileges for security reasons + +The check is skipped automatically inside a recognized sandbox. To run autonomously in a container, use the [dev container](</docs/en/devcontainer>) configuration, which runs Claude Code as a non-root user. `bypassPermissions` offers no protection against prompt injection or unintended actions. For background safety checks without prompts, use auto mode instead. Administrators can block this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in [managed settings](</docs/en/permissions#managed-settings>).
modified Configure permissions View current →
--- a/permissions.md +++ b/permissions.md @@ -33,6 +33,8 @@ * **Deny** rules prevent Claude Code from using the specified tool. Rules are evaluated in order: **deny - > ask -> allow**. The first matching rule wins, so deny rules always take precedence. + +Permission rules are enforced by Claude Code, not by the model. Instructions in your prompt or `CLAUDE.md` shape what Claude tries to do, but they don’t change what Claude Code allows. To grant or revoke access, use `/permissions`, the rules described here, a [permission mode](</docs/en/permission-modes>), or a PreToolUse hook. ## @@ -178,7 +180,7 @@ * **Restrict Bash network tools** : use deny rules to block `curl`, `wget`, and similar commands, then use the WebFetch tool with `WebFetch(domain:github.com)` permission for allowed domains * **Use PreToolUse hooks** : implement a hook that validates URLs in Bash commands and blocks disallowed domains - * Instructing Claude Code about your allowed curl patterns via CLAUDE.md + * **Add CLAUDE.md guidance** : describe your allowed curl patterns in `CLAUDE.md`. This shapes what Claude tries but doesn’t enforce a boundary, so pair it with one of the options above Note that using WebFetch alone does not prevent network access. If Bash is allowed, Claude can still use `curl`, `wget`, or other tools to reach any URL. @@ -212,7 +214,7 @@ `Edit` rules apply to all built-in tools that edit files. Claude makes a best-effort attempt to apply `Read` rules to all built-in tools that read files like Grep and Glob. -Read and Edit deny rules apply to Claude’s built-in file tools, not to Bash subprocesses. A `Read(./.env)` deny rule blocks the Read tool but does not prevent `cat .env` in Bash. For OS-level enforcement that blocks all processes from accessing a path, [enable the sandbox](</docs/en/sandboxing>). +Read and Edit deny rules apply to Claude’s built-in file tools and to file commands Claude Code recognizes in Bash, such as `cat`, `head`, `tail`, and `sed`. They do not apply to arbitrary subprocesses that read or write files indirectly, like a Python or Node script that opens files itself. For OS-level enforcement that blocks all processes from accessing a path, [enable the sandbox](</docs/en/sandboxing>). Read and Edit rules both follow the [gitignore](<https://git-scm.com/docs/gitignore>) specification with four distinct pattern types:
modified Plugins reference View current →
Show diff (136 lines)
--- a/plugins-reference.md +++ b/plugins-reference.md @@ -82,7 +82,7 @@ "hooks": [ { "type": "command", - "command": "${CLAUDE_PLUGIN_ROOT}/scripts/format-code.sh" + "command": "\"${CLAUDE_PLUGIN_ROOT}\"/scripts/format-code.sh" } ] } @@ -254,7 +254,7 @@ [ { "name": "deploy-status", - "command": "${CLAUDE_PLUGIN_ROOT}/scripts/poll-deploy.sh ${user_config.api_endpoint}", + "command": "\"${CLAUDE_PLUGIN_ROOT}\"/scripts/poll-deploy.sh ${user_config.api_endpoint}", "description": "Deployment status changes" }, { @@ -279,7 +279,7 @@ ---|--- `when`| Controls when the monitor starts. `"always"` starts it at session start and on plugin reload, and is the default. `"on-skill-invoke:<skill-name>"` starts it the first time the named skill in this plugin is dispatched -The `command` value supports the same variable substitutions as MCP and LSP server configs: `${CLAUDE_PLUGIN_ROOT}`, `${CLAUDE_PLUGIN_DATA}`, `${user_config.*}`, and any `${ENV_VAR}` from the environment. Prefix the command with `cd "${CLAUDE_PLUGIN_ROOT}" && ` if the script needs to run from the plugin’s own directory. Disabling a plugin mid-session does not stop monitors that are already running. They stop when the session ends. +The `command` value supports the same variable substitutions as MCP and LSP server configs: `${CLAUDE_PLUGIN_ROOT}`, `${CLAUDE_PLUGIN_DATA}`, `${CLAUDE_PROJECT_DIR}`, `${user_config.*}`, and any `${ENV_VAR}` from the environment. Prefix the command with `cd "${CLAUDE_PLUGIN_ROOT}" && ` if the script needs to run from the plugin’s own directory. Disabling a plugin mid-session does not stop monitors that are already running. They stop when the session ends. ### @@ -534,7 +534,7 @@ Environment variables -Claude Code provides two variables for referencing plugin paths. Both are substituted inline anywhere they appear in skill content, agent content, hook commands, monitor commands, and MCP or LSP server configs. Both are also exported as environment variables to hook processes and MCP or LSP server subprocesses. **`${CLAUDE_PLUGIN_ROOT}`** : the absolute path to your plugin’s installation directory. Use this to reference scripts, binaries, and config files bundled with the plugin. This path changes when the plugin updates. The previous version’s directory remains on disk for about seven days after an update before cleanup, but treat it as ephemeral and do not write state here. When a plugin updates mid-session, hook commands, monitors, MCP servers, and LSP servers keep using the previous version’s path. Run `/reload-plugins` to switch hooks, MCP servers, and LSP servers to the new path; monitors require a session restart. **`${CLAUDE_PLUGIN_DATA}`** : a persistent directory for plugin state that survives updates. Use this for installed dependencies such as `node_modules` or Python virtual environments, generated code, caches, and any other files that should persist across plugin versions. The directory is created automatically the first time this variable is referenced. +Claude Code provides three variables for referencing paths. All are substituted inline anywhere they appear in skill content, agent content, hook commands, monitor commands, and MCP or LSP server configs. All are also exported as environment variables to hook processes and MCP or LSP server subprocesses. **`${CLAUDE_PLUGIN_ROOT}`** : the absolute path to your plugin’s installation directory. Use this to reference scripts, binaries, and config files bundled with the plugin. In hook commands, use [exec form](</docs/en/hooks#exec-form-and-shell-form>) with `args` so the path is passed as one argument with no quoting. In shell-form hooks and monitor commands, wrap it in double quotes, as in `"${CLAUDE_PLUGIN_ROOT}"`. This path changes when the plugin updates. The previous version’s directory remains on disk for about seven days after an update before cleanup, but treat it as ephemeral and do not write state here. When a plugin updates mid-session, hook commands, monitors, MCP servers, and LSP servers keep using the previous version’s path. Run `/reload-plugins` to switch hooks, MCP servers, and LSP servers to the new path; monitors require a session restart. **`${CLAUDE_PLUGIN_DATA}`** : a persistent directory for plugin state that survives updates. Use this for installed dependencies such as `node_modules` or Python virtual environments, generated code, caches, and any other files that should persist across plugin versions. The directory is created automatically the first time this variable is referenced. **`${CLAUDE_PROJECT_DIR}`** : the project root. This is the same directory hooks receive in their `CLAUDE_PROJECT_DIR` variable. Use this to reference project-local scripts or config files. Wrap in quotes to handle paths with spaces, for example `"${CLAUDE_PROJECT_DIR}/scripts/server.sh"`. MCP servers can also call the MCP `roots/list` request, which returns the directory Claude Code was launched from. { "hooks": { @@ -543,7 +543,7 @@ "hooks": [ { "type": "command", - "command": "${CLAUDE_PLUGIN_ROOT}/scripts/process.sh" + "command": "\"${CLAUDE_PLUGIN_ROOT}\"/scripts/process.sh" } ] } @@ -617,11 +617,17 @@ ​ -Working with external dependencies - -If your plugin needs to access files outside its directory, you can create symbolic links to external files within your plugin directory. Symlinks are preserved in the cache rather than dereferenced, and they resolve to their target at runtime. The following command creates a link from inside your plugin directory to a shared utilities location: - - ln -s /path/to/shared-utils ./shared-utils +Share files within a marketplace with symlinks + +If your plugin needs to share files with other parts of the same marketplace, you can create symbolic links inside your plugin directory. How a symlink is handled when the plugin is copied into the cache depends on where its target resolves: + + * **Within the plugin’s own directory:** the symlink is preserved as a relative symlink in the cache, so it keeps resolving to the copied target at runtime. + * **Elsewhere within the same marketplace:** the symlink is dereferenced. The target’s content is copied into the cache in its place. This lets a meta-plugin’s `skills/` directory link to skills defined by other plugins in the marketplace. + * **Outside the marketplace:** the symlink is skipped for security. This prevents plugins from pulling arbitrary host files such as system paths into the cache. + +For plugins installed with `--plugin-dir` or from a local path, only symlinks that resolve within the plugin’s own directory are preserved. All others are skipped. The following command creates a link from inside a marketplace plugin to a shared skill defined by a sibling plugin. On Windows, use `mklink /D` from an elevated Command Prompt or enable Developer Mode: + + ln -s ../../shared-plugin/skills/foo ./skills/foo This provides flexibility while maintaining the security benefits of the caching system. @@ -881,6 +887,56 @@ ​ +plugin details + +Show a plugin’s component inventory and projected token cost. The output lists all components the plugin contributes, grouped as Skills (skills and commands), Agents, Hooks, and MCP servers, along with an estimate of how many tokens it adds to each session. + + claude plugin details <name> + +**Arguments:** + + * `<name>`: Plugin name or `plugin-name@marketplace-name` + +**Options:** + +Option| Description| Default +---|---|--- +`-h, --help`| Display help for command| + +The output shows two cost figures for each component: + + * **Always-on:** tokens added to every session by the plugin’s listing text, such as skill descriptions, agent descriptions, and command names, regardless of whether any component fires. + * **On-invoke:** tokens a component costs when it fires. Shown per component, not as a plugin total, because a typical session invokes only a subset of components. + +This example shows what the output looks like for a plugin with two skills: + + security-guidance 1.2.0 + Real-time security analysis for Claude Code sessions + Source: security-guidance@claude-code-marketplace + + Component inventory + Skills (2) scan-dependencies, review-changes + Agents (0) + Hooks (1) (harness-only — no model context cost) + MCP servers (0) + + Projected token cost + Always-on: ~180 tok added to every session + + Per-component (rounded) + component always-on on-invoke + scan-dependencies ~100 ~2400 + review-changes ~80 ~1800 + + On-invoke cost is paid each time a skill or agent fires. + Token counts are estimates and may differ from actual usage. + +The always-on total is computed via the `count_tokens` API for your active model. Per-component numbers are proportionally scaled from that total. If the API is unreachable, the command falls back to a character-based estimate. + +### + +​ + plugin tag Create a release git tag for the plugin in the current directory. Run from inside the plugin’s folder. See [Tag plugin releases](</docs/en/plugin-dependencies#tag-plugin-releases-for-version-resolution>). @@ -960,7 +1016,7 @@ 1. Check the script is executable: `chmod +x ./scripts/your-script.sh` 2. Verify the shebang line: First line should be `#!/bin/bash` or `#!/usr/bin/env bash` - 3. Check the path uses `${CLAUDE_PLUGIN_ROOT}`: `"command": "${CLAUDE_PLUGIN_ROOT}/scripts/your-script.sh"` + 3. Check the path uses `${CLAUDE_PLUGIN_ROOT}`: `"command": "\"${CLAUDE_PLUGIN_ROOT}\"/scripts/your-script.sh"` 4. Test the script manually: `./scripts/your-script.sh` **Hook not triggering on expected events** :
modified Agent SDK reference - Python View current →
--- a/python.md +++ b/python.md @@ -2822,10 +2822,12 @@ **Output:** { - "response": str, # AI model's response to the prompt + "bytes": int, # Size of the fetched content in bytes + "code": int, # HTTP response code + "codeText": str, # HTTP response code text + "result": str, # Processed result from applying the prompt to the content + "durationMs": int, # Time to fetch and process the content, in milliseconds "url": str, # URL that was fetched - "final_url": str | None, # Final URL after redirects - "status_code": int | None, # HTTP status code } ### @@ -2845,9 +2847,9 @@ **Output:** { - "results": [{"title": str, "url": str, "snippet": str, "metadata": dict | None}], - "total_results": int, - "query": str, + "query": str, # The search query + "results": list[str | {"tool_use_id": str, "content": list[{"title": str, "url": str}]}], + "durationSeconds": float, # Search duration in seconds } ###
modified Quickstart View current →
--- a/quickstart.md +++ b/quickstart.md @@ -263,10 +263,10 @@ Save time with shortcuts - * Press `?` to see all available keyboard shortcuts + * Type `/` to see all commands and skills * Use Tab for command completion * Press ↑ for command history - * Type `/` to see all commands and skills + * Press `Shift+Tab` to cycle permission modes ##
modified Run prompts on a schedule View current →
--- a/scheduled-tasks.md +++ b/scheduled-tasks.md @@ -6,7 +6,7 @@ Scheduled tasks require Claude Code v2.1.72 or later. Check your version with `claude --version`. -Scheduled tasks let Claude re-run a prompt automatically on an interval. Use them to poll a deployment, babysit a PR, check back on a long-running build, or remind yourself to do something later in the session. To react to events as they happen instead of polling, see [Channels](</docs/en/channels>): your CI can push the failure into the session directly. Tasks are session-scoped: they live in the current conversation and stop when you start a new one. Resuming with `--resume` or `--continue` brings back any task that hasn’t expired: a recurring task created within the last 7 days, or a one-shot whose scheduled time hasn’t passed yet. For scheduling that survives independently of any session, use [Routines](</docs/en/routines>), [Desktop scheduled tasks](</docs/en/desktop-scheduled-tasks>), or [GitHub Actions](</docs/en/github-actions>). +Scheduled tasks let Claude re-run a prompt automatically on an interval. Use them to poll a deployment, babysit a PR, check back on a long-running build, or remind yourself to do something later in the session. To react to events as they happen instead of polling, see [Channels](</docs/en/channels>): your CI can push the failure into the session directly. To keep the session working turn after turn until a condition is met rather than on an interval, see [`/goal`](</docs/en/goal>). Tasks are session-scoped: they live in the current conversation and stop when you start a new one. Resuming with `--resume` or `--continue` brings back any task that hasn’t expired: a recurring task created within the last 7 days, or a one-shot whose scheduled time hasn’t passed yet. For scheduling that survives independently of any session, use [Routines](</docs/en/routines>), [Desktop scheduled tasks](</docs/en/desktop-scheduled-tasks>), or [GitHub Actions](</docs/en/github-actions>). ## @@ -122,7 +122,7 @@ Stop a loop -To stop a `/loop` while it is waiting for the next iteration, press `Esc`. This clears the pending wakeup so the loop does not fire again. Tasks you scheduled by asking Claude directly are not affected by `Esc` and stay in place until you delete them. +To stop a `/loop` while it is waiting for the next iteration, press `Esc`. This clears the pending wakeup so the loop does not fire again. Tasks you scheduled by asking Claude directly are not affected by `Esc` and stay in place until you delete them. In self-paced mode, Claude can also end the loop on its own by not scheduling the next wakeup once the task is provably complete. Loops on a fixed interval keep running until you stop them or seven days elapse. ##
modified Claude Code settings View current →
--- a/settings.md +++ b/settings.md @@ -188,11 +188,13 @@ `awsCredentialExport`| Custom script that outputs JSON with AWS credentials (see [advanced credential configuration](</docs/en/amazon-bedrock#advanced-credential-configuration>))| `/bin/generate_aws_grant.sh` `blockedMarketplaces`| (Managed settings only) Blocklist of marketplace sources. Enforced on marketplace add and on plugin install, update, refresh, and auto-update, so a marketplace added before the policy was set cannot be used to fetch plugins. Blocked sources are checked before downloading, so they never touch the filesystem. See [Managed marketplace restrictions](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>)| `[{ "source": "github", "repo": "untrusted/plugins" }]` `channelsEnabled`| (Managed settings only) Allow [channels](</docs/en/channels>) for the organization. On claude.ai Team and Enterprise plans, channels are blocked when this is unset or `false`. For [Anthropic Console](</docs/en/authentication#claude-console-authentication>) accounts using API key authentication, channels are allowed by default unless your organization deploys managed settings, in which case this key must be set to `true`| `true` +`claudeMd`| (Managed settings only) CLAUDE.md-style instructions injected as organization-managed memory. Only honored when set in managed or policy settings and ignored in user, project, and local settings. See [organization-wide CLAUDE.md](</docs/en/memory#deploy-organization-wide-claude-md>)| `"Always run make lint before committing."` `claudeMdExcludes`| Glob patterns or absolute paths of `CLAUDE.md` files to skip when loading [memory](</docs/en/memory>). Patterns match against absolute file paths. Only applies to user, project, and local memory; managed policy files cannot be excluded| `["**/vendor/**/CLAUDE.md"]` `cleanupPeriodDays`| Session files older than this period are deleted at startup (default: 30 days, minimum 1). Setting to `0` is rejected with a validation error. Also controls the age cutoff for automatic removal of [orphaned subagent worktrees](</docs/en/worktrees#clean-up-worktrees>) at startup. To disable transcript writes entirely, set the [`CLAUDE_CODE_SKIP_PROMPT_HISTORY`](</docs/en/env-vars>) environment variable, or in non-interactive mode (`-p`) use the `--no-session-persistence` flag or the `persistSession: false` SDK option.| `20` `companyAnnouncements`| Announcement to display to users at startup. If multiple announcements are provided, they will be cycled through at random.| `["Welcome to Acme Corp! Review our code guidelines at docs.acme.com"]` `defaultShell`| Default shell for input-box `!` commands. Accepts `"bash"` (default) or `"powershell"`. Setting `"powershell"` routes interactive `!` commands through PowerShell on Windows. Requires `CLAUDE_CODE_USE_POWERSHELL_TOOL=1`. See [PowerShell tool](</docs/en/tools-reference#powershell-tool>)| `"powershell"` `deniedMcpServers`| When set in managed-settings.json, denylist of MCP servers that are explicitly blocked. Applies to all scopes including managed servers. Denylist takes precedence over allowlist. See [Managed MCP configuration](</docs/en/mcp#managed-mcp-configuration>)| `[{ "serverName": "filesystem" }]` +`disableAgentView`| Set to `true` to turn off [background agents and agent view](</docs/en/agent-view>): `claude agents`, `--bg`, `/background`, and the on-demand supervisor. Typically set in [managed settings](</docs/en/permissions#managed-settings>). Equivalent to setting `CLAUDE_CODE_DISABLE_AGENT_VIEW` to `1`| `true` `disableAllHooks`| Disable all [hooks](</docs/en/hooks>) and any custom [status line](</docs/en/statusline>)| `true` `disableAutoMode`| Set to `"disable"` to prevent [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) from being activated. Removes `auto` from the `Shift+Tab` cycle and rejects `--permission-mode auto` at startup. Most useful in [managed settings](</docs/en/permissions#managed-settings>) where users cannot override it| `"disable"` `disableDeepLinkRegistration`| Set to `"disable"` to prevent Claude Code from registering the `claude-cli://` protocol handler with the operating system on startup. [Deep links](</docs/en/deep-links>) let external tools open a Claude Code session with a pre-filled prompt. Useful in environments where protocol handler registration is restricted or managed separately| `"disable"`
modified Create custom subagents View current →
--- a/sub-agents.md +++ b/sub-agents.md @@ -6,7 +6,7 @@ Subagents are specialized AI assistants that handle specific types of tasks. Use one when a side task would flood your main conversation with search results, logs, or file contents you won’t reference again: the subagent does that work in its own context and returns only the summary. Define a custom subagent when you keep spawning the same kind of worker with the same instructions. Each subagent runs in its own context window with a custom system prompt, specific tool access, and independent permissions. When Claude encounters a task that matches a subagent’s description, it delegates to that subagent, which works independently and returns results. To see the context savings in practice, the [context window visualization](</docs/en/context-window>) walks through a session where a subagent handles research in its own separate window. -If you need multiple agents working in parallel and communicating with each other, see [agent teams](</docs/en/agent-teams>) instead. Subagents work within a single session; agent teams coordinate across separate sessions. +Subagents work within a single session. To run many independent sessions in parallel and monitor them from one place, see [background agents](</docs/en/agent-view>). For sessions that communicate with each other, see [agent teams](</docs/en/agent-teams>). Subagents help you: @@ -164,7 +164,7 @@ * Delete custom subagents * See which subagents are active when duplicates exist -This is the recommended way to create and manage subagents. For manual creation or automation, you can also add subagent files directly. To list all configured subagents from the command line without starting an interactive session, run `claude agents`. This shows agents grouped by source and indicates which are overridden by higher-priority definitions. +This is the recommended way to create and manage subagents. For manual creation or automation, you can also add subagent files directly. To list all configured subagents from the command line without opening [agent view](</docs/en/agent-view>), pipe the output of `claude agents`. For example, `claude agents | cat` prints agents grouped by source and indicates which are overridden by higher-priority definitions. ### @@ -254,7 +254,7 @@ Field| Required| Description ---|---|--- -`name`| Yes| Unique identifier using lowercase letters and hyphens +`name`| Yes| Unique identifier using lowercase letters and hyphens. [Hooks](</docs/en/hooks#subagentstart>) receive this value as `agent_type`. The filename does not have to match `description`| Yes| When Claude should delegate to this subagent `tools`| No| Tools the subagent can use. Inherits all tools if omitted. To preload Skills into context, use the `skills` field rather than listing `Skill` here `disallowedTools`| No| Tools to deny, removed from inherited or specified list @@ -664,15 +664,15 @@ Subagents can run in the foreground (blocking) or background (concurrent): - * **Foreground subagents** block the main conversation until complete. Permission prompts and clarifying questions (like [`AskUserQuestion`](</docs/en/tools-reference>)) are passed through to you. - * **Background subagents** run concurrently while you continue working. Before launching, Claude Code prompts for any tool permissions the subagent will need, ensuring it has the necessary approvals upfront. Once running, the subagent inherits these permissions and auto-denies anything not pre-approved. If a background subagent needs to ask clarifying questions, that tool call fails but the subagent continues. + * **Foreground subagents** block the main conversation until complete. Permission prompts are passed through to you as they come up. + * **Background subagents** run concurrently while you continue working. They run with the permissions already granted in the session and auto-deny any tool call that would otherwise prompt. If a background subagent needs to ask clarifying questions, that tool call fails but the subagent continues. If a background subagent fails due to missing permissions, you can start a new foreground subagent with the same task to retry with interactive prompts. Claude decides whether to run subagents in the foreground or background based on the task. You can also: * Ask Claude to “run this in the background” * Press **Ctrl+B** to background a running task -To disable all background task functionality, set the `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS` environment variable to `1`. See [Environment variables](</docs/en/env-vars>). When fork mode is enabled, every subagent spawn runs in the background regardless of the `background` field. Forks still surface permission prompts in your terminal as they occur instead of pre-approving; named subagents follow the pre-approval flow above. +To disable all background task functionality, set the `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS` environment variable to `1`. See [Environment variables](</docs/en/env-vars>). When fork mode is enabled, every subagent spawn runs in the background regardless of the `background` field. Forks still surface permission prompts in your terminal as they occur; named subagents auto-deny anything that would prompt, as described above. ### @@ -832,7 +832,7 @@ Context| Full conversation history| Fresh context with the prompt you pass System prompt and tools| Same as main session| From the subagent’s definition file Model| Same as main session| From the subagent’s `model` field -Permissions| Prompts surface in your terminal| Pre-approved before launch, then auto-denied +Permissions| Prompts surface in your terminal| Auto-denied when running in the background Prompt cache| Shared with main session| Separate cache Because a fork’s system prompt and tool definitions are identical to the parent, its first request reuses the parent’s prompt cache. This makes forking cheaper than spawning a fresh subagent for tasks that need the same context. When Claude spawns a fork through the Agent tool, it can pass `isolation: "worktree"` so the fork’s file edits are written to a separate git worktree instead of your checkout.
modified Enterprise deployment overview View current →
--- a/third-party-integrations.md +++ b/third-party-integrations.md @@ -12,22 +12,23 @@ Compare deployment options -For most organizations, Claude for Teams or Claude for Enterprise provides the best experience. Team members get access to both Claude Code and Claude on the web with a single subscription, centralized billing, and no infrastructure setup required. **Claude for Teams** is self-service and includes collaboration features, admin tools, and billing management. Best for smaller teams that need to get started quickly. **Claude for Enterprise** adds SSO and domain capture, role-based permissions, compliance API access, and managed policy settings for deploying organization-wide Claude Code configurations. Best for larger organizations with security and compliance requirements. Learn more about [Team plans](<https://support.claude.com/en/articles/9266767-what-is-the-team-plan>) and [Enterprise plans](<https://support.claude.com/en/articles/9797531-what-is-the-enterprise-plan>). If your organization has specific infrastructure requirements, compare the options below: Feature| Claude for Teams/Enterprise| Anthropic Console| Amazon Bedrock| Google Vertex AI| Microsoft Foundry ----|---|---|---|---|--- -Best for| Most organizations (recommended)| Individual developers| AWS-native deployments| GCP-native deployments| Azure-native deployments +For most organizations, Claude for Teams or Claude for Enterprise provides the best experience. Team members get access to both Claude Code and Claude on the web with a single subscription, centralized billing, and no infrastructure setup required. **Claude for Teams** is self-service and includes collaboration features, admin tools, and billing management. Best for smaller teams that need to get started quickly. **Claude for Enterprise** adds SSO and domain capture, role-based permissions, compliance API access, and managed policy settings for deploying organization-wide Claude Code configurations. Best for larger organizations with security and compliance requirements. Learn more about [Team plans](<https://support.claude.com/en/articles/9266767-what-is-the-team-plan>) and [Enterprise plans](<https://support.claude.com/en/articles/9797531-what-is-the-enterprise-plan>). If your organization has specific infrastructure requirements, compare the options below: Feature| Claude for Teams/Enterprise| Anthropic Console| Amazon Bedrock| Claude Platform on AWS| Google Vertex AI| Microsoft Foundry +---|---|---|---|---|---|--- +Best for| Most organizations (recommended)| Individual developers| AWS-native deployments| AWS Marketplace billing with Claude API features| GCP-native deployments| Azure-native deployments Billing| **Teams:** $150/seat (Premium) with PAYG available -**Enterprise:** [Contact Sales](<https://claude.com/contact-sales?utm_source=claude_code&utm_medium=docs&utm_content=third_party_enterprise>)| PAYG| PAYG through AWS| PAYG through GCP| PAYG through Azure -Regions| Supported [countries](<https://www.anthropic.com/supported-countries>)| Supported [countries](<https://www.anthropic.com/supported-countries>)| Multiple AWS [regions](<https://docs.aws.amazon.com/bedrock/latest/userguide/models-regions.html>)| Multiple GCP [regions](<https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations>)| Multiple Azure [regions](<https://azure.microsoft.com/en-us/explore/global-infrastructure/products-by-region/>) -Prompt caching| Enabled by default| Enabled by default| Enabled by default| Enabled by default| Enabled by default -Authentication| Claude.ai SSO or email| API key| API key or AWS credentials| GCP credentials| API key or Microsoft Entra ID -Cost tracking| Usage dashboard| Usage dashboard| AWS Cost Explorer| GCP Billing| Azure Cost Management -Includes Claude on web| Yes| No| No| No| No -Enterprise features| Team management, SSO, usage monitoring| None| IAM policies, CloudTrail| IAM roles, Cloud Audit Logs| RBAC policies, Azure Monitor +**Enterprise:** [Contact Sales](<https://claude.com/contact-sales?utm_source=claude_code&utm_medium=docs&utm_content=third_party_enterprise>)| PAYG| PAYG through AWS| PAYG through AWS Marketplace| PAYG through GCP| PAYG through Azure +Regions| Supported [countries](<https://www.anthropic.com/supported-countries>)| Supported [countries](<https://www.anthropic.com/supported-countries>)| Multiple AWS [regions](<https://docs.aws.amazon.com/bedrock/latest/userguide/models-regions.html>)| Multiple AWS regions| Multiple GCP [regions](<https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations>)| Multiple Azure [regions](<https://azure.microsoft.com/en-us/explore/global-infrastructure/products-by-region/>) +Prompt caching| Enabled by default| Enabled by default| Enabled by default| Enabled by default| Enabled by default| Enabled by default +Authentication| Claude.ai SSO or email| API key| API key or AWS credentials| API key or AWS credentials| GCP credentials| API key or Microsoft Entra ID +Cost tracking| Usage dashboard| Usage dashboard| AWS Cost Explorer| AWS Cost Explorer| GCP Billing| Azure Cost Management +Includes Claude on web| Yes| No| No| No| No| No +Enterprise features| Team management, SSO, usage monitoring| None| IAM policies, CloudTrail| IAM policies, CloudTrail| IAM roles, Cloud Audit Logs| RBAC policies, Azure Monitor Select a deployment option to view setup instructions: * [Claude for Teams or Enterprise](</docs/en/authentication#claude-for-teams-or-enterprise>) * [Anthropic Console](</docs/en/authentication#claude-console-authentication>) * [Amazon Bedrock](</docs/en/amazon-bedrock>) + * [Claude Platform on AWS](</docs/en/claude-platform-on-aws>) * [Google Vertex AI](</docs/en/google-vertex-ai>) * [Microsoft Foundry](</docs/en/microsoft-foundry>) @@ -40,7 +41,7 @@ Most organizations can use a cloud provider directly without additional configuration. However, you may need to configure a corporate proxy or LLM gateway if your organization has specific network or management requirements. These are different configurations that can be used together: * **Corporate proxy** : Routes traffic through an HTTP/HTTPS proxy. Use this if your organization requires all outbound traffic to pass through a proxy server for security monitoring, compliance, or network policy enforcement. Configure with the `HTTPS_PROXY` or `HTTP_PROXY` environment variables. Learn more in [Enterprise network configuration](</docs/en/network-config>). - * **LLM Gateway** : A service that sits between Claude Code and the cloud provider to handle authentication and routing. Use this if you need centralized usage tracking across teams, custom rate limiting or budgets, or centralized authentication management. Configure with the `ANTHROPIC_BASE_URL`, `ANTHROPIC_BEDROCK_BASE_URL`, or `ANTHROPIC_VERTEX_BASE_URL` environment variables. Learn more in [LLM gateway configuration](</docs/en/llm-gateway>). + * **LLM Gateway** : A service that sits between Claude Code and the cloud provider to handle authentication and routing. Use this if you need centralized usage tracking across teams, custom rate limiting or budgets, or centralized authentication management. Configure with the `ANTHROPIC_BASE_URL`, `ANTHROPIC_BEDROCK_BASE_URL`, `ANTHROPIC_AWS_BASE_URL`, or `ANTHROPIC_VERTEX_BASE_URL` environment variables. Learn more in [LLM gateway configuration](</docs/en/llm-gateway>). The following examples show the environment variables to set in your shell or shell profile (`.bashrc`, `.zshrc`). See [Settings](</docs/en/settings>) for other configuration methods. @@ -173,7 +174,7 @@ Pin model versions for cloud providers -If you deploy through [Bedrock](</docs/en/amazon-bedrock>), [Vertex AI](</docs/en/google-vertex-ai>), or [Foundry](</docs/en/microsoft-foundry>), pin specific model versions using `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL`. Without pinning, model aliases resolve to the latest version, which may not yet be enabled in your account when Anthropic releases an update. Pinning lets you control when your users move to a new model. See [Model configuration](</docs/en/model-config#pin-models-for-third-party-deployments>) for what each provider does when the latest version is unavailable. +If you deploy through [Bedrock](</docs/en/amazon-bedrock>), [Vertex AI](</docs/en/google-vertex-ai>), [Foundry](</docs/en/microsoft-foundry>), or [Claude Platform on AWS](</docs/en/claude-platform-on-aws>), pin specific model versions using `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL`. Without pinning, model aliases resolve to the latest version, which may not yet be enabled in your account when Anthropic releases an update. Pinning lets you control when your users move to a new model. See [Model configuration](</docs/en/model-config#pin-models-for-third-party-deployments>) for what each provider does when the latest version is unavailable. ###
modified Scale to many tools with tool search View current →
--- a/tool-search.md +++ b/tool-search.md @@ -27,12 +27,12 @@ Configure tool search -By default, tool search is always on. You can change this with the `ENABLE_TOOL_SEARCH` environment variable: +Tool search is on by default. It is disabled by default on Vertex AI, which does not accept the tool search beta header, and when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies do not forward `tool_reference` blocks. You can override this with the `ENABLE_TOOL_SEARCH` environment variable: Value| Behavior ---|--- -(unset)| Tool search is always on. Tool definitions are never loaded into context. This is the default. -`true`| Same as unset. +(unset)| Tool search is on. Tool definitions are deferred and discovered on demand. Falls back to loading upfront on Vertex AI or a non-first-party `ANTHROPIC_BASE_URL`. +`true`| Tool search is always on. The SDK sends the beta header even on Vertex AI and through proxies. Requests fail if the backend or proxy does not support `tool_reference` blocks. `auto`| Checks the combined token count of all tool definitions against the model’s context window. If they exceed 10%, tool search activates. If they’re under 10%, all tools are loaded into context normally. `auto:N`| Same as `auto` with a custom percentage. `auto:5` activates when tool definitions exceed 5% of the context window. Lower values activate sooner. `false`| Tool search is off. All tool definitions are loaded into context on every turn.
modified Tools reference View current →
Show diff (233 lines)
--- a/tools-reference.md +++ b/tools-reference.md @@ -8,26 +8,28 @@ Tool| Description| Permission Required ---|---|--- -`Agent`| Spawns a [subagent](</docs/en/sub-agents>) with its own context window to handle a task| No +`Agent`| Spawns a [subagent](</docs/en/sub-agents>) with its own context window to handle a task. See Agent tool behavior| No `AskUserQuestion`| Asks multiple-choice questions to gather requirements or clarify ambiguity| No `Bash`| Executes shell commands in your environment. See Bash tool behavior| Yes `CronCreate`| Schedules a recurring or one-shot prompt within the current session. Tasks are session-scoped and restored on `--resume` or `--continue` if unexpired. See [scheduled tasks](</docs/en/scheduled-tasks>)| No `CronDelete`| Cancels a scheduled task by ID| No `CronList`| Lists all scheduled tasks in the session| No -`Edit`| Makes targeted edits to specific files| Yes +`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| 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| No -`Glob`| Finds files based on pattern matching| No -`Grep`| Searches for patterns in file contents| No +`Glob`| Finds files based on pattern matching. See Glob tool behavior| No +`Grep`| Searches for patterns in file contents. See Grep tool behavior| No `ListMcpResourcesTool`| Lists resources exposed by connected [MCP servers](</docs/en/mcp>)| No `LSP`| Code intelligence via language servers: jump to definitions, find references, report type errors and warnings. See LSP tool behavior| No `Monitor`| Runs a command in the background and feeds each output line back to Claude, so it can react to log entries, file changes, or polled status mid-conversation. See Monitor tool| Yes -`NotebookEdit`| Modifies Jupyter notebook cells| Yes +`NotebookEdit`| Modifies Jupyter notebook cells. See NotebookEdit tool behavior| Yes `PowerShell`| Executes PowerShell commands natively. See PowerShell tool for availability| Yes -`Read`| Reads the contents of files| No +`PushNotification`| Sends a desktop notification, and a phone push when [Remote Control](</docs/en/remote-control>) is connected, so a long-running task or [scheduled task](</docs/en/scheduled-tasks>) can reach you when you step away. Push delivery runs through Anthropic-hosted infrastructure, which is not accessible from Amazon Bedrock, Google Vertex AI, or Microsoft Foundry| No +`Read`| Reads the contents of files. See Read tool behavior| No `ReadMcpResourceTool`| Reads a specific MCP resource by URI| No +`RemoteTrigger`| Creates, updates, runs, and lists [Routines](</docs/en/routines>) on claude.ai. Backs the `/schedule` command. Routines live on claude.ai and require a Pro, Max, Team, or Enterprise plan, so this tool is not accessible from Amazon Bedrock, Google Vertex AI, or Microsoft Foundry| No `SendMessage`| Sends a message to an [agent team](</docs/en/agent-teams>) teammate, or [resumes a subagent](</docs/en/sub-agents#resume-subagents>) by its agent ID. Stopped subagents auto-resume in the background. Only available when `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1` is set| No `ShareOnboardingGuide`| Uploads `ONBOARDING.md` and returns a share link teammates can open in Claude Code. Called from `/team-onboarding` after the guide is written. Available to claude.ai subscribers on Pro, Max, Team, and Enterprise plans| Yes `Skill`| Executes a [skill](</docs/en/skills#control-who-invokes-a-skill>) within the main conversation| Yes @@ -41,11 +43,59 @@ `TeamDelete`| Disbands an agent team and cleans up teammate processes. Only available when `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1` is set| No `TodoWrite`| Manages the session task checklist. Available in non-interactive mode and the [Agent SDK](</docs/en/headless>); interactive sessions use TaskCreate, TaskGet, TaskList, and TaskUpdate instead| No `ToolSearch`| Searches for and loads deferred tools when [tool search](</docs/en/mcp#scale-with-mcp-tool-search>) is enabled| No -`WebFetch`| Fetches content from a specified URL| Yes -`WebSearch`| Performs web searches| Yes -`Write`| Creates or overwrites files| Yes - -Permission rules can be configured using `/permissions` or in [permission settings](</docs/en/settings#available-settings>). Also see [Tool-specific permission rules](</docs/en/permissions#tool-specific-permission-rules>). +`WebFetch`| Fetches content from a specified URL. See WebFetch tool behavior| Yes +`WebSearch`| Performs web searches. See WebSearch tool behavior| Yes +`Write`| Creates or overwrites files. See Write tool behavior| Yes + +## + +​ + +Configure tools with permission rules and hooks + +For the most part, Claude decides when to use these tools and you do not need to name them yourself when interacting with Claude. You reference tool names directly when defining permissions and other configuration: + + * in [`permissions.allow` and `permissions.deny`](</docs/en/settings#available-settings>) in settings, and the `/permissions` interface + * in the `--allowedTools` and `--disallowedTools` [CLI flags](</docs/en/cli-reference>) + * in the Agent SDK’s [`allowedTools` and `disallowedTools`](</docs/en/agent-sdk/permissions#allow-and-deny-rules>) options + * in a [subagent’s `tools` or `disallowedTools`](</docs/en/sub-agents#supported-frontmatter-fields>) frontmatter + * in a [skill’s `allowed-tools`](</docs/en/skills#frontmatter-reference>) frontmatter + * in a hook’s [`if` condition](</docs/en/hooks-guide#filter-by-tool-name-and-arguments-with-the-if-field>) + +All of these accept the same rule format, `ToolName(specifier)`. The specifier depends on the tool, and several tools share a format: + +Rule format| Applies to| Details +---|---|--- +`Bash(npm run *)`| Bash, Monitor| [Command pattern matching](</docs/en/permissions#bash>) +`PowerShell(Get-ChildItem *)`| PowerShell| [Command pattern matching](</docs/en/permissions#powershell>) +`Read(~/secrets/**)`| Read, Grep, Glob, LSP| [Path pattern matching](</docs/en/permissions#read-and-edit>) +`Edit(/src/**)`| Edit, Write, NotebookEdit| [Path pattern matching](</docs/en/permissions#read-and-edit>) +`Skill(deploy *)`| Skill| [Skill name matching](</docs/en/skills#restrict-claude%E2%80%99s-skill-access>) +`Agent(Explore)`| Agent| [Subagent type matching](</docs/en/permissions#agent-subagents>) +`WebFetch(domain:example.com)`| WebFetch| [Domain matching](</docs/en/permissions#webfetch>) +`WebSearch`| WebSearch| No specifier; allow or deny the tool as a whole + +Tools not listed here, such as `ExitPlanMode` or `ShareOnboardingGuide`, accept only the bare tool name with no specifier. An `Edit(...)` allow rule also grants read access to the same path, so you do not need a matching `Read(...)` rule. Hook `matcher` fields use bare tool names, not the parenthesized rule format. See [matcher patterns](</docs/en/hooks#matcher-patterns>) for the matching rules. For the field names each tool passes to `tool_input` in hooks, see the [PreToolUse input reference](</docs/en/hooks#pretooluse-input>). + +## + +​ + +Agent tool behavior + +The Agent tool spawns a subagent in a separate context window. The subagent works through its task autonomously, then returns a single text result to the parent conversation. The parent does not see the subagent’s intermediate tool calls or outputs, only that final result. To cap how many turns a subagent runs, set `maxTurns` in the [subagent definition](</docs/en/sub-agents#supported-frontmatter-fields>). The same Agent tool also launches [forked subagents](</docs/en/sub-agents#fork-the-current-conversation>) when fork mode is enabled. A fork inherits the full parent conversation instead of starting fresh, always runs in the background, and still surfaces permission prompts in your terminal. The rest of this section describes named subagents. Which tools a named subagent can use depends on the `tools` and `disallowedTools` fields in the [subagent definition](</docs/en/sub-agents>): + + * **Neither field set** : the subagent inherits every tool available to the parent. + * **`tools` only**: the subagent gets only the listed tools. + * **`disallowedTools` only**: the subagent gets every parent tool except the listed ones. + * **Both set** : `disallowedTools` takes precedence. A tool listed in both is removed. + +Launching the subagent does not itself prompt for permission. The subagent’s own tool calls are checked against your permission rules as it runs: + + * **Foreground subagents** show the same permission prompts you would see in the main conversation, at the moment each tool call happens. + * **Background subagents** do not show prompts. They run with the permissions already granted in the session and auto-deny any tool call that would otherwise prompt. After a denial, the subagent keeps going without that tool. + +To limit what a subagent can reach in the first place, narrow its `tools` field, leave Bash off the list, or set deny rules in your settings, as described in [Control subagent capabilities](</docs/en/sub-agents#control-subagent-capabilities>). For more on choosing between foreground and background, see [Run subagents in foreground or background](</docs/en/sub-agents#run-subagents-in-foreground-or-background>). ## @@ -60,7 +110,54 @@ * To disable this carry-over so every Bash command starts in the project directory, set `CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR=1`. * Environment variables do not persist. An `export` in one command will not be available in the next. -Activate your virtualenv or conda environment before launching Claude Code. To make environment variables persist across Bash commands, set [`CLAUDE_ENV_FILE`](</docs/en/env-vars>) to a shell script before launching Claude Code, or use a [SessionStart hook](</docs/en/hooks#persist-environment-variables>) to populate it dynamically. +Activate your virtualenv or conda environment before launching Claude Code. To make environment variables persist across Bash commands, set [`CLAUDE_ENV_FILE`](</docs/en/env-vars>) to a shell script before launching Claude Code, or use a [SessionStart hook](</docs/en/hooks#persist-environment-variables>) to populate it dynamically. Two limits bound each command: + + * **Timeout** : two minutes by default. Claude can request up to 10 minutes per command with the `timeout` parameter. Override the default and ceiling with [`BASH_DEFAULT_TIMEOUT_MS` and `BASH_MAX_TIMEOUT_MS`](</docs/en/env-vars>). + * **Output length** : 30,000 characters by default. When a command produces more than that, Claude Code saves the full output to a file in the session directory and gives Claude the file path plus a short preview from the start. Claude reads or searches that file when it needs the rest. Raise the limit with [`BASH_MAX_OUTPUT_LENGTH`](</docs/en/env-vars>), up to a hard ceiling of 150,000 characters. + +For long-running processes such as dev servers or watch builds, Claude can set `run_in_background: true` to start the command as a background task and continue working while it runs. List and stop background tasks with `/tasks`. + +## + +​ + +Edit tool behavior + +The Edit tool performs exact string replacement. It takes an `old_string` and a `new_string` and replaces the first with the second. It does not use regex or fuzzy matching. Three checks must pass for an edit to apply: + + * **Read-before-edit** : Claude must have read the file in the current conversation, and the file must not have changed on disk since that read. This check runs first, before any string matching. + * **Match** : `old_string` must appear in the file exactly as written. A single character of whitespace or indentation difference is enough to miss. + * **Uniqueness** : `old_string` must appear exactly once. When it appears more than once, Claude either supplies a longer string with enough surrounding context to pin down one occurrence, or sets `replace_all: true` to replace them all. + +Viewing a file with Bash also satisfies the read-before-edit requirement when the command is `cat path/to/file` or `sed -n 'X,Yp' path/to/file` on a single file with no pipes or redirects. Other Bash commands such as `head`, `tail`, or piped output do not count, and Claude must use Read before editing in those cases. This affects edit eligibility only, not permissions. [Read and Edit deny rules](</docs/en/permissions#tool-specific-permission-rules>) also apply to file commands Claude Code recognizes in Bash, such as `cat`, `head`, `tail`, and `sed`, but not to arbitrary subprocesses that read or write files indirectly, like a Python or Node script that opens files itself. For OS-level enforcement that covers every process, [enable the sandbox](</docs/en/sandboxing>). + +## + +​ + +Glob tool behavior + +The Glob tool finds files by name pattern. It supports standard glob syntax including `**` for recursive directory matching: + + * `**/*.js` matches all `.js` files at any depth + * `src/**/*.ts` matches all `.ts` files under `src/` + * `*.{json,yaml}` matches `.json` and `.yaml` files in the current directory + +Results are sorted by modification time and capped at 100 files. If the cap is hit, Claude sees a truncation flag in the result and can narrow the pattern. Glob does not respect `.gitignore` by default, so it finds gitignored files alongside tracked ones. This differs from Grep, which skips gitignored files. To make Glob respect `.gitignore`, set `CLAUDE_CODE_GLOB_NO_IGNORE=false` before launching Claude Code. + +## + +​ + +Grep tool behavior + +The Grep tool searches file contents for patterns. Where Glob finds files by name, Grep finds lines inside them. Grep is built on [ripgrep](<https://github.com/BurntSushi/ripgrep>) and uses ripgrep’s regex syntax, not POSIX grep. Patterns that include regex metacharacters need escaping. For example, finding `interface{}` in Go code takes the pattern `interface\{\}`. Three output modes control what comes back: + + * `files_with_matches`: file paths only, no line content. This is the default. + * `content`: matching lines with file and line number. + * `count`: match count per file. + +Claude can scope results by file with the `glob` parameter, such as `**/*.tsx`, or by language with the `type` parameter, such as `py` or `rust`. By default, patterns match within a single line. Claude can set `multiline: true` to match across line boundaries. Grep respects `.gitignore`, so gitignored files are skipped. To search a gitignored file, Claude passes its path directly. ## @@ -100,6 +197,20 @@ ​ +NotebookEdit tool behavior + +NotebookEdit modifies a Jupyter notebook one cell at a time, targeting cells by their `cell_id`. It does not perform string replacement across the notebook the way Edit does on plain files. Three edit modes control what happens to the target cell: + + * `replace`: overwrite the cell’s source. This is the default. + * `insert`: add a new cell after the target. With no `cell_id`, the new cell goes at the start of the notebook. Requires `cell_type` set to `code` or `markdown`. + * `delete`: remove the target cell. + +Permission rules use the `Edit(...)` path format. A rule like `Edit(notebooks/**)` covers NotebookEdit calls on files in that directory. + +## + +​ + PowerShell tool The PowerShell tool lets Claude run PowerShell commands natively. On Windows, this means commands run in PowerShell instead of routing through Git Bash. On Windows without Git Bash, the tool is enabled automatically. On Windows with Git Bash installed, the tool is rolling out progressively. On Linux, macOS, and WSL, the tool is opt-in. @@ -149,6 +260,53 @@ ​ +Read tool behavior + +The Read tool takes a file path and returns the contents with line numbers. Claude is instructed to always pass absolute paths. By default, Read returns the file from the start. Files over a size threshold return an error rather than partial content, prompting Claude to retry with `offset` and `limit` to read a specific range. Read handles several file types beyond plain text: + + * **Images** : PNG, JPG, and other image formats are returned as visual content that Claude can see, not as raw bytes. Claude Code resizes and recompresses large images to fit the model’s image size limits before sending them, so Claude may see a downscaled version of a large screenshot. If Claude misses fine pixel-level detail in a large image, ask it to crop the region of interest first, for example with ImageMagick via Bash. + * **PDFs** : Claude reads short `.pdf` files whole. For PDFs longer than 10 pages, it reads in ranges with a `pages` parameter, such as `"1-5"`, up to 20 pages at a time. + * **Jupyter notebooks** : `.ipynb` files return all cells with their outputs, including code, markdown, and visualizations. + +Read only reads files, not directories. Claude uses `ls` via the Bash tool to list directory contents. + +## + +​ + +WebFetch tool behavior + +WebFetch takes a URL and a prompt describing what to extract. It fetches the page, converts the response to Markdown when the server returns HTML, and runs the prompt against the content using a small, fast model. For most fetches, Claude receives that model’s answer, not the raw page. The conversion step is not configurable. This makes WebFetch lossy by design. The extraction prompt determines what reaches Claude, so a result that says a page does not mention something may only mean the prompt did not ask about it. Ask Claude to fetch again with a more specific prompt, or use `curl` via Bash for the unprocessed page. A few behaviors shape the response Claude receives: + + * HTTP URLs are automatically upgraded to HTTPS. + * Large pages are truncated to a fixed character limit before processing. + * Responses are cached for 15 minutes, so repeated fetches of the same URL return quickly. + * When a URL redirects to a different host, WebFetch returns a text result that names the original URL and the redirect target instead of following it. Claude then fetches the new URL with a second WebFetch call. + +In the default and `acceptEdits` permission modes, WebFetch prompts the first time it reaches a new domain. To allow a domain in advance without a prompt, add a permission rule like `WebFetch(domain:example.com)`. The `auto` and `bypassPermissions` [permission modes](</docs/en/permissions#permission-modes>) skip the prompt entirely. WebFetch sets a `User-Agent` header beginning with `Claude-User`, and an `Accept` header that prefers Markdown over HTML so servers that support content negotiation can return Markdown directly. [Sandbox](</docs/en/sandboxing>) network rules are configured separately, so a domain you want a sandboxed process to reach still needs an explicit sandbox permission rule. + +## + +​ + +WebSearch tool behavior + +WebSearch runs a query against Anthropic’s [web search](<https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool>) backend and returns result titles and URLs. It does not fetch the result pages. To read a page Claude finds in search results, it follows up with WebFetch. The tool may issue up to eight backend searches per call, refining the search internally before returning results. Claude can scope results with `allowed_domains` to include only certain hosts, or `blocked_domains` to exclude them. The two lists cannot be combined in a single call. The search backend is not configurable. To search with a different provider, add an [MCP server](</docs/en/mcp>) that exposes a search tool. WebSearch permission rules take no specifier. A bare `WebSearch` entry in `allow` or `deny` is the only form. + +WebSearch is available on the Claude API and Microsoft Foundry. On Google Cloud Vertex AI it works with Claude 4 models, including Opus, Sonnet, and Haiku. Amazon Bedrock does not expose the server-side web search tool. + +## + +​ + +Write tool behavior + +The Write tool creates a new file or overwrites an existing one with the full content provided. It does not append or merge. If the target path already exists, Claude must have read that file at least once in the current conversation before overwriting it. A Write to an unread existing file fails with an error. This constraint does not apply to new files. Viewing the file with Bash `cat` or `sed -n` also satisfies this requirement, as described in Edit tool behavior. For partial changes to an existing file, Claude uses Edit instead of Write. + +## + +​ + Check which tools are available Your exact tool set depends on your provider, platform, and settings. To check what’s loaded in a running session, ask Claude directly:
modified Handle approvals and user input View current →
--- a/user-input.md +++ b/user-input.md @@ -4,7 +4,7 @@ > > Use this file to discover all available pages before exploring further. -While working on a task, Claude sometimes needs to check in with users. It might need permission before deleting files, or need to ask which database to use for a new project. Your application needs to surface these requests to users so Claude can continue with their input. Claude requests user input in two situations: when it needs **permission to use a tool** (like deleting files or running commands), and when it has **clarifying questions** (via the `AskUserQuestion` tool). Both trigger your `canUseTool` callback, which pauses execution until you return a response. This is different from normal conversation turns where Claude finishes and waits for your next message. For clarifying questions, Claude generates the questions and options. Your role is to present them to users and return their selections. You can’t add your own questions to this flow; if you need to ask users something yourself, do that separately in your application logic. The callback can stay pending indefinitely. Execution remains paused until your callback returns, and the SDK only cancels the wait when the query itself is cancelled. If a user might take longer to respond than your process can reasonably stay running, the TypeScript SDK supports the [`defer` hook decision](</docs/en/hooks#defer-a-tool-call-for-later>), which lets the process exit and resume later from the persisted session; this option is not available in the Python SDK. This guide shows you how to detect each type of request and respond appropriately. +While working on a task, Claude sometimes needs to check in with users. It might need permission before deleting files, or need to ask which database to use for a new project. Your application needs to surface these requests to users so Claude can continue with their input. Claude requests user input in two situations: when it needs **permission to use a tool** (like deleting files or running commands), and when it has **clarifying questions** (via the `AskUserQuestion` tool). Both trigger your `canUseTool` callback, which pauses execution until you return a response. This is different from normal conversation turns where Claude finishes and waits for your next message. For clarifying questions, Claude generates the questions and options. Your role is to present them to users and return their selections. You can’t add your own questions to this flow; if you need to ask users something yourself, do that separately in your application logic. The callback can stay pending indefinitely. Execution remains paused until your callback returns, and the SDK only cancels the wait when the query itself is cancelled. If a user might take longer to respond than your process can reasonably stay running, return the [`defer` hook decision](</docs/en/hooks#defer-a-tool-call-for-later>), which lets the process exit and resume later from the persisted session. This guide shows you how to detect each type of request and respond appropriately. ##
modified Use Claude Code in VS Code View current →
--- a/vs-code.md +++ b/vs-code.md @@ -256,6 +256,7 @@ Open in New Tab| `Cmd+Shift+Esc` (Mac) / `Ctrl+Shift+Esc` (Windows/Linux)| Open a new conversation as an editor tab Open in New Window| -| Open a new conversation in a separate window New Conversation| `Cmd+N` (Mac) / `Ctrl+N` (Windows/Linux)| Start a new conversation. Requires Claude to be focused and `enableNewConversationShortcut` set to `true` +Reopen Closed Session| `Cmd+Shift+T` (Mac) / `Ctrl+Shift+T` (Windows/Linux)| Reopen the most recently closed Claude session tab. Falls through to VS Code’s normal reopen-closed-editor when the last closed tab wasn’t a Claude session. Disable with `enableReopenClosedSessionShortcut` Insert @-Mention Reference| `Option+K` (Mac) / `Alt+K` (Windows/Linux)| Insert a reference to the current file and selection (requires editor to be focused) Show Logs| -| View extension debug logs Logout| -| Sign out of your Anthropic account @@ -326,6 +327,7 @@ `autosave`| `true`| Auto-save files before Claude reads or writes them `useCtrlEnterToSend`| `false`| Use Ctrl/Cmd+Enter instead of Enter to send prompts `enableNewConversationShortcut`| `false`| Enable Cmd/Ctrl+N to start a new conversation +`enableReopenClosedSessionShortcut`| `true`| Use Cmd/Ctrl+Shift+T to reopen the most recently closed Claude session tab. When the last closed tab wasn’t a Claude session, the shortcut runs VS Code’s normal reopen-closed-editor command instead. `hideOnboarding`| `false`| Hide the onboarding checklist (graduation cap icon) `respectGitIgnore`| `true`| Exclude .gitignore patterns from file searches `usePythonEnvironment`| `true`| Activate the workspace’s Python environment when running Claude. Requires the Python extension.
added Run parallel sessions with worktrees View current →
Show diff (156 lines)
--- a/worktrees.md +++ b/worktrees.md @@ -0,0 +1,153 @@ +> ## Documentation Index +> +> Fetch the complete documentation index at: <https://code.claude.com/docs/llms.txt> +> +> Use this file to discover all available pages before exploring further. + +A [git worktree](<https://git-scm.com/docs/git-worktree>) is a separate working directory with its own files and branch, sharing the same repository history and remote as your main checkout. Running each Claude Code session in its own worktree means edits in one session never touch files in another, so you can have Claude building a feature in one terminal while fixing a bug in a second. This page covers worktree isolation in the CLI. Everything below assumes a git repository. For other version control systems, see Non-git version control. The [desktop app](</docs/en/desktop#work-in-parallel-with-sessions>) creates a worktree for every new session automatically. Worktrees are one of several ways to run Claude in parallel. They isolate file edits, while [subagents](</docs/en/sub-agents>) and [agent teams](</docs/en/agent-teams>) coordinate the work itself. See [Run agents in parallel](</docs/en/agents>) to compare the approaches, or skip ahead to Isolate subagents with worktrees to use worktrees and subagents together. + +## + +​ + +Start Claude in a worktree + +Pass `--worktree` or `-w` to create an isolated worktree and start Claude in it. By default, the worktree is created under `.claude/worktrees/<value>/` at your repository root, on a new branch named `worktree-<value>`: + + claude --worktree feature-auth + +To put worktrees somewhere else, configure a `WorktreeCreate` hook. Run the command again with a different name in another terminal to start a second isolated session: + + claude --worktree bugfix-123 + +If you omit the name, Claude generates one such as `bright-running-fox`: + + 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`. + +Add `.claude/worktrees/` to your `.gitignore` so worktree contents don’t appear as untracked files in your main checkout. + +### + +​ + +Choose the base branch + +Worktrees branch from your repository’s default branch, `origin/HEAD`, so they start from a clean tree matching the remote. If no remote is configured or the fetch fails, the worktree falls back to your current local `HEAD`. To always branch from local `HEAD` instead, set `worktree.baseRef` to `"head"` in [settings](</docs/en/settings#worktree-settings>). Setting `baseRef` to `"head"` makes new worktrees carry your unpushed commits and feature-branch state, which is useful when isolating subagents that need to operate on in-progress work. The setting accepts only `"fresh"` or `"head"`, not arbitrary git refs: + + { + "worktree": { + "baseRef": "head" + } + } + +To branch from a specific pull request, pass the PR number prefixed with `#`, or a full GitHub pull request URL. Claude Code fetches `pull/<number>/head` from `origin` and creates the worktree at `.claude/worktrees/pr-<number>`: + + claude --worktree "#1234" + +For full control over how worktrees are created, configure a [`WorktreeCreate` hook](</docs/en/hooks#worktreecreate>), which replaces the default `git worktree` logic entirely. + +## + +​ + +Copy gitignored files into worktrees + +A worktree is a fresh checkout, so untracked files like `.env` or `.env.local` from your main repository are not present. To copy them automatically when Claude creates a worktree, add a `.worktreeinclude` file to your project root. The file uses `.gitignore` syntax. Only files that match a pattern and are also gitignored are copied, so tracked files are never duplicated. This `.worktreeinclude` copies two env files and a secrets config into each new worktree: + +.worktreeinclude + + .env + .env.local + config/secrets.json + +This applies to worktrees created with `--worktree`, subagent worktrees, and parallel sessions in the [desktop app](</docs/en/desktop#work-in-parallel-with-sessions>). + +## + +​ + +Isolate subagents with worktrees + +Subagents can run in their own worktrees so parallel edits don’t conflict. Ask Claude to “use worktrees for your agents”, or set it permanently on a [custom subagent](</docs/en/sub-agents#supported-frontmatter-fields>) by adding `isolation: worktree` to the frontmatter. Each subagent gets a temporary worktree that is removed automatically when the subagent finishes without changes. + +## + +​ + +Clean up worktrees + +When you exit a worktree session, cleanup depends on whether you made changes: + + * **No changes** : the worktree and its branch are removed automatically + * **Changes or 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 all uncommitted changes 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. + +## + +​ + +Manage worktrees manually + +For full control over worktree location and branch configuration, create worktrees with Git directly. This is useful when you need to check out a specific existing branch or place the worktree outside the repository. Create a worktree on a new branch: + + git worktree add ../project-feature-a -b feature-a + +Create a worktree from an existing branch: + + git worktree add ../project-bugfix bugfix-123 + +Start Claude in the worktree: + + cd ../project-feature-a && claude + +List your worktrees: + + git worktree list + +Remove one when you’re done with it: + + git worktree remove ../project-feature-a + +See the [Git worktree documentation](<https://git-scm.com/docs/git-worktree>) for the full command reference. Remember to initialize your development environment in each new worktree: install dependencies, set up virtual environments, or run whatever your project’s setup requires. + +## + +​ + +Non-git version control + +Worktree isolation uses git by default. For SVN, Perforce, Mercurial, or other systems, configure [`WorktreeCreate` and `WorktreeRemove` hooks](</docs/en/hooks#worktreecreate>) to provide custom creation and cleanup logic. Because the hook replaces the default git behavior, `.worktreeinclude` is not processed when you use `--worktree`. Copy any local configuration files inside your hook script instead. This `WorktreeCreate` hook reads the worktree name from stdin, checks out a fresh SVN working copy, and prints the directory path so Claude Code can use it as the session’s working directory: + + { + "hooks": { + "WorktreeCreate": [ + { + "hooks": [ + { + "type": "command", + "command": "bash -c 'NAME=$(jq -r .name); DIR=\"$HOME/.claude/worktrees/$NAME\"; svn checkout https://svn.example.com/repo/trunk \"$DIR\" >&2 && echo \"$DIR\"'" + } + ] + } + ] + } + } + +Pair it with a `WorktreeRemove` hook to clean up when the session ends. See the [hooks reference](</docs/en/hooks#worktreecreate>) for the input schema and a removal example. + +## + +​ + +See also + +Worktrees handle file isolation. The related pages below cover delegating work into those isolated checkouts and switching between the sessions you create: + + * [Subagents](</docs/en/sub-agents>): delegate work to isolated agents within a session + * [Agent teams](</docs/en/agent-teams>): coordinate multiple Claude sessions automatically + * [Manage sessions](</docs/en/sessions>): name, resume, and switch between conversations + * [Desktop parallel sessions](</docs/en/desktop#work-in-parallel-with-sessions>): worktree-backed sessions in the desktop app