Claude Code sandbox: how to enable and configure it
Turn on Claude Code’s native sandbox with /sandbox, set filesystem and network rules, and learn what it covers on a Mac and what it leaves outside.
Claude Code’s native sandbox is off by default. Run /sandbox in a session, or set sandbox.enabled to true in a settings file such as ~/.claude/settings.json. On macOS it uses the built-in Seatbelt framework. It limits shell commands and the processes they start. It does not limit Claude Code’s built-in file and web tools.
What it covers and what it doesn’t
The docs say the limits apply to Bash, PowerShell and Monitor commands and the processes they start. These run outside the sandbox: built-in file and web tools, hooks, MCP servers, LSP servers, status line commands and mods. Commands you type at the ! shell-mode prompt usually run unsandboxed too. Because file tools sit outside, your permission rules still matter. Claude Code permissions
The sandbox runs on macOS, Linux and WSL2. By default, if the platform doesn’t support it or a dependency check fails at startup, Claude Code runs commands without sandboxing. Set sandbox.failIfUnavailable to true to make it exit instead.
Defaults
| Access | Default |
|---|---|
| Writes | The working directory, a per-user temp directory and directories you’ve added. Protected paths such as .claude settings and .bashrc stay write-denied. |
| Reads | Most of the machine, including credential files such as ~/.ssh and ~/.aws/credentials. |
| Network | No direct route out. Connections go through a proxy that checks each host against your allowed domains, which start empty. |
| Environment | Inherited from Claude Code, including any secrets in its environment. |
That read default matters. A sandboxed command can still read your SSH keys unless you add denyRead or credentials entries.
Configuration
{
"sandbox": {
"enabled": true,
"filesystem": {
"allowWrite": ["~/.kube", "/tmp/build"],
"denyRead": ["~/"],
"allowRead": ["."]
},
"network": {
"allowedDomains": ["github.com", "*.npmjs.org"]
},
"excludedCommands": ["docker compose *"],
"failIfUnavailable": true,
"allowUnsandboxedCommands": false
}
}Sandbox paths are standard, so /tmp/build is absolute and ~/.kube is relative to your home directory. This differs from Read and Edit permission rules, which use //path for absolute paths. credentials can declare files and environment variables to protect with "mode": "deny" or "mode": "mask".
Two modes
In auto-allow mode, Claude Code approves a sandboxed command without a prompt. In regular permissions mode, all Bash commands go through the usual permission flow even when sandboxed. The permissions doc names the key for auto-allow as sandbox.autoAllowBashIfSandboxed. Content-scoped ask rules such as Bash(git push *) still prompt.
The escape hatch
When a command fails in the sandbox, Claude may retry it with the dangerouslyDisableSandbox parameter, and the retry is approved according to your permission mode. Set "allowUnsandboxedCommands": false to ignore that parameter. The /sandbox Overrides tab calls this strict sandbox mode. Entries in excludedCommands run outside the sandbox. The docs warn that an excluded command “runs with your full access.”
Limits to know
The docs say sandboxing “reduces risk but is not a complete isolation boundary.”
- The proxy decides from the hostname and does not inspect TLS by default. Allowing a broad domain such as
github.comcan create paths for data exfiltration, and the docs mention domain fronting. allowUnixSocketscan grant access to system services. The docs give/var/run/docker.sockas an example.- On macOS, Apple Events are blocked by default.
allowAppleEventsremoves code-execution isolation and is honored only from user, managed or CLI settings. - Broad
allowWritepaths, such as directories on$PATHor.zshrc, can undo the protection. - Tools that ignore proxy variables, such as plain
ssh, can’t connect even to allowed hosts. The docs listdockeras incompatible.
If sandbox.enabled and similar keys are set in managed settings or by --settings, /sandbox reports that higher-priority settings override your choice. Run /status to see which sources loaded.
Checked against the vendor documentation on November 25, 2026. Sandboxing · Permissions · Settings
Where Excellent fits
Excellent Pro can configure both Claude Code’s and Codex’s native Mac sandboxes from your file and folder rules, with a plan to review first. Sandbox setup
Pro also adds checks before supported actions. Claude Code can display an ask prompt. Pro is US-only for now. Pricing · Agent coverage
Excellent’s free scan reads supported logs on the Mac and reports findings for review. Run the free scan · See a sample report. For Codex’s equivalent, see Codex sandbox.


