CONCEPT Two very different ways to cut prompts
Both reduce permission prompts, but they are opposites in safety. The exam turns on telling them apart:
Sandbox (/sandbox) | --dangerously-skip-permissions | |
|---|---|---|
| What it controls | What a Bash command can access once it runs | Whether each tool call runs at all |
| Enforced by | The operating system (Seatbelt / bubblewrap) | Nothing — checks are skipped |
| Replaces the prompt with | The sandbox boundary itself (auto-allow mode) | Nothing at all |
| Prompt-injection protection | Yes — OS boundary holds even if the model is fooled | None |
The sandboxed Bash tool lets Claude run most shell commands without asking, because you
instead define which files and network domains commands may touch and the OS enforces that boundary for every
Bash command and its child processes. Enable it with /sandbox; it runs on macOS (Seatbelt), Linux,
and WSL2 (bubblewrap + socat). Native Windows is not supported.
- Filesystem isolation: default write access is the working directory + session temp
dir; default read is the whole machine minus denied paths. Widen/narrow with
sandbox.filesystem.allowWrite,denyWrite,denyRead,allowRead. - Network isolation: no domains pre-allowed; the first hit on a new domain prompts.
Pre-allow with
allowedDomains, block withdeniedDomains. - Auto-allow mode runs sandboxed commands without prompting — but explicit deny rules,
content-scoped ask rules like
Bash(git push *), andrm -rf /-style removals still prompt.
CONCEPT When bypassing prompts is acceptable — and when it's reckless
--dangerously-skip-permissions (equivalently --permission-mode bypassPermissions)
skips prompts and safety checks. It offers no protection against prompt injection or unintended
actions.
auto mode instead
— it keeps a background classifier reviewing actions.bypassPermissions, explicit ask rules still force a prompt, and
removals targeting the filesystem root or home (rm -rf /, rm -rf ~) still prompt as a
circuit breaker against model error.DIAGRAM Layers of defense in depth
deny / ask rules?"} P -->|"deny"| STOP["🔴 Blocked before it runs"] P -->|"ask"| PR["🟠 Prompt (even if sandboxed)"] P -->|"allowed / auto-allow"| S{"Sandbox enabled?"} S -->|"yes"| OS["🟢 Runs, but OS confines FS + network
holds even under prompt injection"] S -->|"no + bypassPermissions"| RAW["🔴 Runs with full host access
no injection protection"] classDef ok fill:#d4edda,stroke:#28a745,color:#155724; classDef gate fill:#ffe8cc,stroke:#ff9f40,color:#9a4a0a; classDef bad fill:#f8d7da,stroke:#dc3545,color:#721c24; class OS ok; class PR gate; class STOP bad; class RAW bad;
CODE Enabling and shaping the sandbox
# Turn the sandbox on for the current project (panel: Mode / Overrides / Config) /sandbox # Enable across all your projects + grant a couple of write paths, in settings.json { "sandbox": { "enabled": true, "filesystem": { "allowWrite": ["~/.kube", "/tmp/build"], "denyRead": ["~/.ssh", "~/.aws"] }, "network": { "allowedDomains": ["registry.npmjs.org", "*.github.com"] } } } # Container / CI only: skip prompts entirely (no injection protection) claude --dangerously-skip-permissions
kubectl, terraform, npm), not just Claude's own file
tools. Sandbox filesystem paths use standard prefixes (/abs, ~/home),
which differ from Read/Edit rules' //abs convention.TRADE-OFFS Sandbox auto-allow vs. skip-permissions
✅ Sandbox (auto-allow)
- Fewer prompts and a real OS-enforced boundary
- Survives prompt injection — a fooled model still can't leave the box
- Deny/ask rules and
rm -rf /circuit breakers still apply
🚫 --dangerously-skip-permissions
- Zero prompts, zero safety checks, no injection protection
- Broad
allowedDomains(e.g.github.com) can still enable exfiltration paths - Only safe in throwaway containers/VMs, ideally offline
EXAM TRAPS
/sandbox is a permission mode." → It isn't. Permission modes decide
whether a call runs and whether you're prompted; the sandbox restricts what a Bash command can
access once it runs. They compose.--dangerously-skip-permissions is fine as long as I'm careful." →
It offers no protection against prompt injection or unintended actions. Reserve it for isolated
containers/VMs; on a real machine, prefer auto mode or the sandbox.~/.ssh and ~/.aws/credentials. You must add them to
denyRead (or use sandbox.credentials) to block them.github.com in the sandbox is safe." → Broad domains can
create data-exfiltration paths; the proxy decides from the client-supplied hostname without inspecting TLS, so
techniques like domain fronting can slip out. Allow only trusted domains.PRACTICE
Q1 · Why does the sandbox protect against prompt injection while --dangerously-skip-permissions does not?
The sandbox boundary is enforced by the operating system on the running process, so it holds regardless of what the (possibly manipulated) model chose to run. Skip-permissions removes checks entirely, so a fooled model's command executes with full host access.
Q2 · A test suite needs to reach registry.npmjs.org under the sandbox but keeps prompting. Fix?
Pre-allow the domain: add registry.npmjs.org to
sandbox.network.allowedDomains. Otherwise the first request to each new domain prompts for
approval.
Q3 · When is --dangerously-skip-permissions the right call?
In an isolated, disposable environment — a container, VM, or dev container, ideally without internet — such as CI or an ephemeral agent, where Claude Code can't damage your host or leak data. Never on a workstation with real credentials and network access.