The Claude Code sandbox is an OS-enforced boundary around the shell commands Claude runs on your machine. It limits which files and network hosts those commands can reach, so you can let Claude work with fewer permission prompts — or unattended — without handing it the whole host.
The short answer: run /sandbox (or set sandbox.enabled: true in settings) to wrap Bash, PowerShell, and Monitor commands and their child processes. The sandbox covers shell commands only — Claude's file tools, MCP servers, and hooks still run on the host under permission rules. For whole-process isolation, use the sandbox runtime, a container, or a VM.
What the sandbox covers — and what it does not
The sandboxed Bash tool is built into Claude Code and restricts shell commands (sandbox docs). The boundary applies to Bash, PowerShell, and Monitor commands and the processes they spawn.
These run outside the sandbox and follow permission rules instead:
- Built-in file and web tools: Read, Edit, Write, WebFetch, WebSearch.
- MCP servers.
- Hooks.
That split is the most important fact about the feature. A sandboxed rm is confined; a Write tool edit is not. denyRead does not block the Read tool, and allowedDomains does not limit WebFetch — those are governed by permissions, not the sandbox.
Enable it
The sandbox is off by default. Turn it on in a session with /sandbox, or persist it in settings:
{
"sandbox": { "enabled": true }
}Set it in .claude/settings.local.json for one project, or ~/.claude/settings.json for all projects. The /sandbox panel has a Mode tab (how commands are approved), a Config tab (the resolved boundary), and on Linux a Dependencies tab if something is missing.
Platform support: macOS uses the built-in Seatbelt framework; Linux and WSL2 need bubblewrap and socat. Native Windows runs commands unsandboxed — use WSL2 to get the sandbox on Windows.
Choose a mode
- Auto-allow: sandboxed commands run without prompting. With
autoAllowBashIfSandboxedat its default of true, the sandbox boundary substitutes for the whole-tool Bash prompt. - Normal permissions: commands still go through the usual permission prompts even though they are sandboxed.
In plan mode, Claude Code skips the auto-allow substitution, so commands still gate through the regular permission flow while you plan.
Set the boundary
By default a sandboxed command can write the working directory, the per-user temp directory, and any directory added with --add-dir / /add-dir or permissions.additionalDirectories. Network egress has no direct path: connections go through a local proxy that matches each host against your allowed domains (initially empty), and Claude Code prompts when a command first needs a new domain.
Two settings harden the boundary:
sandbox.failIfUnavailable: true— exit at startup if the sandbox cannot run, instead of silently falling back to unsandboxed commands. Use this when the sandbox is a required security gate.allowUnsandboxedCommands: false— stop Claude from retrying a blocked command outside the sandbox.
claude --settings '{"sandbox": {"enabled": true, "allowUnsandboxedCommands": false}}'Pick the right isolation level
The sandboxed Bash tool is the lightest option. Stronger boundaries wrap more of the process (sandbox environments):
| Option | What is isolated | Cost |
|---|---|---|
| Sandboxed Bash tool | Shell commands + child processes only | Built in; file tools, MCP, hooks stay on host |
| Sandbox runtime | The whole Claude Code process | More setup; everything inside the boundary |
| Dev container / Docker | Process + filesystem + network | Container tooling required |
| Virtual machine | A separate machine | Heaviest; strongest separation |
Match the option to your threat model. The more you let Claude run unattended, the further up the ladder you should go.
Sandbox and permissions are complementary
Permissions decide which tools Claude may use and which files or domains they may touch. Sandboxing adds OS-level enforcement on shell commands. Use both for defense-in-depth: sandbox restrictions still apply even if a prompt injection bypasses Claude's decision-making. Paths and domains from sandbox settings and permission rules merge into the final configuration.
One caution from the docs: sandboxing reduces the impact of a breach, it does not eliminate risk. Any approach that allows network egress can still leak data the agent can read, and any approach that mounts your project writable can still modify that code.



