modified Configure auto mode View current →
--- a/auto-mode-config.md +++ b/auto-mode-config.md @@ -329,7 +329,42 @@ Review denials -To review and retry actions the auto mode classifier denied, open `/permissions` and select the **Recently denied** tab, where Claude Code records each denial. Press `r` on a denied action to mark it for retry: when you exit the dialog, Claude Code sends a message telling the model it may retry that tool call and resumes the conversation. When the classifier produces [no verdict on the action](</docs/en/errors#auto-mode-cannot-determine-the-safety-of-an-action>), because a safety check separate from auto mode refused the classifier’s own request or its response didn’t parse, Claude Code denies the action without recording it under **Recently denied**. The linked error entry covers what Claude is told and how to run the action if you need it. +To let Claude retry a blocked action, use the **Recently blocked** tab in `/permissions`: + +1 + +Open the tab + +Run `/permissions` in your session to open the permissions dialog, then select the **Recently blocked** tab. + +2 + +Check the action + +Highlight the action’s row and read its command or input below the list. Go by the command or input, not the row’s description, which Claude or the tool wrote. + +3 + +Approve the action + +Press `r` to approve the action and let Claude retry it. + +4 + +Close the dialog + +Press `Esc` to close the dialog and apply your approval. If Claude was working when you opened `/permissions`, send a message once Claude finishes to let Claude retry the action. Otherwise, you don’t need to send anything: Claude continues now and may retry it. If it doesn’t, name the action in your next message, as [Approvals you state in conversation](</docs/en/permission-modes#approvals-you-state-in-conversation>) describes. + +Approving an action doesn’t add a permission rule. In auto mode, a retried action goes through the check again, so it can be blocked again. To let a command through from now on, add an `allow` rule. If you don’t want Claude to retry right away, you can approve an action for later, take back an approval, or close the dialog and discard your approvals: + + * **Approve for later** : press `Enter` on the row, then `Esc`. The row leaves the tab, and Claude may retry the action after your next message once Claude finishes. If you also pressed `r` on another row, the row where you pressed `Enter` stays on the tab and Claude isn’t told about that action. Approve that row on your next visit, or press `r` on both + * **Take back an approval** : before you press `Esc`, press `Enter` on the row, whether you approved it with `Enter` or `r` + * **Close the dialog and discard your approvals** : press `Ctrl+C` twice + +You can’t approve an action from the tab when its row can’t show all of its command or input, or when the action has no row: + + * **The row reads`This row can't be approved here`**: if you intended the action, tell Claude in your next message and Claude may try it again + * **No row, and`Not run` or a classifier error in the conversation**: auto mode’s classifier gave no verdict. To see how to run the action, read [Auto mode cannot determine the safety of an action](</docs/en/errors#auto-mode-cannot-determine-the-safety-of-an-action>) ### @@ -337,13 +372,13 @@ Fix a denial with an allow rule, an environment entry, or a retry -To read the command or URL behind a notice such as `bash denied by auto mode · [Data Exfiltration] · /permissions`, use the **Recently denied** tab, a hook, or the conversation: - - * **Recently denied tab** : in the `/permissions` dialog, highlight a denied Bash or PowerShell action to read its command below the list. In [screen reader mode](</docs/en/accessibility>), all the commands appear before the list instead. - * **Hook** : to capture the exact input of denials programmatically, add a [`PermissionDenied` hook](</docs/en/hooks#permissiondenied>), which receives it as `tool_input`. +Notices read like `bash blocked by auto mode · /permissions · Auto mode: [Data Exfiltration]`. To read the command or URL behind one, use the **Recently blocked** tab, a hook, or the conversation: + + * **Recently blocked tab** : highlight the action’s row. In [screen reader mode](</docs/en/accessibility>), every command and input appears before the list. + * **Hook** : to capture the exact input of denials programmatically, add a [`PermissionDenied` hook](</docs/en/hooks#permissiondenied>), which receives it as `tool_input`. If your hook reads `reason`, expect no `Auto mode:` prefix, and text such as `Blocked by classifier` instead of `No reason provided`. * **Conversation** : find the tool call. If the call appears shortened or folded into a summary line such as `Ran 3 shell commands`, press `Ctrl+O` to open the [transcript viewer](</docs/en/interactive-mode#transcript-viewer>), which expands it. -The text beneath the call tells you whether there is anything to fix. A dim `Not run · auto mode's check had no usable answer` row, or text that reports a problem with the classifier itself, such as `Auto mode could not evaluate this action`, means Claude Code blocked the call without a verdict from the classifier. For a `Not run` row, press `Ctrl+O` to read the full message, then see [Auto mode cannot determine the safety of an action](</docs/en/errors#auto-mode-cannot-determine-the-safety-of-an-action>) or [The server returned no safety verdict](</docs/en/errors#the-server-returned-no-safety-verdict>) for what to do. Otherwise, a line reading `Denied by auto mode classifier` with a reason such as `[Production Deploy]` or `Blocked by classifier` means the classifier judged the call unsafe, so pick the fix from what the call was trying to reach or do: +The text beneath the call tells you whether there is anything to fix. A dim `Not run · auto mode's check had no usable answer` row, or text that reports a problem with the classifier itself, such as `Auto mode could not evaluate this action`, means Claude Code blocked the call without a verdict from the classifier. For a `Not run` row, press `Ctrl+O` to read the full message, then see [Auto mode cannot determine the safety of an action](</docs/en/errors#auto-mode-cannot-determine-the-safety-of-an-action>) or [The server returned no safety verdict](</docs/en/errors#the-server-returned-no-safety-verdict>) for what to do. Otherwise, a `Blocked by auto mode` line means the classifier judged the call unsafe. To let the call through, take the step that matches what Claude was trying to reach or do: * A destination Claude needs throughout the task, such as a package registry, an internal domain, or a repository host: add it to `autoMode.environment`. * A command you want to run without review from now on: add an `allow` rule.
modified Best practices for Claude Code View current →
--- a/best-practices.md +++ b/best-practices.md @@ -387,7 +387,7 @@ * Sensitive data sent to external endpoints * Actions that look driven by content Claude read rather than by you -When it does block something, you get a notification and the action shows up under **Recently denied** in `/permissions`, where you can retry it with a manual approval. After [three blocks in a row](</docs/en/permission-modes#when-auto-mode-falls-back>) (or twenty in total), auto mode pauses and goes back to asking you. None of this replaces your deterministic controls, because it runs _after_ them. Deny and ask rules and `PreToolUse` hooks apply before the classifier sees anything, so a deny rule blocks in auto mode exactly like it does everywhere else. The sandbox still confines the [shell commands it wraps](</docs/en/sandboxing#what-runs-outside-the-sandbox>). +When auto mode blocks an action, you get a notification and the action shows up under **Recently blocked** in `/permissions`, where you can [approve the action so Claude may retry](</docs/en/auto-mode-config#review-denials>). After [three blocks in a row](</docs/en/permission-modes#when-auto-mode-falls-back>) (or twenty in total), auto mode pauses and goes back to asking you. None of this replaces your deterministic controls, because it runs _after_ them. Deny and ask rules and `PreToolUse` hooks apply before the classifier sees anything, so a deny rule blocks in auto mode exactly like it does everywhere else. The sandbox still confines the [shell commands it wraps](</docs/en/sandboxing#what-runs-outside-the-sandbox>). You can also say `don't push until I've reviewed` in the conversation, and the classifier [treats that as a block signal](</docs/en/permission-modes#boundaries-you-state-in-conversation>). It’s still a model reading the transcript, and the sentence can get lost when the conversation compacts, so anything that matters belongs in a deny rule.
modified Claude apps gateway configuration View current →
Show diff (120 lines)
--- a/claude-apps-gateway-config.md +++ b/claude-apps-gateway-config.md @@ -355,9 +355,46 @@ version: "1" # a published version number, or DRAFT # keep the quotes: a bare 1 fails at boot -The gateway doesn’t support guardrail input tags. It adds no guard content tags to prompts, so a guardrail filter that Amazon Bedrock applies only to tagged input doesn’t run on traffic through the gateway. For which filters depend on input tags, see [input tags](<https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-tagging.html>) in the Amazon Bedrock documentation. - Also grant `bedrock:ApplyGuardrail` on the guardrail to the principal that signs this upstream’s requests: the gateway’s AWS principal, or with `assume_role` the role named in `role_arn`. Set `guardrail` on every `bedrock` upstream or on none. The gateway refuses to start on a mix, because failover could otherwise send a request to a Bedrock upstream that has no guardrail. The guardrail covers Bedrock upstreams only. If you list another provider in `upstreams`, the gateway sends requests to that provider without the guardrail, or refuses to start if that provider is `mantle`. When a `/v1/messages` request whose body carries an `amazon-bedrock-*` field, such as `amazon-bedrock-guardrailConfig`, reaches a Bedrock upstream that has `guardrail` set, the gateway answers 400 instead of forwarding it. + +By default the gateway adds no input tags to prompts, so a guardrail filter that Amazon Bedrock applies only to tagged input doesn’t run on traffic through the gateway. To add the tags, set `input_tagging`. For which filters depend on input tags, see [input tags](<https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-tagging.html>) in the Amazon Bedrock documentation. + +##### Add guardrail input tags + +To have the gateway add the input tags that an Amazon Bedrock guardrail’s [prompt attacks filter](<https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-prompt-attack.html>) needs, set `input_tagging` in the `guardrail` block and restart the gateway. Set the same value on every `bedrock` upstream, or the gateway refuses to start. Requires Claude Code v2.1.316 or later on the gateway server. A gateway on a version that lacks the key exits at startup with `Unrecognized key(s) in object: 'input_tagging'`. + +According to [Amazon Bedrock’s documentation](<https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-tagging.html>), every filter in the guardrail stops evaluating untagged content once a request carries input tags. Try `input_tagging` on a test gateway before you set it on one that developers use. + +`input_tagging` takes one of these values: + +`input_tagging`| Where the gateway tags text| After the guardrail blocks a prompt +---|---|--- +`last_message`| The `user` messages since Claude’s last reply| In Claude Code, the next prompt can pass, and Claude then receives the blocked prompt as part of the conversation +`user_messages`| `user` messages| Later prompts in the session can be blocked as well, until the developer removes the blocked prompt +`all_messages`| `user` and `assistant` messages| Same as `user_messages` +`all_messages_and_system`| The system prompt and every message, including [mid-conversation system messages](</docs/en/llm-gateway-protocol#feature-pass-through>)| Same as `user_messages` + +With `last_message`, if the `user` messages since Claude’s last reply hold no text to tag, the gateway tags the mid-conversation system messages since that reply instead. A tool call counts as a reply. Amazon Bedrock’s guidance for the prompt attacks filter is to [tag user input so that the system prompt is excluded](<https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-prompt-attack.html>). If you set `all_messages_and_system`, a filter that flags Claude Code’s own system prompt can block requests. The example below tags text in every `user` message: + + upstreams: + - provider: bedrock + region: us-east-1 + auth: {} + guardrail: + id: gr-abc123 + version: "1" + input_tagging: user_messages + +`user` messages can also hold text that Claude Code adds, such as [system reminders](</docs/en/glossary#system-reminder>), so check on the test gateway that ordinary requests aren’t blocked. In Anthropic’s testing, a tagged session kept its [prompt cache](</docs/en/prompt-caching>) reads from one prompt to the next, and the tags added no input tokens. + +##### What input tags don’t cover + +No `input_tagging` value stops a developer who deliberately puts text where no tag goes. Don’t count on the guardrail to evaluate these parts of a request: + + * **Content the gateway doesn’t tag** : messages that your `input_tagging` value leaves out, tool definitions, tool call inputs, images, and PDFs, among others. Unless you set `all_messages_and_system`, the system prompt is untagged too. + * **Tool results** : these hold what Claude’s tools return, such as file contents and web pages. In Anthropic’s testing, a word filter didn’t evaluate them, with or without tags. + +If your AWS account or organization enforces a guardrail, see [Amazon Bedrock’s documentation](<https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-enforcements.html>) for how that guardrail treats input tags. ##### Bedrock in another AWS account @@ -768,7 +805,7 @@ `managed` -The `managed` block defines role-based access policies keyed on IdP groups or email domain. Policies are evaluated in order; the first match is selected, then merged onto the `match: {}` catch-all base. They are served per-user at `GET /managed/settings` with ETag/304 caching. +The `managed` block defines role-based access policies keyed on IdP groups or email domain. Policies are evaluated in order; by default the first match is selected, then merged onto the `match: {}` catch-all base. A user who matches two role policies gets only the first, so the second policy’s deny rules don’t apply unless you apply every matching policy. Policies are served per-user at `GET /managed/settings` with ETag/304 caching. managed: policies: @@ -803,7 +840,7 @@ `match: { email_domain: example.com }`| Matches the part after the last `@` in the JWT’s `email` claim, case-insensitive. Accepts one domain per policy. `match: { groups: [a], email_domain: example.com }`| Both conditions must match -An authenticated user who matches no policy gets the gateway’s defaults, which means every model in the catalog and no managed settings. Add a `match: {}` catch-all last if you want a guaranteed default policy. +An authenticated user who matches no policy gets the gateway’s defaults, which means every model in the catalog and no managed settings. Add a `match: {}` catch-all last if you want a guaranteed default policy. Put organization-wide deny rules in the `match: {}` policy, because a group policy’s rules apply only while the user’s token carries that group. The gateway keeps no user directory of its own. It authorizes each request from the user’s IdP token, reading group membership from the token’s `groups` claim and evaluating policies against it. There is no roster to enumerate and no accounts to pre-create, and therefore no SCIM endpoint, because there is nothing for SCIM to sync into.Run user and group lifecycle management at the source of truth, which is your IdP’s native SCIM provisioning or a dedicated identity-governance platform. Membership and deprovisioning governed there flow into the gateway automatically through the token. If you want SCIM provisioning of Claude accounts themselves, that is a [Claude for Enterprise](</docs/en/admin-setup>) capability.Two propagation clocks apply: @@ -811,6 +848,50 @@ * **Group membership** : changing a user’s group membership changes which policy matches them. This takes effect on the next session re-mint, meaning the next silent refresh, bounded by `session.ttl_hours`. Claude Desktop follows its own schedule. + +#### + +​ + +Apply every matching policy + +A user who matches several role policies gets only the first unless you set `policy_mode: layered` beside `policies`. With `layered`, every policy that matches the user applies, down to the first `match: {}` policy. `policy_mode` requires Claude Code v2.1.316 or later on the gateway server. A gateway on a version that lacks it refuses to start when it finds the key. Upgrade every replica before you add the key, and remove the key before you roll back to an earlier version. This example has one group that loses `WebFetch` and one that gains Opus: + + managed: + policy_mode: layered + policies: + - match: { groups: [no-web] } + cli: + permissions: { deny: ["WebFetch"] } + - match: { groups: [opus-users] } + cli: + availableModels: [opus, sonnet] + - match: {} + cli: + availableModels: [sonnet] + enforceAvailableModels: true + +The table shows what a user in both `no-web` and `opus-users` receives under the default, `first_match`, and under `layered`. + +Setting| `first_match`| `layered` +---|---|--- +`availableModels`| `sonnet`| `opus`, `sonnet` +`enforceAvailableModels`| `true`| `true` +`permissions.deny`| `WebFetch`| `WebFetch` + +The gateway merges each matching policy onto the ones listed below it, by the same merge rules as the base layer: + + * **Allow-lists, single values, and blocks such as`sandbox`**: each comes whole from the first-listed matching policy that sets it, so two groups’ `availableModels` lists don’t add up. + * **Deny-lists and hook arrays** : these add up across every matching policy, so a user in two groups gets both groups’ deny rules. + * **`env`, `modelOverrides`, and `skillOverrides`**: entries merge by name, and the first-listed matching policy that sets a name supplies its value. + * **`desktop` keys**: these merge by the rules for the base `desktop` block. + +Policies can add up to looser rules than any one of them gives alone. For example, the `match: {}` policy sets `sandbox.enabled: true`, one group’s policy sets `permissions.allow: ["Bash"]`, and another group’s sets `sandbox.enabled: false`. A user in both groups receives `Bash` allowed with the sandbox off. In this case, list the policy that allows `Bash` first, and copy the `match: {}` policy’s whole `sandbox` block into it. + +With `layered`, the gateway refuses to start on some settings, including these: + + * **A`!` pattern**: a [`!` negation](</docs/en/permissions#special-characters-and-negation>) in a `Read` or `Edit` rule in any policy’s `permissions.deny` or `permissions.ask` list, the `match: {}` policy’s included + * **A limit on hooks outside the catch-all** : `disableAllHooks`, `allowedHttpHookUrls`, or `httpHookAllowedEnvVars` in any policy other than `match: {}` ####
modified Deploy Claude apps gateway on AWS View current →
--- a/claude-apps-gateway-on-aws.md +++ b/claude-apps-gateway-on-aws.md @@ -592,7 +592,7 @@ Have the developer pass the id of the team the work is for, such as `claude --model data-claude-opus-4-8`. -The gateway applies the [first policy that matches](</docs/en/claude-apps-gateway-config#managed>), so a developer in only the two team groups gets the `team-platform` policy. Their sessions on the data team’s id fail with `is not in your role's availableModels allowlist`, naming Claude Code’s default model and not the id they typed. If you list both team groups in one policy’s `groups` instead, everyone in either team can bill either team’s profile. In the gateway’s own [spend limits](</docs/en/claude-apps-gateway-spend-limits#set-a-cap>), the developer has one total and one cap per period, by default the lowest of their groups’ caps, whichever id a session uses. To keep one team’s lower cap from stopping work for the other, set a per-user cap for the developer. +By default, the gateway applies the [first policy that matches](</docs/en/claude-apps-gateway-config#managed>), so a developer in only the two team groups gets the `team-platform` policy. Their sessions on the data team’s id fail with `is not in your role's availableModels allowlist`, naming Claude Code’s default model and not the id they typed. If you list both team groups in one policy’s `groups` instead, everyone in either team can bill either team’s profile. In the gateway’s own [spend limits](</docs/en/claude-apps-gateway-spend-limits#set-a-cap>), the developer has one total and one cap per period, by default the lowest of their groups’ caps, whichever id a session uses. To keep one team’s lower cap from stopping work for the other, set a per-user cap for the developer. ##
modified Commands View current →
--- a/commands.md +++ b/commands.md @@ -92,7 +92,7 @@ `/model [model]`| Switch the AI model and save it as your default for new sessions. For models that support it, use left/right arrows to [adjust effort level](</docs/en/model-config#adjust-effort-level>). With no argument, opens a picker; press `s` on a row to switch for the current session only. See [when the new model starts](</docs/en/interactive-mode#when-claude-code-sends-what-you-queued>). Before v2.1.242, it could wait. With `-p`, pass a model argument, which isn’t saved as your default; requires v2.1.205 or later `/output-style [style]`| List [output styles](</docs/en/output-styles>) or switch to one, for example `/output-style concise`. See [Change your output style](</docs/en/output-styles#change-your-output-style>). Requires Claude Code v2.1.269 or later `/passes`| Share a free week of Claude Code with friends. Only visible if your account is eligible -`/permissions`| Manage allow, ask, and deny rules for tool permissions. Opens an interactive dialog where you can view rules by scope, add or remove rules, manage working directories, and review [recent auto mode denials](</docs/en/auto-mode-config#review-denials>). You can also view and edit [auto mode classifier rules](</docs/en/auto-mode-config#edit-rules-from-permissions>) from the dialog’s **Auto mode** tab. When you run it while Claude is responding, Claude Code opens the dialog immediately and applies your changes starting with Claude’s next tool call in the same turn. Before v2.1.234, Claude Code queued the command until the turn finished. Alias: `/allowed-tools` +`/permissions`| Manage allow, ask, and deny rules for tool permissions. Opens an interactive dialog where you can view rules by scope, add or remove rules, manage working directories, and review [recent auto mode denials](</docs/en/auto-mode-config#review-denials>). You can also view and edit [auto mode classifier rules](</docs/en/auto-mode-config#edit-rules-from-permissions>) from the dialog’s **Auto mode** tab. Alias: `/allowed-tools` `/plan [description]`| Enter plan mode directly from the prompt. Pass an optional description to enter plan mode and immediately start with that task, for example `/plan fix the auth bug` `/plugin [subcommand]`| Manage Claude Code [plugins](</docs/en/plugins/overview>). Run with no argument to open the plugin menu, or pass a subcommand such as `list`, `install`, `enable`, or `disable` to act directly. Claude Code can activate a plugin during the install; the [install summary](</docs/en/plugins/install#install-a-plugin>) tells you whether it did or whether to run `/reload-plugins` `/plugin-authoring`| Load the reference Claude works from to [write a mod](</docs/en/plugins/mods/create#ask-claude-for-a-mod>). Claude can load it on its own when you ask for a mod. This is a skill from a [built-in plugin](</docs/en/plugins/mods/overview#mods-built-into-claude-code>), which you can turn off in `/plugin`. Requires Claude Code v2.1.287 or later
modified Desktop application View current →
--- a/desktop.md +++ b/desktop.md @@ -124,7 +124,7 @@ Claude can start a dev server and open it in the Browser pane to verify its changes. This works for frontend web apps as well as backend servers: Claude can test API endpoints, view server logs, and iterate on issues it finds. In most cases, Claude starts the server automatically after editing project files. You can also ask Claude to preview at any time. By default, Claude auto-verifies changes after every edit. In a local session, click an HTML, PDF, or video path in the chat to open it in the Browser pane. -In an SSH session, Claude can’t open your app in the Browser pane, because it doesn’t have the pane’s tools there. To look at the app yourself, forward its port to your computer. +In an SSH session, Claude doesn’t have the Browser pane’s tools, so it can’t open your app in the pane or auto-verify its changes. The pane’s **Dev servers** menu and your configured preview servers aren’t available either. To look at the app yourself, start its server on the remote machine, then forward its port to your computer. If the Browser pane isn’t open after Claude starts a server in a local session, click **Open** on the server’s card in the chat. From the Browser pane, you can: @@ -1162,7 +1162,7 @@ * **One-time codes with`MaxSessions 1`**: if every login prompts you, as with one-time codes, `!` commands fail. Run those commands in a terminal tab instead, which prompts in its own pane. * **Install folder** : Desktop installs a helper program and Claude Code under `~/.claude/remote/` in your home directory. It runs them from there, so that folder can’t be on a file system mounted `noexec`. Allow about 1 GB of disk space in the home directory of each user who connects. For what that folder holds, see Files and processes on the remote machine. * **Shell** : the shell set for your account on the remote machine has to run commands sent over SSH, as Bash, Zsh, and `sh` do - * **Network** : Claude Code runs on the remote machine and makes its network requests from there, so the machine needs the [network access that Claude Code requires](</docs/en/network-config#network-access-requirements>). If the machine can’t download Claude Code, Desktop downloads it on your computer and uploads it. Claude Code’s other requests still go out from the remote machine. On a Linux remote machine, if those requests need a proxy, set it for SSH sessions. + * **Network** : Claude Code runs on the remote machine and makes its network requests from there, so the machine needs the [network access that Claude Code requires](</docs/en/network-config#network-access-requirements>). If the machine can’t download Claude Code, Desktop downloads it on your computer and uploads it. Claude Code’s other requests still go out from the remote machine. If a Linux remote machine needs a proxy or a CA certificate, set it for SSH sessions. #### @@ -1194,7 +1194,7 @@ Set a proxy or a CA certificate for SSH sessions -If a Linux remote machine reaches the internet through a proxy or needs a CA certificate, add the [proxy and CA variables](</docs/en/network-config>) under `env` in `~/.claude/settings.json` there. Add them even if you already export them in `~/.profile`, `~/.bash_profile`, `~/.zprofile`, or `~/.zshrc` on that machine. In an SSH session, Claude Code doesn’t get the variables from those files, even when `claude` in a terminal on that machine does. The session can then hang, or show **The connection from … to the API failed** or **Authentication failed** , and signing in again doesn’t help. +If a Linux remote machine reaches the internet through a proxy or needs a CA certificate, add the [proxy and CA variables](</docs/en/network-config>) under `env` in `~/.claude/settings.json` there. Add them even if you already export them in `~/.profile`, `~/.bash_profile`, `~/.zprofile`, or `~/.zshrc` on that machine. In an SSH session, Claude Code doesn’t get the variables from those files, even when `claude` in a terminal on that machine does. The session can then hang, or show **The connection from … to the API failed** , **Authentication failed** , or **Claude Code on … couldn’t verify the API connection’s certificate**. Signing in again doesn’t help. 1 @@ -2081,6 +2081,32 @@ * **[Cowork](<https://claude.com/docs/cowork/overview>) sessions**: in a Cowork session on this machine, Claude Code never fetches admin-console settings, even when the user signs in with a Team or Enterprise account, and reads policy deployed to the machine unless your Claude Desktop configuration sets `requireCoworkFullVmSandbox`. Remote Cowork sessions receive neither. See [where and when a policy applies](</docs/en/managed-settings#where-and-when-a-policy-applies>) for which device files reach Cowork, and [MCP permission rules](</docs/en/permissions#mcp>) for how `Bash` and `WebFetch` rules apply to Cowork’s tools. In local and SSH sessions, the desktop app delivers each user’s connected claude.ai connectors to Claude Code directly. No MCP setting or `managed-mcp.json` reaches those connectors, whichever settings source or file location you use. To block a connector’s tools in these sessions, use your organization’s [connector tool controls](</docs/en/mcp#organization-controls-on-connector-tools>). [How connectors reach Claude Code](</docs/en/mcp#how-connectors-reach-claude-code>) shows which settings govern connectors in each kind of session. `permissions.disableBypassPermissionsMode` and `disableAutoMode` also work in user and project settings, but placing them in managed settings prevents users from overriding them. For the permission, plugin, and delivery keys only a managed source can set, see [Keys only managed settings can set](</docs/en/managed-settings#managed-only-settings>). + +#### + +​ + +Claude Code settings that behave differently in the Code tab + +In a local session, these keys, among others, have a different effect or no visible one, because the Code tab replaces the terminal interface. They still apply in the terminal, so you can leave them set. + +Key| In a local session +---|--- +`askUserQuestionTimeout`| the timeout doesn’t apply, so a question from Claude stays open for a user to answer +`awaySummaryEnabled`| the key has no effect +`bashEditDiffEnabled`| the Code tab doesn’t show the list of files that a Bash command changed +`companyAnnouncements`| the Code tab doesn’t show announcements +`defaultShell`| commands that users type after `!` run in a shell that the app chooses: their login shell on macOS and Linux, PowerShell on Windows +`fileSuggestion`| the `@` file picker builds its own file list and doesn’t run the command you set +`modelPicker`| the model picker lists the models available to each user’s account. To limit them, set [`availableModels`](</docs/en/model-config#restrict-model-selection>). +`pluginTrustMessage`| the warning that users see when they install a plugin doesn’t include the message you set +`prUrlTemplate`| pull request links use the pull request’s own URL, not the template +`respectGitignore`| the `@` file picker builds its own file list and doesn’t read this key +`respondToBashCommands`| Claude responds to the output of commands that users run with `!`, whatever the value +`showClearContextOnPlanAccept`| users get no clear-context option when they approve a plan +`skipDangerousModePermissionPrompt`| the Code tab has its own confirmation for Bypass permissions mode, and this key doesn’t skip it +`verbose`, `viewMode`| each user chooses the view under **Transcript view** in the session menu +`worktree.baseRef`, `worktree.sparsePaths`, `worktree.symlinkDirectories`| not used for the worktree that the Code tab creates for a session ### @@ -2236,7 +2262,7 @@ * **[CLAUDE.md](</docs/en/memory>)** and `CLAUDE.local.md` files in your project are used by both * **[MCP servers](</docs/en/mcp>)** configured in `~/.claude.json` or `.mcp.json` work in both * **[Hooks](</docs/en/hooks>)** and **[skills](</docs/en/skills>)** defined in settings apply to both - * **[Settings](</docs/en/settings>)** in `~/.claude.json` and `~/.claude/settings.json` are shared. Permission rules, allowed tools, and other settings in `settings.json` apply to Desktop sessions. + * **[Settings](</docs/en/settings>)** in `~/.claude.json` and `~/.claude/settings.json` are shared. Permission rules, allowed tools, and other settings in `settings.json` apply to Desktop sessions. Some keys behave differently in the Code tab. * **Models** : the same [models](</docs/en/model-config#available-models>) are available in both. In Desktop, select the model from the model picker in the row under the prompt box. You can change the model mid-session from the same picker. #### @@ -2471,7 +2497,12 @@ * **Windows** : **Show Logs in File Explorer** * **Linux** : **Show Logs in File Manager** -Look through the files before you send them, because they can include names and other details from your environment. `<host>` and `<user>` stand for names that Desktop replaced. Desktop doesn’t replace every name, and an SSH host or user name can still appear as written. If you send the zip file to someone, tell them which host failed and when, because the logs may not name it. The zip file doesn’t hold the log of the helper program that Desktop installs on the remote machine. To get that log as well, copy `remote-server.log` from the helper’s folder under `~/.claude/remote/run/` in the home directory of the user who connected. Look through that file too before you send it. +Look through the files before you send them, because they can include names and other details from your environment. `<host>` and `<user>` stand for names that Desktop replaced. Desktop doesn’t replace every name, and an SSH host or user name can still appear as written. If you send the zip file to someone, tell them which host failed and when, because the logs may not name it. The zip file doesn’t hold the log of the helper program that Desktop installs on the remote machine. To get that log as well, copy these files from the helper’s folder under `~/.claude/remote/run/` in the home directory of the user who connected: + + * **`remote-server.log`** : the log of the helper’s latest run. + * **`remote-server.log.old`** , if it is there: the log of the run before that. Copy it as soon as you can, because you lose it the next time Desktop connects and has to start the helper again. + +Look through those files too before you send them. ###
modified Error reference View current →
--- a/errors.md +++ b/errors.md @@ -318,6 +318,9 @@ `MCP server "<name>" tool "<tool>" timed out after <N>s. The server asked the user a question, and no answer came before the time limit.`| Tool errors `would be spawned with zero tools — refusing`| Tool errors `File is covered by a Read deny rule in your permission settings`| Tool errors +`<path> is outside <dirs>; the permissions.blockWritesOutsideWorkingDirectories setting blocks writes outside the working directories`| Tool errors +`<path>: Writes outside the working directories are blocked (permissions.blockWritesOutsideWorkingDirectories)`| Tool errors +`Writes to Claude Code settings files are blocked while permissions.blockWritesOutsideWorkingDirectories is on`| Tool errors `cannot contain null bytes (\0)`| Tool errors `Path contains null bytes`| Tool errors `command contains the invisible character U+FEFF (byte order mark) or U+180E (Mongolian vowel separator), and was not run`| Tool errors @@ -666,7 +669,7 @@ <model> is temporarily unavailable, so auto mode cannot determine the safety of <tool> right now. Wait a moment and then try this action again. -In an interactive session, a dim `Not run · auto mode's check had no usable answer` row appears under the tool call instead of this message. Press `Ctrl+O` to read the message in the [transcript viewer](</docs/en/interactive-mode#transcript-viewer>). The `gave no verdict` denials under The server returned no safety verdict show the same row. Before v2.1.296, the message appeared under the call as a red error. When Claude Code can determine the failure category, it names the category in parentheses after `temporarily unavailable`, for example `<model> is temporarily unavailable (rate-limited), so auto mode cannot determine the safety of <tool> right now`. The categories are `(rate-limited)`, `(overloaded)`, `(server error)`, `(timed out)`, and `(connection failed)`. If `(timed out)` or `(connection failed)` repeats, check your connection; see Unable to connect to API. Before v2.1.229, the message never named a category and read `Wait briefly and then try this action again`. When no category fits, the message appears with no category in parentheses; more than one failure produces that form. On [Amazon Bedrock](</docs/en/amazon-bedrock>), including the [Mantle endpoint](</docs/en/amazon-bedrock#use-the-mantle-endpoint>), it also appears when your AWS account can’t invoke the model named in the message, and that failure repeats on every retry until your account is granted access to the model. **What to do:** +In an interactive session, a dim `Not run · auto mode's check had no usable answer` row appears under the tool call instead of this message. The row can also replace a message saying the server gave no verdict or, outside a remote session, one starting `Auto mode could not evaluate`. Press `Ctrl+O` to read its message in the [transcript viewer](</docs/en/interactive-mode#transcript-viewer>). Before v2.1.296, the message appeared as a red error. When Claude Code can determine the failure category, it names the category in parentheses after `temporarily unavailable`, for example `<model> is temporarily unavailable (rate-limited), so auto mode cannot determine the safety of <tool> right now`. The categories are `(rate-limited)`, `(overloaded)`, `(server error)`, `(timed out)`, and `(connection failed)`. If `(timed out)` or `(connection failed)` repeats, check your connection; see Unable to connect to API. Before v2.1.229, the message never named a category and read `Wait briefly and then try this action again`. When no category fits, the message appears with no category in parentheses; more than one failure produces that form. On [Amazon Bedrock](</docs/en/amazon-bedrock>), including the [Mantle endpoint](</docs/en/amazon-bedrock#use-the-mantle-endpoint>), it also appears when your AWS account can’t invoke the model named in the message, and that failure repeats on every retry until your account is granted access to the model. **What to do:** * Retry after a few seconds; Claude sees the same message and usually retries on its own. A transient failure is unrelated to [auto mode eligibility](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>); you don’t need to change settings * If retries keep failing, continue with read-only tasks and come back to the blocked action later @@ -4381,6 +4384,48 @@ * If Claude should be able to change the file, remove or narrow the `Read` deny rule in `/permissions` or in [settings](</docs/en/settings-reference#permission-settings>) * If the file must stay untouched, keep the rule and add an `Edit` deny rule for the same path to block the NotebookEdit tool too + +### + +​ + +Setting blocks writes outside the working directories + +When Claude tries to write a file and the tool call fails with this message, the path is outside the session’s [working directories](</docs/en/permissions#working-directories>) and [`permissions.blockWritesOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockwritesoutsideworkingdirectories>) is on: + + <path> is outside <dirs>; the permissions.blockWritesOutsideWorkingDirectories setting blocks writes outside the working directories. Ask the user to add the directory with /add-dir, or to remove that setting. + +Claude Code refuses that write in every permission mode. The refusal can also read: + + <path>: Writes outside the working directories are blocked (permissions.blockWritesOutsideWorkingDirectories). Add the directory with /add-dir, or remove that setting. + +**What to do:** + + * If Claude shouldn’t write there, do nothing + * To let Claude write to an existing directory that contains the path, run `/add-dir <directory>` at the Claude Code prompt, or pass `--add-dir <directory>` when you start Claude Code + * If the path is a Claude Code settings file, such as `~/.claude/settings.json`, edit it yourself. Adding its directory with `/add-dir` doesn’t help, because Claude Code then refuses the write as a settings file. + * To keep a directory writable in every session, list it under [`permissions.additionalDirectories`](</docs/en/settings-reference#permissions-additionaldirectories>) in your user or managed settings + * To turn `permissions.blockWritesOutsideWorkingDirectories` off, remove it from every settings file that sets it, then restart Claude Code + * If none of your settings files has `permissions.blockWritesOutsideWorkingDirectories`, it can come from `--settings` or from a host application. Claude Code also refuses these writes while it can’t read `permissions` in your [managed settings](</docs/en/managed-settings#keys-that-fail-closed>). Ask whoever launches or manages the session. + +### + +​ + +Writes to Claude Code settings files are blocked + +When Claude tries to write a file and the tool call fails with this message, Claude Code treats the file as one of its settings files and [`permissions.blockWritesOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockwritesoutsideworkingdirectories>) is on: + + <path>: Writes to Claude Code settings files are blocked while permissions.blockWritesOutsideWorkingDirectories is on, because a settings file can lift that block. While a managed settings folder cannot be resolved, any .json file counts as one. + +**What to do:** + + * To change a setting, edit the settings file yourself + * To let Claude edit settings files again, remove `permissions.blockWritesOutsideWorkingDirectories` from every settings file that sets it, then restart Claude Code + * If the file isn’t one of your settings files, find it among the other files Claude Code treats as settings files: + * **A file you passed to`--agents` or `--mcp-config`**: edit it yourself + * **The stored copy of[server-managed settings](</docs/en/server-managed-settings#security-considerations>) and the files kept with it**: ask an [Owner](</docs/en/server-managed-settings#access-control>) to change the setting in server-managed settings. + * **Any`.json` file, while Claude Code can’t work out where the [`managed-settings.d/`](</docs/en/managed-settings#split-a-file-based-policy-across-teams>) folder leads**: ask your administrator to check that folder ###
modified Manage Claude Code plugins for your organization View current →
--- a/org.md +++ b/org.md @@ -373,7 +373,7 @@ To run stable and early-access channels, host two marketplaces that point at different refs of the same plugins. Then give each user group its own marketplace through either separate endpoint-managed settings or a gateway policy. Server-managed settings from the admin console [apply to every user in your organization](</docs/en/server-managed-settings#current-limitations>), so they can’t assign different settings to different groups. * Deploy separate [endpoint-managed settings](</docs/en/managed-settings#delivery-mechanisms>), such as a managed settings file or an MDM profile, to each group’s devices. To check whether the per-group file or profile applies on a device that also has an organization-wide source, see [How Claude Code combines managed sources](</docs/en/managed-settings#precedence-within-the-managed-tier>). - * Define one [Claude apps gateway policy](</docs/en/claude-apps-gateway-config#managed>) per group. The gateway applies the first policy whose match rule fits a user, so order the policies so that each user reaches their group’s policy. That policy’s `extraKnownMarketplaces` map doesn’t merge with any other policy’s, so list every marketplace the group needs in it, not only its channel marketplace. + * Define one [Claude apps gateway policy](</docs/en/claude-apps-gateway-config#managed>) per group. By default, the gateway applies the first policy whose match rule fits a user, so order the policies so that each user reaches their group’s policy. That policy’s `extraKnownMarketplaces` map doesn’t merge with any other policy’s, so list every marketplace the group needs in it, not only its channel marketplace. With either mechanism, the stable group receives this configuration:
modified Choose a permission mode View current →
--- a/permission-modes.md +++ b/permission-modes.md @@ -33,6 +33,7 @@ * Recognized `rm` and `rmdir` critical-path removals, which no allow rule or `PreToolUse` hook `"allow"` approves, and Bash commands flagged `Dangerous rm operation not ruled out` * The cross-session messaging safeguards * Reads outside the working directories while [`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>) is on: recognized file-reading Bash commands prompt even in auto mode and `bypassPermissions` mode, and so does any [unsandboxed retry](</docs/en/sandboxing#the-unsandboxed-retry-escape-hatch>) that needs approval to run outside the sandbox. Requires Claude Code v2.1.257 or later. A command the shell parser can’t trace, such as one that changes directory more than once or runs a subshell, prompts the same way even when it names no outside path. This prompt doesn’t apply when the command runs in the [sandbox](</docs/en/sandboxing>) and the sandbox enforces the block. + * Writes outside the working directories while [`permissions.blockWritesOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockwritesoutsideworkingdirectories>) is on: Claude Code refuses `Write`, `Edit`, and `NotebookEdit` calls there, apart from [some of its own files](</docs/en/settings-reference#what-the-write-block-refuses-and-what-stays-writable>). The key doesn’t limit shell commands, MCP tools, or the programs hooks run, so use [sandboxing](</docs/en/sandboxing>) to limit where shell commands write. Requires Claude Code v2.1.314 or later. ## @@ -515,9 +516,9 @@ When auto mode can’t approve your session’s actions, what happens depends on the case: - * **A blocked action** : Claude Code shows a notification and lists the action in `/permissions` under the **Recently denied** tab, where you can press `r` to retry it with a manual approval. + * **A blocked action** : Claude Code shows a notification and lists the action in `/permissions` under the **Recently blocked** tab, where you can [approve the action so Claude may retry](</docs/en/auto-mode-config#review-denials>). * **Repeated blocks** : if the classifier blocks an action 3 times in a row or 20 times total, auto mode pauses and Claude Code resumes prompting. Approving the prompted action resumes auto mode. See Repeated-block thresholds for how the blocks are counted. - * **No verdict from the classifier** : when a safety check separate from auto mode refuses the classifier’s own request, or the classifier’s response doesn’t parse, Claude Code denies the action without the notification or the **Recently denied** entry. See [Auto mode cannot determine the safety of an action](</docs/en/errors#auto-mode-cannot-determine-the-safety-of-an-action>) for the message each case shows and what to do. + * **No verdict from the classifier** : when a safety check separate from auto mode refuses the classifier’s own request, or the classifier’s response doesn’t parse, Claude Code blocks the action without the notification or the **Recently blocked** entry. See [Auto mode cannot determine the safety of an action](</docs/en/errors#auto-mode-cannot-determine-the-safety-of-an-action>) for the message each case shows and what to do. * **No verdict from the server** : under server-side classifier review, Claude Code denies an action the server gives no verdict for, and stops the turn after ten responses in a row with no verdict. See [The server returned no safety verdict](</docs/en/errors#the-server-returned-no-safety-verdict>). * **A mode switch during a check** : if you switch permission modes while a classifier check is pending, Claude Code discards a verdict the new mode wouldn’t have requested. You’re prompted for approval instead, or the action is auto-denied in `dontAsk` mode. @@ -670,7 +671,7 @@ `dontAsk`| Denied `bypassPermissions`| Allowed -In a session started with [`--restricted`](</docs/en/cli-reference#cli-flags>), which requires Claude Code v2.1.248 or later, the classifier can’t approve protected-path writes. In the modes that route protected-path writes to the classifier, a write that the [symlink check](</docs/en/permissions#symlinks>) resolves to a protected path prompts you instead when the path Claude requested isn’t itself protected. [`permissions.allow`](</docs/en/permissions#manage-permissions>) rules in settings files do not pre-approve protected-path writes. The safety check runs before Claude Code evaluates allow rules from settings, so an entry such as `Edit(.claude/**)` in `~/.claude/settings.json` or `.claude/settings.json` does not change the per-mode outcome in the table above. In permission modes that prompt, the prompt for a write to the project’s `.claude/` folder or to `~/.claude/` can offer one of these session-scoped options: +In a session started with [`--restricted`](</docs/en/cli-reference#cli-flags>), which requires Claude Code v2.1.248 or later, the classifier can’t approve protected-path writes. While [`permissions.blockWritesOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockwritesoutsideworkingdirectories>) is on, Claude Code refuses `Write`, `Edit`, and `NotebookEdit` writes to settings files in every permission mode. In the modes that route protected-path writes to the classifier, a write that the [symlink check](</docs/en/permissions#symlinks>) resolves to a protected path prompts you instead when the path Claude requested isn’t itself protected. [`permissions.allow`](</docs/en/permissions#manage-permissions>) rules in settings files do not pre-approve protected-path writes. The safety check runs before Claude Code evaluates allow rules from settings, so an entry such as `Edit(.claude/**)` in `~/.claude/settings.json` or `.claude/settings.json` does not change the per-mode outcome in the table above. In permission modes that prompt, the prompt for a write to the project’s `.claude/` folder or to `~/.claude/` can offer one of these session-scoped options: * For the project’s `.claude/` folder: **Yes, and allow Claude to edit files in this project’s .claude folder for this session** * For `~/.claude/`: **Yes, and allow Claude to edit files in its ~/.claude folder for this session** @@ -706,6 +707,7 @@ * `.devcontainer.json` * `.ripgreprc`, `pyrightconfig.json` * `.mcp.json`, `.claude.json` + * `remote-settings.json`, the stored copy of your organization’s [server-managed settings](</docs/en/server-managed-settings>), and the signature, sync, and consent files Claude Code keeps with it, in `~/.claude` or the directory [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>) points to * A file you passed to [`--settings`](</docs/en/cli-reference#cli-flags>), `--mcp-config`, or `--agents` when you started the session * The file that your user, project, or local [settings file](</docs/en/settings#settings-files-and-who-they-affect>) points to when the settings file is itself a symbolic link, for example into a dotfiles repository. In the modes that route protected-path writes to the classifier, a write to this file prompts you instead, even when an allow rule matches. If the file’s own path is also that of a settings file, such as `.claude/settings.json` in another folder, the write goes to the classifier as other protected-path writes do
modified Settings files and precedence View current →
--- a/settings.md +++ b/settings.md @@ -339,6 +339,7 @@ [`enableArtifact`](</docs/en/settings-reference#enableartifact>)| `false` from any scope, and `disableArtifact: true` from any scope| Honored even when a managed source sets `true`; nothing turns the [Artifact tool](</docs/en/artifacts#disable-artifacts>) back on. Requires Claude Code v2.1.242 or later [`isolatePeerMachines`](</docs/en/settings-reference#isolatepeermachines>)| `true` from any scope| Honored even when a managed source sets `false` [`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>)| `true` from any scope| Honored even when a managed source sets `false`. Requires Claude Code v2.1.257 or later +[`permissions.blockWritesOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockwritesoutsideworkingdirectories>)| `true` from any scope| Honored even when a managed source sets `false`. Requires Claude Code v2.1.314 or later [`autoMode.classifyAllShell`](</docs/en/settings-reference#automode-classifyallshell>)| `true` from `~/.claude/settings.json` or `--settings`| Honored even when a managed source sets `false` [`remoteControlAtStartup`](</docs/en/settings-reference#remotecontrolatstartup>)| `false` from `.claude/settings.json` or `.claude/settings.local.json`| Honored even when a managed source sets `true`; a project or local `true` is ignored [`crossSessionInbound`](</docs/en/settings-reference#crosssessioninbound>)| A stricter value from `.claude/settings.json` or `.claude/settings.local.json`, on the `accept` < `hold` < `refuse` ladder| Honored over managed, `--settings`, and user values; a project or local value that isn’t stricter is ignored
modified All settings View current →
--- a/settings-reference.md +++ b/settings-reference.md @@ -138,6 +138,7 @@ `permissions.allow`| Approve listed [tool uses](</docs/en/permissions#permission-rule-syntax>) without a prompt| Permission settings| Any file `permissions.ask`| Always prompt before listed [tool uses](</docs/en/permissions#permission-rule-syntax>)| Permission settings| Any file `permissions.blockReadsOutsideWorkingDirectories`| Make the file tools refuse reads outside the [working directories](</docs/en/permissions#working-directories>) in every permission mode| Permission settings| Any file +`permissions.blockWritesOutsideWorkingDirectories`| Make the `Write`, `Edit`, and `NotebookEdit` tools refuse paths outside the [working directories](</docs/en/permissions#working-directories>) in every permission mode, apart from some of Claude Code’s own files| Permission settings| Any file `permissions.defaultMode`| Set the [permission mode](</docs/en/permission-modes#which-mode-a-session-starts-in>) new sessions start in| Permission settings| Any file `permissions.deny`| Block listed [tool uses](</docs/en/permissions#permission-rule-syntax>), including reads of files that hold secrets| Permission settings| Any file `permissions.disableBypassPermissionsMode`| Prevent anyone from entering [bypassPermissions mode](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>)| Permission settings| Any file @@ -979,7 +980,7 @@ Control which tools Claude can use without asking, which ones always prompt, and which ones are blocked, and set the [permission mode](</docs/en/permission-modes>) a session starts in. Every `permissions.*` key below nests under this object. * **Scope** : `Any file` - * **Type** : object with `allow`, `ask`, `deny`, `additionalDirectories`, `blockReadsOutsideWorkingDirectories`, `defaultMode`, `disableBypassPermissionsMode`, and `disableAutoMode` + * **Type** : object with `allow`, `ask`, `deny`, `additionalDirectories`, `blockReadsOutsideWorkingDirectories`, `blockWritesOutsideWorkingDirectories`, `defaultMode`, `disableBypassPermissionsMode`, and `disableAutoMode` * **Default** : unset This example approves `npm run` commands without asking, prompts before `git push`, blocks reads of `.env`, and starts sessions in `acceptEdits`: @@ -1181,6 +1182,53 @@ * Files your global git configuration names through `[include]`, `[includeIf]`, `core.excludesFile`, or `core.attributesFile` Claude Code judges each file separately. When a file lies where a sandboxed command can write, directly or through a symlink, Claude Code doesn’t re-open the files it names. On Linux and WSL2, a configuration file that is a symlink can stay unreadable at its own path, and `git` then runs without it. `~/.git-credentials` and `$XDG_CONFIG_HOME/git/credentials` stay blocked. If a re-opened file holds a secret, such as an `http.extraHeader` token, add its path to `sandbox.filesystem.denyRead`. A `denyRead` entry that covers a file always takes precedence over this re-open. + +### + +​ + +`permissions.blockWritesOutsideWorkingDirectories` + +Make the `Write`, `Edit`, and `NotebookEdit` tools refuse paths outside your [working directories](</docs/en/permissions#working-directories>) in every permission mode, including `bypassPermissions`, apart from some of Claude Code’s own files. The key doesn’t limit shell commands, MCP tools, or the programs hooks run. To limit where shell commands write, turn on [sandboxing](</docs/en/sandboxing>). Requires Claude Code v2.1.314 or later. Once the key is on, Claude Code also removes the `EnterWorktree` and `ExitWorktree` tools or refuses calls to them. To keep working in worktrees, follow [Claude has no `EnterWorktree` tool](</docs/en/worktrees#claude-has-no-enterworktree-tool>). + + * **Scope** : `Any file`. A `true` in any file the session loads applies, so a repository can turn the block on for itself but can’t lift yours. In a [cloud session](</docs/en/claude-code-on-the-web>), Claude Code might not apply the key, because the file tools run in a container that is itself the boundary. + * **Type** : Boolean + * `true`: turns the block on + * `false`: the same as unset; the block still applies if another file sets `true` + * **Default** : unset, so writes outside the working directories follow your [permission mode](</docs/en/permission-modes>). The block is also on while Claude Code can’t read the `permissions` object in your [managed settings](</docs/en/managed-settings#keys-that-fail-closed>). + +settings.json + + { + "permissions": { + "blockWritesOutsideWorkingDirectories": true + } + } + +To test the block, ask Claude to use the Write tool to create a file outside your working directories, such as `~/block-test.txt` if your home directory isn’t one of them. Claude Code refuses the call, and the refusal says the [setting blocks writes outside the working directories](</docs/en/errors#setting-blocks-writes-outside-the-working-directories>). To lift the block, remove the key from every settings file that sets it, then restart Claude Code. + +#### + +​ + +What the write block refuses and what stays writable + +Some of Claude Code’s own files stay writable, such as plan files, the [scratchpad](</docs/en/claude-directory#session-scratchpad-directory>), a [background session](</docs/en/agent-view>)’s `tmp` directory, and `.md` files in this project’s [auto memory](</docs/en/memory#storage-location>). Along with your own files outside the working directories, the block refuses writes to: + + * **Claude Code settings files** : Claude Code [refuses these writes](</docs/en/errors#writes-to-claude-code-settings-files-are-blocked>) inside the working directories too, because a settings file can lift the block. Edit settings files yourself. + * **A directory that only repository settings add** : one that `additionalDirectories` lists only in `.claude/settings.json`, or in `.claude/settings.local.json` unless git reports that file as untracked + * **A subagent’s worktree** : an [`isolation: worktree`](</docs/en/worktrees#isolate-subagents-with-worktrees>) subagent’s file edits are refused when its worktree sits outside the working directories + * **Auto memory in a directory the repository chose** : a directory that `autoMemoryDirectory` names in repository settings + +Settings files stay refused whatever you add. To let a write through in any of the other cases, add a working directory. `/add-dir` needs a directory that exists, so name the `.claude/worktrees` directory at the repository root for subagent worktrees. + +#### + +​ + +Let one directory through the read or write block + +To let Claude reach one directory outside the project while `blockReadsOutsideWorkingDirectories` or `blockWritesOutsideWorkingDirectories` is `true`, add it as a working directory. Run `/add-dir <directory>` in the session, pass `--add-dir <directory>` when you start Claude Code, or list it under `additionalDirectories` in your user or managed settings. No [allow rule](</docs/en/permissions#read-and-edit>) lets Claude’s file tools through either block. ###
modified Advanced setup View current →
--- a/setup.md +++ b/setup.md @@ -26,6 +26,7 @@ Additional dependencies * **ripgrep** : usually included with Claude Code. If search fails, see [search troubleshooting](</docs/en/troubleshooting#search-and-discovery-issues>). + * **Git** : optional. If git is installed, [`claude plugin eval`](</docs/en/plugin-evals#requirements>) requires 2.31 or later. [Uploads of a local repository to a cloud session](</docs/en/claude-code-on-the-web#send-local-repositories-without-github>) from macOS, Linux, or WSL need git 2.31 or later. Run `git --version` to see your version. ##
modified Tools reference View current →
--- a/tools-reference.md +++ b/tools-reference.md @@ -14,9 +14,9 @@ `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. 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 +`EnterWorktree`| Creates an isolated [git worktree](</docs/en/worktrees>) and switches into it, or switches into an existing worktree. See EnterWorktree tool behavior| Yes `ExitPlanMode`| Presents a plan for approval and exits plan mode| Yes -`ExitWorktree`| Exits a worktree session and returns to the original directory. Not available to subagents that already run in their own working directory, such as with [`isolation: worktree`](</docs/en/sub-agents#supported-frontmatter-fields>)| No +`ExitWorktree`| Exits a worktree session and returns to the original directory. Not available to subagents that already run in their own working directory, such as with [`isolation: worktree`](</docs/en/sub-agents#supported-frontmatter-fields>). Removed or refused once [`permissions.blockWritesOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockwritesoutsideworkingdirectories>) is on| No `Glob`| Finds files based on pattern matching. Absent by default on macOS, Linux, and WSL. See Glob tool behavior| No `Grep`| Searches for patterns in file contents. Absent by default on macOS, Linux, and WSL. See Grep tool behavior| No `ListAgents`| Lists the agents Claude can message with `SendMessage`: subagents in the session, [agent team](</docs/en/agent-teams>) teammates, your other local Claude Code sessions, and, while this session is connected to [Remote Control](</docs/en/remote-control>), your [cloud sessions](</docs/en/claude-code-on-the-web>) and your Remote Control sessions on other machines. Backs the `/list-agents` command. See [cross-session messaging](</docs/en/cross-session-messaging>). Requires Claude Code v2.1.224 or later, and appears only in sessions where [cross-session messaging is enabled](</docs/en/cross-session-messaging#availability>). Teammate rows and the first line showing this session’s own name require v2.1.239 or later| No @@ -301,6 +301,19 @@ ​ +EnterWorktree tool behavior + +The EnterWorktree tool creates an isolated [git worktree](</docs/en/worktrees>) and switches into it. Given a `path`, it switches into an existing worktree instead of creating a new one. + + * **Which worktrees`path` can name**: on first entry the target may be a worktree of the current repository. In a repository that holds other repositories, it may also be a worktree of a repository nested inside it. Before v2.1.203, a nested repository’s worktree was rejected. + * **When you’re prompted** : 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 inside a worktree** : from within a worktree session, only the `path` form is available and the target must be under `.claude/worktrees/` of the session’s repository. The same holds for a subagent with a pinned working directory, such as [`isolation: worktree`](</docs/en/sub-agents#supported-frontmatter-fields>). + * **When the tool is missing** : once [`permissions.blockWritesOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockwritesoutsideworkingdirectories>) is on, Claude Code removes `EnterWorktree` and `ExitWorktree` or refuses calls to them. To keep working in worktrees, see [Claude has no `EnterWorktree` tool](</docs/en/worktrees#claude-has-no-enterworktree-tool>). + +## + +​ + Glob tool behavior The Glob tool finds files by name pattern. On Windows, it’s part of the default tool set. On macOS, Linux, and WSL, Claude Code leaves Glob and Grep out of the default tool set, and Claude searches with `find` and `grep` through the Bash tool instead. In Claude’s shell those two commands run embedded versions of `bfs` and `ugrep`, and the searches reach your hooks and permission rules as `Bash` calls. On macOS, Linux, and WSL, you get the Glob and Grep tools back in these cases:
modified Run parallel sessions with worktrees View current →
--- a/worktrees.md +++ b/worktrees.md @@ -35,12 +35,28 @@ Ask Claude to create a worktree -You can also ask Claude to “work in a worktree” during a session, and it creates one with the [`EnterWorktree`](</docs/en/tools-reference>) tool. Once in a worktree, Claude can switch directly to another one under `.claude/worktrees/` by calling `EnterWorktree` with the target path; the previous worktree stays on disk untouched. When Claude enters a path outside the repository’s `.claude/worktrees/` directory, Claude Code asks for your approval first. The move takes the session’s working directory, write access, and project configuration such as `CLAUDE.md` and settings to that location. An `EnterWorktree` [permission rule](</docs/en/permissions>) or choosing “don’t ask again” doesn’t suppress this prompt; only `bypassPermissions` mode skips it. +You can also ask Claude to “work in a worktree” during a session, and it creates one with the [`EnterWorktree`](</docs/en/tools-reference#enterworktree-tool-behavior>) tool. Once in a worktree, Claude can switch directly to another one under `.claude/worktrees/` by calling `EnterWorktree` with the target path; the previous worktree stays on disk untouched. When Claude enters a path outside the repository’s `.claude/worktrees/` directory, Claude Code asks for your approval first. The move takes the session’s working directory, write access, and project configuration such as `CLAUDE.md` and settings to that location. An `EnterWorktree` [permission rule](</docs/en/permissions>) or choosing “don’t ask again” doesn’t suppress this prompt; only `bypassPermissions` mode skips it. **Hook paths don’t follow the worktree.** After Claude enters a worktree, Claude Code keeps `${CLAUDE_PROJECT_DIR}` in your [hooks](</docs/en/hooks#reference-scripts-by-path>) where it was and passes the worktree path to them a different way: * **`${CLAUDE_PROJECT_DIR}` stays put**: it still points at the project root where the session started, so a hook command such as `${CLAUDE_PROJECT_DIR}/.claude/hooks/check-style.sh` still runs the script in the main checkout. * **`cwd` follows Claude**: the `cwd` field in the hook’s [input JSON](</docs/en/hooks#common-input-fields>) is the worktree root, and it moves again when Claude runs `cd`. Read it when a hook needs the worktree path. + +#### + +​ + +Claude has no `EnterWorktree` tool + +If you ask Claude to work in a worktree and it has no `EnterWorktree` or `ExitWorktree` tool, check whether [`permissions.blockWritesOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockwritesoutsideworkingdirectories>) is on. Once the key is on, Claude Code removes both worktree tools or refuses calls to them. You can keep working in worktrees while the key is on: + + * **Interactive sessions** : start the session in a worktree with `claude --worktree`. + * **[Background sessions](</docs/en/agent-view#how-file-edits-are-isolated>)** : Claude Code refuses a background session’s edits in your main checkout until the session calls `EnterWorktree`, which it doesn’t have. Any of these lets the session edit: + * Start it with `claude --bg --worktree` + * Set [`worktree.bgIsolation`](</docs/en/settings-reference#worktree-bgisolation>) to `"none"` + * Have Claude edit in a worktree made with `git worktree add` under the directory the session started in + +To get the tools back, run `/status` in the session to list the [setting sources it loaded](</docs/en/settings#check-what-loaded>), and remove the key from every file that sets it. Then restart Claude Code. If managed settings set the key, ask your administrator whether the policy should change. ## @@ -63,7 +79,7 @@ Resume a worktree session -When you resume a session that ended inside a worktree without exiting it, Claude Code returns the session to that worktree. This holds for interactive resumes, for `--continue` and `--resume` in [non-interactive mode](</docs/en/headless>) with `-p`, and for the Agent SDK. `--continue` picks the most recent session recorded under the directory you launch from. Back inside the worktree, Claude can still exit it with the [`ExitWorktree`](</docs/en/tools-reference>) tool. Before returning the session to its worktree, Claude Code verifies that the worktree is still a checkout separate from the main one, and declines to re-enter a worktree that fails the check. For a git worktree, the check reads its git metadata. A worktree without git metadata, such as one a `WorktreeCreate` hook created, can pass the check; the cases Claude Code still refuses are listed with their recoveries under Claude Code refuses to use a worktree. For the messages and how to recover from each, see The session resumes outside its worktree. Where you launch from, and how you resume, change what Claude Code re-enters: +When you resume a session that ended inside a worktree without exiting it, Claude Code returns the session to that worktree. This holds for interactive resumes, for `--continue` and `--resume` in [non-interactive mode](</docs/en/headless>) with `-p`, and for the Agent SDK. `--continue` picks the most recent session recorded under the directory you launch from. Back inside the worktree, Claude can leave with the [`ExitWorktree`](</docs/en/tools-reference>) tool when the session has that tool. Before returning the session to its worktree, Claude Code verifies that the worktree is still a checkout separate from the main one, and declines to re-enter a worktree that fails the check. For a git worktree, the check reads its git metadata. A worktree without git metadata, such as one a `WorktreeCreate` hook created, can pass the check; the cases Claude Code still refuses are listed with their recoveries under Claude Code refuses to use a worktree. For the messages and how to recover from each, see The session resumes outside its worktree. Where you launch from, and how you resume, change what Claude Code re-enters: * **Launch directory** : resume with `--resume` from the main checkout or another directory of the repository. Claude Code re-enters a worktree it created with git under `.claude/worktrees/` even when you launch from inside it. When you launch from inside any other worktree, Claude Code re-enters it only if it can vouch for it from there: a worktree that is its own repository, one without git metadata, or a launch from a subdirectory of a worktree you created with `git worktree add` declines, so launch those from the main checkout. * **`--fork-session`** : the forked session starts in the directory you launched Claude from, and Claude Code leaves the original session’s worktree untouched. @@ -81,7 +97,7 @@ While a session is isolated in a worktree, Claude Code blocks the tool calls the checks below define. The same rules apply whether you started the session with `--worktree`, Claude entered a worktree with `EnterWorktree`, or you resumed a worktree session. The same enforcement covers every subagent Claude spawns from the isolated session. It applies whether the session is interactive or runs in the [background](</docs/en/agent-view#how-file-edits-are-isolated>). Subagents that run in their own worktree carry the same checks. Their version history is under [Write subagent files](</docs/en/sub-agents#write-subagent-files>). Claude Code applies four checks: - * **File edits** : Claude Code blocks an `Edit`, `Write`, or `NotebookEdit` that targets a path in the main checkout. + * **File edits** : Claude Code blocks an `Edit`, `Write`, or `NotebookEdit` that targets a path in the main checkout. To change a file in the main checkout, edit it yourself or start an interactive session there. * **Command working directory** : Claude Code blocks a Bash, PowerShell, or Monitor command whose working directory resolves to the main checkout, or whose working directory it can’t verify stays outside it. * **Git redirects** : Claude Code blocks a Bash or Monitor command that redirects git into the main checkout. The redirect can come through `git -C`, `--git-dir`, a `GIT_DIR` or `GIT_WORK_TREE` variable, or a `cd` into the main checkout before running git. * **Command shape** : Claude Code blocks a Bash or Monitor command when it can’t verify from the command text that any git the command runs stays inside the worktree. That happens, for example, when the command name is computed at runtime, when the syntax can’t be parsed, or when an expansion such as `${!name}` or `${ command; }` could run a command the text doesn’t spell out. Claude Code tells Claude how to rewrite the refused command, such as splitting it into plain, separate commands. You can’t turn this check off.