Claude Code sandbox: what it blocks and what it doesn't

Claude Code's built-in sandbox is an operating-system boundary around the shell commands Claude runs: writes stay in your project, and network traffic goes only to domains you allow. It is off by default, and Claude's file tools, MCP servers and hooks run outside it.

Contents

The Claude Code sandbox is an operating-system boundary around the shell commands Claude runs. With it on, those commands can write only to your project and a temp folder, and reach only the network domains you allow. It's off by default: turn it on with /sandbox. Claude's own file tools, MCP servers and hooks still run outside it.

Whether the sandbox is enough for you comes down to that last sentence. Everything below is from Anthropic's sandboxing page and its guide to choosing a sandbox environment, read on 24 October 2026.

What the Claude Code sandbox covers#

The sandbox wraps commands from three tools, Bash, PowerShell and Monitor, and every process those commands start. macOS enforces it with Seatbelt. Linux and WSL2 use bubblewrap, with socat carrying traffic to a proxy. Native Windows has no sandbox: Claude Code runs commands unsandboxed there, so use WSL2.

The default boundary, once it's on:

Access Default
Writes The working directory, a per-user temp directory and directories you've added. Protected paths stay write-denied
Reads Most of the machine, including ~/.ssh and ~/.aws/credentials
Network No direct route out. A local proxy checks each host against your allowed domains, a list that starts empty; your permission mode decides what happens to any other host
Environment variables Inherited from Claude Code, secrets included

Out of the box, a command can't write outside your project. A connection to a host you haven't allowed waits for a decision, and your permission mode makes it:

Permission mode A host you haven't allowed
default You get a prompt
dontAsk Refused
auto Refused unless the command named that host and the classifier approved it
bypassPermissions Goes through unless strictAllowlist is on

Reads are the gap. With the default boundary, cat ~/.ssh/id_ed25519 runs inside the sandbox and its output lands in the conversation. denyRead paths close that.

What runs outside it#

Anthropic's page lists five things outside the boundary.

  • Read, Edit, Write, WebFetch and WebSearch, Claude's built-in file and web tools. They follow permission rules, not the sandbox: a denyRead entry doesn't stop the Read tool, and allowedDomains doesn't limit WebFetch.
  • Other processes Claude Code starts. Command hooks, local MCP servers, plugin monitors, LSP servers, your status line command and apiKeyHelper run with your full access.
  • Commands you type after !, in most cases.
  • Anything matching excludedCommands.
  • Unsandboxed retries. When a command fails inside, Claude can ask to run it again with dangerouslyDisableSandbox. Set allowUnsandboxedCommands to false and Claude Code ignores the request.

Turn it on and set the boundary#

Run /sandbox, or put a block like this in .claude/settings.json (the project) or ~/.claude/settings.json (you):

json
{
  "sandbox": {
    "enabled": true,
    "failIfUnavailable": true,
    "filesystem": {
      "denyRead": ["~/.ssh", "~/.aws"]
    },
    "network": {
      "allowedDomains": ["github.com", "*.npmjs.org"]
    },
    "allowUnsandboxedCommands": false
  }
}

Two defaults to know. autoAllowBashIfSandboxed is true, so sandboxed commands run without a prompt; set it to false if you still want to approve each one. And if the sandbox can't start, Claude Code runs commands without it unless failIfUnavailable is true.

Anthropic's page also names three ways out of a sandbox that is on.

  • The proxy doesn't look inside TLS, so an allowed broad domain such as github.com is a way out for data.
  • Access to /var/run/docker.sock is access to the host.
  • Write access to a $PATH folder or to .bashrc or .zshrc lets code run later, outside the sandbox.

Sandbox, sandbox runtime, container or VM?#

Six boxes growing in width: the Bash sandbox around shell commands, the sandbox runtime around all of Claude Code, a dev container, a custom container, a virtual machine and a cloud session. Bash sandboxshell commandsSandbox runtimeall of Claude CodeDev containerthe environmentCustom containerthe environmentVirtual machinean operating systemCloud sessionhosted by Anthropic
Approach What's inside the boundary Docker Fits
Bash sandbox (/sandbox) Shell commands and their child processes No Fewer prompts in everyday work on your own machine
Sandbox runtime (srt claude) All of Claude Code: file tools, MCP servers, hooks No Unattended runs without Docker. A beta research preview
Dev container The whole development environment Yes A team standard; skip-permissions runs behind its firewall
Custom container The whole development environment Yes Existing container setups and CI runners
Virtual machine A whole operating system No Untrusted code; the strongest separation
Cloud session A whole operating system, hosted by Anthropic No No local setup; needs a Claude subscription

Anthropic's rule for --dangerously-skip-permissions is plain: run it in a container, a VM or the sandbox runtime, so file tools, MCP servers and hooks are inside the boundary too. The Bash sandbox alone "is not sufficient for fully unattended runs". You can layer them: the Bash sandbox inside a container adds per-command limits on top of the outer box. Our dev container guide covers that setup, and skipping permissions safely the trade-offs.

No row in that table changes what reaches the model. Your prompts and the files Claude reads go to the API with or without a sandbox, and a project Claude can write to can still be changed. A sandbox limits the damage a command does; it doesn't make a hostile repository safe.

Claude Code's sandbox in Shuriken#

Shuriken doesn't sandbox your chats. An agent works on your computer as you, with your access, like a CLI you run in a terminal; our security page spells out what that means. Claude Code chats in a Shuriken project read the project's .claude/settings.json, so a sandbox block there applies to them as it does in the terminal.

If you'd rather keep agents off your laptop altogether, run them on a machine of your own: add it under Settings › Devices › Add device › A server, and its chats show on every device you use. The same secrets advice applies wherever they run. To try it, download Shuriken.

Sources

  1. Claude Code docs: Configure the sandboxed Bash tool (accessed 24 October 2026)
  2. Claude Code docs: Choose a sandbox environment (accessed 24 October 2026)
  3. anthropics/sandbox-runtime on GitHub (accessed 24 October 2026)

Frequently asked questions

How do I turn on the Claude Code sandbox?

Run /sandbox in a session and choose a mode, or set sandbox.enabled to true in a settings file such as ~/.claude/settings.json or the project's .claude/settings.json.

Does the Claude Code sandbox work on Windows?

Not natively. Anthropic's docs say it runs on macOS, Linux and WSL2, and that on native Windows Claude Code runs commands unsandboxed. Use WSL2, a container or a VM.

Does the sandbox stop Claude from reading my SSH keys?

Not by default: with the sandbox on, shell commands can still read most of the machine, ~/.ssh and ~/.aws/credentials included. List both in sandbox.filesystem.denyRead, and add a Read(~/.ssh/**) permission deny rule too, because the Read tool follows permission rules, not the sandbox.

Is the sandbox enough for --dangerously-skip-permissions?

No. Anthropic says to run skip-permissions sessions inside a container, a VM or the sandbox runtime, so that file tools, MCP servers and hooks are inside the boundary too.

What happens if the sandbox can't start?

By default Claude Code runs the commands without it. Set sandbox.failIfUnavailable to true and Claude Code exits at startup instead.

Free tools