sandbox-cli

module
v0.0.0-...-a271580 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2026 License: MIT

README

sandbox-cli

Run AI coding agents (Claude Code, Codex, Gemini, OpenCode, Cline, Goose, Crush, Aider, Copilot CLI, Cursor, Qwen, Amp, Continue, OpenHands, Droid) — or any command — inside a disposable, isolated Docker container. Only the project you choose is mounted at /workspace; HOME is a fake, ephemeral directory. A mistaken rm -rf ~ or a prompt-injected command can't touch the rest of your machine.

        Host                                Sandbox (container, --rm)
  ~/projects/myapp  ── bind ──►  /workspace   (the only host-connected path)
  ~/.ssh ~/.aws ~/  ── NOT mounted            HOME=/sandbox/home  (ephemeral)

  (the agent wrappers additionally mount a sandbox-owned agent home and,
   for claude, your history for this one project — both opt-out)

Developers want to run agents with full autonomy (--dangerously-skip-permissions / "Allow All") but don't want the agent to have unrestricted access to their host filesystem and credentials. sandbox-cli gives the agent the convenience of "Allow All" while limiting the blast radius to the project it's already meant to edit.

Install

curl -fsSL https://raw.githubusercontent.com/Amitgb14/sandbox-cli/main/install.sh | sh

Needs Docker (Docker Desktop on macOS/Windows, Docker Engine on Linux; Podman also works). The installer verifies the release against its checksums, installs to ~/.local/bin, and writes a commented ~/.config/sandbox/config.yaml if you don't have one. Other routes — go install, a pinned version, Windows, uninstall — are in Install.

Quick start

cd ~/your-project

sandbox-cli claude                       # an agent, in a container (logs in the first time)
sandbox-cli run -- npm test              # or any command at all
sandbox-cli run --dry-run -- npm test    # see the exact docker argv first

sandbox-cli claude --worktree feature-a -- -p "implement A"   # its own branch, its own container
sandbox-cli list                         # what is running right now
sandbox-cli doctor                       # is my setup ready?

Everything after a leading run of sandbox flags is forwarded to the agent verbatim, so sandbox-cli claude --dangerously-skip-permissions just works — the exact rule is in Running commands and agents.

What you get

  • A boundary you can read. Only /workspace is host-connected; /, your home directory and any ancestor of it are refused as a workspace by rules no flag overrides. Host environment variables are default-deny.
  • Egress allowlist, on by default. Outbound traffic is default-denied by an in-container firewall that permits DNS, a baseline of agent APIs and package registries, and whatever you add with --allow — so npm install works and arbitrary exfiltration doesn't. It fails closed.
  • Logins that survive --rm. Each agent gets its own sandbox-owned home, kept separate from your real ~/.claude. Claude's history for the current project is shared both ways, so --resume works on either side.
  • Parallel agents on real git worktrees. One branch each, one container each, your checkout untouched — a single agent with --worktree, or a whole fleet.yaml whose work is checked by a verify: command before it can land.
  • Sessions you can supervise. A container outlives the process that started it, so list, logs, attach and kill address one by id, name or branch — and never reach a container sandbox-cli didn't start.
  • A crash safety net. The workspace is snapshotted into your own repo under refs/sandbox/ while a run is in flight; sandbox-cli recover puts it back on a branch without touching your index, HEAD or working tree.
  • Two profiles, neither of them lax. dev warns when the host can't deliver a control; prod refuses, and doesn't mount the persisted credential at all.

Studio, in the browser

The same runs, with a control plane you can look at: launch, watch the terminal, read the diff, land the branch. From the repository you want to work in:

curl -fsSL https://raw.githubusercontent.com/Amitgb14/sandbox-cli/main/studio.sh | sh

That installs sandbox-cli and sandbox-studio-api from one release archive, pulls the UI image, and starts both halves on loopback — the UI in a container, the API as an ordinary host process. The split is the point rather than an accident: the API launches containers, so in a container it would need the host's docker socket, and a process holding that socket can start a container mounting /. --api-in-docker takes that path for anyone who wants it, and says what it costs first.

Studio owns no isolation policy of its own. A run it starts builds the same options a --worktree --detach run does, so every boundary above holds unchanged — which is also why it can be a web page at all.

It manages one repository at a time: the one it was started in. Point it elsewhere without moving — sh studio.sh up --project ~/other-project — or run up from inside that repository. Either restarts the pair on the same ports and token, so an open tab follows, and sh studio.sh status always prints which repository the daemon reports.

To remove it, the installer is enough — no copy of studio.sh required: install.sh --uninstall stops the UI container and the host API process, removes both binaries, and lists what it left (Uninstall).

Documentation

Start at the documentation index, or jump to:

User guide The walkthrough: first run, everyday use, every feature
Agent reference All 15 agents, their prerequisites and login flows
Commands and flags Every sandbox flag, and how flags reach the agent
Sessions list, attach, logs, kill, clean
Worktrees · Fleet One agent per branch, and many at once
Crash recovery What to run when a sandbox died mid-write
Configuration The two config files, and which keys a project may not set
Security Profiles, doctor, the security model, stronger isolation
Platform support The matrix, plus Linux and Podman
Studio The browser control plane, its HTTP API, and who may drive it
Alternatives How this compares, including where it loses

Security

A full security audit of this codebase was carried out on 2026-07-26: 22 issues found, all reproduced end to end and all fixed. A same-day re-audit of those fixes, and a later external review of the pull request, each found more; those are fixed too. The ledger is docs/security/audit-2026-07-26.md and the live backlog is open-items.md.

The isolation invariants live in one pure function, runtime.BuildArgs, and are asserted by internal/runtime/args_test.go and the --dry-run golden test in internal/cli/dryrun_test.go. A project .sandbox.yaml is treated as untrusted input: the privilege-relevant keys are refused from it. Full model: Security.

Development

make build             # -> bin/sandbox-cli
make install           # go install ./cmd/sandbox-cli
make test              # unit tests (no Docker)
make test-integration  # end-to-end tests (requires Docker)
make fmt               # gofmt -w .

docs/DEVELOPMENT.md has the full workflow — every make target, single-test commands, release engineering, and the macOS install gotchas. Releases are built by GoReleaser and published by CI when a version tag is pushed.

What's next

Six pieces of work, in order, each with its own scope document under docs/roadmap/:

  1. Better local / dev agent experienceshipped
  2. Multi-agent supportshipped
  3. Stronger isolation for Linux production (Kata) — next
  4. Run provenancenot started
  5. Checkpoint and forknot started
  6. macOS microVMnot started

The roadmap index also records what is deliberately deferred and what has been considered and declined, with reasons — which is most of the rest.

Directories

Path Synopsis
cmd
sandbox-cli command
Command sandbox runs AI coding agents and arbitrary commands inside a disposable, isolated Docker container.
Command sandbox runs AI coding agents and arbitrary commands inside a disposable, isolated Docker container.
sandbox-studio-api command
Command sandbox-studio-api runs the local HTTP control plane for sandbox-cli — see internal/studioapi and docs/studio-api/README.md.
Command sandbox-studio-api runs the local HTTP control plane for sandbox-cli — see internal/studioapi and docs/studio-api/README.md.
internal
agentctx
Package agentctx knows where each agent keeps its conversation transcripts, and remembers what it found.
Package agentctx knows where each agent keeps its conversation transcripts, and remembers what it found.
agents
Package agents describes the AI coding agents sandbox-cli knows how to start, as data rather than as code duplicated per subcommand.
Package agents describes the AI coding agents sandbox-cli knows how to start, as data rather than as code duplicated per subcommand.
agentusage
Package agentusage reads how much of an agent's subscription window has been spent and when it resets.
Package agentusage reads how much of an agent's subscription window has been spent and when it resets.
audit
Package audit records what each sandbox run actually did.
Package audit records what each sandbox run actually did.
cli
Package cli wires the cobra command tree for the `sandbox-cli` binary.
Package cli wires the cobra command tree for the `sandbox-cli` binary.
config
Package config defines the sandbox configuration schema and its layered discovery/merge rules: built-in defaults < user config < project config < flags.
Package config defines the sandbox configuration schema and its layered discovery/merge rules: built-in defaults < user config < project config < flags.
creds
Package creds is the credential broker.
Package creds is the credential broker.
doctor
Package doctor asks whether a host can deliver what a profile promises.
Package doctor asks whether a host can deliver what a profile promises.
egressproxy
Package egressproxy enforces the egress allowlist by **name** rather than by address.
Package egressproxy enforces the egress allowlist by **name** rather than by address.
fleet
Package fleet runs several agents at once: one detached container per git branch, launched from a single task file, then supervised and landed by branch name.
Package fleet runs several agents at once: one detached container per git branch, launched from a single task file, then supervised and landed by branch name.
githard
Package githard neutralises the parts of a git repository's own configuration that make git run commands.
Package githard neutralises the parts of a git repository's own configuration that make git run commands.
history
Package history is a queryable index over the audit log.
Package history is a queryable index over the audit log.
image
Package image lazily builds the embedded sandbox base image on first use.
Package image lazily builds the embedded sandbox base image on first use.
metrics
Package metrics renders a live, one-line resource gauge (memory, CPU, elapsed time, and the workspace's git branch) for a running sandbox container.
Package metrics renders a live, one-line resource gauge (memory, CPU, elapsed time, and the workspace's git branch) for a running sandbox container.
netpolicy
Package netpolicy is a seam for network egress control.
Package netpolicy is a seam for network egress control.
rescue
Package rescue is the crash safety net for the user's work.
Package rescue is the crash safety net for the user's work.
runtime
Package runtime executes a normalized RunSpec inside a container backend.
Package runtime executes a normalized RunSpec inside a container backend.
sandbox
Package sandbox composes config, image building, and the runtime backend into a single Session that resolves a request and runs it in an isolated container.
Package sandbox composes config, image building, and the runtime backend into a single Session that resolves a request and runs it in an isolated container.
studioapi
Package studioapi is the HTTP control plane for sandbox-cli: a local API server a frontend ("Sandbox Studio") talks to instead of shelling out to the CLI itself.
Package studioapi is the HTTP control plane for sandbox-cli: a local API server a frontend ("Sandbox Studio") talks to instead of shelling out to the CLI itself.
termsafe
Package termsafe strips the characters a terminal reads as commands from strings that came from somewhere untrusted.
Package termsafe strips the characters a terminal reads as commands from strings that came from somewhere untrusted.
version
Package version holds build metadata and the base image tag.
Package version holds build metadata and the base image tag.
worktree
Package worktree makes "one sandbox per git branch" a one-liner.
Package worktree makes "one sandbox per git branch" a one-liner.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL