Claude Code sandbox now asks before Bash commands: autoAllowBashIfSandboxed fix

Claude Code Sandbox Now Asks Before Bash Commands (2.1.325): How to Turn Auto-Allow Back On

If Claude Code started asking before every sandboxed Bash command after an update, that’s not a bug. Since version 2.1.325 (13 November 2026), sandboxed commands go through the normal permission flow by default. To get the old behaviour back, add "autoAllowBashIfSandboxed": true to the sandbox block of your settings. I tested both settings, plus the cases where auto-allow still asks, on Claude Code 2.1.326.

Quick fix: put this in .claude/settings.json (one project) or ~/.claude/settings.json (every project):

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

Or run /sandbox, open the Mode tab and pick auto-allow. That saves the choice to .claude/settings.local.json for the current project.

Tested on: Claude Code 2.1.326, macOS 26.7.1 (Apple Silicon), 17 November 2026. Every command below was run for this guide and the outputs are copied from that run. Drafted with AI assistance (Claude) and checked against the official docs linked in the text.

What changed in 2.1.325

The Claude Code changelog entry for 2.1.325 says:

Changed sandboxed Bash commands to follow the normal permission flow by default; set sandbox.autoAllowBashIfSandboxed: true to keep running them without prompts

The settings reference now lists the default as false and adds: “Before v2.1.324, the default was true.” So if you turned the sandbox on months ago, you got auto-approval for free. After the update you get prompts, even though nothing in your own settings changed.

The sandbox itself didn’t get weaker or stronger. As the sandboxing docs put it, both modes enforce “the same filesystem and network restrictions; the difference is only in whether sandboxed commands are auto-approved or require explicit permission.”

Does this affect you?

  • Yes, if you have sandbox.enabled: true (or turned it on with /sandbox) and you’re on 2.1.325 or later. Check with claude --version.
  • Yes, and it can break things, if you run claude -p in scripts or CI with the sandbox on. A print-mode run can’t show a prompt, so commands that used to run are now refused (test 1 below).
  • Probably not, if your permission mode is auto. Its safety check approved my test commands anyway (more on that below).
  • No, if you never turned the sandbox on. It’s off by default.

The test: same command, before and after

I made two empty project folders. Both had the sandbox on; only the second had auto-allow. To see what someone with default settings gets, I ran claude -p with --setting-sources project,local (ignore my own user settings) and --permission-mode default, and asked Claude to run touch inside.txt, a write inside the project folder.

Test 1: sandbox on, auto-allow not set (the new default)

$ cat .claude/settings.json
{ "sandbox": { "enabled": true } }

CALL Bash touch inside.txt
RESULT is_error=true: touch in '$SCRATCH/default/inside.txt' needs approval. The path is inside
the working directories for this session ('$SCRATCH/default'), and Claude Code asks before a
shell command creates, changes or removes files there.
FINAL turns=2 permission_denials=1 Bash: touch inside.txt

$ ls inside.txt
ls: inside.txt: No such file or directory

In an interactive session that’s a permission prompt. In print mode it’s a refusal, and the file is never created.

Test 2: sandbox on, autoAllowBashIfSandboxed: true

$ cat .claude/settings.json
{ "sandbox": { "enabled": true, "autoAllowBashIfSandboxed": true } }

CALL Bash touch inside.txt
RESULT is_error=false: (Bash completed with no output)
FINAL turns=2 permission_denials=0

$ ls inside.txt
inside.txt

Same command, no prompt, file created. That’s the pre-2.1.324 behaviour back.

Auto-allow is not a free pass

Turning auto-allow on doesn’t loosen the sandbox. Two quick checks, both with auto-allow on:

Writing outside the project is still blocked

CALL Bash touch "$HOME/exploreday-sandbox-probe.txt"
RESULT is_error=true: Exit code 1
touch: ~/exploreday-sandbox-probe.txt: Operation not permitted

$ ls ~/exploreday-sandbox-probe.txt
ls: ~/exploreday-sandbox-probe.txt: No such file or directory

The command was auto-approved, then the operating system’s sandbox (Seatbelt on macOS) stopped the write. By default, sandboxed commands can write to the working directory, a per-user temp directory and folders you add with --add-dir; everything else needs sandbox.filesystem.allowWrite (sandboxing docs).

Some commands still ask, by design

CALL Bash FOO=bar touch second.txt
RESULT is_error=true: touch in '$SCRATCH/autoallow/second.txt' needs approval. ...
FINAL turns=2 permission_denials=1 Bash: FOO=bar touch second.txt

A variable set in front of a command “can change which program runs”, so the docs route it through the regular permission flow even in auto-allow mode. The same goes for make CC=clang and eval "ls". The fix is an allow rule that matches the whole command, for example Bash(FOO=bar touch *). Per the auto-allow docs, these also still apply in auto-allow mode:

  • Bash deny rules still block.
  • Content-scoped ask rules such as Bash(git push *) still prompt. A bare Bash ask rule is skipped for sandboxed commands, except in plan mode.
  • rm or rmdir on a critical path still asks.
  • Commands that run outside the sandbox (listed in excludedCommands, or retried unsandboxed) go through the normal flow.
  • Monitor tool commands aren’t auto-approved.

Why some people never notice: auto mode

My first run of test 1 didn’t ask at all. The reason was my own ~/.claude/settings.json, which sets "defaultMode": "auto". In auto mode, Claude Code’s safety check approves commands it judges safe, so touch inside.txt went through without the sandbox’s auto-allow. Only when I excluded user settings did I see the new default.

So if a teammate says “it doesn’t ask me”, compare permission modes before comparing versions.

How to turn auto-allow back on

Where How Applies to
One project, shared with the team Add both keys to .claude/settings.json (above) Everyone who uses that repo
One project, just you /sandbox → Mode → auto-allow (saves to .claude/settings.local.json) You, in that project
Every project Add both keys to ~/.claude/settings.json You, everywhere
A whole organization Set it in the sandbox block of your highest-ranked managed settings source (the changelog says managed settings that turn the sandbox on need this too) Every managed machine
One script or CI run claude -p ... --settings ./ci-settings.json with both keys That run

One catch from the settings reference: setting CLAUDE_CODE_SUBPROCESS_ENV_SCRUB turns auto-allow off, whatever the setting says.

Should you turn it back on?

My take: for local development, yes. The sandbox is the protection, and auto-allow just stops it from asking about commands it’s already containing. The new default makes sense for people who switched the sandbox on in a shared repo without realising it also meant “stop asking me”.

For CI, I’d leave auto-allow off and add explicit allow rules for the commands your job runs, such as Bash(npm test *). That way a changed prompt or a compromised dependency can’t quietly run something new.

Other permission changes in 2.1.323 to 2.1.326

The same week brought a run of stricter Bash checks (changelog). If you see more prompts than before, one of these may be why:

  • 2.1.323: “some commands that could run differently from how they were checked now ask for permission”, and a fix for “a case where a Bash allow rule could run a different program than the one it names”.
  • 2.1.325: some compound commands that “could run without asking” now ask, and wildcard rules such as Bash(ls*) no longer skip the prompt in some cases. A rule that names a variable, such as Bash(NODE_ENV*), now asks.
  • 2.1.326: some cp and mv commands ask first, commands that reach Claude Code’s sign-in files ask, and the sandbox asks before some lines that set environment variables when auto-allow is off (“unattended runs can refuse them”).

What didn’t work / gotchas

A broken settings file with a sandbox key now stops start-up

Since 2.1.325, Claude Code refuses to start when a --settings file isn’t valid JSON and contains a sandbox key. Before, a bad file could mean running unsandboxed without noticing. I fed it a truncated file:

$ cat bad-settings.json
{"sandbox": {"enabled": true,

$ claude -p "hi" --settings bad-settings.json
These settings files did not load, so nothing in them is in effect, including hooks and permission
rules. Each loads again once the problem listed for it is fixed:
  $SCRATCH/bad-settings.json: Invalid or malformed JSON

Error: sandbox required but unavailable: the settings passed with --settings or the SDK's settings
option configure the sandbox but failed validation, so none of them apply (Invalid or malformed JSON).
Fix them and start again
  Refusing to start without a working sandbox (see sandbox.failIfUnavailable).

If your CI suddenly fails at start-up after updating, validate the settings file first, for example with jq . ci-settings.json.

Inline JSON for --settings isn’t the same as a file

My first attempt passed the broken JSON inline (--settings '{"sandbox": ...'). Claude Code treated the invalid text as a file path and said Settings file not found. Use a real file when you test this.

Read-only commands never prompt anyway

I first tested with ls -la, and it ran in both modes. Read-only commands don’t need permission, so they can’t show this change. Test with a write such as touch.

FAQ

Did 2.1.325 make the sandbox less secure?

No. The filesystem and network limits are the same in both modes. The change only decides whether you’re asked before a sandboxed command runs.

Where does /sandbox save my choice?

In .claude/settings.local.json for the current project, which Claude Code adds to your global gitignore. To apply it everywhere, set the keys in ~/.claude/settings.json (sandboxing docs).

Does the sandbox work on Windows?

Not natively. On Windows, Claude Code runs commands unsandboxed. Use WSL2 to get the sandbox. On Linux and WSL2 it needs bubblewrap and socat.

Why does a command with FOO=bar in front still ask?

Because a variable set before a command can change which program runs. Add an allow rule that includes the assignment, such as Bash(FOO=bar npm *).

New to Claude Code’s config files? See CLAUDE.md best practices and how to add an MCP server to Claude Code.

Sources

Similar Posts