SpyBara
Go Premium

permission-modes.md 2026-09-27 23:59 UTC to 2026-09-28 17:00 UTC

This page contains 7 additions and 1 deletion.

2026
Tue 1 21:02 Wed 2 04:58 Fri 4 23:59 Tue 8 20:00 Wed 9 22:58 Thu 10 23:00 Fri 11 23:01 Tue 15 23:58 Fri 18 23:58 Sat 19 23:57 Tue 22 23:59 Thu 24 22:57 Fri 25 23:58 Sat 26 23:59 Mon 28 17:00

Choose a permission mode

Control whether Claude asks before acting. Switch permission modes with Shift+Tab in the CLI, the mode indicator in VS Code, or the mode selector in Desktop.

A permission mode sets which actions Claude can take in a session without asking you first. In Manual mode, Claude Code stops and asks you before most actions that edit files, run shell commands, or reach the network. In auto mode, a second model, the classifier, reviews actions instead of you; how the classifier evaluates actions lists which actions it reviews and which skip it.

With Claude Code v2.1.283 or later, auto mode is the built-in starting permission mode for interactive terminal and VS Code sessions. On earlier versions, it's the built-in starting permission mode only on Pro, Max, and Team plans. Which mode a session starts in covers the surfaces and settings that change the starting permission mode. You can also change a running session's permission mode at any time.

Available modes

Each mode makes a different tradeoff between convenience and oversight. The table below shows what Claude can do without a permission prompt in each mode. Manual mode appears under its config value, default.

Mode What runs without asking Best for
default Reads only Reviewing every action yourself, sensitive work
acceptEdits Reads, file edits, and common filesystem commands (mkdir, touch, mv, cp, etc.) Iterating on code you're reviewing
plan Reads, plus classifier-approved commands when auto mode is available Exploring a codebase before changing it
auto Everything, with background safety checks Long tasks, reducing prompt fatigue
dontAsk Reads and pre-approved tools; anything that would prompt is denied 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.

Writes to protected paths are never auto-approved except in bypassPermissions mode and in plan-mode sessions where bypass permissions are available, meaning interactive terminal sessions started in a way that puts bypassPermissions in the mode cycle.

Modes set the baseline. Layer permission rules on top to pre-approve or block specific tools. Deny rules block in every mode, including bypassPermissions. Deny and ask rules don't apply to EndConversation as long as Claude still has at least one other tool it can call. Allow rules have no effect in bypassPermissions.

Actions no mode auto-approves

Claude Code doesn't auto-approve the following in any mode, including bypassPermissions. Each bullet links to the section that says what happens instead in each mode:

  • Tools matched by an explicit ask rule

  • Connector tools your organization set to ask, in sessions where that setting reaches Claude Code

  • Tools that require user interaction: the built-in AskUserQuestion tool and MCP tools marked requiresUserInteraction

  • rm and rmdir removals targeting a critical path, which no allow rule or PreToolUse hook "allow" approves

  • The cross-session messaging safeguards

  • Reads outside the working directories while permissions.blockReadsOutsideWorkingDirectories is on: recognized file-reading Bash commands prompt even in auto mode and bypassPermissions mode, and so does any unsandboxed retry 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 and the sandbox enforces the block.

Common setups

Permission modes decide whether Claude asks before an action, and the Bash sandbox and outer isolation boundaries decide what an action can reach once it runs. Each row below pairs a goal with the flags or settings that get you there and the isolation it needs, as a starting point. Available modes lists what runs without a prompt in each mode.

You want to Start with Isolation needed Notes
Review every action yourself Manual mode: claude --permission-mode default None Sensitive work, unfamiliar code
Iterate locally with fewer prompts, without a classifier Manual mode plus the Bash sandbox in auto-allow mode: claude --permission-mode default, then run /sandbox and select auto-allow The built-in Bash sandbox, on macOS, Linux, and WSL2 Deny rules still apply, and ask rules that name a command, such as Bash(git push *), still prompt. To turn the sandbox on from a settings file instead, set sandbox.enabled to true
Explore before changing anything claude --permission-mode plan None Claude Code blocks edits until you approve a plan
Work hands-off in auto mode claude --permission-mode auto, the built-in starting permission mode with v2.1.283 or later None; a sandbox or container adds defense in depth Requires a supported model, and your organization can turn auto mode off
Run in CI with an exact allowlist claude -p "run the test suite" --permission-mode dontAsk --allowedTools "Bash(npm test)" "Read" None beyond what your CI runner provides Cloud sessions ignore dontAsk from settings files
Run fully unattended inside a container claude -p "<prompt>" --dangerously-skip-permissions Required: a container, VM, or the sandbox runtime; on Linux and macOS, run it as a non-root user Cloud sessions ignore this mode from settings files. In this -p run, the few calls that would still prompt are denied instead

The Bash sandbox and auto mode work independently and combine, with the exceptions listed under Sandbox modes. For the full interaction, see How sandboxing relates to permissions and permission modes and How isolation relates to permission modes.

Which mode a session starts in

When you start a new session in a terminal, Claude Code takes the permission mode from the first of these that applies:

  1. The --permission-mode flag, or --dangerously-skip-permissions

  2. permissions.defaultMode in a settings file

    If you set "auto" in .claude/settings.json or .claude/settings.local.json, the value doesn't take effect, and Claude Code then uses the built-in default rather than a defaultMode from ~/.claude/settings.json. If you set "bypassPermissions" in those two files, it doesn't take effect either, and the session starts in Manual mode. The other values apply from any settings file.

  3. The built-in default

Conversations the VS Code extension starts follow the extension's own list in Switch permission modes. For the permission mode Claude Code starts a resumed session in, see permission mode on resume.

The built-in auto default requires Claude Code v2.1.228 or later on macOS, Linux, and WSL, and v2.1.233 or later on native Windows. On earlier versions, the built-in default is Manual.

The built-in default depends on how you run Claude Code. The first row that matches your session applies. The table covers sessions you start in a terminal or through the VS Code extension; for the desktop app and claude.ai, see the Desktop and Web tabs in Switch permission modes.

How you run Claude Code Built-in starting permission mode
Any settings file sets disableAutoMode to "disable" default
claude -p or the Agent SDK default
In a terminal or through the VS Code extension auto with Claude Code v2.1.283 or later; on earlier versions, auto on Pro, Max, or Team plans in sessions that fetch feature flags, and default otherwise

In your first session after an install or upgrade, Claude Code can choose the starting permission mode before its feature flags arrive. That session can start in a different permission mode than the table gives, and your next session matches the table.

When the flag, a settings file, or the built-in default selects auto but auto mode isn't available to the session, Claude Code starts the session in Manual instead. Auto mode is unavailable when the session doesn't meet the availability requirements, such as a settings file turning it off or a model that doesn't support it, or when Anthropic has temporarily turned it off server-side.

The first time the built-in default starts one of your sessions in auto mode, Claude Code shows a notice that links to this page:

  • In a terminal, once, at the top of the session
  • In the VS Code extension, as a card on the new-conversation screen that stays until you dismiss it

On Pro, Max, and Team plans, if your ~/.claude/settings.json sets a defaultMode other than auto and no other settings file sets one, your sessions keep starting in that mode. Claude Code asks once, in the terminal or in the VS Code extension, whether to change the setting to auto mode. If you decline, your setting stays as it is.

Start in a different permission mode

You can set the starting permission mode for one session, or as a default for every session on a machine, in a project, or in an organization. When more than one settings file sets permissions.defaultMode, settings precedence decides, so a project or managed value outranks ~/.claude/settings.json. To change the permission mode of a session that's already running, see Switch permission modes.

To set the starting permission mode for Do this
One session you're about to start Pass the permission mode as a flag, for example claude --permission-mode default
Every terminal session you start on this machine Set permissions.defaultMode in ~/.claude/settings.json. For what the VS Code extension reads, see Switch permission modes
Every terminal session you start in one project Set permissions.defaultMode in the project's .claude/settings.json. Sessions you start in a terminal honor every value except auto and bypassPermissions; sessions the VS Code extension starts don't read project settings for the starting permission mode
Every terminal session in your organization Set permissions.defaultMode in managed settings. Terminal sessions start in that mode and people can still switch to auto mode; for what the VS Code extension reads, see Switch permission modes. To remove auto mode so nobody can select it, set permissions.disableAutoMode to "disable" instead

This example makes every terminal session on your machine start in Manual mode, whose config value is default. Save it in ~/.claude/settings.json:

{
  "permissions": {
    "defaultMode": "default"
  }
}

The next session you start shows ⏸ manual mode on in the status bar.

Switch permission modes

Each interface has its own control for switching permission modes during a session and its own way of choosing the permission mode new sessions start in. Select your interface to see its controls.

During a session: press Shift+Tab to cycle permission modes. From auto, the first press switches to default, and the cycle then runs default → acceptEdits → plan → back to default. Optional modes, described below, slot in after plan. The status bar shows the active mode as a gray ⏸ manual mode on for default, or as ⏵⏵ accept edits on, ⏸ plan mode on, ⏵⏵ auto mode on, ⏵⏵ don't ask on, or ⏵⏵ bypass permissions on.

Not every mode is in the default cycle:

  • auto: appears when auto mode is available; cycling to it switches permission modes without a confirmation prompt
  • bypassPermissions: appears after you start with --permission-mode bypassPermissions, --dangerously-skip-permissions, --allow-dangerously-skip-permissions, or permissions.defaultMode: "bypassPermissions" in user, --settings, or managed settings. The --allow- variant adds the permission mode to the cycle without activating it
  • dontAsk: never appears in the cycle; set it with --permission-mode dontAsk

Enabled optional modes slot in after plan, with bypassPermissions first and auto last. If you have both enabled, you will cycle through bypassPermissions on the way to auto.

From a Bash permission prompt: in the Manual and acceptEdits permission modes, when auto mode is available, Claude Code adds Yes, and switch to auto mode to a Bash command's permission prompt. Select it to approve the command and switch the session to auto mode. PowerShell tool prompts don't offer the option. Requires Claude Code v2.1.247 or later.

Claude Code doesn't add the option to prompts forced by one of your ask rules or by a hook, because auto mode still shows you those prompts, so switching wouldn't remove them.

At startup: pass the permission mode as a flag.

claude --permission-mode plan

As a default: set permissions.defaultMode at the scope you want, as described in Start in a different permission mode.

The same --permission-mode flag works with -p for non-interactive runs.

Auto-approve file edits with acceptEdits mode

acceptEdits mode lets Claude create and edit files in your working directory without prompting. The status bar shows ⏵⏵ accept edits on while this mode is active.

In addition to file edits, acceptEdits mode auto-approves common filesystem Bash commands: mkdir, touch, rm, rmdir, mv, cp, and sed. These commands are also auto-approved when prefixed with safe environment variables such as LANG=C or NO_COLOR=1, or process wrappers such as timeout, nice, or nohup. Like file edits, auto-approval applies only to paths inside your working directory or additionalDirectories.

Each path also goes through the symlink check, so a write that resolves outside that scope isn't auto-approved either. Paths outside that scope, writes to protected paths, rm and rmdir removals targeting a critical path, and all other Bash commands except the built-in read-only set still prompt.

When the PowerShell tool is enabled, acceptEdits mode also auto-approves Set-Content, Add-Content, Clear-Content, and Remove-Item on in-scope paths, along with their common aliases. The same scope and protected-path rules apply, and Remove-Item gets its own check. A positional argument that contains a quote character, such as the apostrophe in Set-Content .\notes.txt "It's done", still prompts even on in-scope paths, because Claude Code can't statically validate an argument whose quoted and unquoted readings differ. Pass the content through a named parameter such as -Value to avoid the prompt.

Use acceptEdits when you want to review changes in your editor or via git diff after the fact rather than approving each edit inline.

Press Shift+Tab once from Manual mode to enter it, or start with it directly:

claude --permission-mode acceptEdits

Analyze before you edit with plan mode

Plan mode tells Claude to research and propose changes without making them. Claude reads files, runs shell commands to explore, and writes a plan, but does not edit your source. Except in interactive terminal sessions with bypass permissions available, edits stay blocked until you approve the plan.

What happens to a shell command during planning depends on the session, and the first of these cases that matches applies:

  • Interactive terminal sessions with bypass permissions available: neither the classifier nor a prompt applies to planning commands. Skip all checks with bypassPermissions mode covers the few things that still prompt there.
  • Auto mode available and the useAutoModeDuringPlan setting on, which it is by default: the classifier reviews shell commands other than critical-path removals instead of prompting you. Approved commands run, and rejected ones are blocked.
  • Auto mode not available, or useAutoModeDuringPlan off: commands outside the built-in read-only set prompt for approval, including when the sandbox's auto-allow mode is enabled.

Enter plan mode by pressing Shift+Tab or prefixing a single prompt with /plan. You can also start in plan mode from the CLI:

claude --permission-mode plan

Press Shift+Tab again to leave plan mode without approving a plan.

Review and approve a plan

When the plan is ready, Claude presents it and asks how to proceed. From that prompt you can choose:

  • Yes, and use auto mode: approve and start in auto mode. If auto mode isn't available to your session, for example because your organization turned it off, this option reads Yes, auto-accept edits. If you started the session with bypass permissions enabled, the option reads Yes, and switch to BYPASS PERMISSIONS (no further prompts) for this session instead.
  • Yes, manually approve edits: approve and review each edit individually.
  • No, keep planning: stay in plan mode and tell Claude what to change.

Approving a plan exits plan mode and switches the session to the permission mode each approve option describes, so Claude starts editing. To plan again, cycle back to plan mode with Shift+Tab, or prefix your next prompt with /plan.

Press Ctrl+G to open the proposed plan in your default text editor and edit it directly before Claude proceeds. When showClearContextOnPlanAccept is enabled, the list gains a first option that approves the plan and clears the planning context.

Accepting a plan also gives the session a generated title based on the plan, unless you've already named the session.

Set plan mode as the default

To make plan mode the default for a project's terminal sessions, set defaultMode to plan in .claude/settings.json, placed as the example under Start in a different permission mode shows. Conversations the VS Code extension starts don't read project settings for the starting permission mode. There, set claudeCode.initialPermissionMode to plan in your VS Code user settings instead.

Eliminate permission prompts with auto mode

Auto mode lets Claude execute without routine permission prompts. A separate classifier model reviews actions before they run, blocking anything that escalates beyond your request, targets unrecognized infrastructure, or appears driven by hostile content Claude read. Explicit ask rules still force a prompt.

With Claude Code v2.1.283 or later, auto mode is the built-in starting permission mode for interactive terminal and VS Code sessions on every plan and provider. On earlier versions, it's the built-in starting permission mode only on Pro, Max, and Team plans.

The classifier also reviews each message Claude sends to another agent with SendMessage, whether plain text or a structured agent team message, before Claude Code delivers it, both in auto mode and in plan mode while the classifier reviews commands; the send review requires Claude Code v2.1.222 or later.

By default, the classifier doesn't review rm and rmdir removals targeting a critical path, such as rm -rf / or rm -rf ~. Critical paths covers what happens to them in each permission mode.

Auto mode also nudges Claude to keep working without stopping for clarifying questions, though Claude still asks when your prompt or a skill explicitly relies on it. For stronger autonomous behavior in a mode that still prompts you, set the Proactive output style instead.

Auto mode is available only when your account meets all of these requirements:

  • Plan: All plans.
  • Organization: on Team and Enterprise, auto mode is available by default. Administrators can turn it off for the organization by setting permissions.disableAutoMode to "disable" in managed settings.
  • Model: on the Anthropic API and Claude Platform on AWS, Claude Opus 4.6 or later, Sonnet 4.6 or later, or a Fable model. On Amazon Bedrock, Google Cloud's Agent Platform, Microsoft Foundry, and signed-in Claude apps gateway sessions, only Claude Sonnet 5, Opus 4.7 or later, and the Fable models. Older models, including Sonnet 4.5, Opus 4.5, Haiku, and claude-3 models, are not supported on any provider.
  • Provider: available by default on the Anthropic API, Claude Platform on AWS, Amazon Bedrock, Google Cloud's Agent Platform, Microsoft Foundry, and signed-in Claude apps gateway sessions.

If Claude Code reports auto mode as unavailable, first check these requirements and whether any settings file sets disableAutoMode. Anthropic may also have turned auto mode off server-side, or the server may have rejected auto mode for your account. A session that received either answer keeps auto mode off until the session ends, so start a new session later.

A separate message that names a model and says auto mode "cannot determine the safety" of an action means a classifier request failed. That failure is usually transient, but on Amazon Bedrock it can repeat until your account can invoke the named model. See the error reference for the causes and what to do.

If you set defaultMode: "auto" in settings and a terminal session starts in Manual mode with no error, the setting is likely in .claude/settings.json or .claude/settings.local.json. auto doesn't take effect from those files. Move it to ~/.claude/settings.json. For a conversation the VS Code extension started, check the extension's own list in Switch permission modes instead.

Auto mode on Bedrock, Agent Platform, or Foundry

On Amazon Bedrock, Google Cloud's Agent Platform, Microsoft Foundry, and signed-in Claude apps gateway sessions, auto mode is available by default. With Claude Code v2.1.283 or later, it's also the built-in starting permission mode for interactive terminal and VS Code sessions. To choose the starting permission mode yourself, set permissions.defaultMode as Start in a different permission mode describes, or pick a permission mode from the VS Code extension's mode indicator.

Only Claude Sonnet 5, Opus 4.7 or later, and the Fable models are supported on these providers. On any other model, the session starts in Manual instead.

To prevent developers from using auto mode, set disableAutoMode to "disable" in managed settings. This removes auto from the Shift+Tab cycle, and a session started with --permission-mode auto starts in Manual instead. A session already running in auto mode leaves it when the setting reaches that session from an admin-deployed source, and shows auto mode disabled by settings. Before v2.1.251, a running session kept auto mode until it ended.

In v2.1.158 through v2.1.206, auto mode was off on these providers until you set CLAUDE_CODE_ENABLE_AUTO_MODE=1, and Claude Code ignored defaultMode: "auto" on these providers unless the variable was also set. The variable is still accepted for compatibility and has no effect from v2.1.207 onward.

Server-side classifier review

In auto mode, Claude Code can ask the server to check the actions that the decision order sends for review, as part of the session's model requests, in place of sending its own classifier requests. These sessions ask:

  • A direct connection to the Anthropic API: in an interactive terminal session, on every claude.ai plan and on accounts that use the Claude API, as Anthropic rolls it out. Requires Claude Code v2.1.271 or later on Pro, Max, and Team plans, and v2.1.278 or later on Enterprise plans and Claude API accounts. From v2.1.282, a session that doesn't fetch feature flags, for example because you turned telemetry off, asks the server by default in any kind of session.
  • A cloud provider, or an LLM gateway or proxy: on Claude Platform on AWS, Amazon Bedrock, Google Cloud's Agent Platform, and Microsoft Foundry, and whenever you point ANTHROPIC_BASE_URL at an LLM gateway or proxy, whatever your plan. Asking by default requires Claude Code v2.1.278 or later.
  • A signed-in Claude apps gateway session: requires Claude Code v2.1.280 or later

Where the server reviews the actions, its verdicts decide them. Two other outcomes are possible:

  • The server doesn't review the session: a response completes with no review results, or the server answers that it doesn't review this session. The most common causes are an LLM gateway or proxy that drops the request for review or the results, and a platform, region, or credential that doesn't have server-side checks yet. Claude Code falls back to its own classifier requests. Once that fallback holds for the rest of the session, it shows a notice about classifier request charges on accounts where those requests are billed.
  • The server gives no verdict for an action: Claude Code denies the action rather than run it unreviewed. On any connection, this happens when the response ends before the review results arrive or the results arrive in a form Claude Code can't read. An LLM gateway or proxy that cuts responses short or rewrites the results can cause either. On a direct connection to the Anthropic API, it also happens when the server's check fails for the action, for example by timing out. The server returned no safety verdict covers the denial message, what happens when denials repeat, and what to do.

To skip asking the server and always use Claude Code's own classifier requests, set CLAUDE_CODE_AUTO_MODE_SERVER=0. On a direct connection to the Anthropic API, the variable requires Claude Code v2.1.281 or later. Setting it to 1 there turns server review on in a session that doesn't have it yet, such as a -p or Agent SDK session, unless you've also set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1. If you set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 and leave CLAUDE_CODE_AUTO_MODE_SERVER unset, Claude Code also stops asking the server, except as Disable pre-release capabilities describes.

What the classifier blocks by default

The classifier trusts your working directory and the remotes that were configured for it when the session started. A remote added or repointed during the session with git remote add or git remote set-url isn't trusted, and everything else is treated as external until you configure trusted infrastructure. Before v2.1.200, remotes added mid-session were also trusted.

Blocked by default:

  • Downloading and executing code, like curl | bash
  • Sending sensitive data to external endpoints
  • Production deploys and migrations
  • Mass deletion on cloud storage
  • Granting IAM or repo permissions
  • Modifying shared infrastructure
  • Irreversibly destroying files that existed before the session
  • Force push
  • Committing or pushing a change that would send secrets or sensitive data outside the repository when it runs, or widen what a deploy exposes. This covers a CI workflow or deploy configuration that passes a secret to a destination that doesn't already receive it, a script or setup step that reads a secret store and sends the data out, and a config change that widens what a deploy publishes, such as a registry, visibility, artifact, or sourcemap setting. The check applies on any branch, applies even when the repository is public, and fires when the change is committed or pushed, whether or not that commit or push triggers the pipeline; clearing it requires naming the execution effect, not only the commit or push. Before v2.1.211, this check was scoped to the default branch instead: a push there was blocked when it carried sensitive content, changes concealed or misdescribed relative to what you asked for, content ported in from outside the repository, or routed around a review you asked for
  • git reset --hard, git checkout -- ., git restore ., git clean -fd, git stash drop, or git stash clear, which the classifier presumes would discard uncommitted changes
  • git commit --amend when the commit at HEAD was not created in this session
  • From v2.1.198, git commit --amend when the commit at HEAD has already been pushed. A message-only reword is not blocked: --amend -m with nothing newly staged, on a commit that Claude created during this session
  • terraform destroy, pulumi destroy, cdk destroy, or terragrunt destroy, and applying a plan that destroys resources

Claude Code v2.1.195 and later block more categories by default. Several depend on environment entries, such as sensitive remote targets and protected IaC scopes, that you can narrow to concrete names.

  • Writing to a secret manager, or changing DNS records or TLS certificates
  • Merging a pull request no human has approved, approving Claude's own pull request, or disabling CI checks
  • Posting a comment that is itself a command to automation, such as atlantis apply or a bot's /deploy or /merge
  • Toggling, ramping, or deleting a production feature flag
  • Applying infrastructure changes to a protected IaC scope, or draining and removing cluster nodes
  • Writes to a shared compute cluster that reach beyond the resource you named, such as a label selector or --all that catches other users' jobs
  • Creating Kubernetes resources that run on every node or intercept cluster traffic, such as DaemonSets and admission webhooks
  • Interactive shells or port-forwards into a sensitive remote target
  • Opening a tunnel or reverse shell that makes a local service reachable from the public internet
  • Printing a live credential or token into the transcript or a file
  • Accessing a location listed as a sensitive data location in your environment, or copying data out of one. As of v2.1.198 this also blocks sending data from one to an audience the entry excludes
  • Routing a package install around your internal package registry to a public registry. As of v2.1.198, this also applies when you've told Claude an internal registry or mirror exists in the conversation, not only when one is listed in your environment
  • Running a command with a flag that disarms a safety guard, like --insecure
  • Launching an autonomous agent loop that runs without human approval or a sandbox, such as one started with --dangerously-skip-permissions or --no-sandbox. As of v2.1.198 this also covers running a third-party agent or eval harness with isolation and per-action approval disabled, such as a runner started with --yes-always
  • Claude in Chrome browser actions that could send page content, cookies, or credentials off-origin

Claude Code v2.1.198 and later also block these by default:

  • Deleting files in /tmp, $TMPDIR, or another shared scratch or cache directory by wildcard, glob, or age filter rather than by a specific named path
  • Including sensitive details in content sent, uploaded, published, or written to other people or shared systems, when your own message didn't authorize those details for that recipient. PR and issue bodies, commit messages, and comments count as this kind of outbound content when the repository is outside the trust boundary or public, including your organization's own public repositories; internal file paths, code names, live API response data such as emails or account identifiers, and infrastructure identifiers count as sensitive details. The PR, issue, and commit-message scoping requires Claude Code v2.1.200 or later. Live personal data from an API response in a PR or issue body, such as an email address, an account or organization identifier, or a usage metric, requires you to name those details and the recipient regardless of the repository's visibility or trust boundary. That check requires Claude Code v2.1.203 or later
  • Sending keystrokes to Claude Code's own tmux pane to drive its own interface, which the classifier treats as Claude changing its own permissions or oversight

Claude Code v2.1.200 and later also block these by default:

  • Commenting out, deleting, or force-passing a test or assertion that guards security behavior, such as auth, access control, input validation, or sandboxing
  • Deleting or tearing down a stateful resource Claude didn't create in the session, when no more specific deletion rule applies and you didn't name that resource
  • Repointing an API base URL, proxy endpoint, webhook receiver, or registry mirror at a third-party host that doesn't fit the task, including in example files like .env.example
  • Changing where pushes go with git remote set-url or git remote add, unless you named the new remote
  • Pushing secrets or personal or entrusted data to a repository known to be public, or pushing confidential material there that isn't part of that repository's own work. A dotfiles repository's own subject matter is the one exception for personal or entrusted data, and content from a private repository reaching any public surface is blocked the same way; both refinements require Claude Code v2.1.203 or later. Before v2.1.203, personal data was grouped with confidential material and blocked only when it wasn't part of that repository's own work. When a repository's visibility isn't established, the classifier doesn't block on that alone; it judges the content against the other rules instead
  • Opening a pull request against a different repository or organization, forking with gh repo fork, or pushing to a third-party repository, unless you named that external target

Claude Code v2.1.203 and later also block these by default:

  • Content from a sensitive local store, or from a file whose name, path, or type marks it as sensitive, entering a commit, a push, PR or issue text, a gist or paste, or a package publish, unless you named both the source and the destination. Session transcripts and conversation logs, credential and configuration dot-folders such as SSH keys, cloud credentials, browser profiles, and shell history, and user-data exports all count, and the repository being private doesn't clear it

Claude Code v2.1.205 and later also block these by default:

  • Writing to Claude Code session transcripts, the .jsonl history files under ~/.claude/projects/ or your configured config directory, whether directly or through a shell command. The rule also covers the metadata lines Claude Code appends to each transcript entry for its own checks. Reading a transcript isn't blocked

  • A recursive forced delete such as rm -rf "$VAR" or Remove-Item -Recurse -Force $dir whose target is a shell variable that isn't assigned anywhere in the conversation the classifier sees, or a glob rooted at such a variable. The value came only from earlier command output, which the classifier never receives, so the classifier can't verify the deletion target against the other deletion rules. The block clears when you name the exact path being deleted, or when Claude re-runs the delete with the resolved literal path written into the command. Deletes whose target the classifier can resolve aren't affected.

    A glob directly under the variable, as in rm -rf "$VAR"/*, is a critical path instead. Remove-Item targets that are a bare * or end in /* or \* never reach the classifier: Claude Code denies them outright.

Claude Code v2.1.257 and later also block these by default:

  • Requesting credentials from the cloud instance-metadata endpoint, such as 169.254.169.254, or explicitly authenticating a cloud, cluster, or registry call with the machine's own service-account or node identity
  • Reaching a public host by a route other than a direct request, such as a tunnel, a reverse shell, or a resolver or proxy configuration rewritten to point outside
  • Reading credentials that belong to the host rather than to your task, such as node certificates or the node's container-registry auth
  • Connecting to or scanning sibling containers, pods, or VMs that Claude didn't start, or the node beneath the container

If Claude Code runs somewhere that is meant to allow one of these, describe that setup in a Host containment entry in autoMode.environment.

Claude Code v2.1.261 and later also block these by default:

  • Posting or writing a link to a public paste, diagram, or data-sharing service in a message, PR or issue text, a document, or anywhere else the link will be opened or fetched, when the URL itself carries the content being shared, unless you named that service

Allowed by default:

  • Local file operations in your working directory
  • Installing dependencies declared in your lock files or manifests
  • Reading .env and sending credentials to their matching API
  • Read-only HTTP requests
  • Pushing to any branch of the repository you're working in, including the default branch. A non-default branch whose name marks it as a deploy or publication target, such as production or gh-pages, isn't covered: the classifier judges a push there on its own terms. The push's content is still checked against the other rules, permissions.deny rules can still block push commands as written in every mode, and the remote's own branch protection still applies. Before v2.1.211, only pushes to the branch you started on, branches Claude created, and routine pushes to the default branch were allowed by default, and before v2.1.203 any direct push to the default branch was blocked

Claude Code v2.1.195 and later also allow these by default:

  • Deleting the exact jobs Claude created earlier in the same session
  • Reading, reviewing, or writing security-related code, configs, and threat models as part of your task
  • Messages between agents working together in the same multi-agent session
  • Sending data to the trusted domains, buckets, and services you list in environment. This covers data flow only, not destructive or credential operations on the same infrastructure
  • Claude in Chrome navigation to a trusted internal domain, localhost, or a URL you named

Sandboxed commands don't get network access by default. Claude names the hosts a command needs on the command itself, the classifier reviews them with the command, and an approved list opens those hosts for that one command alone. Per-command allowed domains covers what a list can and can't open and what happens when a command reaches for an unlisted host.

Run claude auto-mode defaults to print the full rule lists as JSON. If routine actions get blocked, an administrator can add trusted repos, buckets, and services via the autoMode.environment setting: see Configure auto mode.

Pushing to any branch of the repository you're working in and creating a pull request that matches your request run without a prompt, unless the push or pull request falls under the blocked list, such as secrets or sensitive data leaving the repository, or a pull request that targets a different repository or organization. To require a human checkpoint before these commands while staying in auto mode, add permissions.ask rules, which match the command as written: see Common boundaries.

The first read outside the working directories

While permissions.blockReadsOutsideWorkingDirectories is off, file reads run without a prompt in auto mode, including reads outside the working directories. The first time Claude uses the Read, Grep, or Glob tool on a path outside them, Claude Code asks you whether to keep allowing those reads.

The prompt doesn't appear in non-interactive -p runs or background sessions; reads there run as before.

Whatever you answer, Claude keeps working:

  • Keep allowing: the read runs, later reads outside the working directories run as before, and Claude Code records your answer so the prompt doesn't appear again
  • Block from now on: the read is refused, and Claude Code sets permissions.blockReadsOutsideWorkingDirectories to true in your user settings, which makes the file tools refuse such reads in every later session and every permission mode. To let Claude read such a path later, add its directory with /add-dir or remove the setting.
  • Ask again next time: the read is refused, and the next read outside the working directories prompts again

Boundaries you state in conversation

The classifier treats boundaries you state in the conversation as a block signal. If you tell Claude "don't push" or "wait until I review before deploying", the classifier blocks matching actions even when the default rules would allow them. A boundary stays in force until you lift it in a later message. Claude's own judgment that a condition was met does not lift it.

Boundaries are not stored as rules. The classifier re-reads them from the transcript on each check, so a boundary can be lost if context compaction removes the message that stated it. For a hard guarantee, add a deny rule instead.

Approvals you state in conversation

If you tell Claude that a blocked action is allowed, the classifier reads that as your approval and can clear the block. How you worded it decides whether the action runs, and how far the approval reaches:

  • Name the action and its specifics: your message has to name the action and the specific thing that makes it dangerous, such as the branch of a force push. Naming the verb alone clears nothing, so "you can force-push" leaves the block in place.
  • Expect it to cover one action: an approval covers the destructive action you named, so a later action is blocked again unless you granted the approval as standing. To stop approving a routine pattern one action at a time, add it to autoMode.allow.
  • Some blocks stay in place: the classifier's precedence order sets out which blocks your approval can reach. To run a step it won't clear, leave auto mode and answer the permission prompt.

When auto mode falls back

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. When the classifier produces no verdict on the 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 the notification or the Recently denied entry.
  • 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. These thresholds are not configurable. Any allowed action resets the consecutive counter, while the total counter persists for the session and resets only when its own limit triggers a fallback. Claude Code doesn't count a denial toward either threshold when a safety check separate from auto mode refuses the classifier's own request; the linked entry covers how Claude Code handles those denials.
  • Sessions that can't prompt: a non-interactive -p run without a --permission-prompt-tool has no prompt to fall back to. When repeated blocks reach a threshold, the action doesn't run and Claude keeps working. The same applies when a safety check separate from auto mode refuses the classifier's request. Claude Code doesn't stop the run in either case.
  • 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.
  • 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 rather than applying it: you're prompted for approval instead, or the action is auto-denied in dontAsk mode.

Repeated blocks usually mean the classifier is missing context about your infrastructure. Use /feedback to report false positives, or have an administrator configure trusted infrastructure.

Each action goes through a fixed decision order. The first matching step wins:
1. Actions matching your [allow, ask, or deny rules](/docs/en/permissions#manage-permissions) resolve immediately, with these exceptions:
   * Writes to [protected paths](#protected-paths) route to the classifier even when an allow rule matches
   * No allow rule approves `rm` and `rmdir` removals targeting a [critical path](#critical-paths)
   * MCP tools marked [`requiresUserInteraction`](/docs/en/mcp#require-approval-for-a-specific-tool) prompt you directly even when an allow rule matches, and so do connector tools [your organization set to `ask`](/docs/en/mcp#organization-controls-on-connector-tools) in sessions where that setting reaches Claude Code
   * A shell command that carries [per-command allowed domains](/docs/en/sandboxing#per-command-allowed-domains-in-auto-mode) also routes to the classifier even when an allow rule matches, because a rule approves the command, not its hosts
   * Ask rules that match on a command's content, such as `Bash(git push *)`, fall back to a permission prompt
   * A write that the [symlink check](/docs/en/permissions#symlinks) resolves to a protected path prompts you when the path Claude requested isn't itself protected
2. Read-only actions and file edits in your working directory are auto-approved, except writes to [protected paths](#protected-paths) and [the first read outside the working directories](#first-read-outside-the-working-directories), which prompts you
   * In a session with [server-side classifier review](#server-side-classifier-review), read-only and [sandboxed](/docs/en/sandboxing#sandbox-modes) shell commands wait for that review and are blocked if it flags them
   * A write inside your working directory that the [symlink check](/docs/en/permissions#symlinks) resolves to a location outside it prompts you
3. Everything else goes to the classifier, apart from [critical-path removals](#critical-paths) under their default handling. The connector tools and `requiresUserInteraction` MCP tools that prompt you directly in step 1 never reach the classifier either, so neither an org-required approval nor a consent step is auto-approved
4. If the classifier blocks, Claude receives the reason and tries an alternative. In most sessions the reason names the rule the classifier matched, such as `[Data Exfiltration]`, rather than giving a written explanation; see [Review denials](/docs/en/auto-mode-config#review-denials)

On entering auto mode, broad allow rules that grant arbitrary code execution are dropped:

* Blanket `Bash(*)` or `PowerShell(*)`
* Wildcarded interpreters like `Bash(python*)`
* Package-manager run commands
* `Agent` allow rules
* [`Monitor`](/docs/en/tools-reference#monitor-tool) allow rules, because Claude Code runs Monitor commands through the shell

Narrow rules like `Bash(npm test)` stay in effect. Claude Code restores the dropped rules when you leave auto mode. Before v2.1.236, Claude Code left `Monitor` allow rules in effect in auto mode, so a rule that matched the whole tool approved Monitor commands without classifier review.

Claude Code also runs `git status` itself before a command that would discard uncommitted work, such as `git reset --hard` or `rm -rf`, and shows the classifier whether staged, modified, or untracked work is present. Claude Code reports untracked files in that check even when the repository's git configuration sets `status.showUntrackedFiles=no`.

In the classifier requests sent by Claude Code itself, the classifier sees user messages, tool calls other than read-only lookups such as file reads and searches, and your CLAUDE.md content. Tool results are stripped from those requests, so hostile content in a file or web page can't manipulate the classifier directly.

You can annotate a call's result with a [PostToolUse hook's `classifierContext` field](/docs/en/hooks#annotate-a-result-for-the-auto-mode-classifier), which the classifier reads as application-provided context. The field requires Claude Code v2.1.236 or later.

A separate server-side probe scans incoming tool results and flags suspicious content before Claude reads it. For more on how these layers work together, see the [auto mode announcement](https://claude.com/blog/auto-mode) and the [engineering deep dive](https://www.anthropic.com/engineering/claude-code-auto-mode).
How auto mode handles subagents

The classifier checks subagent work at three points:

  1. Before a subagent starts, the delegated task description is evaluated, so a dangerous-looking task is blocked at spawn time.
  2. While the subagent runs, each of its actions goes through the classifier with the same rules as the parent session, and any permissionMode in the subagent's frontmatter is ignored.
  3. When the subagent finishes, the classifier reviews its work and its final report before the parent reads the report. When the classifier flags the subagent's work or report, or a separate API safety check refuses the review, the report is still delivered, prepended with a security warning. When the classifier is unavailable for the review, the report arrives with a note to verify the subagent's work before acting on it.
Cost and latency

The classifier runs on Claude Sonnet 5 by default rather than on your /model selection. A classifier model that Anthropic configures server-side takes precedence over that default. When your session's model is Claude Sonnet 4.6, or when availableModels excludes Sonnet 5, the classifier runs on the session's model instead, or on an Opus model when the session runs on a Fable model; on providers other than the Anthropic API, that Opus fallback is the provider's default Opus model.

The session's first auto-mode request validates the Sonnet 5 default: if the request succeeds, Sonnet 5 stays the session's classifier model, and if it fails because the model isn't available, the session uses the fallback instead. After that validation settles, the classifier's model doesn't change for the session.

On Enterprise plans and on accounts that use the Claude API, Claude Platform on AWS, Amazon Bedrock, Google Cloud's Agent Platform, or Microsoft Foundry, classifier calls count toward your token usage. Each check sends a portion of the transcript plus the pending action, adding a round-trip before execution. Reads and working-directory edits outside protected paths skip the classifier, so the overhead comes mainly from shell commands and network operations. Where the server reviews the actions as part of the session's model requests, there are no separate classifier calls to count; see Server-side classifier review.

Sandboxed network access adds no per-connection classifier requests. The classifier judges the hosts a command names together with the command in one review, and Claude Code checks each connection against the approved list without calling the classifier again.

Allow only pre-approved tools with dontAsk mode

If you set dontAsk mode, Claude Code auto-denies every tool call that would otherwise prompt you. Claude still runs actions that need no approval in Manual mode, such as file reads inside your working directories and read-only Bash commands, plus actions matching your permissions.allow rules and calls approved by a PreToolUse hook. Use this mode for CI pipelines or restricted environments where you pre-define what Claude may do; the session never waits for input. The status bar shows ⏵⏵ don't ask on while this mode is active.

Claude Code denies calls matching your explicit ask rules rather than prompting. It also denies the built-in AskUserQuestion tool even if your allow rules match it, and does the same to connector tools your organization set to ask in sessions where that setting reaches Claude Code. It denies MCP tools marked _meta["anthropic/requiresUserInteraction"] the same way, because their approval card needs an answer this mode never collects; this requires Claude Code v2.1.199 or later.

rm and rmdir removals targeting a critical path, such as rm -rf / and rm -rf ~, are denied even when an allow rule matches them or a PreToolUse hook allows them.

Cloud sessions ignore defaultMode: "dontAsk"; see bypassPermissions for details.

Set it at startup with the flag:

claude --permission-mode dontAsk

Skip all checks with bypassPermissions mode

bypassPermissions mode disables permission prompts and safety checks so tool calls execute immediately, including writes to protected paths.

The actions no mode auto-approves still prompt in this mode. The Remove-Item in PowerShell denies also apply in this mode.

Two cross-session messaging safeguards still apply in this mode, and in interactive terminal plan-mode sessions where bypass permissions are available:

  • The isolatePeerMachines approval prompt for messages to your sessions beyond this machine still appears.
  • When no crossSessionInbound value applies, Claude Code holds an inbound message from another of your sessions for your approval, and delivers without asking only when the sending session identifies itself as also bypassing permission prompts. If you leave the permission mode while messages are held, Claude Code re-applies the inbound rules and delivers any held message they now accept.

In interactive terminal sessions with bypass permissions available, Claude Code also doesn't enforce plan mode's blocks. Claude is still instructed to plan without editing, but a file edit or shell command it attempts during planning runs without prompting. Explicit ask rules and rm and rmdir removals targeting a critical path still prompt.

Plan mode keeps its blocks wherever Claude Code runs without an interactive terminal, including non-interactive runs with -p, Agent SDK sessions, and conversations in the VS Code extension's chat panel. There, --allow-dangerously-skip-permissions makes bypassPermissions selectable later.

You can't enter bypassPermissions from a session you started without it enabled. Enable it at launch with permissions.defaultMode: "bypassPermissions" or with an enabling flag:

claude --permission-mode bypassPermissions

The --dangerously-skip-permissions flag is equivalent.

Claude Code refuses bypassPermissions in a session you start with --restricted. --restricted requires Claude Code v2.1.248 or later.

The first time you start an interactive session with this mode enabled, Claude Code shows a warning dialog asking you to accept responsibility for actions taken without permission checks. Claude Code saves your acceptance to user settings, so the dialog appears only once. If you decline, Claude Code exits. In non-interactive mode no dialog is shown, and a background session started with --bg is refused until you've accepted the dialog in an interactive session.

On Linux and macOS, Claude Code refuses to start in this mode when running as root or under sudo:

--dangerously-skip-permissions cannot be used with root/sudo privileges for security reasons

The check is skipped automatically inside a recognized sandbox. To run autonomously in a container, use the dev container configuration, which runs Claude Code as a non-root user.

Cloud sessions don't honor defaultMode: "bypassPermissions" or "dontAsk" from your settings files, so a repository's checked-in settings can't start a cloud session in bypass-permissions mode. The setting is ignored silently and the session starts in the permission mode shown in the mode dropdown instead. See Switch permission modes for which modes cloud sessions offer.

Protected paths

Writes to a small set of paths are never auto-approved, except in bypassPermissions mode and in interactive terminal sessions in plan mode with bypass permissions available. This prevents accidental corruption of repository state and Claude's own configuration.

Mode Protected-path writes
default, acceptEdits Prompted
plan Allowed in interactive terminal sessions with bypass permissions available. Otherwise, routed to the classifier when auto mode is available during planning, and prompted when it isn't
auto Routed to the classifier
dontAsk Denied
bypassPermissions Allowed

In a session started with --restricted, 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 resolves to a protected path prompts you instead when the path Claude requested isn't itself protected.

permissions.allow 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

Protected directories:

  • .git
  • .config/git
  • .vscode
  • .idea
  • .husky
  • .cargo
  • .devcontainer
  • .yarn
  • .mvn
  • .claude, except for .claude/worktrees where Claude stores its own git worktrees

Protected files:

  • .gitconfig, .gitmodules
  • .bashrc, .bash_profile, .bash_login, .bash_aliases, .bash_logout, .zshrc, .zprofile, .zshenv, .zlogin, .zlogout, .profile, .envrc
  • .npmrc, .yarnrc, .yarnrc.yml, .pnp.cjs, .pnp.loader.mjs, .pnpmfile.cjs, bunfig.toml, .bunfig.toml
  • .bazelrc, .bazelversion, .bazeliskrc
  • .pre-commit-config.yaml, lefthook.yml, lefthook.yaml, .lefthook.yml, .lefthook.yaml
  • gradle-wrapper.properties, maven-wrapper.properties
  • .devcontainer.json
  • .ripgreprc, pyrightconfig.json
  • .mcp.json, .claude.json

Critical paths

Claude Code never lets a permissions.allow rule or a PreToolUse hook that returns "allow" approve an rm or rmdir command that targets a critical path, even in modes that skip other prompts. This circuit breaker guards against model error. A matching deny rule still blocks the command outright.

What happens instead depends on your permission mode:

Mode What Claude Code does with a critical-path removal
default, acceptEdits Asks you to approve it
plan Asks you to approve it. When the classifier reviews commands during planning and no bypass permissions are available, handles it as in auto mode
auto Asks you to approve it in the terminal, with a time limit. Elsewhere, denies it
dontAsk Denies it
bypassPermissions Asks you to approve it, with a time limit in the terminal

If an explicit ask rule matches the command, Claude Code asks you instead, even in auto mode and without a time limit. In modes that ask, a PermissionRequest hook can answer the prompt.

The auto and bypassPermissions handling requires Claude Code v2.1.281 or later. To turn it off, set CLAUDE_CODE_DISABLE_DANGEROUS_RM_TIMEOUT=1 in the environment that launches Claude Code. In auto mode, critical-path removals then go to the classifier instead, and in bypassPermissions mode the prompt has no time limit.

In auto and bypassPermissions modes, the terminal prompt shows a two-minute countdown:

  • If the countdown runs out before you answer, Claude Code denies the command and tells Claude what to do instead, so an unattended session keeps working.
  • Press any key while the prompt is open to stop the countdown and keep the prompt waiting for your answer.
  • After three of these prompts run out unanswered in a session, Claude Code stops showing them and denies further critical-path removals immediately. Sending a new message starts the count over.

In auto mode, wherever Claude Code can't show you a terminal prompt, it denies the command immediately, for example in non-interactive runs with -p, in Agent SDK sessions, and in the VS Code extension's chat panel and the Desktop app. The denial tells Claude to report what it wanted to delete and leave the removal to you.

Claude Code treats an rm or rmdir target as a critical path when it is any of the following:

  • The filesystem root
  • Top-level directories, meaning any direct child of the root, such as /usr, /etc, or /data
  • Your home directory
  • Windows drive roots and their top-level directories, such as C:\ and C:\Windows
  • Your working directory and its parents
  • Your additional working directories and their parents, but only when the removal is a glob under one of them, such as rm -rf <dir>/*. rm -rf <dir> on the directory itself doesn't trigger this check

Claude Code also treats a glob or trailing slash directly under a shell variable, such as rm -rf "$DIR"/*, as a critical-path removal, because the command becomes a removal from the filesystem root when the variable is empty.

The prompt for this variable case names the flagged rm and says how to rewrite it so the check passes:

  • For a variable such as $DIR, guard each expansion so the shell stops with an error when the variable is unset or empty, as in rm -rf "${DIR:?}"/*, or use a literal path
  • For a variable that is normally set, such as $HOME, use a literal path

A removal whose expansions are all guarded that way passes this check, so in bypassPermissions mode it runs without a prompt unless another check in this section flags it.

Claude Code also treats these targets as critical paths:

  • A shell variable followed by one top-level directory name, such as rm -rf "$TMPDIR/mnt": when the variable expands empty, the command removes /mnt. This covers common top-level names such as mnt, tmp, usr, and Users.
  • A variable that the same command assigns from a directory-printing substitution, such as D=$(pwd); rm -rf "$D" or an assignment from $(git rev-parse --show-toplevel): the value can name your working directory or repository root. A "${D:?}" guard doesn't clear this check, because the variable isn't empty; use a literal path instead.
  • A backslash-only target, such as rm -rf "\\": Git Bash on Windows reads a lone backslash as the current drive's root, so the check applies on every platform.
  • Only the output of a command substitution, such as rm -rf "$(pwd)", when the rm is recursive: Claude Code can't check the target before the command runs, so the prompt tells Claude to run the substitution on its own first and then remove the literal paths it prints. To turn off this one check, set CLAUDE_CODE_DISABLE_SUBSTITUTION_RM_PROMPT=1 in the environment that launches Claude Code.

When a trailing command substitution can expand empty, as in rm -rf ~/$(cmd), Claude Code checks the path that would remain, your home directory in this example.

Hiding the removal inside a subshell with (...), a brace group with { ...; }, command substitution with $(...) or backticks, or process substitution with <(...), doesn't skip the check. Claude Code finds a critical-path removal whether it sits inside the nested form, as in (rm -rf ~) or echo "$(rm -rf ~)", or elsewhere in the same command.

Remove-Item in PowerShell

When you enable the PowerShell tool, Claude Code gives Remove-Item and the cmd built-ins rd, rmdir, del, and erase their own checks, separate from the rm critical-path list. For Remove-Item, the outcome depends on the target, and the first matching case applies:

  • System paths: the filesystem root and its top-level directories, drive roots and their top-level directories, and your home directory. Claude Code denies the command in every mode, without asking you.
  • Wildcards: a bare *, or any target ending in /* or \*, including a glob under a shell variable such as $dir/*. Claude Code denies the command in every mode, without asking you, before the classifier sees it.
  • Your working directory or one of its parents, with -Recurse: Claude Code treats the command like any other that needs approval in your permission mode, so it asks you in modes that ask, sends it to the classifier in auto mode, and denies it in dontAsk mode. bypassPermissions mode skips this check.

The system-paths case also applies to rd, rmdir, del, and erase when Claude runs them through cmd, as in cmd /c rd /s /q C:\Users. By default, Claude Code denies such a command in every mode, without asking you. This cmd check requires Claude Code v2.1.283 or later.

When judging a cmd target, Claude Code treats a PowerShell variable that follows literal text as empty. That makes cmd /c rd /s /q "C:\$name" a removal of C:\, so it is denied too. A trailing wildcard counts as the folder it empties, so cmd /c del /q C:\* is denied and cmd /c del /q dist\* in your project is not.

To turn the cmd check off, set CLAUDE_CODE_DISABLE_POWERSHELL_CMD_RM_DENY=1 in the environment that launches Claude Code. Claude Code ignores this variable in a settings file's env block. Remove-Item on a system path stays denied either way.

See also

  • Permissions: allow, ask, and deny rules; managed policies
  • Configure auto mode: tell the classifier which infrastructure your organization trusts
  • Hooks: custom permission logic via PreToolUse and PermissionRequest hooks
  • Security: safeguards and best practices
  • Sandboxing: filesystem and network isolation for Bash commands
  • Non-interactive mode: run Claude Code with the -p flag