Safeguard
AI Security•

Which Claude Code isolation option fits: sandbox, container, VM, or cloud?

Anthropic documents six isolation approaches for Claude Code. A decision guide for choosing between the Bash sandbox, container, VM, and cloud session.

Safeguard Security Team
6 min read

Anthropic's documentation lists six ways to isolate Claude Code: the sandboxed Bash tool, the sandbox runtime, a dev container, a custom container, a virtual machine, and a cloud session. Pick by threat model. Everyday work suits the Bash sandbox. Unattended runs need a boundary around the whole process. Untrusted repositories call for a VM or a cloud session.

The six options

ApproachWhat is isolatedDocker neededSetup effort
Sandboxed Bash toolShell commands and their child processesNoMinimal on macOS, low on Linux and WSL2
Sandbox runtimeThe whole Claude Code process, including file tools, MCP servers, and hooksNoLow
Dev containerFull development environmentYesMedium
Custom containerFull development environmentYesMedium to high
Virtual machineFull operating systemNoHigh
Cloud sessionFull operating system, hosted by AnthropicNoNone, but needs a subscription

The first two run on the host operating system without containers. The rest place Claude Code inside a container or virtual machine. The sandbox runtime is described as a beta research preview whose configuration format may change.

What the Bash sandbox does not cover

The built-in Bash sandbox restricts shell commands. The documentation states that Claude's file tools, MCP servers, and hooks run outside it. Built-in tools such as Read, Edit, and WebFetch follow permission rules instead. If your concern includes MCP servers or hooks, the Bash sandbox alone is not enough, and the documentation points to running the whole process inside the sandbox runtime, a dev container, or a custom container.

Match your goal to an option

You want toStart with
Reduce permission prompts on your own machineThe sandboxed Bash tool
Work unattended with prompts skippedA container, a VM, or the sandbox runtime
Isolate MCP servers and hooks without DockerThe sandbox runtime
Work on an untrusted repositoryA dedicated VM, or a cloud session
Standardize a team environmentA dev container copied into the repository
Use Claude Code from a device with no local setupA cloud session
Work on native WindowsA container or VM, or WSL2 for the Bash sandbox

Worked example: three developers, three choices

An illustrative scenario.

Priya works on a trusted internal service on a Mac. She turns on the Bash sandbox in auto-allow mode so routine commands stop prompting. Her network allowlist starts empty and she adds the registries she uses. She keeps MCP servers off because the sandbox does not cover them.

Marcus runs agents overnight to chase flaky tests. Because he lets them run with permission prompts skipped, he uses the preconfigured dev container with its default deny firewall. The documentation says that with no prompts to catch mistakes, the isolation boundary protects your system, and that such sessions should run inside a container, VM, or the sandbox runtime.

Elena reviews contributions from outside the company. She does not want any of that code on her laptop, so she uses a cloud session, with a network level set to Custom.

Each chose the boundary that matches how much she trusts the code and how much supervision there is.

Layering is allowed

The documentation says you can layer approaches. Running the sandboxed Bash tool inside a container or VM gives OS level command restrictions on top of the outer boundary. That is a reasonable pattern for unattended work on code you partly trust.

Warnings worth repeating

  • Isolation reduces the impact of a breach but does not eliminate risk. Any approach that allows network egress can still leak data the agent can read, and any approach that mounts the project writable can still modify that code.
  • Isolation does not change what is sent to the model. Prompts and files Claude reads go to the API or your configured provider with or without a sandbox.
  • The unsandboxed retry escape hatch lets a command that fails in the sandbox ask to run outside it. You can disable it with the allowUnsandboxedCommands setting set to false.

Steps to decide for a team

  1. List the tasks: exploration, unattended runs, untrusted code, team standard.
  2. Rate how much supervision each gets.
  3. Choose the minimum boundary that covers the process and the risk, using the table above.
  4. Decide whether to enforce it. Only the built-in Bash sandbox is enforced by Claude Code through managed settings. Containers and VMs are conventions unless you enforce them with device management or software allowlisting.
  5. Test the boundary: ask the agent to read a file outside the project and reach a host outside the allowlist.
  6. Record the choice and review it when tasks change.

Try it yourself

Click through it at your own pace, or open it full screen.

Watch how an assistant is connected to a security tool and what it can ask for, which is the access an isolation boundary has to contain.

Where Safeguard fits

Safeguard does not provide these isolation options. It can connect to Claude and other assistants, and its MCP Guardrail, agent identity, and policies and gates apply to what an agent does. Its CLI is a single static binary that you can run in a pipeline or terminal. It can write code as well as scan.

Quick check

Is the Bash sandbox enough for unattended runs?

The documentation says it is not sufficient on its own for fully unattended runs, since it constrains only shell commands. Put the whole process inside a container, VM, or the sandbox runtime.

Do containers and VMs get enforced by Claude Code?

No. Claude Code does not require a container, so enforcement comes from your device management or software allowlisting. Only the built-in Bash sandbox is enforceable through managed settings.

Does a sandbox stop prompts and files going to the model?

No. Isolation limits local reach, while prompts and files Claude reads are still sent to the API or your provider.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.