[BUG] sandbox auto-allow does not work vor env-prefixed commands
Resolved 💬 6 comments Opened Apr 18, 2026 by nomeata Closed May 28, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
In /sandbox mode, with auto-allow on, normal bash commands are auto-approved, but not those prefixed with an environment variable.
What Should Happen?
They should be allowed as well, as they used to be in a previous version.
Error Messages/Logs
Steps to Reproduce
╭─── Claude Code v2.1.112 ──────────────────────────────────────────────────────────────────────────────────╮
│ │ Tips for getting started │
│ Welcome back Joachim! │ Ask Claude to create a new app or clone a repository │
│ │ ──────────────────────────────────────────────────── │
│ ▐▛███▜▌ │ Recent activity │
│ ▝▜█████▛▘ │ No recent activity │
│ ▘▘ ▝▝ │ │
│ Opus 4.7 (1M context) with xh… · Claude Max · │ │
│ mail@joachim-breitner.de's Organization │ │
│ ~/claude-test │ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
❯ /sandbox
⎿ ✓ Sandbox enabled with auto-allow for bash commands
❯ I believe we have a bug in claude cli: Even with /sandbox in auto-allow, commands that set environment variables are not auto allowed. This used to work in a previous version. Can you
demonstrate that bug by runing a harmless command like cwd in the sandbox, and then try to run `SOME_VAR=true`.
● Bash(pwd)
⎿ /home/joachim/claude-test
● Bash(SOME_VAR=true)
⎿ (No output)
● The first command (pwd) ran auto-allowed in the sandbox. The second (SOME_VAR=true) — if you saw a permission prompt, that demonstrates the bug: a pure env-var assignment triggers approval
instead of being auto-allowed under /sandbox.
❯ I meant `SOME_VAR=true pwd`
● Bash(SOME_VAR=true pwd)
⎿ Running…
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Bash command
SOME_VAR=true pwd
Run pwd with an environment variable set
This command requires approval
Do you want to proceed?
❯ 1. Yes
2. Yes, and don’t ask again for: SOME_VAR=true pwd *
3. No
Esc to cancel · Tab to amend · ctrl+e to explain
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.77
Claude Code Version
2.1.112
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
Other
Additional Information
_No response_
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗