modified Set up Claude Code for your organization View current →
--- a/admin-setup.md +++ b/admin-setup.md @@ -79,7 +79,7 @@ [Plugin marketplace control](</docs/en/plugin-marketplaces#managed-marketplace-restrictions>)| Restrict which marketplace sources users can add and install from, reject the CLI flags that sideload plugins, agents, and MCP servers for a single run, and allowlist which marketplaces’ plugins can be suggested| `strictKnownMarketplaces`, `blockedMarketplaces`, `disableSideloadFlags`, `pluginSuggestionMarketplaces` [Customization lockdown](</docs/en/settings#strictpluginonlycustomization>)| Block skills, agents, hooks, and MCP servers from user and project sources, so they can only come from plugins or managed settings| `strictPluginOnlyCustomization` [Hook restrictions](</docs/en/settings#hook-configuration>)| Only managed hooks load; restrict HTTP hook URLs| `allowManagedHooksOnly`, `allowedHttpHookUrls` -[Login enforcement](</docs/en/settings#available-settings>)| Restrict login to a specific method or Anthropic organization. The method restriction is enforced across the terminal, VS Code extension, Agent SDK, `claude setup-token`, and `/install-github-app`; the organization restriction covers the terminal, VS Code extension, and Agent SDK. Before v2.1.212, only terminal logins enforced either key. When set, sessions authenticated by `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, or `apiKeyHelper` are blocked at startup; cloud provider sessions aren’t affected| `forceLoginMethod`, `forceLoginOrgUUID` +[Login enforcement](</docs/en/settings#available-settings>)| Restrict login to a specific method or Anthropic organization. The method restriction is enforced across the terminal, VS Code extension, Agent SDK, `claude setup-token`, and `/install-github-app`; the organization restriction covers the terminal, VS Code extension, and Agent SDK, except [gateway](</docs/en/claude-apps-gateway>) sign-in, which doesn’t authenticate against an Anthropic organization. Before v2.1.212, only terminal logins enforced either key. When set, sessions authenticated by `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, or `apiKeyHelper` are blocked at startup; cloud provider sessions aren’t affected| `forceLoginMethod`, `forceLoginOrgUUID` [Disable agent view](</docs/en/agent-view#how-background-sessions-are-hosted>)| Turn off `claude agents`, `--bg`, `/background`, and the on-demand supervisor| `disableAgentView` [Configure the corporate launcher](</docs/en/corporate-launcher>)| Prefix the [background-agent supervisor](</docs/en/agent-view#how-background-sessions-are-hosted>), its workers, and the [other covered background processes](</docs/en/corporate-launcher#what-the-launcher-covers>) with a required corporate launcher instead of turning agent view off| `processWrapper` [Model restrictions](</docs/en/model-config#restrict-model-selection>)| `availableModels` filters which models appear in the picker. Adding `enforceAvailableModels` also constrains the auto-selected default model. See [surface coverage](</docs/en/model-config#surface-coverage>) for how this setting reaches the CLI, web, and IDE| `availableModels`, `enforceAvailableModels`
modified How the agent loop works View current →
--- a/agent-loop.md +++ b/agent-loop.md @@ -228,7 +228,7 @@ `"acceptEdits"`| Auto-approves file edits and common filesystem commands (`mkdir`, `touch`, `mv`, `cp`, etc.); other Bash commands follow default rules `"plan"`| Claude explores and plans without editing your source files; file edits are never auto-approved and prompt through your `canUseTool` callback `"dontAsk"`| Never prompts. Tools pre-approved by [permission rules](</docs/en/settings#permission-settings>) run; everything else is denied. `AskUserQuestion`, connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) are denied even if you’ve allowed them -`"auto"`| Uses a model classifier to approve or deny each tool call. See [Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) for availability and behavior +`"auto"`| Uses a model classifier to approve or deny permission prompts. See [Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) for availability and behavior `"bypassPermissions"`| Runs all allowed tools without asking, except tools matched by an explicit [`ask` rule](</docs/en/settings#permission-settings>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), and tools that require user interaction; see [How permissions are evaluated](</docs/en/agent-sdk/permissions#how-permissions-are-evaluated>) for the precedence order. Cannot be used when running as root on Unix. Use only in isolated environments where the agent’s actions cannot affect systems you care about For interactive applications, use `"default"` with a tool approval callback to surface approval prompts. For autonomous agents on a dev machine, `"acceptEdits"` auto-approves file edits and common filesystem commands (`mkdir`, `touch`, `mv`, `cp`, etc.) while still gating other `Bash` commands behind allow rules. Reserve `"bypassPermissions"` for CI, containers, or other isolated environments. See [Permissions](</docs/en/agent-sdk/permissions>) for full details.
modified Manage multiple agents with agent view View current →
--- a/agent-view.md +++ b/agent-view.md @@ -87,7 +87,7 @@ State| Icon shows as| What it means ---|---|--- Working| Animated| Claude is actively running tools or generating a response -Needs input| Yellow| Claude is waiting on something only you can provide: an answer to a question, a permission decision, a [sandbox](</docs/en/sandboxing>) prompt to allow a network host, an MCP server’s [request for input](</docs/en/mcp#respond-to-mcp-elicitation-requests>), or a managed-settings prompt +Needs input| Yellow| Claude is waiting on something only you can provide: an answer to a question, a permission decision, a [sandbox](</docs/en/sandboxing>) prompt to allow a network host, an MCP server’s [request for input](</docs/en/mcp#respond-to-mcp-elicitation-requests>), a managed-settings prompt, or an MCP authentication or settings request held by a session with no terminal attached Idle| Dimmed| The session has nothing to do and is ready for your next prompt Completed| Green| The task finished successfully Failed| Red| The task ended with an error @@ -148,7 +148,7 @@ Attach to a session -Press `Enter` or `→` on a selected row to attach. Agent view is replaced by the full interactive session. 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: [commands](</docs/en/commands>), keyboard shortcuts, and features all work, with the exceptions below. A background session refuses `/install-github-app` and the [`/mcp`](</docs/en/mcp>) settings list, including its authentication actions, whether you’re attached or replying from the peek panel. The message directs you to a regular `claude` session, and `/mcp reconnect <server>`, `/mcp enable`, and `/mcp disable` still work. Attached sessions always render in [fullscreen mode](</docs/en/fullscreen>), regardless of your `tui` setting, because a background session has no terminal scrollback to append to. Scroll with `PgUp`, `PgDn`, or the mouse wheel, and press `Ctrl+O` for transcript mode. Your terminal’s native scroll and tmux copy mode show only the current viewport, the same as when you run any fullscreen application. Press `←` on an empty prompt, or run `/exit`, to detach and return to agent view, whether you opened the session from agent view or with `claude attach <id>` from your shell. `Ctrl+Z` also detaches but goes back to where you started instead: agent view if you attached from there, or your shell if you ran `claude attach`. Use `Ctrl+Z` when a dialog has focus and isn’t responding to `←`. `Ctrl+C` keeps its standard interrupt behavior while attached: it cancels a running response or `!` shell command rather than detaching. Pressing `Ctrl+C` twice on an empty prompt detaches, the same as in any session. Detaching never stops a background session: `←`, `Ctrl+Z`, `/exit`, and double `Ctrl+C` or double `Ctrl+D` all leave it running. To end a session from inside it, run `/stop`. In a session running in the foreground, one you started in the terminal rather than attached to from agent view, pressing `←` on an empty prompt backgrounds it and opens agent view with that row selected, so you can switch sessions without leaving the terminal. The same single press detaches an attached session. [Claude’s task list](</docs/en/interactive-mode#task-list>) moves to the background session with the conversation, so the checklist is intact when you return to that row. The row you pressed `←` from also keeps a bold, undimmed name after you move the selection with the arrow keys or the mouse, so you can tell which session you came from. If a tool is running when you press `←`, Claude Code waits up to about ten seconds for it to finish before backgrounding, and the response continues in the background session. Press `←` again to background immediately instead of waiting. When in-flight work can’t carry over to the background session, the `Background this session?` dialog appears first, the same as with `/background`. The ten-second limit doesn’t apply while [subagents](</docs/en/sub-agents>) are running. Claude Code keeps waiting so their work carries over, and shows a `Still backgrounding after the current tool` notice while it waits; press `←` again to background without waiting, which restarts the subagents from the beginning. Pressing `←` creates the session’s row even when the conversation has no messages yet, so `→` still returns to it. You can turn this shortcut off with the `leftArrowOpensAgents` setting in `/config`. +Press `Enter` or `→` on a selected row to attach. Agent view is replaced by the full interactive session. 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: [commands](</docs/en/commands>), keyboard shortcuts, and features all work, with the exceptions below. While you’re attached, `/install-github-app` and the [`/mcp`](</docs/en/mcp>) settings list work normally, since a human at the terminal can complete their dialogs. When nobody is attached, these commands can’t open their dialogs, so the session appears under `Needs input` in agent view with a row such as `open this session to manage MCP servers`, and the transcript reply says the same. Attach and run the command again to continue; the needs-input row clears when you attach. `/mcp reconnect <server>`, `/mcp enable`, and `/mcp disable` work without attaching either way. From v2.1.208 through v2.1.215, Claude Code refused these commands in a background session: v2.1.214 and v2.1.215 told you to attach and run the command again, and v2.1.208 through v2.1.212 refused them even with a terminal attached, directing you to a regular `claude` session instead. Before v2.1.208, the dialogs opened inside the background session. Attached sessions always render in [fullscreen mode](</docs/en/fullscreen>), regardless of your `tui` setting, because a background session has no terminal scrollback to append to. Scroll with `PgUp`, `PgDn`, or the mouse wheel, and press `Ctrl+O` for transcript mode. Your terminal’s native scroll and tmux copy mode show only the current viewport, the same as when you run any fullscreen application. Press `←` on an empty prompt, or run `/exit`, to detach and return to agent view, whether you opened the session from agent view or with `claude attach <id>` from your shell. `Ctrl+Z` also detaches but goes back to where you started instead: agent view if you attached from there, or your shell if you ran `claude attach`. Use `Ctrl+Z` when a dialog has focus and isn’t responding to `←`. `Ctrl+C` keeps its standard interrupt behavior while attached: it cancels a running response or `!` shell command rather than detaching. Pressing `Ctrl+C` twice on an empty prompt detaches, the same as in any session. Detaching never stops a background session: `←`, `Ctrl+Z`, `/exit`, and double `Ctrl+C` or double `Ctrl+D` all leave it running. To end a session from inside it, run `/stop`. In a session running in the foreground, one you started in the terminal rather than attached to from agent view, pressing `←` on an empty prompt backgrounds it and opens agent view with that row selected, so you can switch sessions without leaving the terminal. The same single press detaches an attached session. [Claude’s task list](</docs/en/interactive-mode#task-list>) moves to the background session with the conversation, so the checklist is intact when you return to that row. The row you pressed `←` from also keeps a bold, undimmed name after you move the selection with the arrow keys or the mouse, so you can tell which session you came from. If a tool is running when you press `←`, Claude Code waits up to about ten seconds for it to finish before backgrounding, and the response continues in the background session. Press `←` again to background immediately instead of waiting. When in-flight work can’t carry over to the background session, the `Background this session?` dialog appears first, the same as with `/background`. The ten-second limit doesn’t apply while [subagents](</docs/en/sub-agents>) are running. Claude Code keeps waiting so their work carries over, and shows a `Still backgrounding after the current tool` notice while it waits; press `←` again to background without waiting, which restarts the subagents from the beginning. Pressing `←` creates the session’s row even when the conversation has no messages yet, so `→` still returns to it. You can turn this shortcut off with the `leftArrowOpensAgents` setting in `/config`. ###
modified Authentication View current →
--- a/authentication.md +++ b/authentication.md @@ -135,10 +135,11 @@ Restrict login to your organization -To require that developer sessions authenticate into a specific Anthropic organization, set [`forceLoginMethod` and `forceLoginOrgUUID`](</docs/en/settings#available-settings>) in [managed settings](</docs/en/settings#settings-files>). Set `forceLoginOrgUUID` to your organization ID, shown in [claude.ai admin settings](<https://claude.ai/admin-settings/organization>) for Claude for Teams or Enterprise organizations, or at [platform.claude.com/settings/organization](<https://platform.claude.com/settings/organization>) for Console organizations. With both keys set, Claude Code restricts login to the listed organization and exits at startup if the active credential belongs to a different one. Developers can log in from several paths: the terminal `/login` flow, the [VS Code extension](</docs/en/vs-code>), the Agent SDK, `claude setup-token`, and `/install-github-app`. On Claude Code v2.1.212 or later, every path enforces `forceLoginMethod`; before v2.1.212, only terminal logins enforced either key. The paths differ on `forceLoginOrgUUID`: +To require that developer sessions authenticate into a specific Anthropic organization, set [`forceLoginMethod` and `forceLoginOrgUUID`](</docs/en/settings#available-settings>) in [managed settings](</docs/en/settings#settings-files>). Set `forceLoginOrgUUID` to your organization ID, shown in [claude.ai admin settings](<https://claude.ai/admin-settings/organization>) for Claude for Teams or Enterprise organizations, or at [platform.claude.com/settings/organization](<https://platform.claude.com/settings/organization>) for Console organizations. With both keys set, Claude Code restricts login to the listed organization and exits at startup if the active credential belongs to a different one. Developers can log in from several paths: the terminal `/login` flow, the [VS Code extension](</docs/en/vs-code>), the Agent SDK, `claude setup-token`, `/install-github-app`, and [gateway](</docs/en/claude-apps-gateway>) sign-in for organizations that route through a cloud gateway. On Claude Code v2.1.212 or later, every path enforces `forceLoginMethod`; before v2.1.212, only terminal logins enforced either key. The paths differ on `forceLoginOrgUUID`: * **Terminal, VS Code extension, and Agent SDK logins** : enforce both keys * **`claude setup-token` and `/install-github-app`**: enforce only `forceLoginMethod`, so they can mint a token in a different organization + * **[Gateway](</docs/en/claude-apps-gateway>) sign-in**: selected by `forceLoginMethod: "gateway"` rather than restricted by it, and doesn’t authenticate against an Anthropic organization, so `forceLoginOrgUUID` doesn’t apply; use your gateway identity provider to restrict access Deploy the keys through your device management tooling. [Server-managed settings](</docs/en/server-managed-settings>) reach only accounts that are already authenticated into your organization, so they can’t redirect a developer’s first login. If your organization distributes server-managed settings as well, set the keys in both places: managed-settings sources [don’t merge](</docs/en/server-managed-settings#settings-precedence>), and cached server-managed settings replace the device-managed file entirely. The keys also block sessions authenticated by `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, or `apiKeyHelper`, since organization membership can’t be verified for an environment credential. Cloud provider sessions such as Amazon Bedrock authenticate against your cloud provider and aren’t blocked; restrict those through your cloud IAM policies. See [`forceLoginOrgUUID`](</docs/en/settings#available-settings>) in the settings reference for the full behavior. Before v2.1.146, the pin applied only to the login flow and didn’t block API-key credentials.
modified Claude Code changelog View current →
--- a/changelog.md +++ b/changelog.md @@ -1,4 +1,51 @@ 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.216 + +July 20, 2026 + + * Added `sandbox.filesystem.disabled` setting to skip filesystem isolation while keeping network egress control + * Fixed a slowdown in long sessions where message normalization cost grew quadratically with the number of turns, causing multi-second stalls and slow resumes + * Fixed auto mode denying commands with “HTTP 401” classifier errors after the OAuth token expired or rotated mid-session + * Fixed AskUserQuestion telling Claude to continue even when your answer asked it to wait or explain first — free-text answers now get neutral wording + * Fixed Claude Code on the web re-asking the same question and dropping your answer after the session sat idle for a few minutes + * Fixed @-mentions silently attaching nothing after file-modifying hooks, vim dot-repeat of `c`-operators and paste, statusline running twice on resume, and resume-picker hangs on failure + * Fixed resumed background agent sessions reverting to the default agent: the agent’s prompt and tool restrictions are now restored + * Fixed worktree-isolated subagents redirecting git into the shared checkout via `git -C`, `--git-dir`, or `GIT_DIR`/`GIT_WORK_TREE` + * Fixed worktree sessions landing in another project’s leftover worktree when the working directory did not match the selected project + * Fixed background sessions whose worktree has no git repository being undeletable + * Fixed `claude daemon stop --any` potentially terminating an unrelated process via a stale legacy daemon lockfile + * Fixed Esc-Esc at an idle prompt not opening the rewind picker in long-running sessions with background tasks + * Fixed Bash command permission checking for compound statements with redirects inside `&&` lists or negations + * Fixed pressing Ctrl+X twice in the agent list failing to delete a session, and deleted sessions reappearing when their background worker had died + * Fixed background subagents getting cancelled when a high-priority message arrives during their startup window + * Fixed mouse and focus garbage in the terminal while a GUI editor from `/memory`, `/plan`, `/keybindings`, or Ctrl+G is open; `/memory` no longer waits for the editor to close + * Fixed Claude-in-Chrome 403-looping on reconnect when the session’s OAuth token lacks a required scope + * Fixed workflow saves and scheduled-task writes following a symlink at `.claude`, which could redirect writes outside the project + * Fixed MCP re-authenticate revoking working credentials before the new sign-in succeeds, and the reconnect needs-auth message in background sessions pointing at an unusable command + * Fixed read-only commands on Windows accessing network paths without a permission prompt + * Fixed Bash command parsing of non-ASCII characters to match real shell word boundaries + * Fixed PowerShell tool permission validation of commands containing invisible Unicode characters + * Fixed dialogs in fullscreen mode stretching past the right-hand edge of their panel + * Fixed the `/config` settings list in fullscreen mode clipping its keyboard-hint footer + * Fixed the transcript-mode (Ctrl+O) footer hint wrapping on terminals narrower than 104 columns + * Fixed the Prometheus metrics endpoint (`OTEL_METRICS_EXPORTER=prometheus`) emitting invalid `# UNIT` lines + * Fixed skills and commands changed during a session not appearing in the slash menu until restart + * Fixed plugin skills with a `name` frontmatter field losing their plugin prefix in slash-command autocomplete + * Fixed telemetry misreporting permission denials: failed permission-prompt requests no longer count as user rejections, and user interrupts are now reported as user aborts instead of rejections + * Improved the `/fork` confirmation to one line with the new session’s name, `claude attach` id, and a note when the copy shares your checkout + * Improved validation of `git` and `gh` command arguments in the PowerShell tool + * Improved the `/ultrareview` diff-too-large error to show configured limits, measured diff size, and largest contributing files + * Improved `/code-review ultra` empty-diff message to name the exact base ref and suggest passing an explicit base + * Improved the spend limit adjustment prompt to show the server’s reason when a spend limit change is rejected + * `/context` now shows an explicit warning when the conversation exceeds the context window, and a failed `/compact` displays as an error + * `/rewind` no longer restores or deletes files through symlinks or hard links at tracked paths and reports how many paths it skipped + * Background sessions: `/mcp` and `/install-github-app` now park a “needs input” request in the agent view when no client is attached + * Updated the bundled dataviz skill: reordered the default chart palette and fixed guidance that suggested direct labels for four-series charts + * [VSCode] Fixed right-to-left text (Arabic, Hebrew, Persian) rendering in the wrong order when mixed with English or code + * Fixed cloud sessions dropping the in-flight message when the session’s container restarts mid-turn — the interrupted turn now re-runs on resume instead of leaving the session unresponsive ​
modified Explore the .claude directory View current →
--- a/claude-directory.md +++ b/claude-directory.md @@ -20,7 +20,7 @@ ---|---|--- `managed-settings.json`| System-level, varies by OS| Enterprise-enforced settings that you can’t override. See [server-managed settings](</docs/en/server-managed-settings>). `CLAUDE.local.md`| Project root| Your private preferences for this project, loaded alongside CLAUDE.md. Create it manually and add it to `.gitignore`. -Installed plugins| `~/.claude/plugins`| Cloned marketplaces, installed plugin versions, and per-plugin data, managed by `claude plugin` commands. Orphaned versions are deleted 7 days after a plugin update or uninstall. See [plugin caching](</docs/en/plugins-reference#plugin-caching-and-file-resolution>). +Installed plugins| `~/.claude/plugins`| Cloned marketplaces, installed plugin versions, and per-plugin data, managed by `claude plugin` commands. Orphaned versions are deleted 14 days after a plugin update or uninstall. See [plugin caching](</docs/en/plugins-reference#plugin-caching-and-file-resolution>). `~/.claude` also holds data Claude Code writes as you work: transcripts, prompt history, file snapshots, caches, and logs. See application data below.
modified CLI reference View current →
--- a/cli-reference.md +++ b/cli-reference.md @@ -75,7 +75,7 @@ `--debug`| Enable debug mode with optional category filtering (for example, `"api,hooks"` or `"!statsig,!file"`)| `claude --debug "api,mcp"` `--debug-file <path>`| Write debug logs to a specific file path. Implicitly enables debug mode. Takes precedence over `CLAUDE_CODE_DEBUG_LOGS_DIR`| `claude --debug-file /tmp/claude-debug.log` `--disable-slash-commands`| Disable all skills and commands for this session| `claude --disable-slash-commands` -`--disallowedTools`, `--disallowed-tools`| Deny rules. A bare tool name removes the matching tools from the model’s context: `"Edit"` removes Edit, `"*"` removes every tool, and `"mcp__*"` removes every MCP tool. A scoped rule such as `Bash(rm *)` leaves the tool available and denies only matching calls| `"Bash(git log *)" "Bash(git diff *)" "Edit"` +`--disallowedTools`, `--disallowed-tools`| Deny rules. A bare tool name removes the matching tools from Claude’s context: `"Edit"` removes Edit, `"*"` removes every tool, and `"mcp__*"` removes every MCP tool. A scoped rule such as `Bash(rm *)` leaves the tool available and denies only matching calls. A rule naming [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) can’t remove it while any other tool remains| `"Bash(git log *)" "Bash(git diff *)" "Edit"` `--effort`| Set the [effort level](</docs/en/model-config#adjust-effort-level>) for the current session. Options: `low`, `medium`, `high`, `xhigh`, `max`, or `ultracode`. Available levels depend on the model. `ultracode` starts the session at `xhigh` effort with [ultracode](</docs/en/workflows#let-claude-decide-with-ultracode>) turned on, and requires Claude Code v2.1.203 or later. Overrides the [`effortLevel`](</docs/en/settings#available-settings>) setting for this session and does not persist| `claude --effort high` `--enable-auto-mode`| Removed in v2.1.111. Auto mode is now in the `Shift+Tab` cycle by default; use `--permission-mode auto` to start in it| `claude --permission-mode auto` `--exclude-dynamic-system-prompt-sections`| Move per-machine sections from the system prompt (working directory, environment info, memory paths, git-repo flag) into the first user message. Improves prompt-cache reuse across different users and machines running the same task. Only applies with the default system prompt; ignored when `--system-prompt` or `--system-prompt-file` is set. Use with `-p` for scripted, multi-user workloads| `claude -p --exclude-dynamic-system-prompt-sections "query"` @@ -125,7 +125,7 @@ `--teleport`| Resume a [web session](</docs/en/claude-code-on-the-web>) in your local terminal| `claude --teleport` `--teammate-mode`| Set how [agent team](</docs/en/agent-teams>) teammates display: `in-process` (default), `auto`, `tmux`, or `iterm2` (added in v2.1.186). The default changed from `auto` in v2.1.179. Overrides the [`teammateMode`](</docs/en/settings#available-settings>) setting for this session. See [Choose a display mode](</docs/en/agent-teams#choose-a-display-mode>)| `claude --teammate-mode auto` `--tmux`| Create a tmux session for the worktree. Requires `--worktree`. Uses iTerm2 native panes when available; pass `--tmux=classic` for traditional tmux| `claude -w feature-auth --tmux` -`--tools`| Restrict which built-in tools Claude can use. Use `""` to disable all, `"default"` for all, or tool names like `"Bash,Edit,Read"`. MCP tools are not affected; to deny those too, use `--disallowedTools "mcp__*"`, or pass `--strict-mcp-config` without `--mcp-config` so no MCP servers load| `claude --tools "Bash,Edit,Read"` +`--tools`| Restrict which built-in tools Claude can use. Use `""` to disable all, `"default"` for all, or tool names like `"Bash,Edit,Read"`. The flag doesn’t affect MCP tools; to deny those too, use `--disallowedTools "mcp__*"`, or pass `--strict-mcp-config` without `--mcp-config` so no MCP servers load. A list that omits [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) doesn’t remove it; `""` removes it only when no MCP tools remain| `claude --tools "Bash,Edit,Read"` `--verbose`| Enable verbose logging, shows full turn-by-turn output. Overrides the [`viewMode`](</docs/en/settings#available-settings>) setting for this session| `claude --verbose` `--version`, `-v`| Output the version number| `claude -v` `--worktree`, `-w`| Start Claude in an isolated [git worktree](</docs/en/worktrees>) at `<repo>/.claude/worktrees/<name>`. If no name is given, one is auto-generated. Pass `#<number>` or a GitHub pull request URL to fetch that PR from `origin` and branch the worktree from it| `claude -w feature-auth`
modified Give Claude custom tools View current →
--- a/custom-tools.md +++ b/custom-tools.md @@ -170,13 +170,15 @@ } } +Combine this snippet with the tool and server definitions from the weather tool example in one file, then run it with `python weather.py` for Python or `npx tsx weather.ts` for TypeScript. Claude calls `get_temperature` and the script prints a one-line answer with the current temperature in San Francisco. + ### ​ Add more tools -A server holds as many tools as you list in its `tools` array. With more than one tool on a server, you can list each one in `allowedTools` individually or use the wildcard `mcp__weather__*` to cover every tool the server exposes. The example below adds a second tool, `get_precipitation_chance`, to the `weatherServer` from the weather tool example and rebuilds it with both tools in the array. +A server holds as many tools as you list in its `tools` array. With more than one tool on a server, you can list each one in `allowedTools` individually or use the wildcard `mcp__weather__*` to cover every tool the server exposes. The example below defines a second tool, `get_precipitation_chance`, and replaces the `weatherServer` definition from the weather tool example with one that lists both tools in the array. Python @@ -256,7 +258,7 @@ tools: [getTemperature, getPrecipitationChance] }); -Every tool in this array consumes context window space on every turn. If you’re defining dozens of tools, see [tool search](</docs/en/agent-sdk/tool-search>) to load them on demand instead. +[Tool search](</docs/en/agent-sdk/tool-search>) is on by default and defers SDK MCP tools: Claude sees each tool’s name in a compact list and loads its full schema on demand. With tool search disabled, every tool in this array consumes context window space on every turn. In TypeScript, pass `alwaysLoad: true` in the `extras` argument of [`tool()`](</docs/en/agent-sdk/typescript#tool>) or in the options of [`createSdkMcpServer()`](</docs/en/agent-sdk/typescript#createsdkmcpserver>) to keep a tool’s full schema in the initial prompt. ### @@ -363,6 +365,7 @@ import json import httpx from typing import Any + from claude_agent_sdk import tool from claude_agent_sdk import tool @@ -478,6 +481,7 @@ import base64 import httpx + from claude_agent_sdk import tool from claude_agent_sdk import tool @@ -768,7 +772,7 @@ tools: [convert] }); -Once the server is defined, pass it to `query` the same way as the weather example. This example sends three different prompts in a loop to show the same tool handling different unit types. For each response, it inspects `AssistantMessage` objects (which contain the tool calls Claude made during that turn) and prints each `ToolUseBlock` before printing the final `ResultMessage` text. This lets you see when Claude is using the tool versus answering from its own knowledge. +Once the server is defined, pass it to `query` the same way as the weather example. This example sends three different prompts in a loop to show the same tool handling different unit types. For each response, it inspects `AssistantMessage` objects (which contain the tool calls Claude made during that turn) and prints each `ToolUseBlock` before printing the final `ResultMessage` text. This lets you see when Claude is using the tool versus answering from its own knowledge. Because [tool search](</docs/en/agent-sdk/tool-search>) is on by default, the output may also include a `ToolSearch` call as Claude loads the deferred tool schema. Python
modified Environment variables View current →
--- a/env-vars.md +++ b/env-vars.md @@ -258,6 +258,7 @@ `CLAUDE_CODE_OAUTH_SCOPES`| Space-separated OAuth scopes the refresh token was issued with, such as `"user:profile user:inference user:sessions:claude_code"`. Required when `CLAUDE_CODE_OAUTH_REFRESH_TOKEN` is set `CLAUDE_CODE_OAUTH_TOKEN`| OAuth access token for Claude.ai authentication. Alternative to `/login` for SDK and automated environments. Takes precedence over keychain-stored credentials. Generate one with [`claude setup-token`](</docs/en/authentication#generate-a-long-lived-token>) `CLAUDE_CODE_OPUS_4_6_FAST_MODE_OVERRIDE`| Removed in v2.1.160 and now a no-op. Previously pinned [fast mode](</docs/en/fast-mode>) to Claude Opus 4.6 instead of the current default. Opus 4.6 no longer supports fast mode +`CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH`| Maximum length of content-bearing OpenTelemetry attributes (model responses, tool content, system prompts, raw API bodies), truncation marker included, in UTF-16 code units (default: 61440, i.e. 60 KB). Raise it only if your telemetry backend accepts attribute values larger than 64 KB, or lower it to cut telemetry volume. Requires Claude Code v2.1.214 or later. See [Monitoring](</docs/en/monitoring-usage>) `CLAUDE_CODE_OTEL_DIAG_STDERR`| Set to `1` to write OpenTelemetry exporter diagnostic errors to stderr. By default these errors only appear with `--debug`, so a misconfigured exporter such as a Prometheus port collision otherwise fails silently. Requires Claude Code v2.1.179 or later. See [Monitoring](</docs/en/monitoring-usage>) `CLAUDE_CODE_OTEL_FLUSH_TIMEOUT_MS`| Timeout in milliseconds for flushing pending OpenTelemetry spans (default: 5000). See [Monitoring](</docs/en/monitoring-usage>) `CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MS`| Interval for refreshing dynamic OpenTelemetry headers in milliseconds (default: 1740000 / 29 minutes). See [Dynamic headers](</docs/en/monitoring-usage#dynamic-headers>) @@ -326,6 +327,7 @@ `CLAUDE_ENABLE_BYTE_WATCHDOG_BEDROCK`| Set to `1` to enable the byte-level streaming idle watchdog on Amazon Bedrock `vnd.amazon.eventstream` responses. Off by default. Configure the timeout with `CLAUDE_STREAM_IDLE_TIMEOUT_MS` `CLAUDE_ENABLE_STREAM_WATCHDOG`| Set to `0` to force-disable the event-level streaming idle watchdog, or set to `1` to force-enable it. When unset, the watchdog is on by default for all providers. Before v2.1.196, the unset default was server-controlled on the direct Anthropic API and off on other providers. As of v2.1.169, providers other than the direct Anthropic API and Claude Platform on AWS also have a default-on 5-minute body idle timeout independent of this variable; see `API_FORCE_IDLE_TIMEOUT`. On Amazon Bedrock, you can also enable the independent byte-level watchdog with `CLAUDE_ENABLE_BYTE_WATCHDOG_BEDROCK`; the two run together when both are set. Configure the timeout with `CLAUDE_STREAM_IDLE_TIMEOUT_MS` `CLAUDE_ENV_FILE`| Path to a shell script whose contents Claude Code runs before each Bash command in the same shell process, so exports in the file are visible to the command. Use to persist virtualenv or conda activation across commands. Also populated dynamically by [SessionStart](</docs/en/hooks#persist-environment-variables>), [Setup](</docs/en/hooks#setup>), [CwdChanged](</docs/en/hooks#cwdchanged>), and [FileChanged](</docs/en/hooks#filechanged>) hooks +`CLAUDE_PID`| Claude Code sets this to its own process ID in the subprocesses it spawns: Bash and PowerShell tool commands and hook commands. On Linux, the Bash tool’s shell integration uses it to refuse a `pkill` pattern that would match the Claude Code process itself; see [the error reference](</docs/en/errors#pkill-pattern-matches-the-claude-code-process>). Read it from your own scripts to identify or signal the parent Claude Code process deliberately. Requires Claude Code v2.1.214 or later `CLAUDE_REMOTE_CONTROL_SESSION_NAME_PREFIX`| Prefix for auto-generated [Remote Control](</docs/en/remote-control>) session names when no explicit name is provided. Defaults to your machine’s hostname, producing names like `myhost-graceful-unicorn`. The `--remote-control-session-name-prefix` CLI flag sets the same value for a single invocation `CLAUDE_STREAM_IDLE_TIMEOUT_MS`| Timeout in milliseconds before the streaming idle watchdog closes a stalled connection. When you set this variable explicitly, the minimum is `300000` (5 minutes); lower values are silently clamped to absorb extended thinking pauses and proxy buffering. When unset, the event-level watchdog defaults to 300 seconds and the byte-level watchdog defaults to 180 seconds on direct Anthropic API connections (300 seconds on Claude Platform on AWS and other providers). The unset 180-second byte-watchdog default is a separate value and is not subject to the 5-minute clamp. The body idle timeout described under `API_FORCE_IDLE_TIMEOUT` applies independently. On Amazon Bedrock, also applies when `CLAUDE_ENABLE_BYTE_WATCHDOG_BEDROCK=1` `DEBUG`| Set to `1` to enable debug mode, equivalent to launching with [`--debug`](</docs/en/cli-reference#cli-flags>). Debug logs are written to `~/.claude/debug/<session-id>.txt`, or to the path set by `CLAUDE_CODE_DEBUG_LOGS_DIR`. Only the truthy values `1`, `true`, `yes`, and `on` enable debug mode, so namespace patterns like `DEBUG=express:*` set for other tools do not trigger it @@ -375,8 +377,9 @@ `MCP_TIMEOUT`| Timeout in milliseconds for MCP server startup (default: 30000, or 30 seconds) `MCP_TOOL_TIMEOUT`| Timeout in milliseconds for MCP tool execution (default: 100000000, about 28 hours). For an HTTP, SSE, or claude.ai connector server, each request also times out after 60 seconds by default; set this variable, or the per-server `timeout`, above 60000 to raise that per-request limit. A lower value still shortens the overall tool-execution timeout but leaves the per-request limit at 60 seconds. Stdio and WebSocket servers have no per-request timer. A per-server `timeout` field in `.mcp.json` overrides this for that server. A per-server `timeout` of at least 1000 also sets the minimum idle window for that server’s tool calls, so `CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT` never aborts them sooner; this floor requires Claude Code v2.1.203 or later. For the env variable, values below 1000 are floored to one second; for the per-server field, values below 1000 are ignored `NO_PROXY`| List of domains and IPs to which requests will be directly issued, bypassing proxy +`OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT`| Standard OpenTelemetry SDK limit on attribute value length. Claude Code caps content-bearing telemetry attributes at the smaller of this and `CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH`, so the truncation marker stays within the SDK limit. Claude Code reads the `OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT` and `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT` variants the same way, and the smallest set value applies to all signals. Requires Claude Code v2.1.214 or later. See [Monitoring](</docs/en/monitoring-usage#common-configuration-variables>) `OTEL_LOG_ASSISTANT_RESPONSES`| Set to `1` to include the model’s response text on `assistant_response` OpenTelemetry log events. When unset, the value of `OTEL_LOG_USER_PROMPTS` is used instead. Set to `0` to keep responses redacted even when `OTEL_LOG_USER_PROMPTS` is set. Requires Claude Code v2.1.193 or later. See [Monitoring](</docs/en/monitoring-usage#assistant-response-event>) -`OTEL_LOG_RAW_API_BODIES`| Emit Anthropic Messages API request and response JSON as `api_request_body` / `api_response_body` log events. Set to `1` for inline bodies truncated at 60 KB, or `file:<dir>` to write untruncated bodies to disk and emit a `body_ref` path instead. Disabled by default; bodies include the entire conversation history. See [Monitoring](</docs/en/monitoring-usage#api-request-body-event>) +`OTEL_LOG_RAW_API_BODIES`| Emit Anthropic Messages API request and response JSON as `api_request_body` / `api_response_body` log events. Set to `1` for inline bodies truncated at the content limit, or `file:<dir>` to write untruncated bodies to disk and emit a `body_ref` path instead. `CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH` configures the content limit, 60 KB by default. Disabled by default; bodies include the entire conversation history. See [Monitoring](</docs/en/monitoring-usage#api-request-body-event>) `OTEL_LOG_TOOL_CONTENT`| Set to `1` to include tool input and output content in OpenTelemetry span events. Disabled by default to protect sensitive data. See [Monitoring](</docs/en/monitoring-usage>) `OTEL_LOG_TOOL_DETAILS`| Set to `1` to include tool input arguments, MCP server names, user-authored workflow names, raw error strings on tool failures, the refusal `category` on `api_refusal` events, and other tool details in OpenTelemetry traces and logs. Disabled by default to protect PII. See [Monitoring](</docs/en/monitoring-usage>) `OTEL_LOG_USER_PROMPTS`| Set to `1` to include user prompt text in OpenTelemetry traces and logs. Disabled by default (prompts are redacted). See [Monitoring](</docs/en/monitoring-usage>)
modified Error reference View current →
Show diff (362 lines)
--- a/errors.md +++ b/errors.md @@ -26,6 +26,7 @@ `Server is temporarily limiting requests`| Usage limits `Request rejected (429)`| Usage limits `Credit balance is too low`| Usage limits +`Failed to update spend limit` / `Failed to update auto-reload` / `Could not update your spend limit`| Usage limits `Not logged in · Please run /login`| Authentication `Could not resolve authentication method`| Authentication `Invalid API key`| Authentication @@ -43,6 +44,7 @@ `AWS authentication failed`| Authentication `AWS default-chain credential resolve timed out`| Authentication `Unable to connect to API`| Network +`Socket is closed`| Network `Waiting for API response · will retry in`| Automatic retries, or Network if it persists `Bedrock streaming response has content-type "..."; expected "application/vnd.amazon.eventstream"`| Network `SSL certificate verification failed`| Network @@ -50,6 +52,7 @@ `403` with `x-deny-reason: host_not_allowed` in a cloud or routine session| Network `Couldn't reconnect to your Remote Control session`| Network `Prompt is too long`| Request errors +`Context exceeds the ...-token limit by ... tokens` in `/context` output| Request errors `Error during compaction: Conversation too long`| Request errors `Request too large`| Request errors `Image was too large`| Request errors @@ -70,8 +73,12 @@ `Download timed out: exceeded the total deadline`| Installation errors `--bg and --print conflict`| Command-line errors `Error: --json-schema is not a valid JSON Schema`| Command-line errors +`Error: Settings file exceeds the 2MiB limit`| Command-line errors +`Error: Workspace not trusted` when starting Remote Control| Command-line errors `Could not import <server>: <reason>`| Command-line errors `Error: MCP tool <name> (passed via --permission-prompt-tool) not found`| Command-line errors +`Diff is too large for ultrareview` / `PR #<N> is too large for ultrareview`| Command-line errors +`Failed to resume the conversation`| Command-line errors `Marketplace "<name>" is registered from an untrusted source`| Plugin errors `references ${user_config.*} in a shell-form command`| Plugin errors `Monitor "<name>" from plugin <plugin> references ${user_config.*} in its command`| Plugin errors @@ -79,10 +86,14 @@ `would be spawned with zero tools — refusing`| Tool errors `File is covered by a Read deny rule in your permission settings`| Tool errors `Error: this write left the memory index at MEMORY.md at ..., over its ... read limit`| Tool errors +`pkill: refusing to run`| Tool errors +`Can't open MCP settings while no terminal is attached to this background session`| Background session errors `Can't open MCP settings in a background session`| Background session errors `This session has no saved transcript`| Background session errors +`This session was running agent '<name>', which is no longer available`| Background session errors `CLAUDE_CODE_PROCESS_WRAPPER: launcher ...`| Background session errors `EUNKNOWN: unknown error, uv_spawn`| Background session errors +`Restored the code, but skipped N files`| Rewind warnings `Ignoring N permissions.allow entries from ... this workspace has not been trusted`| Configuration warnings Responses seem lower quality than usual| Response quality @@ -98,7 +109,7 @@ * As of v2.1.199, a server error that arrives after Claude has already streamed visible output keeps the partial response and appends an incomplete-response notice instead of retrying, since re-running the request could execute the same tools twice. Earlier versions discarded the partial output and reported the turn as an error. * An Amazon Bedrock streaming response with an unexpected content-type fails on the first attempt, because the gateway or proxy rewriting the response would rewrite the retry the same way. Requires Claude Code v2.1.208 or later. -While retrying, the spinner shows a `Retrying in Ns · attempt x/y` countdown after an error label. The label names the specific reason from the first attempt for failures you can act on right away: the network is down, a TLS handshake failed, or you hit a rate limit. For other errors it reads `API error` at first. As of v2.1.198 it switches to the specific reason from the third attempt, or on the final attempt when `CLAUDE_CODE_MAX_RETRIES` allows fewer than three; earlier versions switch only on the final attempt. As of v2.1.198, the usual spinner tip is suppressed during retries. Once the error reason is revealed, if the failure is a 529 overload the line below the countdown also names where to check service status: `status.claude.com` on the Anthropic API, or the provider or gateway host named in the message on other configurations. If no data arrives on the response stream for 20 seconds while a request is still pending, the spinner shows `Waiting for API response · will retry in … · check your network` before any retry has started. The request has not failed yet: the countdown runs to the point where Claude Code aborts the stalled connection and retries, so the banner clears on its own once data resumes or the retry succeeds. As of v2.1.185 the threshold is 20 seconds; earlier versions show the banner after 10 seconds with different wording. If it reappears on every attempt, treat it as a network issue. When you see one of the errors on this page, those retries have already been exhausted, unless it belongs to a class that isn’t retried, such as a certificate-validation failure. You can tune the behavior with these environment variables: +While retrying, the spinner shows a `Retrying in Ns · attempt x/y` countdown after an error label. The label names the specific reason from the first attempt for failures you can act on right away: the network is down, a TLS handshake failed, or you hit a rate limit. For other errors it reads `API error` at first. As of v2.1.198 it switches to the specific reason from the third attempt, or on the final attempt when `CLAUDE_CODE_MAX_RETRIES` allows fewer than three; earlier versions switch only on the final attempt. As of v2.1.198, the usual spinner tip is suppressed during retries. Once the error reason is revealed, if the failure is a 529 overload the line below the countdown also names where to check service status: `status.claude.com` on the Anthropic API, or the provider or gateway host named in the message on other configurations. If no data arrives on the response stream for 20 seconds while a request is still pending, the spinner shows `Waiting for API response · will retry in … · check your network` before any retry has started. The request has not failed yet: the countdown runs to the point where Claude Code aborts the stalled connection and retries, so the banner clears on its own once data resumes or the retry succeeds. As of v2.1.185 the threshold is 20 seconds; earlier versions show the banner after 10 seconds with different wording. If it reappears on every attempt, treat it as a network issue. While Claude is consulting the [advisor](</docs/en/advisor>), the banner appears after 90 seconds without data instead of 20, because a long advisor review can send nothing for well over 20 seconds. Before v2.1.214, the 20-second threshold applied during advisor calls too, so the banner appeared during advisor reviews even when nothing was wrong. When you see one of the errors on this page, those retries have already been exhausted, unless it belongs to a class that isn’t retried, such as a certificate-validation failure. You can tune the behavior with these environment variables: Variable| Default| Effect ---|---|--- @@ -201,7 +212,7 @@ * If retries keep failing, continue with read-only tasks and come back to the blocked action later * This is transient and unrelated to [auto mode eligibility](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>); you don’t need to change settings -When the classifier returned an unparseable response: +When a classifier request fails because your OAuth token expired or was rotated by another session, Claude Code refreshes the token and retries the request once, so a routine token expiry doesn’t surface as this message. Before v2.1.216, an expired or rotated token failed each classifier request, and auto mode denied every checked action with this message until the token was refreshed. When the classifier returned an unparseable response: Auto mode could not evaluate this action and is blocking it for safety — run with --debug for details @@ -340,6 +351,24 @@ * Add credits at [platform.claude.com/settings/billing](<https://platform.claude.com/settings/billing>), and consider enabling auto-reload there so the balance refills before it hits zero * Switch to subscription authentication with `/login` if you have a Pro, Max, Team, or Enterprise plan * Set per-workspace spend caps in the Console to prevent a single project from draining the org balance. See [Manage costs effectively](</docs/en/costs>). + +### + +​ + +Failed to update spend limit or auto-reload + +The server rejected a spend limit or auto-reload change you made from the [`/usage-credits` dialog](</docs/en/costs#set-a-spend-limit-on-pro-and-max>) or from the prompt that appears when you reach your spend limit. + + Failed to update spend limit: <reason from the server> + Failed to update auto-reload: <reason from the server> + Could not update your spend limit: <reason from the server> + +When the server explains the rejection, for example a ceiling on auto-reload amounts, the message ends with that reason, and retrying the same value fails again. When the failure has no server-provided reason, such as a dropped connection, the message is the generic form without the trailing reason, and the spend limit prompt adds `Press Enter to retry`. Before v2.1.216, Claude Code showed the generic form for every failure. **What to do:** + + * If the message includes a reason, enter a value that satisfies it, such as a lower amount + * If the message shows only the generic form, retry; the failure may be transient + * If the change keeps failing, make it from your [claude.ai billing settings](<https://support.claude.com/en/articles/12429409-extra-usage-for-paid-claude-plans>) in the browser instead ## @@ -646,6 +675,17 @@ ​ +Socket is closed + +The connection carrying a streaming response was closed while the response was still arriving, and the failure surfaced with the text `Socket is closed`. This happens almost exclusively on Windows behind a corporate proxy, when the proxy drops an established tunnel mid-response. Claude Code treats this as a dropped connection and retries it automatically, so the turn continues. Before v2.1.214, the retry didn’t cover this failure, and the turn stopped with an error containing `Socket is closed`. **What to do:** + + * If you see this error, update to v2.1.214 or later with `claude update`, then send your message again + * If turns keep failing behind the same proxy after updating, work through Unable to connect to API and check the proxy setup in [Network configuration](</docs/en/network-config>) + +### + +​ + Bedrock streaming response has an unexpected content-type A gateway or proxy between Claude Code and [Amazon Bedrock](</docs/en/amazon-bedrock>) is transforming the streaming response body or its `Content-Type` header. Amazon Bedrock streams responses as `application/vnd.amazon.eventstream`, and Claude Code rejects a successful streaming response that reports a different content-type instead of decoding a body it can’t read. The request isn’t retried. @@ -746,6 +786,27 @@ ​ +Context exceeds the token limit + +`/context` shows this warning at the top of its output when the conversation has grown past the model’s context window. Requests fail with `Prompt is too long` until you free space. + + Context exceeds the 200k-token limit by 94k tokens — run /compact or /clear to continue. + +When the limit you exceeded is a compaction window smaller than the model’s context window, such as the 200K boundary on 1M-context models, the warning reads differently. Requests still succeed past a compaction window; run the named command to bring usage back under it. + + Context is 94k tokens past the 200k-token compaction window — run /compact to reduce usage. + +Both forms name `/clear` instead of `/compact` when you have set [`DISABLE_COMPACT`](</docs/en/env-vars>). **What to do:** + + * Run `/compact` to summarize earlier turns and free space, or `/clear` to start fresh + * For more ways to reduce usage, see Prompt is too long + +Before v2.1.216, `/context` showed usage above 100% with no warning line explaining what that meant or how to recover. + +### + +​ + Error during compaction: Conversation too long `/compact` itself failed because there is not enough free context to hold the summary it produces. @@ -756,6 +817,8 @@ * Press Esc twice to open the message list and step back several turns. This drops the most recent messages from context. Then run `/compact` again. * If stepping back doesn’t free enough space, run `/clear` to start a fresh session. Your previous conversation is preserved and can be reopened with `/resume`. + +This message and other `/compact` failures display in error styling. Before v2.1.216, they rendered in the same dim style as successful command output, so you could read a failed compaction as a success. ### @@ -814,11 +877,11 @@ PDF errors -The PDF you attached couldn’t be processed. - - PDF too large (max 100 pages, 32 MB). Try splitting it or extracting text first. - PDF is password protected. Try removing protection or extracting text first. - The PDF file was not valid. Try converting to a different format first. +The PDF you attached couldn’t be processed. The messages are shown here in their non-interactive form; in an interactive session they instead prompt you to double press esc and try again. + + PDF too large (max 100 pages, 20MB). Try reading the file a different way (e.g., extract text with pdftotext). + PDF is password protected. Try using a CLI tool to extract or convert the PDF. + The PDF file was not valid. Try converting it to text first (e.g., pdftotext). **What to do:** @@ -1082,6 +1145,39 @@ ​ +Settings file exceeds the 2MiB limit + +The file you passed to [`--settings`](</docs/en/cli-reference#cli-flags>) is larger than 2 MiB, so `claude` exits with code 1 at startup instead of loading it. A settings file is a small JSON document, so a file this large usually means the path points at the wrong file. Before v2.1.214, Claude Code read the file with no size check, and a multi-gigabyte file or a device file such as `/dev/zero` grew memory without bound. + + Error: Settings file exceeds the 2MiB limit: /path/to/settings.json + +Claude Code rejects a `--settings` path that isn’t a regular file the same way: a device, FIFO, or socket reports `Error: Cannot use settings file (Not a regular file (device, FIFO, or socket))` followed by the path, and a directory reports an `EISDIR` reason. **What to do:** + + * Point `--settings` at a regular JSON settings file under 2 MiB. See [Settings](</docs/en/settings>) for the format. + +### + +​ + +Workspace not trusted when starting Remote Control + +You started [Remote Control](</docs/en/remote-control>) server mode with `claude remote-control` or its `claude rc` alias in a directory you haven’t trusted. The command doesn’t show the workspace trust dialog itself, so it exits with code 1 and names the fix: + + Error: Workspace not trusted. Please run `claude` in /Users/you/project first to review and accept the workspace trust dialog. + +In your home directory the message is different, because the workspace trust dialog never saves trust for the home directory, so accepting it there can’t satisfy this check. Before v2.1.214, the home directory showed the message above, whose advice can’t succeed there. + + Error: Workspace not trusted. /Users/you is your home directory, and for security home-directory trust is never saved, so running `claude` here first won't help. Run `claude rc` from a project directory instead (run `claude` there once to accept the trust dialog). + +**What to do:** + + * Run `claude` in the directory, accept the [workspace trust dialog](</docs/en/permissions#project-allow-rules-and-workspace-trust>), then run `claude remote-control` again + * In your home directory, change to a project directory and start Remote Control there + +### + +​ + Could not import a server from Claude Desktop Claude Code couldn’t add one of the servers you selected in `claude mcp add-from-claude-desktop`. The command still imports the other selected servers and prints one line per server it couldn’t add. Before v2.1.205, the first server that failed stopped the import and none of the selected servers were added. @@ -1109,6 +1205,37 @@ * Confirm the tool name matches the `mcp__<server>__<tool>` name the server exposes * If the server needs longer than 30 seconds to start, raise [`MCP_TIMEOUT`](</docs/en/env-vars>) +### + +​ + +Diff is too large for ultrareview + +The diff between your branch and the base branch, including uncommitted and staged changes, exceeds the size limits for an [ultrareview](</docs/en/ultrareview>), so `/code-review ultra` and the `claude ultrareview` subcommand refuse the review before the cloud session starts. A refused review doesn’t use a free run and doesn’t bill usage credits. The message names the limits in effect, the size of your diff, and the files that contribute the most changed lines. Before v2.1.216, the message showed only the raw diff statistics. + + Diff is too large for ultrareview: 812 files, 96,410 lines changed (limits: 500 files, 8,000 lines). Largest files: package-lock.json (41,904 lines), dist/bundle.js (18,210 lines), src/generated/api.ts (9,876 lines). Pass a closer base branch (`/code-review ultra <branch>`) to narrow the scope, or split the change. + +Reviewing a pull request applies the same limits; that form of the message begins `PR #<N> is too large for ultrareview` and names the PR’s file and line counts. **What to do:** + + * Pass a base branch closer to your work, such as `/code-review ultra develop`, so the review covers only the diff against that branch + * Split the change into smaller branches and review each one. The files the message names contribute the most changed lines, so start by moving those to their own branch. + +### + +​ + +Failed to resume the conversation + +Claude Code couldn’t read or process the saved transcript for the session you selected from the [`claude --resume` picker](</docs/en/sessions#use-the-session-picker>), so it ends the process rather than continue in a partially loaded state. The message includes the command to retry: + + Failed to resume the conversation. + Run claude --resume <session-id> to retry, or claude to start a new session. + +Claude Code exits with code 1 after showing the message. The `/resume` picker inside a running session reports `Failed to resume conversation` in the conversation instead, and your current session keeps running. Before v2.1.216, a failed resume from the `claude --resume` picker stayed on the `Resuming conversation…` spinner indefinitely instead of showing this message. **What to do:** + + * Run `claude --resume <session-id>` with the session ID from the message to retry + * If the retry fails again, run `claude` to start a new session + ## ​ @@ -1179,7 +1306,7 @@ * Correct each entry the error names against the [tools available to subagents](</docs/en/sub-agents#available-tools>) * Remove entries for tools the session doesn’t have, such as MCP tools from a server that isn’t connected - * To give the subagent every tool the parent has, delete the `tools` field instead of listing tools + * To give the subagent every [subagent-available](</docs/en/sub-agents#available-tools>) tool the parent has, delete the `tools` field instead of listing tools ### @@ -1211,6 +1338,21 @@ * Let Claude rewrite `MEMORY.md`, or ask it to: keep one line per entry, move detail into topic files, and merge or drop stale entries * To trim the index yourself, see [Audit and edit your memory](</docs/en/memory#audit-and-edit-your-memory>) +### + +​ + +pkill pattern matches the Claude Code process + +A `pkill` command in a Bash tool call used a pattern, typically with `-f`, that matches the Claude Code process itself, so Claude Code refuses the command instead of letting it end the session. Claude Code tests the pattern with `pgrep` before running `pkill` and refuses when its own process ID is in the result. The check runs on Linux only; on macOS, `pkill` runs unmodified. Before v2.1.214, the command ran, and a matching pattern killed the Claude Code session mid-turn. + + pkill: refusing to run — this pattern matches the Claude CLI process (PID 12345). Narrow the pattern, or target your own children with `pkill -P $$ ...`. + +The refusal appears in the Bash tool result rather than as a banner in your terminal, and Claude usually adjusts the command on its own. **What to do:** + + * Narrow the pattern so it matches only the intended process, for example the full path of the target binary rather than a short substring + * To stop processes started by the current shell, use `pkill -P $$` with the pattern, which limits the match to the shell’s own child processes + ## ​ @@ -1225,14 +1367,14 @@ Commands refused in a background session -Commands that open an interactive dialog are refused in a background session with a message naming a form that works there or telling you to run the command from a regular terminal. `/install-github-app`, the `/mcp` settings list, and the authentication actions in the MCP server menu are all refused this way. Before v2.1.208, they opened their dialog inside the background session. In v2.1.208 only, the `/model` picker was also refused in a background session, and `/upgrade` printed the upgrade URL instead of opening a browser. The wording names the command that was refused. The `/mcp` settings list reports: - - Can't open MCP settings in a background session — use `/mcp enable|disable|reconnect <server>` to steer, or run /mcp from an interactive terminal to authenticate. - -**What to do:** - - * Use the form the message names, such as `/mcp reconnect <server>`, `/mcp enable`, or `/mcp disable` - * For sign-in and authorization flows, run the command from a regular `claude` session in a terminal +Commands that open an interactive dialog can’t do so while no terminal is attached to a background session. `/install-github-app`, the `/mcp` settings list, and the authentication actions in the MCP server menu respond with a message, and the session appears under **Needs input** in [agent view](</docs/en/agent-view>) so you can find it, attach, and run the command again. While a terminal is attached, these commands work normally. Before v2.1.216, Claude Code refused these commands outright: in v2.1.214 and v2.1.215 the message told you to attach and run the command again, and from v2.1.208 through v2.1.212 Claude Code refused them even while a terminal was attached, with a message naming a form that works there, such as `Can't open MCP settings in a background session`. Before v2.1.208, they opened their dialog inside the background session. In v2.1.208 only, Claude Code also refused the `/model` picker in a background session, and `/upgrade` printed the upgrade URL instead of opening a browser. The wording names the command. The `/mcp` settings list reports: + + Can't open MCP settings while no terminal is attached to this background session. This session now shows "needs input" in agent view — open it and run /mcp to manage servers, or use `/mcp enable|disable|reconnect <server>` to steer without the panel. + +**What to do:** + + * Attach to the session from agent view, where it’s listed under **Needs input** , and run the command again + * Or use the form the message names, such as `/mcp reconnect <server>`, `/mcp enable`, or `/mcp disable`, which work without attaching ### @@ -1248,6 +1390,23 @@ * The conversation you backgrounded from is intact: resume it with [`claude --resume`](</docs/en/sessions>) or keep working in it * To start the stopped session fresh anyway, run `claude respawn <id>` with the ID from the message, or press `Enter` twice on its row in agent view + * If the session did finish a response and you still see this refusal on a version before v2.1.214, an unreadable folder in `~/.claude/projects` could make the transcript scan miss the saved conversation; update to v2.1.214 or later, which tolerates unreadable folders during the scan + +### + +​ + +Session agent no longer available + +You resumed a session that was running a [custom agent](</docs/en/sub-agents#invoke-subagents-explicitly>), started with `--agent` or the `agent` setting, and no agent by that name exists anymore. Claude Code searches the session’s original directory first, when you have [trusted that workspace](</docs/en/permissions#project-allow-rules-and-workspace-trust>), then the directory you resume from, and warns when neither has the agent. The session still resumes, but with the default tools and system prompt, so the agent’s tool restrictions no longer apply: + + This session was running agent 'code-reviewer', which is no longer available (no agent by that name in /home/you/project). Continuing with the default tools and system prompt — the agent's tool restrictions no longer apply. To restore it, re-create the agent, or resume with an explicit --agent <name>. + +The warning names only the directories Claude Code searched, and it appears in the resumed conversation whether you wake a [background session](</docs/en/agent-view>), run `/resume` or `claude --resume`, or resume in [non-interactive mode](</docs/en/headless>), where it also goes to stderr. Sessions using `--input-format stream-json` don’t show it, because the Agent SDK supplies agents after startup. Claude Code doesn’t save the fallback to the session, so the warning repeats on each resume until you act. The built-in `claude` agent doesn’t trigger the warning, since falling back to the default toolset changes nothing for it. Before v2.1.216, Claude Code silently continued as the default agent, and the lookup covered only the directory you resumed from, so a project-scoped agent was lost on any resume from another directory. **What to do:** + + * Re-create the agent file at `.claude/agents/<name>.md` in the session’s project, or at `~/.claude/agents/<name>.md` for a personal agent, then resume again + * Or resume with `--agent <name>` naming an agent that does exist, to run the session as that agent instead + * If the agent is project-scoped and you haven’t trusted the session’s original directory, run Claude Code there once, accept the trust dialog, then resume again ### @@ -1280,6 +1439,36 @@ * If the message reads `Couldn't start the session`, upgrade to v2.1.212 or later. On earlier versions you can also run `claude daemon run` in a separate terminal first, then start the background session again. That command runs the background service in the terminal’s foreground, so the service lasts only as long as that terminal stays open. * If the error appears on v2.1.212 or later, ask your Windows administrator to allow the Claude Code executable in the restriction policy * If the background service stops when you close the terminal, Claude Code started it without PowerShell. Install PowerShell 7, or ask your administrator to unblock PowerShell, so the service can outlive the terminal. + +## + +​ + +Rewind warnings + +This warning comes from a [`/rewind`](</docs/en/checkpointing>) code restore. It reports paths the restore refused to touch; the restore completed for every other tracked file. + +### + +​ + +Restored the code, but skipped files + +A `/rewind` code restore skipped one or more tracked paths instead of writing or deleting through them. Claude Code skips a path when: + + * it is, or became, a symlink, hard link, or other non-regular file + * its directory changed since the checkpoint + * its backup can’t be safely read + +Skipped paths keep their current contents. Before v2.1.216, `/rewind` wrote and deleted through links at tracked paths, and didn’t report a partial restore. + + Restored the code, but skipped 2 files: the tracked path is (or became) a link or other non-regular file, its directory changed since the checkpoint, or its backup could not be safely read. Skipped files were left untouched — run with --debug for the paths. + +**What to do:** + + * Run Claude Code with `--debug` and repeat the restore. The debug log names each skipped path. + * If a skipped file is a link you created on purpose, such as a config file managed by a dotfile manager or a file hard-linked by tools like pnpm, restore its contents from [version control](</docs/en/checkpointing#not-a-replacement-for-version-control>) instead + * If you didn’t create the link, inspect the path before trusting its contents: something replaced the file after the checkpoint ##
modified Fullscreen rendering View current →
--- a/fullscreen.md +++ b/fullscreen.md @@ -10,7 +10,7 @@ Enable fullscreen rendering -Run `/tui fullscreen` inside any Claude Code conversation. The CLI saves the [`tui` setting](</docs/en/settings#available-settings>) and relaunches into fullscreen with your conversation intact, so you can switch mid-session without losing context. Run `/tui default` to switch back to the classic renderer, or `/tui` with no argument to print which renderer is active. The relaunched session keeps the conversation as it appears on screen. If you ran [`/rewind`](</docs/en/checkpointing#rewind-and-summarize>) earlier in the session, the relaunch resumes from the rewound point rather than the longer transcript saved on disk. Before v2.1.207, switching renderers after a rewind restored the conversation the rewind had removed. You can also set the `CLAUDE_CODE_NO_FLICKER` environment variable before starting Claude Code: +Run `/tui fullscreen` inside any Claude Code conversation. The CLI saves the [`tui` setting](</docs/en/settings#available-settings>) and relaunches into fullscreen with your conversation intact, so you can switch mid-session without losing context. Run `/tui default` to switch back to the classic renderer, or `/tui` with no argument to print which renderer is active. In [screen reader mode](</docs/en/accessibility>), Claude Code always uses the classic renderer except in attached [background sessions](</docs/en/agent-view>), which still render fullscreen. If you run `/tui fullscreen` in any other session, Claude Code prints an explanation instead of switching and doesn’t change the saved `tui` setting. The relaunched session keeps the conversation as it appears on screen. If you ran [`/rewind`](</docs/en/checkpointing#rewind-and-summarize>) earlier in the session, the relaunch resumes from the rewound point rather than the longer transcript saved on disk. Before v2.1.207, switching renderers after a rewind restored the conversation the rewind had removed. You can also set the `CLAUDE_CODE_NO_FLICKER` environment variable before starting Claude Code: CLAUDE_CODE_NO_FLICKER=1 claude
modified Hooks reference View current →
Show diff (171 lines)
--- a/hooks.md +++ b/hooks.md @@ -12,7 +12,7 @@ * once per session: `SessionStart` and `SessionEnd` * once per turn: `UserPromptSubmit`, `Stop`, and `StopFailure` - * on every tool call inside the agentic loop: `PreToolUse` and `PostToolUse` + * on every tool call inside the agentic loop: `PreToolUse` and `PostToolUse`, except [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) calls, which skip both The table below summarizes when each event fires. The Hook events section documents the full input schema and decision control options for each one. @@ -41,8 +41,8 @@ `ConfigChange`| When a configuration file changes during a session `CwdChanged`| When the working directory changes, for example when Claude executes a `cd` command. Useful for reactive environment management with tools like direnv `FileChanged`| When a watched file changes on disk. The `matcher` field specifies which filenames to watch -`WorktreeCreate`| When a worktree is being created via `--worktree` or `isolation: "worktree"`. Replaces default git behavior -`WorktreeRemove`| When a worktree is being removed, either at session exit or when a subagent finishes +`WorktreeCreate`| When a worktree is being created via `--worktree`, `isolation: "worktree"`, or for a background session. Replaces default git behavior +`WorktreeRemove`| When a worktree is being removed at session exit, when a subagent finishes, or when you delete a background session `PreCompact`| Before context compaction `PostCompact`| After context compaction completes `Elicitation`| When an MCP server requests user input during a tool call @@ -193,7 +193,7 @@ Event| What the matcher filters| Example matcher values ---|---|--- `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `PermissionRequest`, `PermissionDenied`| tool name| `Bash`, `Edit|Write`, `mcp__.*` -`SessionStart`| how the session started| `startup`, `resume`, `clear`, `compact` +`SessionStart`| how the session started| `startup`, `resume`, `clear`, `compact`, `fork` `Setup`| which CLI flag triggered setup| `init`, `maintenance` `SessionEnd`| why the session ended| `clear`, `resume`, `logout`, `prompt_input_exit`, `bypass_permissions_disabled`, `other` `Notification`| notification type| `permission_prompt`, `idle_prompt`, `auth_success`, `elicitation_dialog`, `elicitation_complete`, `elicitation_response`, `agent_needs_input`, `agent_completed` @@ -307,7 +307,7 @@ `statusMessage`| no| Custom spinner message displayed while the hook runs `once`| no| If `true`, runs once per session then is removed. Only honored for hooks declared in skill frontmatter; ignored in settings files and agent frontmatter -The `if` field holds exactly one permission rule. There is no `&&`, `||`, or list syntax for combining rules; to apply multiple conditions, define a separate hook handler for each. For Bash patterns, whether your hook command runs depends on the shape of the pattern and the Bash command Claude is invoking. Leading `VAR=value` assignments are stripped before matching. +The `if` field holds exactly one permission rule. There is no `&&`, `||`, or list syntax for combining rules; to apply multiple conditions, define a separate hook handler for each. In an `if` condition for a file tool, a single-segment directory pattern like `"Edit(src/**)"` matches only the `src` directory in the working directory and the files under it. To match a directory named `src` at any depth, write `"Edit(**/src/**)"`. Before v2.1.214, `"Edit(src/**)"` matched a directory named `src` at any depth under the working directory. For Bash patterns, whether your hook command runs depends on the shape of the pattern and the Bash command Claude is invoking. Leading `VAR=value` assignments are stripped before matching. `if` pattern| Bash command| Hook runs?| Why ---|---|---|--- @@ -606,7 +606,7 @@ Exit code output -The exit code from your hook command tells Claude Code whether the action should proceed, be blocked, or be ignored. **Exit 0** means success. Claude Code parses stdout for JSON output fields. JSON output is only processed on exit 0. For most events, stdout is written to the debug log but not shown in the transcript. The exceptions are `UserPromptSubmit`, `UserPromptExpansion`, and `SessionStart`, where stdout is added as context that Claude can see and act on. **Exit 2** means a blocking error. Claude Code ignores stdout and any JSON in it. Instead, stderr text is fed back to Claude as an error message. The effect depends on the event: `PreToolUse` blocks the tool call, `UserPromptSubmit` rejects the prompt, and so on. See exit code 2 behavior for the full list. **Any other exit code** is a non-blocking error for most hook events. The transcript shows a `<hook name> hook error` notice followed by the first line of stderr, so you can identify the cause without `--debug`. Execution continues and the full stderr is written to the debug log. For example, a hook command script that blocks dangerous Bash commands: +The exit code from your hook command tells Claude Code whether the action should proceed, be blocked, or be ignored. **Exit 0** means success. Claude Code parses stdout for JSON output fields. JSON output is only processed on exit 0. For most events, stdout is written to the debug log but not shown in the transcript. The exceptions are `UserPromptSubmit`, `UserPromptExpansion`, and `SessionStart`, where stdout is added as context that Claude can see and act on. **Exit 2** means a blocking error. Claude Code ignores stdout and any JSON in it. Instead, stderr text is fed back to Claude as an error message. The effect depends on the event: `PreToolUse` blocks the tool call, `UserPromptSubmit` rejects the prompt, and so on. See exit code 2 behavior for the full list. A hook that exits 2 while printing JSON that fails JSON output schema validation still blocks: Claude Code uses stderr as the blocking reason and records the validation failure in the debug log. Before v2.1.214, Claude Code treated that combination as a non-blocking error and the action proceeded. **Any other exit code** is a non-blocking error for most hook events. The transcript shows a `<hook name> hook error` notice followed by the first line of stderr, so you can identify the cause without `--debug`. Execution continues and the full stderr is written to the debug log. For example, a hook command script that blocks dangerous Bash commands: #!/bin/bash # Reads JSON input from stdin, checks the command @@ -766,7 +766,7 @@ * **Conditional project rules** : which test command applies to the file just edited, which directories are read-only in this worktree * **External data** : open issues assigned to you, recent CI results, content fetched from an internal service -For instructions that never change, prefer [CLAUDE.md](</docs/en/memory>). It loads without running a script and is the standard place for static project conventions. Write the text as factual statements rather than imperative system instructions. Phrasing such as “The deployment target is production” or “This repo uses `bun test`” reads as project information. Text framed as out-of-band system commands can trigger Claude’s prompt-injection defenses, which causes Claude to surface the text to you instead of treating it as context. Once injected, the text is saved in the session transcript. For mid-session events like `PostToolUse` or `UserPromptSubmit`, resuming with `--continue` or `--resume` replays the saved text rather than re-running the hook for past turns, so values like timestamps or commit SHAs become stale on resume. `SessionStart` hooks run again on resume with `source` set to `"resume"`, so they can refresh their context. +For instructions that never change, prefer [CLAUDE.md](</docs/en/memory>). It loads without running a script and is the standard place for static project conventions. Write the text as factual statements rather than imperative system instructions. Phrasing such as “The deployment target is production” or “This repo uses `bun test`” reads as project information. Text framed as out-of-band system commands can trigger Claude’s prompt-injection defenses, which causes Claude to surface the text to you instead of treating it as context. Claude Code saves the injected text in the session transcript. For mid-session events like `PostToolUse` or `UserPromptSubmit`, when you resume with `--continue` or `--resume`, Claude Code replays the saved text rather than re-running the hook for past turns, so values like timestamps or commit SHAs become stale. `SessionStart` hooks run again on resume with `source` set to `"resume"`, or `"fork"` if you added `--fork-session`, so they can refresh their context. #### @@ -860,6 +860,9 @@ `resume`| `--resume`, `--continue`, or `/resume` `clear`| `/clear` `compact`| Auto or manual compaction +`fork`| A new session forked from an existing one: `--fork-session` with `--resume` or `--continue`, the `/fork` background copy, or `/branch` + +Before v2.1.214, forked sessions reported source `"resume"`. #### @@ -871,7 +874,7 @@ Field| Description ---|--- -`source`| How the session started: `"startup"` for new sessions, `"resume"` for resumed sessions, `"clear"` after `/clear`, or `"compact"` after compaction +`source`| How the session started: `"startup"` for new sessions, `"resume"` for resumed sessions, `"clear"` after `/clear`, `"compact"` after compaction, or `"fork"` for a new session forked from an existing one `model`| The active model identifier. It can be omitted, for example after `/clear` or when a session is restored through conversation recovery, so check for the field before reading it `agent_type`| The agent name, present when you start Claude Code with `claude --agent <name>` `session_title`| The current session title if one is already set, for example via `--name` or `/rename`. A hook that emits `sessionTitle` can check `session_title` first to avoid overwriting a title the user set explicitly @@ -897,7 +900,7 @@ ---|--- `additionalContext`| String added to Claude’s context at the start of the conversation, before the first prompt. See Add context for Claude for how the text is delivered and what to put in it `initialUserMessage`| String used as the first user message of the session. Applies in [non-interactive mode](</docs/en/headless>) with the `-p` flag, where it becomes the first turn even if no prompt is provided. If a prompt is provided, it follows as the next turn. Unlike `additionalContext`, which attaches to an existing turn, this creates the turn -`sessionTitle`| Sets the session title, with the same effect as `/rename`. Use to name sessions automatically from the launch folder, git branch, or worktree name. Applies only when `source` is `"startup"` or `"resume"`; ignored on `"clear"` and `"compact"` +`sessionTitle`| Sets the session title, with the same effect as `/rename`. Use to name sessions automatically from the launch folder, git branch, or worktree name. Applies when `source` is `"startup"`, `"resume"`, or `"fork"`; ignored on `"clear"` and `"compact"` `watchPaths`| Array of absolute paths to watch for FileChanged events during this session `reloadSkills`| Boolean. When `true`, Claude Code re-scans the [skill](</docs/en/skills>) and command directories after the SessionStart hooks complete, so skills the hook installed are available in the same session, starting with the first prompt @@ -1292,7 +1295,7 @@ Runs after Claude creates tool parameters and before processing the tool call. Matches on tool name: `Bash`, `Edit`, `Write`, `Read`, `Glob`, `Grep`, `Agent`, `WebFetch`, `WebSearch`, `AskUserQuestion`, `ExitPlanMode`, and any MCP tool names. -PreToolUse runs only when Claude calls a tool. Files you [reference with `@` in your prompt](</docs/en/common-workflows#reference-files-and-directories>) are added without any tool call: Claude Code inserts their contents while building the prompt, so no PreToolUse hook fires for them, including hooks matching `Read`. To block specific paths from `@` references, use a [`Read` deny rule](</docs/en/permissions#read-and-edit>) instead. +PreToolUse runs only when Claude calls a tool. Files you [reference with `@` in your prompt](</docs/en/common-workflows#reference-files-and-directories>) are added without any tool call: Claude Code inserts their contents while building the prompt, so no PreToolUse hook fires for them, including hooks matching `Read`. To block specific paths from `@` references, use a [`Read` deny rule](</docs/en/permissions#read-and-edit>) instead.PreToolUse also doesn’t fire for [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>). Use PreToolUse decision control to allow, deny, ask, or defer the tool call. An [Agent SDK callback hook](</docs/en/agent-sdk/hooks>) on `PreToolUse` that exceeds its timeout blocks the tool call, and Claude receives an error result naming the timeout. An explicit deny returned by another hook still takes precedence. @@ -1404,13 +1407,14 @@ `status`| string| `"completed"`| `"completed"` for foreground subagents, `"async_launched"` for background subagents. As of v2.1.198, subagents run in the background by default, so an omitted `run_in_background` also produces `"async_launched"` `agentId`| string| `"a4d2c8f1e0b3a297"`| Identifier for the subagent run `content`| array| `[{"type": "text", "text": "Found 12 endpoints..."}]`| The subagent’s final text blocks -`resolvedModel`| string| `"claude-sonnet-4-5"`| Model the subagent ran on, which may differ from the requested model. Requires Claude Code v2.1.174 or later +`resolvedModel`| string| `"claude-sonnet-4-5"`| Model the subagent started on, which may differ from the requested model. Requires Claude Code v2.1.174 or later +`modelsUsed`| array| `["claude-sonnet-4-5", "claude-haiku-4-5"]`| Models used in order, with consecutive repeats collapsed; set only when the model was swapped mid-run. Requires Claude Code v2.1.212 or later `totalTokens`| number| `12450`| Total tokens billed across the subagent’s turns `totalDurationMs`| number| `48211`| Wall-clock duration of the subagent run `totalToolUseCount`| number| `7`| Count of tool calls the subagent made `usage`| object| `{"input_tokens": 8320, ...}`| Per-type token breakdown: `input_tokens`, `output_tokens`, `cache_creation_input_tokens`, `cache_read_input_tokens` -For background subagents, the tool returns immediately after launching, so `tool_response` carries no usage fields. It has `status: "async_launched"`, `agentId`, `description`, `prompt`, `outputFile`, and `resolvedModel`. The `resolvedModel` field names the model the subagent actually runs on, which can differ from the `model` value in `tool_input`, such as when `availableModels` or another override applies. It requires Claude Code v2.1.174 or later. +For background subagents, the tool returns when the task moves to the background, so `tool_response` carries no usage fields: a background launch returns immediately, and a foreground task that Claude Code backgrounds mid-run returns at that transition. It has `status: "async_launched"`, `agentId`, `description`, `prompt`, `outputFile`, and `resolvedModel`. On a `completed` response, `resolvedModel` names the model the subagent started on, which can differ from the `model` value in `tool_input`, such as when `availableModels` or another override applies. It requires Claude Code v2.1.174 or later. On an `async_launched` response, `resolvedModel` names the model in use when the agent moved to the background, so a swap that happened before backgrounding is reflected there. `modelsUsed` and the backgrounding-time `resolvedModel` behavior require Claude Code v2.1.212 or later. ##### AskUserQuestion @@ -1512,7 +1516,7 @@ PermissionRequest input -PermissionRequest hooks receive `tool_name` and `tool_input` fields like PreToolUse hooks, but without `tool_use_id`. An optional `permission_suggestions` array contains the “always allow” options the user would normally see in the permission dialog. The difference is when the hook fires: PermissionRequest hooks run when a permission dialog is about to be shown to the user, while PreToolUse hooks run before tool execution regardless of permission status. +PermissionRequest hooks receive `tool_name` and `tool_input` fields like PreToolUse hooks, but without `tool_use_id`. An optional `permission_suggestions` array contains the “always allow” options the user would normally see in the permission dialog. The difference from PreToolUse is when the hook fires: PermissionRequest hooks run when a permission dialog is about to be shown to the user, while PreToolUse hooks run before tool execution regardless of permission status. Neither event fires for [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>). { "session_id": "abc123", @@ -2448,7 +2452,7 @@ WorktreeCreate -Runs when a worktree is being created, either from `claude --worktree` or from a [subagent using `isolation: "worktree"`](</docs/en/sub-agents#choose-the-subagent-scope>). By default Claude Code creates the isolated working copy with `git worktree`. Configuring a WorktreeCreate hook replaces that default git behavior, letting you use a different version control system like SVN, Perforce, or Mercurial. Because the hook replaces the default behavior entirely, [`.worktreeinclude`](</docs/en/worktrees#copy-gitignored-files-into-worktrees>) is not processed. If you need to copy local configuration files like `.env` into the new worktree, do it inside your hook script. The hook must return the path to the created worktree directory. Claude Code uses this path as the working directory for the isolated session. See WorktreeCreate output for how each hook type returns the path. This example creates an SVN working copy and prints the path for Claude Code to use. Replace the repository URL with your own: +Runs when a worktree is being created, whether from `claude --worktree`, from a [subagent using `isolation: "worktree"`](</docs/en/sub-agents#choose-the-subagent-scope>), or for a [background session](</docs/en/agent-view#how-file-edits-are-isolated>) that Claude Code isolates in its own worktree. By default Claude Code creates the isolated working copy with `git worktree`. Configuring a WorktreeCreate hook replaces that default git behavior, letting you use a different version control system like SVN, Perforce, or Mercurial. Because the hook replaces the default behavior entirely, [`.worktreeinclude`](</docs/en/worktrees#copy-gitignored-files-into-worktrees>) is not processed. If you need to copy local configuration files like `.env` into the new worktree, do it inside your hook script. The hook must return the path to the created worktree directory. Claude Code uses this path as the working directory for the isolated session. See WorktreeCreate output for how each hook type returns the path. This example creates an SVN working copy and prints the path for Claude Code to use. Replace the repository URL with your own: { "hooks": { @@ -2494,7 +2498,7 @@ * **Command hooks** (`type: "command"`): print the path as the last non-empty line of stdout. Claude Code strips ANSI escape codes before reading that line, so shell startup banners printed before your `echo` are ignored. Redirect any other hook output to stderr. * **HTTP hooks** (`type: "http"`): return `{ "hookSpecificOutput": { "hookEventName": "WorktreeCreate", "worktreePath": "/absolute/path" } }` in the response body. -If the hook fails or produces no path, worktree creation fails with an error. Claude Code resolves a relative path against the directory the hook ran in. If the resulting path isn’t a directory Claude Code can enter, the session prints an error naming the path and exits with code 1. Before v2.1.205, a relative path or a path that didn’t exist on disk crashed the session at startup, and with `-p` it stalled for about 30 seconds before exiting with code 0. +If the hook fails or produces no path, worktree creation fails with an error. Claude Code resolves a relative path against the directory the hook ran in, collapsing any `.` or `..` segments in it. If the resulting path isn’t a directory Claude Code can enter, the session prints an error naming the path and exits with code 1. Before v2.1.205, a relative path or a path that didn’t exist on disk crashed the session at startup, and with `-p` it stalled for about 30 seconds before exiting with code 0. Claude Code refuses an absolute path that contains `.` or `..` segments, and any path that passes through a symlink below the repository root, because a symlink committed to the repository could redirect the worktree outside it. The error names the rejected component. Return a normalized path that doesn’t pass through a symlink inside the repository. Before v2.1.216, worktree creation followed the hook’s path without this screening. ### @@ -2502,7 +2506,13 @@ WorktreeRemove -Runs when a worktree is being removed, either when you exit a `--worktree` session and choose to remove it, or when a subagent with `isolation: "worktree"` finishes. This is the cleanup counterpart to WorktreeCreate. For git-based worktrees, Claude Code handles cleanup automatically with `git worktree remove`. If you configured a WorktreeCreate hook for a non-git version control system, pair it with a WorktreeRemove hook to handle cleanup. Without one, the worktree directory is left on disk. Claude Code passes the path returned by WorktreeCreate as `worktree_path` in the hook input. This example reads that path and removes the directory: +Runs when a worktree is being removed. This is the cleanup counterpart to WorktreeCreate. The event fires when: + + * you exit a `--worktree` session and choose to remove it + * a subagent with `isolation: "worktree"` finishes + * you delete a [background session](</docs/en/agent-view#organize-the-list>) whose worktree the hook created + +For git-based worktrees, Claude Code handles cleanup automatically with `git worktree remove`. If you configured a WorktreeCreate hook for a non-git version control system, pair it with a WorktreeRemove hook to handle cleanup. Without one, the worktree directory is left on disk. For a background-session delete, Claude Code verifies the stored worktree path before running the hook and refuses a path that is a symlink or passes through one below the repository root. The hook runs for a worktree that still contains files only when you confirm the delete in [agent view](</docs/en/agent-view#organize-the-list>); for such a worktree, [`claude rm`](</docs/en/agent-view#manage-sessions-from-the-shell>) keeps the session and worktree instead. Before v2.1.216, the hook ran on the stored path without these checks. Claude Code passes the path returned by WorktreeCreate as `worktree_path` in the hook input. This example reads that path and removes the directory: { "hooks": { @@ -3137,11 +3147,10 @@ Debug hooks -Hook execution details, including which hooks matched, their exit codes, and full stdout and stderr, are written to the debug log file. Start Claude Code with `claude --debug-file <path>` to write the log to a known location, or run `claude --debug` and read the log at `~/.claude/debug/<session-id>.txt`. The `--debug` flag doesn’t print to the terminal. - - [DEBUG] Executing hooks for PostToolUse:Write - [DEBUG] Found 1 hook commands to execute - [DEBUG] Executing hook command: <Your command> with timeout 600000ms - [DEBUG] Hook command completed with status 0: <Your stdout> +Hook execution details, including which hooks matched, their exit codes, and full stdout and stderr, are written to the debug log file. Start Claude Code with `claude --debug-file <path>` to write the log to a known location, or run `claude --debug` and read the log at `~/.claude/debug/<session-id>.txt`. The `--debug` flag doesn’t print to the terminal. For example, a `PostToolUse` hook on `Write` whose command prints `hook-ran` produces entries like: + + 2026-07-19T02:03:24.382Z [DEBUG] Hook output does not start with {, treating as plain text + 2026-07-19T02:03:24.382Z [DEBUG] Hook PostToolUse:Write (PostToolUse) success: + hook-ran For more granular hook matching details, set `CLAUDE_CODE_DEBUG_LOG_LEVEL=verbose` to see additional log lines such as hook matcher counts and query matching. For troubleshooting common issues like hooks not firing, Stop hooks that keep blocking, or configuration errors, see [Limitations and troubleshooting](</docs/en/hooks-guide#limitations-and-troubleshooting>) in the guide. For a broader diagnostic walkthrough covering `/context`, `/doctor`, and settings precedence, see [Debug your config](</docs/en/debug-your-config>).
modified Automate actions with hooks View current →
--- a/hooks-guide.md +++ b/hooks-guide.md @@ -431,8 +431,8 @@ `ConfigChange`| When a configuration file changes during a session `CwdChanged`| When the working directory changes, for example when Claude executes a `cd` command. Useful for reactive environment management with tools like direnv `FileChanged`| When a watched file changes on disk. The `matcher` field specifies which filenames to watch -`WorktreeCreate`| When a worktree is being created via `--worktree` or `isolation: "worktree"`. Replaces default git behavior -`WorktreeRemove`| When a worktree is being removed, either at session exit or when a subagent finishes +`WorktreeCreate`| When a worktree is being created via `--worktree`, `isolation: "worktree"`, or for a background session. Replaces default git behavior +`WorktreeRemove`| When a worktree is being removed at session exit, when a subagent finishes, or when you delete a background session `PreCompact`| Before context compaction `PostCompact`| After context compaction completes `Elicitation`| When an MCP server requests user input during a tool call @@ -502,7 +502,7 @@ } } -Your script can parse that JSON and act on any of those fields. `UserPromptSubmit` hooks get the `prompt` text instead, `SessionStart` hooks get a `source` of `startup`, `resume`, `clear`, or `compact`, and so on. See [Common input fields](</docs/en/hooks#common-input-fields>) in the reference for shared fields, and each event’s section for event-specific schemas. +Your script can parse that JSON and act on any of those fields. `UserPromptSubmit` hooks get the `prompt` text instead, `SessionStart` hooks get a `source` of `startup`, `resume`, `clear`, `compact`, or `fork`, and so on. See [Common input fields](</docs/en/hooks#common-input-fields>) in the reference for shared fields, and each event’s section for event-specific schemas. #### @@ -596,7 +596,7 @@ Event| What the matcher filters| Example matcher values ---|---|--- `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `PermissionRequest`, `PermissionDenied`| tool name| `Bash`, `Edit|Write`, `mcp__.*` -`SessionStart`| how the session started| `startup`, `resume`, `clear`, `compact` +`SessionStart`| how the session started| `startup`, `resume`, `clear`, `compact`, `fork` `Setup`| which CLI flag triggered setup| `init`, `maintenance` `SessionEnd`| why the session ended| `clear`, `resume`, `logout`, `prompt_input_exit`, `bypass_permissions_disabled`, `other` `Notification`| notification type| `permission_prompt`, `idle_prompt`, `auth_success`, `elicitation_dialog`, `elicitation_complete`, `elicitation_response`, `agent_needs_input`, `agent_completed`
modified Set up Claude Code in a monorepo or large codebase View current →
--- a/large-codebases.md +++ b/large-codebases.md @@ -105,7 +105,7 @@ API routes are in src/routes/. Each route file exports an Express router. Database queries use Knex in src/db/. Never write raw SQL strings in route handlers. -When you start Claude from `packages/api/`, it loads both `packages/api/CLAUDE.md` and the root `CLAUDE.md`. Claude sees the local instructions alongside the repository-wide rules, with no instructions from `packages/web/` in context. The same holds for any subdirectory in a non-monorepo tree. A few ways to keep the files current as the codebase and models change: +When you start Claude from `packages/api/`, it loads both `packages/api/CLAUDE.md` and the root `CLAUDE.md`. Claude sees the local instructions alongside the repository-wide rules, with no instructions from `packages/web/` in context. The same holds for any subdirectory in a non-monorepo tree. To confirm which files loaded, run `/context` and check the list under **Memory files**. A few ways to keep the files current as the codebase and models change: * **Review in pull requests** : treat CLAUDE.md edits like any other documentation change so conventions track the code * **Revisit after major model releases** : instructions that worked around an older model’s limitation may become overhead once a newer model handles the case on its own. For example, a rule that forces single-file refactors can be deleted once the limitation is gone @@ -134,21 +134,20 @@ Exclude irrelevant CLAUDE.md files -When you start Claude from the repository root, each subdirectory’s CLAUDE.md loads as soon as Claude reads a file in that directory. The `claudeMdExcludes` setting skips specific files by path or glob pattern so they never load. Use this for directories you never work in, such as other teams’ packages, legacy code, or vendored subtrees. The exclusion list is static, not a per-task switch. To focus on one package today and another tomorrow, start Claude from that package’s directory instead of editing exclusions. If you only want these exclusions for yourself, put the setting in `.claude/settings.local.json`. Claude Code gitignores that file when it creates it; since you’re creating it by hand here, add it to your gitignore. Patterns use glob syntax matched against absolute file paths, so start relative-style patterns with `**/` to match anywhere in the tree. The example below excludes packages owned by other teams: +When you start Claude from the repository root, each subdirectory’s CLAUDE.md loads as soon as Claude reads a file in that directory. The `claudeMdExcludes` setting skips specific files by path or glob pattern so they never load. Use this for directories you never work in, such as other teams’ packages, legacy code, or vendored subtrees. The exclusion list is static, not a per-task switch. To focus on one package today and another tomorrow, start Claude from that package’s directory instead of editing exclusions. If you only want these exclusions for yourself, put the setting in `.claude/settings.local.json`. Claude Code gitignores that file when it creates it; since you’re creating it by hand here, add it to your gitignore. Patterns use glob syntax matched against absolute file paths, so start relative-style patterns with `**/` to match anywhere in the tree. The example below excludes a package owned by another team: .claude/settings.local.json { "claudeMdExcludes": [ - "**/packages/admin-dashboard/**", - "**/packages/legacy-*/**" + "**/packages/web/**" ] } -This skips every CLAUDE.md and rules file under those packages. The root CLAUDE.md and the packages you do work in still load normally. These patterns cover other common cases: +This skips every CLAUDE.md and rules file under that package. The root CLAUDE.md and the packages you do work in still load normally. These patterns cover other common cases: * `"**/packages/*/CLAUDE.md"`: excludes every package’s CLAUDE.md while keeping the root - * `"**/packages/web/**"`: excludes everything under the web package, including rules + * `"**/packages/legacy-*/**"`: excludes every package whose name matches the glob, including rules * `"/home/user/monorepo/legacy/CLAUDE.md"`: excludes one specific file by absolute path Managed policy CLAUDE.md files cannot be excluded, so organization-wide instructions always apply. You can set `claudeMdExcludes` at any [settings scope](</docs/en/settings#configuration-scopes>): user, project, local, or managed. Arrays merge across scopes, so a team can set project-level defaults while individuals add local overrides. For the full exclusion documentation, see [Exclude specific CLAUDE.md files](</docs/en/memory#exclude-specific-claude-md-files>). @@ -196,7 +195,7 @@ Reduce file reads with code intelligence -In a large codebase, finding where a symbol is defined or used can cost many file reads and grep calls. [Code intelligence plugins](</docs/en/discover-plugins#code-intelligence>) connect Claude to a language server so it can jump to definitions, find references, and surface type errors directly instead of scanning the tree. The official marketplace has plugins for TypeScript, Python, Go, Rust, and other common languages. The example below installs the TypeScript plugin: +In a large codebase, finding where a symbol is defined or used can cost many file reads and grep calls. [Code intelligence plugins](</docs/en/discover-plugins#code-intelligence>) connect Claude to a language server so it can jump to definitions, find references, and surface type errors directly instead of scanning the tree. The official marketplace has plugins for TypeScript, Python, Go, Rust, and other common languages. Run the command below inside a Claude Code session to install the TypeScript plugin: /plugin install typescript-lsp@claude-plugins-official @@ -216,7 +215,7 @@ Check out only the directories you need -The `--worktree` flag starts a session in a new git worktree so changes stay isolated from your main checkout. By default it checks out the entire repository. In a large repository, the `worktree.sparsePaths` setting uses git sparse-checkout to write only the listed directories plus root-level files to disk, so worktrees start faster and use less space. If everyone working in this directory needs the same paths, commit the setting to `.claude/settings.json`. To add paths for yourself, use `.claude/settings.local.json`: the lists merge across scopes, so a local file can add paths to the committed list but not remove them. The example below shows the committed file: +The `--worktree` flag starts a session in a new git worktree so changes stay isolated from your main checkout. By default it checks out the entire repository. In a large repository, the `worktree.sparsePaths` setting uses git sparse-checkout to write only the listed directories plus root-level files to disk, so worktrees start faster and use less space. If everyone working in this directory needs the same paths, commit the setting to `.claude/settings.json`. To add paths for yourself, use `.claude/settings.local.json`: the lists merge across scopes, so a local file can add paths to the committed list but not remove them. The JSON examples on this page show one setting at a time. If your `.claude/settings.json` already contains other keys, such as the `permissions.deny` rules above, add the `worktree` key alongside them rather than replacing the file. Put it together shows the combined result. The example below shows the committed file: .claude/settings.json @@ -261,7 +260,7 @@ This section applies when you start Claude from a subdirectory, or when a task spans multiple checkouts. If you start from the repository root in a single large tree, Claude already has access to every file and you can skip this. When you start Claude from `packages/api/`, it can read and write files within that directory. If a task requires changes across packages, such as updating a shared type that both `api` and `web` import, you need to grant access to the sibling directory. The same mechanism grants access to a separately-checked-out repository. The `additionalDirectories` setting in `.claude/settings.json` gives Claude access to directories outside the working directory. The example below grants access to two sibling packages: -.claude/settings.json +packages/api/.claude/settings.json { "permissions": {
modified How Claude remembers your project View current →
--- a/memory.md +++ b/memory.md @@ -76,7 +76,7 @@ Set up a project CLAUDE.md -A project CLAUDE.md can be stored in either `./CLAUDE.md` or `./.claude/CLAUDE.md`. Create this file and add instructions that apply to anyone working on the project: build and test commands, coding standards, architectural decisions, naming conventions, and common workflows. These instructions are shared with your team through version control, so focus on project-level standards rather than personal preferences. +A project CLAUDE.md can be stored in either `./CLAUDE.md` or `./.claude/CLAUDE.md`. Create this file and add instructions that apply to anyone working on the project: build and test commands, coding standards, architectural decisions, naming conventions, and common workflows. These instructions are shared with your team through version control, so focus on project-level standards rather than personal preferences. To confirm the file loaded, run `/context` in a session and check the list under **Memory files**. Run `/init` to generate a starting CLAUDE.md automatically. Claude analyzes your codebase and creates a file with build commands, test instructions, and project conventions it discovers. If a CLAUDE.md already exists, `/init` suggests improvements rather than overwriting it. Refine from there with instructions Claude wouldn’t discover on its own.Set `CLAUDE_CODE_NEW_INIT=1` to enable an interactive multi-phase flow. `/init` asks which artifacts to set up: CLAUDE.md files, skills, and hooks. It then explores your codebase with a subagent, fills in gaps via follow-up questions, and presents a reviewable proposal before writing any files. @@ -107,12 +107,12 @@ # Additional Instructions - git workflow @docs/git-instructions.md -For private per-project preferences that shouldn’t be checked into version control, create a `CLAUDE.local.md` at the project root. It loads alongside `CLAUDE.md` and is treated the same way. Add `CLAUDE.local.md` to your `.gitignore` so it isn’t committed; running `/init` and choosing the personal option does this for you. If you work across multiple git worktrees of the same repository, a gitignored `CLAUDE.local.md` only exists in the worktree where you created it. To share personal instructions across worktrees, import a file from your home directory instead: +For private per-project preferences that shouldn’t be checked into version control, create a `CLAUDE.local.md` at the project root. It loads alongside `CLAUDE.md` and is treated the same way. Add `CLAUDE.local.md` to your `.gitignore` so it isn’t committed. With `CLAUDE_CODE_NEW_INIT=1` set, running `/init` and choosing the personal option does this for you. If you work across multiple git worktrees of the same repository, a gitignored `CLAUDE.local.md` only exists in the worktree where you created it. To share personal instructions across worktrees, import a file from your home directory instead: # Individual Preferences - @~/.claude/my-project-instructions.md -The first time Claude Code encounters external imports in a project, it shows an approval dialog listing the files. If you decline, the imports stay disabled and the dialog does not appear again. +An import in a project-level memory file is external when its path resolves outside your working directory, like the home directory import above. The first time Claude Code encounters external imports in a project, it shows an approval dialog listing the files. If you decline, the imports stay disabled and the dialog doesn’t appear again.The dialog protects you from files other people commit to a shared project. Imports in user-scope memory files, such as `~/.claude/CLAUDE.md` and `~/.claude/rules/`, are files you wrote yourself, so they load without the dialog and carry the same trust as the rest of your personal configuration. For a more structured approach to organizing instructions, see `.claude/rules/`. @@ -136,7 +136,7 @@ ln -s AGENTS.md CLAUDE.md -On Windows, creating a symlink requires Administrator privileges or Developer Mode, so use the `@AGENTS.md` import instead. Running [`/init`](</docs/en/commands>) in a repo that already has an `AGENTS.md` reads it and incorporates the relevant parts into the generated `CLAUDE.md`. It also reads other tool configs like `.cursorrules`, `.devin/rules/`, and `.windsurfrules`. +The command prints no output on success. In your next session, run `/context` and confirm `CLAUDE.md` appears under **Memory files**. On Windows, creating a symlink requires Administrator privileges or Developer Mode, so use the `@AGENTS.md` import instead. Running [`/init`](</docs/en/commands>) reads Cursor rules, in `.cursor/rules/` or `.cursorrules`, and Copilot rules, in `.github/copilot-instructions.md`, and incorporates the relevant parts into the generated `CLAUDE.md`. With `CLAUDE_CODE_NEW_INIT=1` set, `/init` also reads `AGENTS.md`, `.devin/rules/`, `.windsurf/rules/` or `.windsurfrules`, and `.clinerules`. ### @@ -331,7 +331,7 @@ Enable or disable auto memory -Auto memory is on by default. To toggle it, open `/memory` in a session and use the auto memory toggle, or set `autoMemoryEnabled` in your project settings: +Auto memory is on by default. To toggle it, open `/memory` in a session and use the auto memory toggle, which saves `autoMemoryEnabled` to your user settings at `~/.claude/settings.json`. To turn it off for a single project, set `autoMemoryEnabled` in that project’s settings: { "autoMemoryEnabled": false @@ -367,7 +367,7 @@ How it works -The first 200 lines of `MEMORY.md`, or the first 25KB, whichever comes first, are loaded at the start of every conversation. Content beyond that threshold is not loaded at session start. Claude keeps `MEMORY.md` concise by moving detailed notes into separate topic files. After Claude writes to `MEMORY.md`, Claude Code measures the file against the 200-line and 25KB read limits. If the file is near a limit, Claude Code reminds Claude to shorten it: keep one line per entry, move detail into topic files, and merge or drop stale entries. If the file is over a limit, the write still succeeds, but Claude Code returns an [error telling Claude to rewrite the index](</docs/en/errors#memory-index-is-over-its-read-limit>), because everything past the limit is dropped on the next load. The check measures only the content that loads: YAML frontmatter and block-level HTML comments are stripped before the index is loaded, so they don’t count toward the limits. Before v2.1.211, Claude Code measured the raw file, and frontmatter or comments could trigger the error even when the loaded content fit. This limit applies only to `MEMORY.md`. CLAUDE.md files are loaded in full regardless of length, though shorter files produce better adherence. Topic files like `debugging.md` or `patterns.md` are not loaded at startup. Claude reads them on demand using its standard file tools when it needs the information. The main conversation’s auto memory isn’t loaded into [subagents](</docs/en/sub-agents#what-loads-at-startup>); the exception is a [fork](</docs/en/sub-agents#fork-the-current-conversation>), which inherits the parent conversation and system prompt. A subagent’s own auto memory, enabled with the subagent `memory` field, is a separate directory. Claude reads and writes memory files during your session. When you see “Writing memory” or “Recalled memory” in the Claude Code interface, Claude is actively updating or reading from `~/.claude/projects/<project>/memory/`. +The first 200 lines of `MEMORY.md`, or the first 25KB, whichever comes first, are loaded at the start of every conversation. Content beyond that threshold is not loaded at session start. Claude keeps `MEMORY.md` concise by moving detailed notes into separate topic files. After Claude writes to `MEMORY.md`, Claude Code measures the file against the 200-line and 25KB read limits. If the file is near a limit, Claude Code reminds Claude to shorten it: keep one line per entry, move detail into topic files, and merge or drop stale entries. If the file is over a limit, the write still succeeds, but Claude Code returns an [error telling Claude to rewrite the index](</docs/en/errors#memory-index-is-over-its-read-limit>), because everything past the limit is dropped on the next load. The check measures only the content that loads: YAML frontmatter and block-level HTML comments are stripped before the index is loaded, so they don’t count toward the limits. Before v2.1.211, Claude Code measured the raw file, and frontmatter or comments could trigger the error even when the loaded content fit. This limit applies only to `MEMORY.md`. CLAUDE.md files are loaded in full regardless of length, though shorter files produce better adherence. Topic files like `debugging.md` or `patterns.md` are not loaded at startup. Claude reads them on demand using its standard file tools when it needs the information. The main conversation’s auto memory isn’t loaded into [subagents](</docs/en/sub-agents#what-loads-at-startup>); the exception is a [fork](</docs/en/sub-agents#fork-the-current-conversation>), which inherits the parent conversation and system prompt. A subagent’s own auto memory, enabled with the subagent `memory` field, is a separate directory. Claude reads and writes memory files during your session. When you see messages like “Saved 2 memories” or “Recalled 2 memories” in the Claude Code interface, Claude is actively updating or reading from `~/.claude/projects/<project>/memory/`. ### @@ -383,7 +383,7 @@ View and edit with `/memory` -The `/memory` command lists your CLAUDE.md, CLAUDE.local.md, and other memory file locations across user and project scopes, lets you toggle auto memory on or off, and provides an option to open the auto memory folder. Select any file to open it in your editor. To check which files actually loaded into the current session, run `/context`. When you ask Claude to remember something, like “always use pnpm, not npm” or “remember that the API tests require a local Redis instance,” Claude saves it to auto memory. To add instructions to CLAUDE.md instead, ask Claude directly, like “add this to CLAUDE.md,” or edit the file yourself via `/memory`. +The `/memory` command lists your CLAUDE.md, CLAUDE.local.md, and other memory file locations across user and project scopes, including user and project CLAUDE.md entries for files that don’t exist yet. It also lets you toggle auto memory on or off and provides an option to open the auto memory folder. Select any file to open it in your editor; selecting one that doesn’t exist yet creates it first. To check which files actually loaded into the current session, run `/context`. When you ask Claude to remember something, like “always use pnpm, not npm” or “remember that the API tests require a local Redis instance,” Claude saves it to auto memory. To add instructions to CLAUDE.md instead, ask Claude directly, like “add this to CLAUDE.md,” or edit the file yourself via `/memory`. ## @@ -401,7 +401,7 @@ CLAUDE.md content is delivered as a user message after the system prompt, not as part of the system prompt itself. Claude reads it and tries to follow it, but there’s no guarantee of strict compliance, especially for vague or conflicting instructions. To debug: - * Run `/context` to verify your CLAUDE.md and CLAUDE.local.md files loaded. If a file is missing from the breakdown, Claude can’t see it. Use `/memory` to open and edit the files. + * Run `/context` and check the list under **Memory files** to verify your CLAUDE.md and CLAUDE.local.md files loaded. If a file is missing there, Claude can’t see it. Use `/memory` to open and edit the files. * Check that the relevant CLAUDE.md is in a location that gets loaded for your session (see Choose where to put CLAUDE.md files). * Make instructions more specific. “Use 2-space indentation” works better than “format code nicely.” * Look for conflicting instructions across CLAUDE.md files. If two files give different guidance for the same behavior, Claude may pick one arbitrarily.
modified Monitoring View current →
--- a/monitoring-usage.md +++ b/monitoring-usage.md @@ -1275,13 +1275,15 @@ All metrics and events are exported with the following resource attributes: - * `service.name`: `claude-code` - * `service.version`: Current Claude Code version + * `service.name`: `claude-code` for terminal sessions, `claude-code-desktop` for sessions started from the Code tab in the [Claude Desktop app](</docs/en/desktop>) + * `service.version`: Current Claude Code version, or the Desktop app version for Code tab sessions * `os.type`: Operating system type (for example, `linux`, `darwin`, `windows`) * `os.version`: Operating system version string * `host.arch`: Host architecture (for example, `amd64`, `arm64`) * `wsl.version`: WSL version number (only present when running on Windows Subsystem for Linux) * Meter Name: `com.anthropic.claude_code` + +If your collector pipelines or dashboards filter on `service.name = claude-code`, add `claude-code-desktop` to the filter to also capture telemetry from Code tab sessions. ##
modified Enterprise network configuration View current →
--- a/network-config.md +++ b/network-config.md @@ -135,18 +135,22 @@ URL| Required for ---|--- -`api.anthropic.com`| Claude API requests +`api.anthropic.com`| Claude API requests, including the WebFetch [domain safety check](</docs/en/data-usage#webfetch-domain-safety-check>), feature flag fetches, and telemetry event logging `claude.ai`| claude.ai account authentication -`platform.claude.com`| Anthropic Console account authentication +`claude.com`| claude.ai account sign-in opens a `claude.com` page in the browser, which redirects to `claude.ai`; pre-approved WebFetch documentation lookups also reach this host from the CLI +`platform.claude.com`| Anthropic Console account authentication. OAuth token exchange, refresh, and revocation also go to this host for claude.ai accounts, so both Console and claude.ai sign-ins require it `mcp-proxy.anthropic.com`| [MCP connectors from claude.ai](</docs/en/mcp#use-mcp-servers-from-claude-ai>), including connectors an organization administrator configures. Connector traffic routes through this proxy; connectors are enabled by default for claude.ai-authenticated users. To disable, set [`ENABLE_CLAUDEAI_MCP_SERVERS=false`](</docs/en/env-vars>) or the [`disableClaudeAiConnectors`](</docs/en/settings#available-settings>) setting -`downloads.claude.ai`| Plugin executable downloads; native installer and native auto-updater +`downloads.claude.ai`| Plugin executable downloads; native installer, native auto-updater, and update version checks `storage.googleapis.com`| Install counts and plugin metadata shown in `/plugin`. Signed [artifact](</docs/en/artifacts>) uploads try this host first; publishing falls back to `api.anthropic.com` when it is blocked `storage.googleapis.com`| Native installer and native auto-updater on versions prior to 2.1.116 `bridge.claudeusercontent.com`| [Claude in Chrome](</docs/en/chrome>) extension WebSocket bridge -`*.claudeusercontent.com`| Viewing [artifacts](</docs/en/artifacts>) on claude.ai. The viewer loads each artifact’s content from a sandboxed subdomain of this origin. Required in the viewer’s browser, not by the CLI itself `raw.githubusercontent.com`| Changelog feed for [`/release-notes`](</docs/en/commands>) and the release notes shown after updating +`http-intake.logs.us5.datadoghq.com`| Operational telemetry events, sent only when the CLI uses the Anthropic API directly, never for Amazon Bedrock, Google Cloud’s Agent Platform, or Microsoft Foundry. Optional: disable with [`DISABLE_TELEMETRY`](</docs/en/data-usage#telemetry-services>) or `DO_NOT_TRACK` +`browser-intake-us5-datadoghq.com`| Operational error reports, sent when the CLI uses the Anthropic API directly and a server-side rollout gate enables them. Optional: disable with `DISABLE_ERROR_REPORTING` or `DISABLE_TELEMETRY`; see [Telemetry services](</docs/en/data-usage#telemetry-services>) +`formulae.brew.sh`| Update version checks on Homebrew installs. Other install methods don’t contact this host +`code.claude.com`| Claude Code documentation lookups by the built-in claude-code-guide agent and pre-approved WebFetch requests. Blocking this host only affects documentation lookups -If you install Claude Code through npm or manage your own binary distribution, end users do not need the native installer and auto-updater uses of `downloads.claude.ai`. The other uses in the table apply regardless of install method. Claude Code also sends optional operational telemetry by default, which you can disable with environment variables. See [Telemetry services](</docs/en/data-usage#telemetry-services>) for how to disable it before finalizing your allowlist. When using [Amazon Bedrock](</docs/en/amazon-bedrock>), [Google Cloud’s Agent Platform](</docs/en/google-vertex-ai>), [Microsoft Foundry](</docs/en/microsoft-foundry>), or a signed-in [Claude apps gateway](</docs/en/claude-apps-gateway>) session, model traffic and authentication go to your provider or gateway instead of `api.anthropic.com`, `claude.ai`, or `platform.claude.com`. The WebFetch tool still calls `api.anthropic.com` for its [domain safety check](</docs/en/data-usage#webfetch-domain-safety-check>) unless you set `skipWebFetchPreflight: true` in [settings](</docs/en/settings>). When routing through an [LLM gateway](</docs/en/llm-gateway>) with [`ANTHROPIC_BASE_URL`](</docs/en/llm-gateway-connect#set-the-base-url-and-credential>), the [fast mode](</docs/en/fast-mode>) availability check still calls `api.anthropic.com` rather than the gateway base URL. The check does honor a configured HTTP proxy, so where a network block is the cause, an allowlist entry for `api.anthropic.com` in the proxy is the fix. A network block fails the check only where the host is unreachable even through the proxy, and fast mode then reports a connectivity error. The same connectivity error appears when the check presents a gateway-issued credential that Anthropic rejects; allowlisting doesn’t help there, since nothing is blocked. See [use fast mode behind proxies and LLM gateways](</docs/en/fast-mode#use-fast-mode-behind-proxies-and-llm-gateways>) for the variables that restore it. [Claude Code on the web](</docs/en/claude-code-on-the-web>) and [Code Review](</docs/en/code-review>) connect to your repositories from Anthropic-managed infrastructure. If your GitHub Enterprise Cloud organization restricts access by IP address, enable [IP allow list inheritance for installed GitHub Apps](<https://docs.github.com/en/enterprise-cloud@latest/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/managing-allowed-ip-addresses-for-your-organization#allowing-access-by-github-apps>). The Claude GitHub App registers its IP ranges, so enabling this setting allows access without manual configuration. To [add the ranges to your allow list manually](<https://docs.github.com/en/enterprise-cloud@latest/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/managing-allowed-ip-addresses-for-your-organization#adding-an-allowed-ip-address>) instead, or to configure other firewalls, see the [Anthropic API IP addresses](<https://platform.claude.com/docs/en/api/ip-addresses>). For self-hosted [GitHub Enterprise Server](</docs/en/github-enterprise-server>) instances behind a firewall, allowlist the same [Anthropic API IP addresses](<https://platform.claude.com/docs/en/api/ip-addresses>) so Anthropic infrastructure can reach your GHES host to clone repositories and post review comments. +If you install Claude Code through npm or manage your own binary distribution, end users don’t need the native installer and auto-updater uses of `downloads.claude.ai`, but npm and bun installs need their package registry, `registry.npmjs.org`, unless your organization mirrors it. The other uses in the table apply regardless of install method. The two Datadog intake hosts carry only optional operational telemetry, and setting [`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`](</docs/en/env-vars>) disables both. Sessions on third-party providers never send to these hosts, even when a platform sets [`CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST`](</docs/en/env-vars>) and telemetry metrics default on. See [Telemetry services](</docs/en/data-usage#telemetry-services>) for everything Claude Code sends and how to disable it before finalizing your allowlist. When using [Amazon Bedrock](</docs/en/amazon-bedrock>), [Google Cloud’s Agent Platform](</docs/en/google-vertex-ai>), [Microsoft Foundry](</docs/en/microsoft-foundry>), or a signed-in [Claude apps gateway](</docs/en/claude-apps-gateway>) session, model traffic and authentication go to your provider or gateway instead of `api.anthropic.com`, `claude.ai`, or `platform.claude.com`. The WebFetch tool still calls `api.anthropic.com` for its [domain safety check](</docs/en/data-usage#webfetch-domain-safety-check>) unless you set `skipWebFetchPreflight: true` in [settings](</docs/en/settings>). When routing through an [LLM gateway](</docs/en/llm-gateway>) with [`ANTHROPIC_BASE_URL`](</docs/en/llm-gateway-connect#set-the-base-url-and-credential>), the [fast mode](</docs/en/fast-mode>) availability check still calls `api.anthropic.com` rather than the gateway base URL. The check does honor a configured HTTP proxy, so where a network block is the cause, an allowlist entry for `api.anthropic.com` in the proxy is the fix. A network block fails the check only where the host is unreachable even through the proxy, and fast mode then reports a connectivity error. The same connectivity error appears when the check presents a gateway-issued credential that Anthropic rejects; allowlisting doesn’t help there, since nothing is blocked. See [use fast mode behind proxies and LLM gateways](</docs/en/fast-mode#use-fast-mode-behind-proxies-and-llm-gateways>) for the variables that restore it. [Claude Code on the web](</docs/en/claude-code-on-the-web>) and [Code Review](</docs/en/code-review>) connect to your repositories from Anthropic-managed infrastructure. If your GitHub Enterprise Cloud organization restricts access by IP address, enable [IP allow list inheritance for installed GitHub Apps](<https://docs.github.com/en/enterprise-cloud@latest/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/managing-allowed-ip-addresses-for-your-organization#allowing-access-by-github-apps>). The Claude GitHub App registers its IP ranges, so enabling this setting allows access without manual configuration. To [add the ranges to your allow list manually](<https://docs.github.com/en/enterprise-cloud@latest/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/managing-allowed-ip-addresses-for-your-organization#adding-an-allowed-ip-address>) instead, or to configure other firewalls, see the [Anthropic API IP addresses](<https://platform.claude.com/docs/en/api/ip-addresses>). For self-hosted [GitHub Enterprise Server](</docs/en/github-enterprise-server>) instances behind a firewall, allowlist the same [Anthropic API IP addresses](<https://platform.claude.com/docs/en/api/ip-addresses>) so Anthropic infrastructure can reach your GHES host to clone repositories and post review comments. ### @@ -154,7 +158,7 @@ Desktop and claude.ai -The preceding table primarily covers the standalone CLI. The Claude Desktop app and claude.ai in a browser load their application code from additional Anthropic CDN hosts, including `assets-proxy.anthropic.com`. Allowing `claude.ai` while blocking those hosts produces a blank page rather than an error. See [network access requirements](</docs/en/desktop#network-access-requirements>) on the Desktop page. +The preceding table covers the standalone CLI. The Claude Desktop app and claude.ai in a browser load their application code and user content from additional Anthropic CDN hosts, including `assets-proxy.anthropic.com` and the `*.claudeusercontent.com` origins that serve [artifacts](</docs/en/artifacts>). Allowing `claude.ai` while blocking those hosts produces a blank page rather than an error. See [network access requirements](</docs/en/desktop#network-access-requirements>) on the Desktop page. ##
modified Choose a permission mode View current →
--- a/permission-modes.md +++ b/permission-modes.md @@ -17,7 +17,13 @@ `dontAsk`| Only pre-approved tools| Locked-down CI and scripts `bypassPermissions`| Everything| Isolated containers and VMs only -The mode that reviews every action is named **Manual** in the CLI, in `claude --help`, in the VS Code and JetBrains extensions, and in the desktop app. Its config value is `default`, which is what hooks and SDK integrations use. The CLI accepts `manual` as an alias wherever you type the value, for example `claude --permission-mode manual` or `"defaultMode": "manual"`. The Manual label and the `manual` alias require Claude Code v2.1.200 or later. The desktop app’s label doesn’t depend on your CLI version. In every mode except `bypassPermissions`, writes to protected paths are never auto-approved, guarding repository state and Claude’s own configuration against accidental corruption. Modes set the baseline. Layer [permission rules](</docs/en/permissions#manage-permissions>) on top to pre-approve or block specific tools. Deny rules, explicit ask rules, the [org `ask` setting on connector tools](</docs/en/mcp#organization-controls-on-connector-tools>), and the [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) marker apply in every mode, including `bypassPermissions`. Allow rules have no effect in that mode because everything else is already approved. +The mode that reviews every action is named **Manual** in the CLI, in `claude --help`, in the VS Code and JetBrains extensions, and in the desktop app. Its config value is `default`, which is what hooks and SDK integrations use. The CLI accepts `manual` as an alias wherever you type the value, for example `claude --permission-mode manual` or `"defaultMode": "manual"`. The Manual label and the `manual` alias require Claude Code v2.1.200 or later. The desktop app’s label doesn’t depend on your CLI version. In every mode except `bypassPermissions`, writes to protected paths are never auto-approved, guarding repository state and Claude’s own configuration against accidental corruption. Modes set the baseline. Layer [permission rules](</docs/en/permissions#manage-permissions>) on top to pre-approve or block specific tools. These controls apply in every mode, including `bypassPermissions`: + + * deny rules and explicit ask rules, which apply to every tool but can’t block [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) while any other tool remains + * the [org `ask` setting on connector tools](</docs/en/mcp#organization-controls-on-connector-tools>) + * the [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) marker + +Allow rules have no effect in `bypassPermissions` because everything else is already approved. ##
modified Configure permissions View current →
--- a/permissions.md +++ b/permissions.md @@ -28,7 +28,7 @@ * **Ask** rules prompt for confirmation whenever Claude Code tries to use the specified tool. * **Deny** rules prevent Claude Code from using the specified tool. -Rules are evaluated in order: deny, then ask, then allow. The first match in that order determines the outcome, and rule specificity doesn’t change the order. A broad deny rule like `Bash(aws *)` blocks every matching call, including calls that also match a narrower allow rule like `Bash(aws s3 ls)`, so a deny rule can’t carry allowlist exceptions. The same precedence applies between ask and allow: a matching ask rule prompts even when a more specific allow rule also matches the same call. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. A bare tool name like `Bash` removes the tool from Claude’s context entirely, so Claude never sees it. A scoped rule like `Bash(rm *)` leaves the tool available and blocks matching calls when Claude attempts them. +Rules are evaluated in order: deny, then ask, then allow. The first match in that order determines the outcome, and rule specificity doesn’t change the order. A broad deny rule like `Bash(aws *)` blocks every matching call, including calls that also match a narrower allow rule like `Bash(aws s3 ls)`, so a deny rule can’t carry allowlist exceptions. The same precedence applies between ask and allow: a matching ask rule prompts even when a more specific allow rule also matches the same call. Deny rules behave differently depending on whether they name a tool or scope a pattern within one. A bare tool name like `Bash` removes the tool from Claude’s context entirely, so Claude never sees it. Bare-name removal applies to every tool except [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>): a deny rule can’t remove it while any other tool remains, and an ask rule never prompts for it. A scoped rule like `Bash(rm *)` leaves the tool available and blocks matching calls when Claude attempts them. 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. @@ -147,7 +147,7 @@ Tool name wildcards -Deny and ask rules also accept glob patterns in the tool-name position. The pattern must match the full tool name: `"*"` matches every tool, and `"mcp__*"` matches every MCP tool across all servers. A tool matched by a bare-name glob deny rule is removed from Claude’s context, the same as a bare tool name. This configuration denies every MCP tool: +Deny and ask rules also accept glob patterns in the tool-name position. The pattern must match the full tool name: `"*"` matches every tool, and `"mcp__*"` matches every MCP tool across all servers. A tool matched by a bare-name glob deny rule is removed from Claude’s context, the same as a bare tool name, including the [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) exception: a glob deny can’t remove it while any other tool remains, and a glob ask never prompts for it. This configuration denies every MCP tool: { "permissions": { @@ -195,9 +195,9 @@ ​ -Process wrappers - -Before matching Bash rules, Claude Code strips a fixed set of process wrappers so a rule like `Bash(npm test *)` also matches `timeout 30 npm test`. The recognized wrappers are `timeout`, `time`, `nice`, `nohup`, and `stdbuf`. Bare `xargs` is also stripped, so `Bash(grep *)` matches `xargs grep pattern`. Stripping applies only when `xargs` has no flags: an invocation like `xargs -n1 grep pattern` is matched as an `xargs` command, so rules written for the inner command do not cover it. This wrapper list is built in and is not configurable. Development environment runners such as `direnv exec`, `devbox run`, `mise exec`, `npx`, and `docker exec` are not in the list. Because these tools execute their arguments as a command, a rule like `Bash(devbox run *)` matches whatever comes after `run`, including `devbox run rm -rf .`. To approve work inside an environment runner, write a specific rule that includes both the runner and the inner command, such as `Bash(devbox run npm test)`. Add one rule per inner command you want to allow. Exec wrappers such as `watch`, `setsid`, `ionice`, and `flock` always prompt and can’t be auto-approved by a prefix rule like `Bash(watch *)`. The same applies to `find` with `-exec` or `-delete`: a `Bash(find *)` rule doesn’t cover these forms. To approve a specific invocation, write an exact-match rule for the full command string. +Wrappers + +Before matching Bash rules, Claude Code strips a fixed set of wrappers, so a rule like `Bash(npm test *)` also matches `timeout 30 npm test`. The stripped wrappers are `timeout`, `time`, `nice`, `nohup`, and `stdbuf`, plus the shell builtins `command` and `builtin`, and zsh’s `noglob`. Each runs its argument as the actual command. Two related forms aren’t stripped: the query form `command -v`, which looks up a command rather than running one, and zsh’s `nocorrect`. Claude Code also strips a leading assignment of certain known-safe environment variables, so `Bash(npm test *)` matches `NODE_ENV=test npm test`. An allow rule won’t match past an assignment of any other variable. A deny or ask rule matches past any leading assignment, so `Bash(rm *)` in deny still matches `FOO=bar rm -rf tmp/`. Bare `xargs` is also stripped, so `Bash(grep *)` matches `xargs grep pattern`. Stripping applies only when `xargs` has no flags: an invocation like `xargs -n1 grep pattern` is matched as an `xargs` command, so rules written for the inner command do not cover it. This wrapper list is built in and is not configurable. Development environment runners such as `direnv exec`, `devbox run`, `mise exec`, `npx`, and `docker exec` are not in the list. Because these tools execute their arguments as a command, a rule like `Bash(devbox run *)` matches whatever comes after `run`, including `devbox run rm -rf .`. To approve work inside an environment runner, write a specific rule that includes both the runner and the inner command, such as `Bash(devbox run npm test)`. Add one rule per inner command you want to allow. Exec wrappers such as `watch`, `setsid`, `ionice`, and `flock` always prompt and can’t be auto-approved by a prefix rule like `Bash(watch *)`. The same applies to `find` with `-exec` or `-delete`: a `Bash(find *)` rule doesn’t cover these forms. To approve a specific invocation, write an exact-match rule for the full command string. #### @@ -369,7 +369,7 @@ Extend permissions with hooks -[Claude Code hooks](</docs/en/hooks-guide>) provide a way to register custom shell commands to perform permission evaluation at runtime. When Claude Code makes a tool call, PreToolUse hooks run before the permission prompt. The hook output can deny the tool call, force a prompt, or skip the prompt to let the call proceed. Hook decisions don’t bypass permission rules. Claude Code evaluates deny and ask rules regardless of what a PreToolUse hook returns: a matching deny rule blocks the call, and a matching ask rule still prompts even when the hook returned `"allow"` or `"ask"`. This preserves the deny-first precedence described in Manage permissions, including deny rules set in managed settings. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) also still prompt when a hook returns `"allow"`. A blocking hook also takes precedence over allow rules. A hook that exits with code 2 stops the tool call before permission rules are evaluated, so the block applies even when an allow rule would otherwise let the call proceed. To run all Bash commands without prompts except for a few you want blocked, add `"Bash"` to your allow list and register a PreToolUse hook that rejects those specific commands. See [Block edits to protected files](</docs/en/hooks-guide#block-edits-to-protected-files>) for a hook script you can adapt. +[Claude Code hooks](</docs/en/hooks-guide>) let you register custom shell commands that evaluate permissions at runtime. When Claude Code makes a tool call, PreToolUse hooks run before the permission prompt, for every tool except [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>). The hook output can deny the tool call, force a prompt, or skip the prompt to let the call proceed. Hook decisions don’t bypass permission rules. Claude Code evaluates deny and ask rules regardless of what a PreToolUse hook returns: a matching deny rule blocks the call, and a matching ask rule still prompts even when the hook returned `"allow"` or `"ask"`. This preserves the deny-first precedence described in Manage permissions, including deny rules set in managed settings. Connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>) and MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>) also still prompt when a hook returns `"allow"`. A blocking hook also takes precedence over allow rules. A hook that exits with code 2 stops the tool call before permission rules are evaluated, so the block applies even when an allow rule would otherwise let the call proceed. To run all Bash commands without prompts except for a few you want blocked, add `"Bash"` to your allow list and register a PreToolUse hook that rejects those specific commands. See [Block edits to protected files](</docs/en/hooks-guide#block-edits-to-protected-files>) for a hook script you can adapt. ## @@ -414,7 +414,7 @@ Permissions and [sandboxing](</docs/en/sandboxing>) are complementary security layers: - * **Permissions** control which tools Claude Code can use and which files or domains it can access. They apply to all tools, including Bash, Read, Edit, WebFetch, and MCP. + * **Permissions** control which tools Claude Code can use and which files or domains it can access. They apply to Bash, Read, Edit, WebFetch, MCP, and every other tool, except that a deny or ask rule can’t block [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) while any other tool remains. * **Sandboxing** provides OS-level enforcement that restricts the Bash tool’s filesystem and network access. It applies only to Bash commands and their child processes. Use both for defense-in-depth:
modified Plugins reference View current →
--- a/plugins-reference.md +++ b/plugins-reference.md @@ -111,8 +111,8 @@ `ConfigChange`| When a configuration file changes during a session `CwdChanged`| When the working directory changes, for example when Claude executes a `cd` command. Useful for reactive environment management with tools like direnv `FileChanged`| When a watched file changes on disk. The `matcher` field specifies which filenames to watch -`WorktreeCreate`| When a worktree is being created via `--worktree` or `isolation: "worktree"`. Replaces default git behavior -`WorktreeRemove`| When a worktree is being removed, either at session exit or when a subagent finishes +`WorktreeCreate`| When a worktree is being created via `--worktree`, `isolation: "worktree"`, or for a background session. Replaces default git behavior +`WorktreeRemove`| When a worktree is being removed at session exit, when a subagent finishes, or when you delete a background session `PreCompact`| Before context compaction `PostCompact`| After context compaction completes `Elicitation`| When an MCP server requests user input during a tool call @@ -645,7 +645,7 @@ } } -`${CLAUDE_PLUGIN_ROOT}` 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 don’t write state there. 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. MCP servers can also call the `roots/list` request to read the session’s working directories at runtime. See [what `roots/list` returns and when Claude Code notifies the server of changes](</docs/en/mcp#option-3-add-a-local-stdio-server>). +`${CLAUDE_PLUGIN_ROOT}` changes when the plugin updates. The previous version’s directory remains on disk for about two weeks after an update before cleanup, but treat it as ephemeral and don’t write state there. 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. MCP servers can also call the `roots/list` request to read the session’s working directories at runtime. See [what `roots/list` returns and when Claude Code notifies the server of changes](</docs/en/mcp#option-3-add-a-local-stdio-server>). #### @@ -699,7 +699,7 @@ * Through `claude --plugin-dir` or `claude --plugin-url`, for the duration of a session. * Through a marketplace, installed for future sessions. -For security and verification purposes, Claude Code copies _marketplace_ plugins to the user’s local **plugin cache** (`~/.claude/plugins/cache`) rather than using them in-place. Understanding this behavior is important when developing plugins that reference external files. Each installed version is a separate directory in the cache. When you update or uninstall a plugin, the previous version directory is marked as orphaned and removed automatically 7 days later. The grace period lets concurrent Claude Code sessions that already loaded the old version keep running without errors. Claude’s Glob and Grep tools skip orphaned version directories during searches, so file results don’t include outdated plugin code. +For security and verification purposes, Claude Code copies _marketplace_ plugins to the user’s local **plugin cache** (`~/.claude/plugins/cache`) rather than using them in-place. Understanding this behavior is important when developing plugins that reference external files. Each installed version is a separate directory in the cache. When you update or uninstall a plugin, the previous version directory is marked as orphaned and removed automatically 14 days later. The grace period lets concurrent Claude Code sessions that already loaded the old version keep running without errors. Claude’s Glob and Grep tools skip orphaned version directories during searches, so file results don’t include outdated plugin code. ###
modified Agent SDK reference - Python View current →
--- a/python.md +++ b/python.md @@ -2678,9 +2678,10 @@ "prompt": str, # The task for the agent to perform "subagent_type": str | None, # The type of specialized agent to use "model": "sonnet" | "opus" | "haiku" | "fable" | None, # Model override for this agent - "run_in_background": bool | None, # Launch the agent in the background + "run_in_background": bool | None, # Agents run in the background by default; set to False to run synchronously "name": str | None, # Name for the spawned agent - "mode": "acceptEdits" | "auto" | "bypassPermissions" | "default" | "dontAsk" | "plan" | None, # Permission mode for the agent + "team_name": str | None, # Deprecated; ignored + "mode": "acceptEdits" | "auto" | "bypassPermissions" | "default" | "dontAsk" | "plan" | None, # Deprecated; ignored. Subagents inherit the parent session's permission mode; agent-definition frontmatter may override it "isolation": "worktree" | "remote" | None, # Isolation mode for the agent's changes } @@ -2697,7 +2698,8 @@ "citations": list | None, } ], - "resolvedModel": str | None, # Model the subagent actually ran on + "resolvedModel": str | None, # Model the subagent started on + "modelsUsed": list[str] | None, # Models used in order, with consecutive repeats collapsed "totalToolUseCount": int, # Number of tool calls the agent made "totalDurationMs": int, # Execution duration in milliseconds "totalTokens": int, # Total tokens used @@ -2735,7 +2737,8 @@ "isAsync": bool | None, # True on background launches "agentId": str, # ID of the launched agent "description": str, # The task description - "resolvedModel": str | None, # Model the subagent runs on + "resolvedModel": str | None, # Model in use at the backgrounding transition + "modelsUsed": list[str] | None, # Models used before backgrounding, in order, with consecutive repeats collapsed "prompt": str, # The prompt the agent runs "outputFile": str, # File path where the agent's output is written "canReadOutputFile": bool | None, # Whether the output file can be read directly @@ -2752,7 +2755,7 @@ "outputFile": str, # File path where the agent's output is written } -Returns the result from the subagent. The output is discriminated on the `status` field: `"completed"` for finished tasks, `"async_launched"` for background tasks, and `"remote_launched"` for tasks Claude Code dispatched to a remote cloud session, where `sessionUrl` links to that session and `taskId` identifies it. Worktree-isolated runs include `worktreePath` and `worktreeBranch` on the `completed` variant. The `resolvedModel` field on the `completed` and `async_launched` variants names the model the subagent actually ran on, which can differ from the requested `model` input when [`availableModels`](</docs/en/model-config#restrict-model-selection>) or another override applies. This field requires Claude Code v2.1.174 or later. +Returns the result from the subagent. The output is discriminated on the `status` field: `"completed"` for finished tasks, `"async_launched"` for background tasks, and `"remote_launched"` for tasks Claude Code dispatched to a remote cloud session, where `sessionUrl` links to that session and `taskId` identifies it. Worktree-isolated runs include `worktreePath` and `worktreeBranch` on the `completed` variant. On the `completed` variant, `resolvedModel` names the model the subagent started on, which can differ from the requested `model` input when [`availableModels`](</docs/en/model-config#restrict-model-selection>) or another override applies. This field requires Claude Code v2.1.174 or later. On the `async_launched` variant, `resolvedModel` names the model in use when the agent moved to the background, so a swap that happened before backgrounding is reflected there. The `modelsUsed` field on both variants lists the models used in order, with consecutive repeats collapsed; it’s set only when the model was swapped mid-run. `modelsUsed` and the backgrounding-time `resolvedModel` behavior require Claude Code v2.1.212 or later. ### @@ -2771,6 +2774,7 @@ { "label": str, # Display text for this option (1-5 words) "description": str, # Explanation of what this option means + "preview": str | None, # Preview content rendered when the option is focused } ], "multiSelect": bool, # Set to true to allow multiple selections @@ -2780,6 +2784,11 @@ # User answers populated by the permission system. Multi-select # answers are a comma-joined string of the selected labels; a # list of labels is accepted on input and coerced to that form + "annotations": dict[str, dict] | None, + # Per-question annotations from the user, keyed by question text. + # Each value can carry "preview" (the selected option's preview + # content) and "notes" (free-text notes on the selection) + "metadata": dict | None, # Analytics metadata, such as {"source": "remember"}; not displayed to the user } **Output:** @@ -2789,12 +2798,17 @@ { "question": str, "header": str, - "options": [{"label": str, "description": str}], + "options": [{"label": str, "description": str, "preview": str | None}], "multiSelect": bool, } ], "answers": dict[str, str], # Maps question text to answer string # Multi-select answers are comma-separated + "response": str | None, + # Freeform reply typed instead of answering the questions; when set, + # Claude receives "The user responded: ..." in place of the answer list + "annotations": dict[str, dict] | None, # Per-question "preview" and "notes" from the user's selections + "afkTimeoutMs": int | None, # Set when the dialog auto-resolved after this many milliseconds of user inactivity; absent when the user answered } ###
modified Continue local sessions from any device with Remote Control View current →
--- a/remote-control.md +++ b/remote-control.md @@ -20,7 +20,7 @@ * **Subscription** : available on Pro, Max, Team, and Enterprise plans. API keys are not supported. On Team and Enterprise, an Owner must first enable the Remote Control toggle in [Claude Code admin settings](<https://claude.ai/admin-settings/claude-code>). * **Authentication** : run `claude` and use `/login` to sign in through claude.ai if you haven’t already. Without an eligible login, `claude remote-control` exits with an error, while `claude --remote-control` still starts an interactive session and shows a Remote Control failure notification shortly after launch. * **API endpoint** : not available on Amazon Bedrock, Google Cloud’s Agent Platform, or Microsoft Foundry. As of v2.1.196, Remote Control is also disabled when [`ANTHROPIC_BASE_URL`](</docs/en/env-vars>) points at a host other than `api.anthropic.com`, such as an [LLM gateway](</docs/en/llm-gateway>) or proxy. Unset the variable to use Remote Control. - * **Workspace trust** : run `claude` in your project directory at least once to accept the workspace trust dialog. + * **Workspace trust** : run `claude` in your project directory at least once to accept the workspace trust dialog. The startup trust dialog never saves trust for your home directory, so start Remote Control from a project directory. ## @@ -105,7 +105,7 @@ * **Long turn** : when a turn runs longer than a server-tuned threshold, a **Still working** notification with a **Check in from your phone** link appears, so you can follow the turn from your phone or browser instead of waiting at the terminal. Claude Code removes it when the turn ends. * **Repeated permission prompts** : after you answer several [permission prompts](</docs/en/permissions>) in a session, an **Approve tool calls from your phone** notification shows the session URL. Claude Code removes it when your next turn starts. -You only see the reminders in sessions where you turned on Remote Control yourself, and Claude Code shows each one a few times in total across sessions rather than at every opportunity. You can’t configure or turn them off; each clears on its own. +The reminders can appear in any connected session, including ones where Remote Control connects automatically. They don’t appear every time these conditions occur, and each one appears only a few times in total across sessions. You can’t configure or turn them off; each clears on its own. ###
modified Automate work with routines View current →
--- a/routines.md +++ b/routines.md @@ -40,7 +40,7 @@ Name the routine and write the prompt -Give the routine a descriptive name and write the prompt Claude runs each time. The prompt is the most important part: the routine runs autonomously, so the prompt must be self-contained and explicit about what to do and what success looks like.The prompt input includes a model selector. Claude uses the selected model on every run. +Give the routine a descriptive name and write the prompt Claude runs each time. The prompt is the most important part: the routine runs autonomously, so the prompt must be self-contained and explicit about what to do and what success looks like.When a trigger fires, the session receives the routine’s saved prompt as its assigned task and carries it out, rather than treating it as untrusted content that arrived mid-conversation. The trigger attests only that the prompt was stored ahead of time by an authorized session on your account, so the fired prompt is not live user input and can’t act as approval or consent for actions during the run. Content the session fetches during the run keeps its normal handling. Before v2.1.214, the session received the same prompt framed as an untrusted background notification and could refuse to act on it.The prompt input includes a model selector. Claude uses the selected model on every run. 3
modified Configure the sandboxed Bash tool View current →
--- a/sandboxing.md +++ b/sandboxing.md @@ -269,7 +269,7 @@ Permission rules and sandboxing control different things: - * **Permission rules** control which tools Claude Code can use and are evaluated before any tool runs. They apply to all tools: Bash, Read, Edit, WebFetch, MCP, and others. + * **Permission rules** control which tools Claude Code can use and are evaluated before any tool runs. They apply to every tool: Bash, Read, Edit, WebFetch, MCP, and others, except that a deny or ask rule can’t block [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) while any other tool remains. * **Sandboxing** provides OS-level enforcement that restricts what Bash commands can access at the filesystem and network level. It applies only to Bash commands and their child processes. The two layers also differ in how they are enforced. Claude Code evaluates permission decisions before a command runs, based on the command string and, in auto mode, a separate classifier’s judgment about whether the command is safe. The operating system enforces the sandbox boundary on the running process, so it holds regardless of what the model chose to run and even if an allowed command does more than its name suggests. Filesystem and network restrictions are configured through both sandbox settings and permission rules:
modified Catch security issues as Claude writes code View current →
--- a/security-guidance.md +++ b/security-guidance.md @@ -7,10 +7,10 @@ Prerequisites * Claude Code CLI version 2.1.144 or later - * Python 3.8 or later on your `PATH`. The plugin tries `python3`, `python`, and `py -3` in that order + * Python 3.7 or later on your `PATH`. The agentic commit review needs Python 3.10 or later, as do all model-backed reviews when Claude Code uses a third-party provider such as Amazon Bedrock or Google Cloud’s Agent Platform. The plugin prefers the versioned interpreters `python3.13` through `python3.10`, then falls back to `python3`, `python`, and `py -3` * A git repository for the directory you work in. The end-of-turn and commit reviews diff against git state and skip silently outside a repository. The per-edit pattern check works anywhere -On first run the plugin creates a virtual environment under `~/.claude/security/` and installs the Claude Agent SDK into it, which requires `pip` and network access. If that install fails, the commit review falls back to a single-shot review instead of the agentic one. On Windows the virtual environment step is skipped, so the agentic commit review runs only if `claude-agent-sdk` is already importable and otherwise falls back the same way. +On first run the plugin creates a virtual environment under `~/.claude/security/` and installs the Claude Agent SDK into it, which requires `pip` and network access. If that install fails, or the available Python is older than 3.10, the commit review on first-party authentication falls back to a single-shot review instead of the agentic one; on a third-party provider such as Amazon Bedrock or Google Cloud’s Agent Platform the model-backed reviews need the SDK themselves, so they skip. The plugin shows a one-time notice when an older Python is the cause. ## @@ -260,7 +260,7 @@ The plugin writes runtime diagnostics to `~/.claude/security/log.txt`. Check there first if reviews are not appearing. Common reasons a review layer skips without a message in the conversation: * The directory is not a git repository: the end-of-turn and commit reviews require git state and skip outside a repository - * The session has no Anthropic authentication: the model-backed reviews skip and only the per-edit pattern check runs + * The session has no Anthropic authentication and no third-party provider configured: the model-backed reviews skip and only the per-edit pattern check runs * A `security-patterns.yaml` file is present but PyYAML is not importable: the file is ignored. Use `security-patterns.json` instead ##
modified Claude Code settings View current →
--- a/settings.md +++ b/settings.md @@ -378,7 +378,7 @@ ---|---|--- `allow`| Array of permission rules to allow tool use. Tool-name globs are supported only in the tool position after a literal `mcp__<server>__` prefix, such as `mcp__github__get_*`; the server segment must be glob-free. See Permission rule syntax below for pattern matching details| `[ "Bash(git diff *)" ]` `ask`| Array of permission rules to ask for confirmation upon tool use. See Permission rule syntax below| `[ "Bash(git push *)" ]` -`deny`| Array of permission rules to deny tool use. Use this to exclude sensitive files from Claude Code access. Tool names accept glob patterns: `"*"` denies every tool and `"mcp__*"` denies all MCP tools. See Permission rule syntax and [Bash permission limitations](</docs/en/permissions#tool-specific-permission-rules>)| `[ "WebFetch", "Bash(curl *)", "Read(./.env)", "Read(./secrets/**)" ]` +`deny`| Array of permission rules to deny tool use. Use this to exclude sensitive files from Claude Code access. Tool names accept glob patterns: `"*"` denies every tool and `"mcp__*"` denies every MCP tool. Deny rules can’t remove [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) while any other tool remains. See Permission rule syntax and [Bash permission limitations](</docs/en/permissions#tool-specific-permission-rules>)| `[ "WebFetch", "Bash(curl *)", "Read(./.env)", "Read(./secrets/**)" ]` `additionalDirectories`| Additional [working directories](</docs/en/permissions#working-directories>) for file access. Most `.claude/` configuration is [not discovered](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) from these directories| `[ "../docs/" ]` `defaultMode`| Default [permission mode](</docs/en/permission-modes>) when opening Claude Code. Valid values: `default`, `acceptEdits`, `plan`, `auto`, `dontAsk`, `bypassPermissions`, and `manual` as an alias for `default`, the mode labeled Manual in the CLI, the VS Code and JetBrains extensions, and the desktop app. The `manual` alias requires Claude Code v2.1.200 or later. `auto` is ignored when set in project or local settings, so a repository can’t grant itself auto mode; set it in `~/.claude/settings.json` instead. Before v2.1.142, project settings could set `auto`. The `--permission-mode` CLI flag overrides this setting for a single session| `"acceptEdits"` `disableBypassPermissionsMode`| Set to `"disable"` to prevent `bypassPermissions` mode from being activated. This disables the `--dangerously-skip-permissions` command-line flag. Typically placed in [managed settings](</docs/en/permissions#managed-settings>) to enforce organizational policy, but works from any scope| `"disable"`
modified Extend Claude with skills View current →
--- a/skills.md +++ b/skills.md @@ -233,7 +233,7 @@ `disable-model-invocation`| No| Set to `true` to prevent Claude from automatically loading this skill. Use for workflows you want to trigger manually with `/name`. Also prevents the skill from being [preloaded into subagents](</docs/en/sub-agents#preload-skills-into-subagents>). As of v2.1.196, also prevents the skill from running when a [scheduled task](</docs/en/scheduled-tasks>) fires with the skill as its prompt. Default: `false`. `user-invocable`| No| Set to `false` to hide from the `/` menu. Use for background knowledge users shouldn’t invoke directly. Default: `true`. `allowed-tools`| No| Tools Claude can use without asking permission during the turn that invokes this skill. The grant clears when you send your next message. Accepts a space- or comma-separated string, or a YAML list. See Pre-approve tools for a skill. -`disallowed-tools`| No| Tools removed from Claude’s available pool while this skill is active. Use for autonomous skills that should never call certain tools, such as `AskUserQuestion` for a background loop. Accepts a space- or comma-separated string, or a YAML list. The restriction clears when you send your next message. +`disallowed-tools`| No| Tools removed from Claude’s available pool while this skill is active. Use for autonomous skills that should never call certain tools, such as `AskUserQuestion` for a background loop. Accepts a space- or comma-separated string, or a YAML list. The restriction clears when you send your next message. Like deny rules, the field can’t remove [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) while any other tool remains. `model`| No| Model to use when this skill is active. The override applies for the rest of the current turn and is not saved to settings; the session model resumes on your next prompt. Accepts the same values as [`/model`](</docs/en/model-config>), or `inherit` to keep the active model. A value excluded by your organization’s [`availableModels`](</docs/en/model-config#restrict-model-selection>) allowlist is not used and the session keeps its current model. `effort`| No| [Effort level](</docs/en/model-config#adjust-effort-level>) when this skill is active. Overrides the session effort level. Default: inherits from session. Options: `low`, `medium`, `high`, `xhigh`, `max`; available levels depend on the model. `context`| No| Set to `fork` to run in a forked subagent context. See Run skills in a subagent. @@ -279,7 +279,17 @@ `${CLAUDE_SKILL_DIR}`| The directory containing the skill’s `SKILL.md` file. For plugin skills, this is the skill’s subdirectory within the plugin, not the plugin root. Use this in bash injection commands to reference scripts or files bundled with the skill, regardless of the current working directory. `${CLAUDE_PROJECT_DIR}`| The project root directory. This is the same path [hooks](</docs/en/hooks#reference-scripts-by-path>) and MCP servers receive as `CLAUDE_PROJECT_DIR`. Use this to reference project-local scripts or files, such as `${CLAUDE_PROJECT_DIR}/.claude/hooks/helper.sh`, independent of where the skill is installed. -The `${CLAUDE_PROJECT_DIR}` substitution requires Claude Code v2.1.196 or later. It applies to both the skill body and the `allowed-tools` frontmatter, so a permission rule like `Bash(${CLAUDE_PROJECT_DIR}/scripts/lint.sh *)` resolves to the same path the skill body uses. Indexed arguments use shell-style quoting, so wrap multi-word values in quotes to pass them as a single argument. For example, `/my-skill "hello world" second` makes `$0` expand to `hello world` and `$1` to `second`. The `$ARGUMENTS` placeholder always expands to the full argument string as typed. An indexed placeholder with no corresponding argument, such as `$2` when only one argument was passed, stays in the content unchanged. A named placeholder from the `arguments` frontmatter with no matching argument expands to an empty string. To include a literal `$` before a digit, `ARGUMENTS`, or a declared argument name, such as `$1.00` in prose, escape it with a backslash: `\$1.00`. A backslash before any other `$` is left unchanged. Only a single backslash directly before the token escapes it. A doubled backslash such as `\\$1` leaves both backslashes in place, and `$1` still expands to the argument value. **Example using substitutions:** +Claude Code substitutes `${CLAUDE_SKILL_DIR}` and `${CLAUDE_PROJECT_DIR}` in two places: the skill’s markdown content, and Bash rules in the `allowed-tools` frontmatter. Using the same variable in both places lets a skill run a bundled script without a permission prompt. The following skill shows the pattern: + + --- + name: render-chart + description: Render a chart from a CSV file + allowed-tools: Bash(${CLAUDE_SKILL_DIR}/scripts/render.sh *) + --- + + Run `${CLAUDE_SKILL_DIR}/scripts/render.sh <csv-file>` to render the chart. + +If this skill is installed at `~/.claude/skills/render-chart/`, both occurrences of `${CLAUDE_SKILL_DIR}` expand to that directory. The `allowed-tools` rule then matches the exact command the skill body tells Claude to run, so the script runs without prompting. The `allowed-tools` substitution for `${CLAUDE_SKILL_DIR}` requires Claude Code v2.1.129 or later. On earlier versions the rule stays a literal `${CLAUDE_SKILL_DIR}` string and never matches, so the command still prompts for permission. The `${CLAUDE_PROJECT_DIR}` substitution requires Claude Code v2.1.196 or later. Indexed arguments use shell-style quoting, so wrap multi-word values in quotes to pass them as a single argument. For example, `/my-skill "hello world" second` makes `$0` expand to `hello world` and `$1` to `second`. The `$ARGUMENTS` placeholder always expands to the full argument string as typed. An indexed placeholder with no corresponding argument, such as `$2` when only one argument was passed, stays in the content unchanged. A named placeholder from the `arguments` frontmatter with no matching argument expands to an empty string. To include a literal `$` before a digit, `ARGUMENTS`, or a declared argument name, such as `$1.00` in prose, escape it with a backslash: `\$1.00`. A backslash before any other `$` is left unchanged. Only a single backslash directly before the token escapes it. A doubled backslash such as `\\$1` leaves both backslashes in place, and `$1` still expands to the argument value. **Example using substitutions:** --- name: session-logger @@ -373,7 +383,7 @@ allowed-tools: Bash(git add *) Bash(git commit *) Bash(git status *) --- -To remove tools from Claude’s available pool while a skill is active, list them in `disallowed-tools` in the skill’s frontmatter. The restriction clears when you send your next message. To block tools across all skills and prompts, add deny rules in your [permission settings](</docs/en/permissions>). +To remove tools from Claude’s available pool while a skill is active, list them in `disallowed-tools` in the skill’s frontmatter. The restriction clears when you send your next message. Like deny rules, the field can’t remove [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) while any other tool remains. To block tools across all skills and prompts, add deny rules in your [permission settings](</docs/en/permissions>). ###
modified Customize your status line View current →
--- a/statusline.md +++ b/statusline.md @@ -124,7 +124,15 @@ How status lines work -Claude Code runs your script and pipes JSON session data to it via stdin. Your script reads the JSON, extracts what it needs, and prints text to stdout. Claude Code displays whatever your script prints. **When it updates** Your script runs after each new assistant message, after `/compact` finishes, when the permission mode changes, or when vim mode toggles. Updates are debounced at 300ms, meaning rapid changes batch together and your script runs once things settle. If a new update triggers while your script is still running, the in-flight execution is cancelled. If you edit your script, the changes won’t appear until your next interaction with Claude Code triggers an update. These triggers can go quiet when the main session is idle, for example while a coordinator waits on background subagents. To keep time-based or externally-sourced segments current during idle periods, set `refreshInterval` to also re-run the command on a fixed timer. **What your script can output** +Claude Code runs your script and pipes JSON session data to it via stdin. Your script reads the JSON, extracts what it needs, and prints text to stdout. Claude Code displays whatever your script prints. **When it updates** Your script runs once when a session starts, including when you resume one. After that, it runs again when: + + * A new assistant message arrives + * `/compact` finishes + * The permission mode changes + * Vim mode toggles + * A `refreshInterval` timer elapses, if you set one + +Before v2.1.216, resuming a session ran the command twice in quick succession, so the first result could flicker before being replaced. Claude Code debounces updates at 300ms, so rapid changes batch together and your script runs once after the changes stop. If a new update triggers while your script is still running, Claude Code cancels the in-flight script. If you edit your script, the changes appear the next time an update trigger re-runs it. The event-driven triggers can go quiet when the main session is idle, for example while a coordinator waits on background subagents. To keep time-based or externally-sourced segments current during idle periods, set `refreshInterval` to also re-run the command on a fixed timer. **What your script can output** * **Multiple lines** : each `echo` or `print` statement displays as a separate row. See the multi-line example. * **Colors** : use [ANSI escape codes](<https://en.wikipedia.org/wiki/ANSI_escape_code#Colors>) like `\033[32m` for green (terminal must support them). See the git status example. @@ -983,7 +991,7 @@ } } -The command runs once per refresh tick with all visible subagent rows passed as a single JSON object on stdin. The input includes the [base hook fields](</docs/en/hooks#common-input-fields>), a `columns` field with the usable row width, and a `tasks` array. Each task has `id`, `name`, `type`, `status`, `description`, `label`, `startTime`, `model`, `contextWindowSize`, `tokenCount`, `tokenSamples`, and `cwd`. The per-task `model` field is the resolved model ID the task runs on. `contextWindowSize` is that model’s context window in tokens, computed the same way as the main status line’s `context_window.context_window_size`, so you can render a per-row percentage from `tokenCount`. Both fields require Claude Code v2.1.205 or later and are omitted for a task whose model isn’t resolved yet. Write one JSON line to stdout per row you want to override, in the form `{"id": "<task id>", "content": "<row body>"}`. The `content` string is rendered as-is, including ANSI colors and OSC 8 hyperlinks. Omit a task’s `id` to keep the default rendering for that row; emit an empty `content` string to hide it. The same trust and `disableAllHooks` gates that apply to `statusLine` apply here. Plugins can ship a default `subagentStatusLine` in their [`settings.json`](</docs/en/plugins-reference#standard-plugin-layout>). +The command runs once per refresh tick and receives all visible subagent rows as a single JSON object on stdin. The input includes the [base hook fields](</docs/en/hooks#common-input-fields>), a `columns` field with the usable row width, and a `tasks` array. Each task has `id`, `name`, `type`, `status`, `description`, `label`, `startTime`, `model`, `effort`, `contextWindowSize`, `tokenCount`, `tokenSamples`, and `cwd`. The per-task `model` field is the resolved model ID the task runs on. `contextWindowSize` is that model’s context window in tokens, computed the same way as the main status line’s `context_window.context_window_size`, so you can render a per-row percentage from `tokenCount`. Both fields require Claude Code v2.1.205 or later and are omitted for a task whose model isn’t resolved yet. The per-task `effort` field is the reasoning effort set for that subagent, in its [definition frontmatter](</docs/en/sub-agents#supported-frontmatter-fields>) or on the individual invocation. The value is either one of the effort level strings `low`, `medium`, `high`, `xhigh`, or `max`, or a numeric token budget. The field reports the configured value as written: if the model doesn’t support that level, the effort Claude Code actually applies may differ. The field requires Claude Code v2.1.214 or later and is absent when the subagent inherits the session’s effort level. Write one JSON line to stdout per row you want to override, in the form `{"id": "<task id>", "content": "<row body>"}`. The `content` string is rendered as-is, including ANSI colors and OSC 8 hyperlinks. Omit a task’s `id` to keep the default rendering for that row; emit an empty `content` string to hide it. The same trust and `disableAllHooks` gates that apply to `statusLine` apply here. Plugins can ship a default `subagentStatusLine` in their [`settings.json`](</docs/en/plugins-reference#standard-plugin-layout>). ##
modified Create custom subagents View current →
--- a/sub-agents.md +++ b/sub-agents.md @@ -276,6 +276,7 @@ Subagents inherit the [internal tools](</docs/en/tools-reference>) and MCP tools available in the main conversation by default. The following tools depend on the main conversation’s UI or session state and aren’t available to subagents, even when listed in the `tools` field: * `AskUserQuestion` + * `EndConversation`, which can end only the main conversation; see [EndConversation tool behavior](</docs/en/tools-reference#endconversation-tool-behavior>) * `EnterPlanMode` * `ExitPlanMode`, unless the subagent’s `permissionMode` is `plan` * `ScheduleWakeup`
modified Configure your terminal for Claude Code View current →
--- a/terminal-config.md +++ b/terminal-config.md @@ -293,7 +293,7 @@ Switch to fullscreen rendering -If the display flickers or the scroll position jumps while Claude is working, switch to [fullscreen rendering mode](</docs/en/fullscreen>). It draws to a separate screen the terminal reserves for full-screen apps instead of appending to your normal scrollback, which keeps memory usage flat and adds mouse support for scrolling and selection. In this mode you scroll with the mouse or PageUp inside Claude Code rather than with your terminal’s native scrollback; see the [fullscreen page](</docs/en/fullscreen#search-and-review-the-conversation>) for how to search and copy. If flicker is the only problem and your terminal supports synchronized output but isn’t auto-detected, such as Emacs `eat`, set [`CLAUDE_CODE_FORCE_SYNC_OUTPUT=1`](</docs/en/env-vars>) to stop the flicker without changing renderers. Run `/tui fullscreen` to switch and save the preference. Your conversation relaunches intact and future sessions start in fullscreen. You can also set the `CLAUDE_CODE_NO_FLICKER` environment variable before starting Claude Code: +In [screen reader mode](</docs/en/accessibility>), this section doesn’t apply. Claude Code always renders as plain scrolling text except in attached [background sessions](</docs/en/agent-view>), and if you run `/tui fullscreen` in any other session, Claude Code prints an explanation instead of switching. If the display flickers or the scroll position jumps while Claude is working, switch to [fullscreen rendering mode](</docs/en/fullscreen>). It draws to a separate screen the terminal reserves for full-screen apps instead of appending to your normal scrollback, which keeps memory usage flat and adds mouse support for scrolling and selection. In this mode you scroll with the mouse or PageUp inside Claude Code rather than with your terminal’s native scrollback; see the [fullscreen page](</docs/en/fullscreen#search-and-review-the-conversation>) for how to search and copy. If flicker is the only problem and your terminal supports synchronized output but isn’t auto-detected, such as Emacs `eat`, set [`CLAUDE_CODE_FORCE_SYNC_OUTPUT=1`](</docs/en/env-vars>) to stop the flicker without changing renderers. Run `/tui fullscreen` to switch and save the preference. Your conversation relaunches intact and future sessions start in fullscreen. You can also set the `CLAUDE_CODE_NO_FLICKER` environment variable before starting Claude Code: Bash and Zsh
modified Tools reference View current →
--- a/tools-reference.md +++ b/tools-reference.md @@ -1,4 +1,6 @@ -Claude Code has access to a set of built-in tools that help it understand and modify your codebase. The tool names are the exact strings you use in [permission rules](</docs/en/permissions#tool-specific-permission-rules>), [subagent tool lists](</docs/en/sub-agents>), and [hook matchers](</docs/en/hooks>). To disable a tool entirely, add its name to the `deny` array in your [permission settings](</docs/en/permissions#tool-specific-permission-rules>). To add custom tools, connect an [MCP server](</docs/en/mcp>). To extend Claude with reusable prompt-based workflows, write a [skill](</docs/en/skills>), which runs through the existing `Skill` tool rather than adding a new tool entry. The Permission required column shows whether the tool prompts in the default permission mode for paths inside the working directory. File-access tools marked No, including `Read`, `Grep`, and `Glob`, still prompt for paths outside the [working directory and additional directories](</docs/en/permissions#working-directories>). `Bash` is marked Yes but runs a built-in set of [read-only commands](</docs/en/permissions#read-only-commands>) without prompting. +Claude Code has access to a set of built-in tools that help it understand and modify your codebase. The tool names are the exact strings you use in [permission rules](</docs/en/permissions#tool-specific-permission-rules>), [subagent tool lists](</docs/en/sub-agents>), and [hook matchers](</docs/en/hooks>). To control which tools Claude can use and when it asks first, configure [permission rules](</docs/en/permissions#tool-specific-permission-rules>) in your settings, [hooks](</docs/en/hooks>), or a [subagent’s tool list](</docs/en/sub-agents#supported-frontmatter-fields>). See Configure tools with permission rules and hooks for each place that accepts a tool name. To add custom tools, connect an [MCP server](</docs/en/mcp>). To extend Claude with reusable prompt-based workflows, write a [skill](</docs/en/skills>), which runs through the existing `Skill` tool rather than adding a new tool entry. + +The `Permission required` column shows whether the tool prompts in the default permission mode for paths inside the working directory. File-access tools marked No, including `Read`, `Grep`, and `Glob`, still prompt for paths outside the [working directory and additional directories](</docs/en/permissions#working-directories>). `Bash` is marked Yes but runs a built-in set of [read-only commands](</docs/en/permissions#read-only-commands>) without prompting. Tool| Description| Permission required ---|---|--- @@ -10,6 +12,7 @@ `CronDelete`| Cancels a scheduled task by ID| No `CronList`| Lists all scheduled tasks in the session| No `Edit`| Makes targeted edits to specific files. See Edit tool behavior| Yes +`EndConversation`| Ends the session, in rare cases of sustained abusive input or when you ask Claude to demonstrate the tool. Requires Claude Code v2.1.213 or later. See EndConversation tool behavior| No `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 instead of creating a new one. On first entry the target may be a worktree of the current repository or, in a multi-repo workspace, of a repository nested inside it. Before v2.1.203, a nested repository’s worktree was rejected. A `path` outside `.claude/worktrees/` prompts for your approval before entering, since it moves the session’s working directory and write access to that location. New-worktree creation and paths under `.claude/worktrees/` don’t prompt. Before v2.1.206, Claude entered paths outside `.claude/worktrees/` without a prompt. From within a worktree session, or from a subagent with a pinned working directory such as [`isolation: worktree`](</docs/en/sub-agents#supported-frontmatter-fields>), only the `path` form is available and the target must be under `.claude/worktrees/` of the session’s repository| Yes `ExitPlanMode`| Presents a plan for approval and exits plan mode| Yes @@ -157,6 +160,30 @@ ​ +EndConversation tool behavior + +The EndConversation tool ends the current session. Claude uses it only in two situations: + + * as a last resort against sustained abusive input, after attempts to redirect the conversation have failed and after a clear warning in an earlier message + * when you explicitly ask to see the tool demonstrated and confirm that you want the session to end + +General frustration, profanity, or a task going badly don’t qualify, and neither do requests for harmful content, which Claude declines instead of ending the session. Claude Code follows the same approach as claude.ai, which can [end a rare subset of chats](<https://www.anthropic.com/research/end-subset-conversations>). After Claude ends an interactive session, the session locks. New prompts and most commands return `Claude ended this conversation. Start a new session (or /clear) to continue.`, and only `/clear`, `/resume`, `/help`, `/exit`, and `/feedback` still run. Claude Code records the end in the session’s transcript, so resuming an ended session restores the lock; the session’s history isn’t deleted. Resuming an ended session in [non-interactive mode](</docs/en/headless>) with the `-p` flag errors and exits with code 1, so a script doesn’t read the ended run as a success. The tool never prompts for permission, and [PreToolUse hooks](</docs/en/hooks#pretooluse>) don’t run for it. While any other tool remains, you can’t block it either: [deny and ask rules](</docs/en/permissions#tool-specific-permission-rules>) naming `EndConversation` have no effect, and neither `--disallowedTools` nor a `--tools` list can remove it. The exemption is deliberate: the tool does nothing except end the conversation, never reading or modifying files or data, and a safeguard of this kind holds only if the session it applies to can’t turn it off. When your deny rules remove every other tool and also match `EndConversation`, as `"*"` does, Claude Code removes it too rather than leaving it as the only tool, unless an allow rule names `EndConversation` explicitly. A deny list that removes every other tool without matching `EndConversation` leaves it in place. [Subagents](</docs/en/sub-agents>) never get the tool. Background tasks that share the main conversation’s tool list see it, but calling it there ends nothing. The tool appears only when all of the following hold: + + * **Version** : Claude Code v2.1.213 or later. + * **Model** : the session’s model is Claude Opus 4.8, Claude Sonnet 5, Claude Fable 5, or a later version of one of those families. + * **Surface** : an interactive terminal session, including a `claude` session in an IDE’s integrated terminal, which is how the [JetBrains plugin](</docs/en/jetbrains>) runs it. Other surfaces don’t include the tool, such as: + * non-interactive `-p` runs + * sessions through the [Agent SDK](</docs/en/agent-sdk/overview>) TypeScript and Python packages + * the [VS Code extension](</docs/en/vs-code>) panel, which bundles its own CLI + * [GitHub Actions](</docs/en/github-actions>) + * [Claude Code on the web](</docs/en/claude-code-on-the-web>) + * **Startup mode** : not a [`--bare`](</docs/en/headless#start-faster-with-bare-mode>) session. Bare mode loads only shell and file tools, so the tool is never registered there. + * **Provider** : not available on [Amazon Bedrock](</docs/en/amazon-bedrock>), [Claude Platform on AWS](</docs/en/claude-platform-on-aws>), [Google Cloud’s Agent Platform](</docs/en/google-vertex-ai>), or [Microsoft Foundry](</docs/en/microsoft-foundry>), or on sessions signed in through a [cloud gateway](</docs/en/claude-apps-gateway>). + +## + +​ + Glob tool behavior The Glob tool finds files by name pattern. It supports standard glob syntax including `**` for recursive directory matching:
modified Troubleshoot installation and login View current →
--- a/troubleshoot-install.md +++ b/troubleshoot-install.md @@ -29,6 +29,7 @@ `cannot execute binary file: Exec format error` in WSL| WSL1 native-binary regression PowerShell installer completes but `claude` is not found or shows an old version| Add the install directory to your PATH, then open a new terminal `dyld: cannot load`, `dyld: Symbol not found`, or `Abort trap` on macOS| Binary incompatibility +`claude update` hangs after `Checking for updates`, or `claude doctor` hangs with no output| Move the directory at a shell config path `Invoke-Expression: Missing argument in parameter list`| Install script returns HTML `App unavailable in region`| Claude Code is not available in your country. See [supported countries](<https://www.anthropic.com/supported-countries>). `unable to get local issuer certificate`| Configure corporate CA certificates @@ -468,6 +469,18 @@ ​ +`claude update` or `claude doctor` hangs + +`claude update` and `claude doctor` scan your shell configuration files for an outdated `claude` alias: `~/.zshrc`, `~/.bashrc`, and `~/.config/fish/config.fish`, plus on macOS the first of `~/.bash_profile`, `~/.bash_login`, or `~/.profile` that exists. If you set `ZDOTDIR`, the Zsh file is `$ZDOTDIR/.zshrc` instead. When one of those paths is a directory, Claude Code skips it and both commands complete normally. Before v2.1.214, a directory at one of those paths made both commands hang and left the System diagnostics section of `/status` blank. `claude doctor` hung with no output; `claude update` hung right after printing `Checking for updates`. If you hit the hang on an earlier version, find the directory. In this command’s output, a line starting with `d` marks that path as a directory. A `No such file or directory` line means nothing exists at that path and isn’t the cause: + + ls -ld ~/.zshrc ~/.bashrc ~/.bash_profile ~/.bash_login ~/.profile ~/.config/fish/config.fish + +Move the directory aside, or update to v2.1.214 or later. Since `claude update` hangs on the affected versions, update by rerunning the [install script](</docs/en/setup#install-claude-code>) instead. + +### + +​ + Claude Desktop overrides the `claude` command on Windows If you installed an older version of Claude Desktop, it may register a `Claude.exe` in the `WindowsApps` directory that takes PATH priority over Claude Code CLI. Running `claude` opens the Desktop app instead of the CLI. Update Claude Desktop to the latest version to fix this issue.
modified Agent SDK reference - TypeScript View current →
--- a/typescript.md +++ b/typescript.md @@ -138,7 +138,7 @@ description: string, inputSchema: Schema, handler: (args: InferShape<Schema>, extra: unknown) => Promise<CallToolResult>, - extras?: { annotations?: ToolAnnotations } + extras?: { annotations?: ToolAnnotations; searchHint?: string; alwaysLoad?: boolean } ): SdkMcpToolDefinition<Schema>; #### @@ -153,7 +153,7 @@ `description`| `string`| A description of what the tool does `inputSchema`| `Schema extends AnyZodRawShape`| Zod schema defining the tool’s input parameters (supports both Zod 3 and Zod 4) `handler`| `(args, extra) => Promise<``CallToolResult``>`| Async function that executes the tool logic -`extras`| `{ annotations?: ``ToolAnnotations`` }`| Optional MCP tool annotations providing behavioral hints to clients +`extras`| `{ annotations?: ``ToolAnnotations``; searchHint?: string; alwaysLoad?: boolean }`| Optional extras. `annotations` provides MCP behavioral hints to clients. `searchHint` is a one-line capability phrase shown in the deferred-tool list when [tool search](</docs/en/agent-sdk/tool-search>) is active. `alwaysLoad: true` keeps this tool’s full schema in the initial prompt instead of deferring it #### @@ -195,7 +195,9 @@ function createSdkMcpServer(options: { name: string; version?: string; + instructions?: string; tools?: Array<SdkMcpToolDefinition<any>>; + alwaysLoad?: boolean; }): McpSdkServerConfigWithInstance; #### @@ -208,7 +210,9 @@ ---|---|--- `options.name`| `string`| The name of the MCP server `options.version`| `string`| Optional version string +`options.instructions`| `string`| Optional server instructions, returned from `initialize` and surfaced to the model as an MCP instructions block `options.tools`| `Array<SdkMcpToolDefinition>`| Array of tool definitions created with `tool()` +`options.alwaysLoad`| `boolean`| When `true`, every tool from this server stays in the initial prompt and is never deferred behind [tool search](</docs/en/agent-sdk/tool-search>). Combines with per-tool `alwaysLoad` in `tool()` ###
modified Find bugs with ultrareview View current →
--- a/ultrareview.md +++ b/ultrareview.md @@ -18,7 +18,7 @@ /code-review ultra -Without arguments, ultrareview reviews the diff between your current branch and the default branch, including any uncommitted and staged changes in your working tree. Claude Code bundles the repository state and uploads it to a remote sandbox for the review. To compare against a different base, such as on a repository whose integration branch is `develop` or `trunk`, pass the branch name instead: `/code-review ultra develop`. A base branch that exists only on `origin` is fetched, and a name with a typo gets a closest-branch suggestion. Both behaviors require Claude Code v2.1.212 or later. To review a GitHub pull request instead, pass the PR number. +Without arguments, ultrareview reviews the diff between your current branch and the default branch, including any uncommitted and staged changes in your working tree. Claude Code bundles the repository state and uploads it to a remote sandbox for the review. To compare against a different base, such as on a repository whose integration branch is `develop` or `trunk`, pass the branch name instead: `/code-review ultra develop`. A base branch that exists only on `origin` is fetched, and a name with a typo gets a closest-branch suggestion. Both behaviors require Claude Code v2.1.212 or later. If your branch shares no merge base with the base branch, for example when the two histories are unrelated, Claude Code offers to review every tracked file in the repository instead. The whole-repository fallback requires a full clone and applies the same size limits as a branch review. Before v2.1.214, `/code-review ultra` refused to run without a merge base. To review a GitHub pull request instead, pass the PR number. /code-review ultra 1234 @@ -73,7 +73,7 @@ claude ultrareview 1234 claude ultrareview origin/main -Without arguments, the subcommand reviews the diff between your current branch and the default branch. Pass a PR number to review a pull request, or pass a base branch to review the diff against that branch instead. Invoking the subcommand counts as consent for the billing and terms prompt that the interactive command shows. If the base branch you pass exists on `origin` but not in your local clone, Claude Code fetches it and continues. If the name matches no branch, the error message suggests the closest branch name. Before v2.1.212, both cases failed with a not-a-branch error. Progress messages and the live session URL go to stderr so stdout stays parseable. Use these flags to control the output and timeout: +Without arguments, the subcommand reviews the diff between your current branch and the default branch, with the same whole-repository fallback as `/code-review ultra` when no merge base exists. Pass a PR number to review a pull request, or pass a base branch to review the diff against that branch instead. Invoking the subcommand counts as consent for the whole-repository fallback and for the billing and terms prompt that the interactive command shows, so the run starts without waiting for input. If the base branch you pass exists on `origin` but not in your local clone, Claude Code fetches it and continues. If the name matches no branch, the error message suggests the closest branch name. Before v2.1.212, both cases failed with a not-a-branch error. Progress messages and the live session URL go to stderr so stdout stays parseable. Use these flags to control the output and timeout: Flag| Description ---|---