DocsWhat may it doClaude Code sandbox

Claude Code sandbox: what it isolates, and what it leaves to rules

The Claude Code sandbox is an operating system boundary around the commands Claude Code runs, which limits the files they can write and the hosts they can reach. It is switched on with /sandbox, and it lets Claude Code run more commands without asking because the damage any one of them can do is smaller.

A sandbox answers where a command can reach. It does not answer whether a particular action should happen, such as a push to main from inside the repository it is allowed to write. This page covers both, and how they fit.

How the Claude Code sandbox works

According to Claude Code's sandboxing docs:

What it does
What it wrapsBash, PowerShell and Monitor commands, and every process they start
macOSthe built-in Seatbelt framework
Linux and WSL2bubblewrap for files, and socat to route network traffic
Writesthe working directory, added directories and a temporary directory, and nowhere else
Readsmost of the machine, apart from the paths you deny
Networkno host is allowed at first, and Claude Code asks the first time a command needs one

The settings live under sandbox in settings.json: sandbox.enabled, sandbox.filesystem.allowWrite and denyRead, sandbox.network.allowedDomains, and sandbox.credentials for the credential files and variables to protect.

One setting is worth knowing before you rely on it. A command that fails inside the sandbox can be retried outside it, through the dangerouslyDisableSandbox parameter. Set sandbox.allowUnsandboxedCommands to false to keep every command inside.

Three ways to put an agent in a box

Claude Code /sandboxDev containermemnox run --untrusted
Works forClaude Codeany agent inside itany agent you start through it
Held bySeatbelt or bubblewrapthe container runtimeSeatbelt on macOS, Landlock on Linux
Your credentialsprotected where sandbox.credentials or a deny names themabsent unless mountedunreadable
Networkasks per new hostwhatever the container allowsonly through the session's egress proxy, which asks for unknown hosts
An outward or destructive action inside the boxleft to Claude Code's permissionsleft to the agent's permissionsasks first

A container is the strongest wall and the most setup, and it leaves you working in a second environment. The Claude Code sandbox is the lightest and covers one agent. memnox run --untrusted is meant for a freshly cloned repository that nobody has vouched for:

bash
memnox run --untrusted -- claude

Writes stay in the repository, credentials and dotfiles in your home directory are unreadable, the network goes through the session's own egress proxy, and every outward or destructive action asks. On macOS Seatbelt holds all of it. On Linux Landlock holds the files, and TCP from Linux 6.7, and the start screen says plainly what the kernel cannot hold. Untrusted repositories and new agents has the full detail.

What a sandbox cannot decide

A sandbox limits reach. Inside that reach, every command is equal. These are all inside a typical sandbox for a repository:

  • git push --force origin main
  • rm -rf src/
  • a migration run against the database whose credentials are in .env
  • a deploy through a CLI that is already logged in

Deciding those is a rule's job, not a wall's. Memnox answers every tool call with allow, ask or deny before it runs, in Claude Code, Codex, Cursor, Gemini CLI and Windsurf, and a deny names what to do instead:

verdict     DENY
reason      you chose to deny this: it rewrites history somebody else may already have pulled
instead     push a branch and open a PR

Use both. The sandbox makes a mistake smaller, and the rules stop the mistakes you can name before they happen. If one gets through anyway, memnox rewind puts the working tree back to before the agent touched it.

Questions people ask

How do I turn on the Claude Code sandbox?

Run /sandbox inside Claude Code and choose the mode, or set sandbox.enabled in settings.json. On Linux and WSL2 it needs bubblewrap and socat installed.

Does the Claude Code sandbox protect my SSH keys?

Only the ones it is told about. Reads are open across most of the machine, so name the paths in sandbox.credentials or sandbox.filesystem.denyRead, or run the agent with memnox run --untrusted, where credentials are unreadable.

Is a sandbox enough to run an agent unattended?

It limits how far a mistake reaches, not which mistakes happen inside that reach. Pair it with rules that deny the actions you never want, and a way to undo what an agent changed.

Can I sandbox Cursor or Codex the same way?

Codex has its own sandbox modes. For any agent, memnox run --untrusted starts it inside the same kernel wall, and a dev container works for all of them.