Sign in
Blog

Claude Code Permissions: Modes, Rules and Sandbox Explained

22 min read

Cover: Allow, ask, deny. One glowing cable splits into three, ending at cards labelled allow, ask and deny

TL;DR

  • Three layers, three jobs. A permission mode sets what runs without asking. Allow, ask and deny rules refine it. The sandbox is separate: the operating system limits what a shell command can touch once it runs.
  • Deny beats ask beats allow, in every scope. The first match in that order wins, and a narrow allow cannot carve an exception out of a broad deny. A deny in your user settings beats an allow in a project file.
  • Check your starting mode. Interactive sessions start in auto mode from 2.1.283, where auto mode is available. claude -p starts in Manual from 2.1.302. Auto mode drops broad allow rules when you enter it.
  • One new setting, one changed default. permissions.denyInsteadOfPrompting arrived in 2.1.319 (6 November 2026). Sandboxed Bash now follows the normal permission flow unless sandbox.autoAllowBashIfSandboxed is true. The changelog files that under 2.1.325 (13 November 2026); the settings reference says "before v2.1.324".

How do Claude Code permissions work?

Claude Code permissions are three layers that people often mix up. A mode decides whether Claude asks before acting. Rules pre-approve, force a prompt for, or block specific tools. The sandbox limits what a shell command can reach after it starts. Permission rules are enforced by Claude Code, not by the model: the docs say instructions in your prompt or CLAUDE.md shape what Claude tries, but they don't change what Claude Code allows.

This guide follows the official docs and changelog as we read them on 15 November 2026, when the newest changelog entry was 2.1.325. On our own machine we ran read-only commands on Claude Code 2.1.319: claude --version, claude --help, claude auto-mode defaults, and claude doctor on example settings files in scratch folders. Nothing here reports how the classifier judged a real command.

Hook, rules, mode and sandbox in a row: the first three are decided by Claude Code, the sandbox by the OS
Hook, rules, mode and sandbox in a row: the first three are decided by Claude Code, the sandbox by the OS

One tool call passes a hook, then rules, then the mode. Those three are decided by Claude Code before the call runs. Only the sandbox is enforced by the operating system while it runs.

LayerIt decidesYou set it withEnforced by
ModeWhat happens to a call no rule settledShift+Tab, --permission-mode, permissions.defaultModeClaude Code
RulesWhich tools and patterns run, prompt or are refusedpermissions.allow, ask, deny, /permissionsClaude Code
SandboxWhat a shell command can read, write and reach/sandbox, the sandbox blockThe operating system

What are the six Claude Code permission modes?

A permission mode sets which actions Claude can take in a session without asking you first. Manual is the label you see in the CLI, and default is its config value.

ModeRuns without askingFits
Manual (default)Reads onlyReviewing every action
acceptEditsReads, file edits, and common filesystem commands such as mkdir, touch, mv and cpIterating on code you review in git diff
planReads, plus classifier-approved commands when auto mode is availableExploring before changing anything
autoEverything, with background safety checksLong tasks and prompt fatigue
dontAskFile reads in your working directories and pre-approved tools; anything that would prompt is deniedCI and scripts
bypassPermissionsEverythingIsolated containers and VMs only

claude --help on 2.1.319 lists the choices as acceptEdits, auto, bypassPermissions, manual, dontAsk and plan. The CLI takes manual as an alias; hooks and SDK integrations use the config value default.

Which mode does a session start in?

A new terminal session takes its mode from the first of these that applies: the --permission-mode flag, permissions.defaultMode in a settings file, then the built-in default. The built-in default is the part that changed:

  • Interactive terminal and VS Code sessions: auto with Claude Code 2.1.283 or later. Before that, auto only on some plans.
  • claude -p and Agent SDK runs: Manual (default) with 2.1.302 or later, when no mode is set. A call that needs approval is denied unless an allow rule, hook or callback approves it.
  • Auto mode unavailable (a settings file turns it off, the model isn't supported, or Anthropic switched it off server-side): the session starts in Manual instead.

One trap catches teams. auto and bypassPermissions set as defaultMode in a project's .claude/settings.json or .claude/settings.local.json don't take effect. A repository can't start your session in either. Put auto in ~/.claude/settings.json if you want it as your default.

Shift+Tab cycles default, acceptEdits and plan during a session. auto joins the cycle when it's available, bypassPermissions only after you started with a flag or setting that enables it, and dontAsk never appears: you set it with --permission-mode dontAsk.

Six modes grouped by who answers a call that no rule settled: you, a classifier, nobody who denies, or nobody who allows
Six modes grouped by who answers a call that no rule settled: you, a classifier, nobody who denies, or nobody who allows

Group the modes by who answers. Deny rules block in every mode. An ask rule forces a prompt, except in dontAsk, where the call is denied instead.

How does auto mode decide?

In auto mode, a separate classifier model reviews actions before they run. It blocks anything that goes beyond your request, targets infrastructure it doesn't recognize, or looks driven by hostile content Claude read. Anthropic's engineering team explains why the mode exists: in practice users accept 93% of manual prompts, which leads to approval fatigue, where people stop paying close attention to what they approve.

Each action goes through a fixed order, and the first match wins:

  1. Your allow, ask and deny rules resolve it immediately, with exceptions such as writes to protected paths, which go to the classifier even when an allow rule matches.
  2. Read-only actions and file edits in your working directory are approved, except writes to protected paths and the first read outside the working directories, which prompt you.
  3. Everything else goes to the classifier, apart from critical-path removals.
  4. If the classifier blocks, Claude receives the reason.

The classifier sees your messages, Claude's tool calls other than read-only lookups, and your CLAUDE.md content. Tool results are stripped from its requests, so hostile text in a web page can't talk to it directly. And a line like "never force push" in CLAUDE.md steers the classifier as well as Claude. For a rule that holds whatever the classifier decides, write a deny rule, and back it with the sandbox for anything that must not happen.

What it blocks by default includes curl | bash, force pushes, production deploys, sending sensitive data to external endpoints, and git reset --hard. On our machine, claude auto-mode defaults printed 16 allow entries, 72 soft_deny entries and 1 hard_deny entry on 2.1.319. claude auto-mode defaults --label 'Git Destructive' prints one rule's full wording.

Two things to hold at once. Anthropic reports that the classifier let through 17% of 52 real overeager actions from its own sessions, and it calls that the honest number. The docs add that auto mode reduces permission prompts but does not guarantee safety.

What auto mode drops on entry. Broad allow rules that grant arbitrary code execution are dropped: blanket Bash(*), wildcarded interpreters like Bash(python*), package-manager run commands, and Agent and Monitor allow rules. Narrow rules such as Bash(npm test) stay, and Claude Code restores the dropped ones when you leave auto mode.

When it falls back. If the classifier blocks an action 3 times in a row or 20 times in total, auto mode pauses and Claude Code resumes prompting. For headless runs, two Anthropic pages disagree (we read both on 15 November 2026):

Whichever applies to your version, read permission_denials at the end of a CI run, as the CI setup below shows.

How do allow, ask and deny rules work?

Permission rules use the form Tool or Tool(specifier). /permissions lists every rule and the settings file it comes from.

RuleEffect
BashMatches every Bash command (as a deny rule, it removes the tool from Claude's context)
Bash(npm run build)Matches that exact command
Bash(npm run *)Matches any command starting npm run
Read(./.env)Matches reading .env in the current directory
WebFetch(domain:example.com)Matches fetches to that host
mcp__puppeteer__*Matches every tool from the puppeteer MCP server

In what order are the rules checked?

The permissions page states it outright: rules are evaluated in order: deny, then ask, then allow. The first match in that order determines the outcome, and rule specificity doesn't change the order. A broad Bash(aws *) deny blocks aws s3 ls even when a narrower Bash(aws s3 ls) allow exists.

Three consequences:

  • A matching ask rule prompts even when a more specific allow rule also matches.
  • Scope doesn't change the order: a user-level deny blocks a project-level allow, and a project deny blocks a user allow.
  • A hook can't loosen a rule. Claude Code evaluates deny and ask rules whatever a PreToolUse hook returns, while a hook that exits with code 2 blocks the call before the rules run.

Since 2.1.319, a session's exact Bash or PowerShell ask rule is refused, not asked about, when a broader deny rule covers the command.

Why do guides disagree on precedence?

Because they were written at different times, and the product moved. We compared three pages that rank for this query with the official docs:

PageWhat it saysWhat the docs say today
A settings-hierarchy guideHooks, then deny, then allow, then ask, then the mode. Auto mode is a --enable-auto-mode research preview with criteria "not public"Deny, then ask, then allow. Auto mode is the starting mode in interactive sessions from 2.1.283, and claude auto-mode defaults prints its rules
A "stop asking me" guide"More specific wins: Local > Project > User", with deny winning at any level. Recommends dontAsk, allowing all Bash commands and denying a fewDeny rules from every scope are checked before allow rules. A Bash deny matches only the command as written, so a short deny list leaves other forms open
A permission-patterns articleSandboxing has a "default autoAllowBashIfSandboxed: true"The default is false now; the sandbox section below gives the version

The "more specific wins" line is true for ordinary keys such as model, where a project-local value is applied over the shared file. Permission rules are the exception: lists merge, and deny is checked first across all of them.

What does a Bash rule not match?

A Bash rule matches the command text Claude writes. It doesn't match the same program invoked in a different form, so a deny rule is not a security boundary around a program:

RuleStopsDoesn't stop
Bash(curl *)curl https://example.com/usr/bin/curl https://example.com, sh -c 'curl https://example.com'
Bash(rm *)rm -rf build//bin/rm -rf build/, bash -c 'rm -rf build/'
Bash(git push *)git push origin maingit -C . push origin main

For filesystem and network limits that don't depend on the command text, the docs point to the sandbox. To inspect the full command with logic of your own, they point to a PreToolUse hook. Two more matching details:

  • Put the * after the subcommand. Bash(git log *) allows only git log commands. In Bash(git * main) the * stands in for the subcommand, so it matches every git subcommand and any option before it, including -c, which makes git run a program you name.
  • A compound command needs every part allowed. Bash(safe-cmd *) won't approve safe-cmd && other-cmd.

How do Read and Edit rules match paths?

Read and Edit rules use gitignore pattern syntax with four path anchors:

PatternMeaningExample
//pathAbsolute pathRead(//Users/alice/secrets/**)
~/pathFrom your home directoryRead(~/Documents/*.pdf)
/pathRelative to the settings file's sourceEdit(/src/**/*.ts)
path or ./pathRelative to the current directoryRead(*.env)

/Users/alice/file isn't an absolute path: the single slash anchors at the settings source. In user settings, Read(/secrets/**) blocks ~/.claude/secrets/**, not a secrets folder in your project.

Claude Code checks files against Edit(path) and Read(path) rules only. Write(docs/**) and Grep(docs/**) are accepted but don't match anything. claude doctor catches this: on a settings file we wrote with three deliberate mistakes, it reported that Write(docs/**) is not matched, that Stop Task matches no known tool, and that Bash(command:rm *) will not match. Run it in the folder after every edit to the file.

A Read deny rule covers the built-in file tools and file commands Claude Code recognizes in Bash, such as cat. It doesn't cover grep -r run over a directory, or a script that opens files itself. For operating-system enforcement that blocks all processes from a path, the docs point to the sandbox.

Where do permission rules live, and which one wins?

Claude Code reads settings from four places:

ScopeFileWho it affects
User~/.claude/settings.jsonYou, in every project
Shared project.claude/settings.jsonEveryone who clones the repo
Project local.claude/settings.local.jsonYou, in this project only
Managedmanaged-settings.json or other managed sourcesEveryone your organization deploys it to

For ordinary keys, the highest level that sets a key wins: managed, command line, project local, shared project, user. Lists such as permissions.allow merge instead of overriding. If a tool is denied at any level, no other level can allow it, and a managed deny can't be overridden by --allowedTools. Administrators who want managed settings to be the only source of rules can set allowManagedPermissionRulesOnly.

What "Yes, and don't ask again" does. For a Bash command or a WebFetch domain, Claude Code saves an allow rule to .claude/settings.local.json at the root of the git repository. The rule applies to future sessions anywhere in that repository. A file-edit approval isn't saved: it lasts until the session ends.

Why you can still get prompted. An allow rule in your local file doesn't outrank an ask rule from a project or managed file. And a project's permissions.allow rules grant capability, so Claude Code applies them only after you accept the workspace trust dialog; deny and ask rules apply right away. claude doctor in a scratch folder with a project settings file showed this directly: "Ignoring 3 permissions.allow entries from .claude/settings.json: this workspace has not been trusted."

To see what loaded, run /status for the settings sources, /permissions for the rules, and claude doctor for entries Claude Code rejected.

What does the Claude Code sandbox cover?

The Bash sandbox is a boundary that the operating system enforces around the shell commands Claude runs and the processes they start. It runs on macOS, Linux and WSL2, and it is off by default: turn it on with /sandbox or sandbox.enabled. On native Windows, Claude Code runs commands unsandboxed, so use WSL2.

By default a sandboxed command has this reach:

AccessDefaultChange it with
WritesThe working directory, a per-user temp directory and directories you addedsandbox.filesystem.allowWrite, denyWrite
ReadsMost of the machine, including credential files such as ~/.ssh and ~/.aws/credentialssandbox.filesystem.denyRead, allowRead
NetworkNo direct route. A proxy checks each host against your allowed domains, which start emptysandbox.network.allowedDomains
Environment variablesInherited from Claude Code, secrets includedcredentials, CLAUDE_CODE_SUBPROCESS_ENV_SCRUB

The default sandbox lets commands read your home directory. It stops writes outside the project and blocks the network, but reads are open. Paths and domains from permission rules are merged into the final sandbox configuration, and the sandbox adds your Read deny paths to what sandboxed commands can't read. That's how a Read(~/.ssh/**) deny rule becomes a limit the OS enforces.

What runs outside the sandbox?

The sandbox covers shell commands only. The built-in file and web tools (Read, Edit, Write, WebFetch, WebSearch) follow permission rules instead. Command hooks, local MCP servers and helper commands such as your status line command run with your full access. So does a command you type yourself at the ! prompt in most sessions. A denyRead entry doesn't stop the Read tool, and allowedDomains doesn't limit WebFetch.

This is one reason to read a skill's scripts and hooks before running them; our post on whether Claude skills are safe covers what to check.

What does autoAllowBashIfSandboxed do now?

The sandbox has two modes. In auto-allow mode, sandboxed commands run without a prompt. In regular permissions mode, they go through the normal flow, so your allow rules and permission mode decide. The setting that picks between them is sandbox.autoAllowBashIfSandboxed, and its default changed.

The two official sources put that change in different releases:

Both agree that 2.1.325 and later default to false. On 2.1.324, open /sandbox and check the Mode tab, which calls the false setting regular permissions mode. We run 2.1.319, so we haven't seen the new default ourselves.

To keep the sandbox and the quiet behavior:

json
{
  "sandbox": {
    "enabled": true,
    "autoAllowBashIfSandboxed": true
  }
}

Even in auto-allow mode, a command in a form that a Bash deny rule matches is still blocked, and content-scoped ask rules like Bash(git push *) still prompt. Commands such as FOO=bar npm test go through the regular flow too.

What is the unsandboxed retry?

When a command fails inside the sandbox, Claude may retry it with dangerouslyDisableSandbox. In Manual and acceptEdits mode you get a prompt titled "Bash command (unsandboxed)". In auto mode the classifier evaluates the command. An allow rule that matches the command also approves its retry, so a broad allow rule can let a command leave the sandbox without a prompt.

To close that path, set "allowUnsandboxedCommands": false, which the docs call strict sandbox mode. A false in your user settings, --settings or managed settings holds even when a project file says true.

Limits worth knowing. The OS enforces the boundary on the running process, so it holds regardless of what the model chose to run, and Anthropic reports that sandboxing reduced permission prompts by 84% in its internal usage. The proxy decides from the hostname without inspecting TLS, so allowing broad domains such as github.com can create paths for data exfiltration. To confirm the sandbox is on, ask Claude to run touch ~/sandbox-probe and curl --noproxy '*' https://example.com; both should fail. Typing them at the ! prompt doesn't test it, because those commands usually run outside the sandbox.

What changed recently, and which version do you need?

Most "why is it different?" questions trace back to a version. Dates are from the changelog:

VersionDateChange
2.1.28325 September 2026Auto mode is the built-in starting mode for interactive terminal and VS Code sessions
2.1.30216 October 2026claude -p and SDK runs with no mode set start in Manual
2.1.31430 October 2026permissions.blockWritesOutsideWorkingDirectories added
2.1.3196 November 2026permissions.denyInsteadOfPrompting added; an exact ask rule is refused when a broader deny covers it
2.1.32513 November 2026Sandboxed Bash follows the normal flow by default (the settings reference says "before v2.1.324"); read-only git commands ask first in a repo that isn't the project's or one you trusted; scheduled tasks and /loop ask before running a skill that declares allowed-tools or hooks

Run claude --version before you trust any row. If you're one release behind, the docs may describe something your binary doesn't do yet.

Which setup fits: solo, team repo or unattended CI?

Pick by who answers the prompts, then add the layers around it.

Decision tree from a person at the keyboard to solo, team repo, locked-down job or open-ended job setups
Decision tree from a person at the keyboard to solo, team repo, locked-down job or open-ended job setups

Start from whether a person is watching, then from whether you can list every command.

We ran claude doctor on a copy of each file below in a scratch folder. It reported no rule problems, apart from the notice that a folder must be trusted before project allow rules apply.

Solo developer

Stay in auto mode, which is already your default on 2.1.283 or later. Add the rules that should hold whatever the classifier decides, and turn the sandbox on. This goes in ~/.claude/settings.json:

json
{
  "permissions": {
    "ask": [
      "Bash(git push *)"
    ],
    "deny": [
      "Read(./.env)",
      "Read(~/.ssh/**)",
      "Read(~/.aws/**)"
    ]
  },
  "sandbox": {
    "enabled": true,
    "autoAllowBashIfSandboxed": true
  }
}

There is no Bash(npm run *) allow rule here on purpose: auto mode drops package-manager run commands, so we keep allow rules narrow. The ask rule on git push forces a prompt in auto mode too. The sandbox turns the Read deny paths into OS limits, as the sandbox section explains.

Team repo

Commit this as .claude/settings.json. It's the file we'd hand a new teammate:

json
{
  "permissions": {
    "allow": [
      "Bash(npm test)",
      "Bash(npm run lint)",
      "Bash(git diff *)"
    ],
    "ask": [
      "Bash(git push *)"
    ],
    "deny": [
      "Read(./.env)",
      "Read(./secrets/**)",
      "Edit(./.github/workflows/**)"
    ]
  },
  "sandbox": {
    "enabled": true,
    "allowUnsandboxedCommands": false,
    "network": {
      "allowedDomains": ["registry.npmjs.org"]
    }
  }
}

Deny and ask rules apply in every session. The allow rules wait until each teammate trusts the folder. Bash(npm test) and Bash(git diff *) are narrow rules of the kind auto mode keeps; Bash(npm run lint) is a package-manager run command, which auto mode may drop while it's on. Our first version also denied Read(./.env.*); with the sandbox on, claude doctor warned that on Linux, "glob patterns in Edit/Read rules will be ignored," so we kept the exact path. On Linux a trailing /** works in denyRead, and claude doctor raised no warning on the final file.

Keep the secrets-related denies in the shared file so every teammate gets them. For a wider check of what an agent can reach, see our email privacy check. Don't set defaultMode to auto or bypassPermissions here; Claude Code ignores both in a repository file.

Unattended CI

Nobody can answer a prompt, so decide beforehand what may run. For one job with a known command list, use dontAsk:

bash
claude -p "Run the test suite and summarize any failures" \
  --permission-mode dontAsk \
  --allowedTools "Bash(npm test)" "Read"

For an open-ended job, keep auto mode and add permissions.denyInsteadOfPrompting. The two are different tools. dontAsk is a mode: only reads and pre-approved tools run. The setting works with the permission mode you're in: auto mode's classifier still approves what it allows, and a call that would have waited on a prompt is denied while the turn continues.

A repository can't set it, so it goes in user or managed settings, or in a file you pass with --settings. On the runner, save this as ~/.claude/settings.json:

json
{
  "permissions": {
    "defaultMode": "auto",
    "denyInsteadOfPrompting": true,
    "deny": [
      "Read(./.env)",
      "Bash(git push *)"
    ]
  }
}

For a single run, pass --permission-prompts none with -p instead; it lasts for that run only and needs 2.1.259 or later. Add --output-format stream-json and read permission_denials in the final result, because a run that was denied ten times probably didn't do its job. Our post on a locked-down claude -p on a schedule covers turn and spend caps.

If a job needs more than that, give it a container or VM. bypassPermissions is for isolated environments like containers, VMs or dev containers without internet access, and on Linux and macOS Claude Code refuses to start in it as root or under sudo. The sandbox-environments page adds: run those sessions inside a container, a VM or the sandbox runtime, so file tools, MCP servers and hooks sit inside the boundary too.

Exercise: write your rules from your own approval history

Every time you chose "Yes, and don't ask again" for a Bash command, Claude Code wrote an allow rule to .claude/settings.local.json. That file is a record of what you actually approve, so use it:

  1. In a project you work in often, list the rules:
    bash
     jq -r '.permissions.allow[]' .claude/settings.local.json | sort
  1. Sort each rule into one of three piles.
    • Promote narrow rules you'd share with the team, like Bash(npm test).
    • Downgrade to ask anything that changes shared state, like Bash(git push origin main).
    • Delete or deny anything touching secrets or deletion, like Bash(rm -rf node_modules), or a curl to a host you don't control. A deny rule matches the command as written, so back it with the sandbox's network allowlist.
  2. Write the promoted rules into .claude/settings.json and the downgraded ones as ask rules. Run claude doctor in the folder to catch mistakes.
  3. Start a session and run /permissions to see each rule and the file it came from.

FAQ

How do I stop Claude Code asking for permission?

Pick the least risky option that fits: stay in auto mode, where a classifier answers instead of you; use acceptEdits and review changes in git diff; turn on the sandbox with autoAllowBashIfSandboxed: true; or add narrow allow rules. Reserve bypassPermissions for a container or VM.

Do deny rules work in bypassPermissions mode?

Yes. Deny rules block in every mode, including bypassPermissions. Allow rules have no effect in that mode, and explicit ask rules still prompt.

Why am I still prompted after allowing a command?

Common causes:

  • An ask rule from a project or managed file outranks your local allow rule.
  • A compound command needs every part allowed.
  • Your project's allow rules wait for workspace trust.
  • Auto mode dropped a broad allow rule.
  • Your version has the new sandbox default (2.1.325 or later), where sandboxed Bash goes through the normal permission flow unless you set autoAllowBashIfSandboxed: true.

How do I see what auto mode blocked?

Run /permissions and open the Recently blocked tab. Approving an action there lets Claude retry it, but doesn't add a permission rule. To let a command through from now on, add an allow rule.

Our free field guide walks the whole stack in 24 lessons, from skills and hooks to runners such as claude -p, and lessons 1 to 3 are open to everyone: start lesson 1. To turn rules like these into a setup of your own, build your Claude Code setup.

  • claude code setup
  • agentic coding workflow

Sources

  1. code.claude.com/docs/en/permission-modes
  2. code.claude.com/docs/en/permissions
  3. code.claude.com/docs/en/sandboxing
  4. code.claude.com/docs/en/sandbox-environments
  5. code.claude.com/docs/en/auto-mode-config
  6. code.claude.com/docs/en/settings
  7. code.claude.com/docs/en/settings-reference
  8. code.claude.com/docs/en/settings-example
  9. code.claude.com/docs/en/headless
  10. code.claude.com/docs/en/changelog
  11. www.anthropic.com/engineering/claude-code-auto-mode
  12. www.anthropic.com/engineering/claude-code-sandboxing
  13. smartscope.blog/en/generative-ai/claude/claude-code-permission-overview
  14. rajiv.com/blog/2026/03/31/stop-asking-me-configuring-claude-code-permissions-for-uninterrupted-flow
  15. dev.to/klement_gunndu/lock-down-claude-code-with-5-permission-patterns-4gcn

Keep reading