How to sandbox Claude Code, Codex and other agent harnesses
To sandbox an agent harness, put a boundary between what it runs and what you can't afford to lose: your files, your credentials and your network. There are five ways to do it, from weakest to strongest: the harness's permission prompts, its built-in sandbox, a container, a microVM on your computer, and a machine in the cloud. The stronger the boundary, the more freely the agent can work without asking you.
Why does an agent harness need a sandbox?
A harness such as Claude Code or Codex runs shell commands as you. It also reads things nobody has checked: web pages, issue comments, a dependency's README. Any of them can carry instructions meant for the agent, and then the agent has your SSH keys, your .env files and your logged-in tools to act with. Simon Willison explained why in June 2025: LLMs are "unable to reliably distinguish the importance of instructions based on where they came from". OWASP lists prompt injection first in its 2025 Top 10 for LLM applications, as LLM01.
Permission prompts are the default defence, and they wear out. After the fiftieth "allow?", it's tempting to turn them off. A sandbox lets you turn them off on purpose. Anthropic reported in October 2025 that sandboxing cut Claude Code's permission prompts by 84% in its own use.
What are the options?
| Option | What isolates it | What it still shares with you | Fits |
|---|---|---|---|
| Permission prompts | You, approving each command | Everything, once you say yes | Short sessions you watch |
| The harness's built-in sandbox | Operating-system rules around each command | The kernel, and every file it's allowed to read | Daily work on your own computer |
| A dev container | Docker's namespaces, often with a firewall script | The host's kernel, and whatever you mount | A repeatable setup for one project |
| A microVM on your computer | A virtual machine with its own kernel | Your computer's power, and its uptime | Unattended runs you want to keep local |
| A machine in the cloud | A virtual machine in a data centre | Nothing, unless you send it | Long, parallel or untrusted work |
What do the built-in sandboxes cover?
- Claude Code has
/sandbox, which is off by default. Commands can write only to the working directory and reach the network only through a proxy with a list of allowed domains. It uses Seatbelt on macOS and bubblewrap on Linux. Anthropic's sandboxing docs say it reduces risk and isn't a complete isolation boundary: reads still cover most of the machine, and MCP servers and hooks run outside it. - Codex sandboxes by default. Its modes are
read-only,workspace-writeanddanger-full-access, andworkspace-writekeeps network access off unless you turn it on. It uses Seatbelt on macOS and bubblewrap with seccomp on Linux, per OpenAI's sandboxing docs. - Gemini CLI has
--sandbox, which you turn on. It uses Seatbelt on macOS or a Docker or Podman container, per its sandbox docs. - OpenCode has permission rules and no operating-system sandbox. Its permissions docs say a shell command runs with the host user's file, process and network access.
These are worth turning on. They stop the common accidents, and they share one limit: the agent is still on your computer, under your user.
When is a container or a local microVM enough?
A dev container gives a project its own filesystem and, with Anthropic's reference setup, a firewall. It shares the host's kernel, and the dev container docs are plain about the rest: with permission prompts off, it doesn't stop a malicious project from sending out anything the container can read, so don't mount secrets such as ~/.ssh.
Docker Sandboxes go a step further and run the harness in a microVM on your computer, through Docker's sbx command, for Claude Code, Codex, OpenCode and others. Local compute is free. If you want the work to stay on your own hardware, it's the strongest of the local options. It uses your computer's memory and battery, and it stops when your computer sleeps. Docker also runs these sandboxes on its own cloud.
When should the sandbox be a cloud machine?
- The agent should work for hours with prompts off, and you don't want that on the computer that holds your keys.
- You want to close the laptop. A cloud machine keeps going.
- You want several at once. Each attempt gets its own machine.
- You don't trust the code at all. Nothing of yours is there to take.
How do I do it on Quivvo?
Each machine is a Firecracker microVM with its own kernel, and the harnesses are installed. Firecracker emulates only 5 devices, so there is little of the host for a guest to attack. Send the code, hand over the task, read the diff:
command -v quivvo >/dev/null || npm i -g quivvo@latest
quivvo create --name box
quivvo push ./api box --include .git
RUN=$(quivvo agent prompt box --env CLAUDE_CODE_OAUTH_TOKEN --cwd api -- "upgrade the dependencies and fix what breaks")
quivvo agent wait box "$RUN" --timeout 100
quivvo agent result box "$RUN" --diff | git -C api apply
quivvo rm box --yes
push sends what git tracks and leaves out what usually holds a credential: .env files, .ssh, .aws, key files and the logins in .claude and .codex. --include .git sends the history, which a run needs to show you a diff, and the git apply line brings that diff back to your own copy. The run has permission prompts off, as root, on a machine with nothing else on it. For Codex, add --provider codex and pass CODEX_API_KEY. The other harnesses run through quivvo exec or a shell: see handing over a task.
What does a sandbox not protect?
- What you put inside it. A key you pass with
--envcan be read by everything the agent runs. Use a key scoped to the job, and for Claude Code a spending limit with--budget. - The way out. A Quivvo machine has open outbound internet, so the boundary is what's on the machine, not where it can connect. If you need an allowlist of domains, Claude Code's sandbox and its reference dev container have one.
- What comes back. Read the diff before you merge it. A directory copied back can carry a
.git/config, an.envrcor editor tasks that run commands on your computer, so look before you work in it.
What does each option cost?
| Option | Price |
|---|---|
| Permission prompts, the built-in sandbox, a dev container | Nothing |
| A microVM on your computer | Nothing for local compute, plus your computer's memory and battery |
| A machine in the cloud | By the hour: $0.017 to $0.166 for 2 vCPUs and 4 GiB across seven providers |
A Quivvo machine of that size is $0.054 an hour while it runs and only its disk while it sleeps. Used two hours on each working day, that comes to about $5 a month. The range comes from our pricing comparison, read on 30 October 2026.
What should I use day to day?
Turn on your harness's built-in sandbox for the work you watch. Move the work you don't watch, and anything you don't trust, to a machine that isn't yours to lose. For what the kinds of isolation are, see what an AI agent sandbox is.
Give your agent a computer
npx quivvo@latest sh