claude-code - 💡(How to fix) Fix [BUG] `autoAllowBashIfSandboxed` prompts for commands containing `key=value` arguments

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Error Messages/Logs

Fix Action

Fix / Workaround

The point of autoAllowBashIfSandboxed is to allow the agent to work independently, and this prevents that from working. The model has no idea why these prompts are happening (resulting in frustrating hallucinated explanations and non-functional workarounds), and it took several rounds of insistent iteration, including having a model reverse-engineer Claude Code's source, to find out what was causing it.

Workaround: Wrap commands in a shell script.

Code Example

This command requires approval

---

{
  "sandbox": {
    "enabled": true,
    "autoAllowBashIfSandboxed": true
  }
}
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

With sandbox.enabled: true and autoAllowBashIfSandboxed: true, Bash commands containing either...

  • variable assignments, or
  • arguments that look like Bash variable assignments (identifier=value where identifier matches [a-zA-Z_][a-zA-Z0-9_]*)

...trigger a permission prompt instead of being auto-allowed.

What Should Happen?

At the very least, this very common shell construct should work without prompting when autoAllowBashIfSandboxed is true.

The point of autoAllowBashIfSandboxed is to allow the agent to work independently, and this prevents that from working. The model has no idea why these prompts are happening (resulting in frustrating hallucinated explanations and non-functional workarounds), and it took several rounds of insistent iteration, including having a model reverse-engineer Claude Code's source, to find out what was causing it.

This is not an edge case:

That said, the sandbox is a safety boundary. There should be a way, even if it's not the default, to allow commands that the static analyzer can't fully understand to be auto-allowed to run inside the sandbox, rather than falling back to a permission prompt. Currently, achieving this would require using the bypassPermissions permission mode, which removes an additional layer of safety beyond what this would permit, as it "skips the permission layer entirely". Additionally, this would not grant the model any access it does not already have, as it can already work around these denials by putting the command into a shell script.

Error Messages/Logs

This command requires approval

Steps to Reproduce

With sandbox enabled and autoAllowBashIfSandboxed true, any Bash command with any variable assignment or any argument matching [a-zA-Z_][a-zA-Z0-9_]*=.* triggers a prompt, regardless of position in the command. Characters that invalidate a bash identifier before the = (digits at start, /, -) suppress the prompt.

{
  "sandbox": {
    "enabled": true,
    "autoAllowBashIfSandboxed": true
  }
}
CommandPrompts?
a=b (standalone assignment)No
FOO=bar swift --versionYes
FOO=bar wc -l fileYes (even though wc is an allowlisted read-only command)
FOO=bar bash script.shYes
python3 helloNo
python3 a=bYes
python3 A=bYes
python3 -c 'pass' a=bYes
python3 1=bNo
python3 a-b=cNo
xcodebuild -versionNo
xcodebuild -destination 'platform=iOS Simulator,...'Yes
xcodebuild -destination 'platform=iOS' -listYes
xcodebuild -destination 'foo=bar' -listYes
xcodebuild -destination 'generic/platform=iOS' -listNo
xcodebuild -destination 'generic/foo=bar' -listNo
xcodebuild -destination 'platform' -listNo
bash script.sh (script contains a command that triggers a prompt)No

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

No response

Claude Code Version

2.1.139 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other (happens in CLI/zsh/iTerm2 and desktop app)

Additional Information

Workaround: Wrap commands in a shell script.

Related, but not duplicates:

  • #43713 (focuses on shell expansions, does not seem to mention variable assignment)
  • #51001 (just marked fixed, but this bug report was tested in the version with that fix)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] `autoAllowBashIfSandboxed` prompts for commands containing `key=value` arguments