Skip to main content

Docker-based sandbox environment for running Claude Code with isolated credentials

Project description

Foundry Sandbox

CI PyPI License: MIT Built for Claude Code

Ephemeral Docker workspaces that isolate AI coding agents from your credentials and host system.

What It Does

Foundry Sandbox runs your code and AI assistants inside ephemeral Docker containers where credentials never enter the sandbox. A unified proxy on the host holds your real API keys and tokens, injecting them into outbound requests only after policy validation. Code running inside — whether an AI assistant, a build script, or a malicious dependency — never sees the actual credentials.

+------------------+     +------------------------------+     +------------------+
|    Sandbox       |     |       Unified Proxy          |     |  External APIs   |
|                  |     |                              |     |                  |
|  AI assistants,  |---->|  API gateways (per-provider) |---->|  GitHub, Claude, |
|  build scripts,  |     |  Network allowlist (Squid)   |     |  OpenAI, Gemini  |
|  your code       |     |  Git policy engine           |     |                  |
|                  |     |                              |     |                  |
|  [no real creds] |     |  [all credentials]           |     |                  |
+------------------+     +------------------------------+     +------------------+

Multiple independent security layers provide defense in depth:

Layer What it does
Credential isolation API keys never enter the container; injected by proxy on egress
Read-only filesystem Prevents destructive commands (rm -rf / is a no-op)
Network allowlists Egress restricted to approved domains only
Branch isolation Each sandbox sees only its own branch; other branches are hidden
Git safety Protected branches, force-push blocking, GitHub API controls

Each sandbox is a git worktree — create one in seconds, destroy it with zero trace.

Key Features

Security

  • Credential isolation via unified proxy (enabled by default)
  • Network control: allowlist, host-only, or no network
  • Branch isolation and git safety policies

Developer experience

  • Claude Code, Gemini CLI, and Codex CLI are pre-installed
  • Fast creation: worktrees share git objects, new sandboxes spin up in seconds
  • Presets and history: save configurations, repeat last command with cast repeat
  • Spec-driven development: foundry-mcp server pre-configured for Claude Code

Automation

  • Volume mounts (read-write or read-only)
  • All commands support --json for scripting

Quick Start

1. Install

curl -fsSL https://raw.githubusercontent.com/foundry-works/foundry-sandbox/main/install.sh | bash

Clones to ~/.foundry-sandbox, adds the cast command, enables tab completion, and builds the Docker image. Also available on PyPI (pipx install foundry-sandbox). See Getting Started for manual install, uninstall, and prerequisites.

2. Set up credentials

claude setup-token              # Claude Code
codex login                     # Codex CLI (ChatGPT subscription)
gh auth login                   # GitHub (for private repos and push)
gemini auth                     # Gemini CLI (if using)

Credentials stay on the host — the proxy injects them into requests so they never enter the sandbox. See Configuration for all supported API keys.

3. Create a sandbox

Use the guided wizard to create a new sandbox.

cast new

4. Work inside

Launch your favorite AI agent.

claude              # Claude Code
gemini              # Gemini CLI
codex               # Codex CLI

4. Commit, push

Ask your AI agent to commit and push changes.

5. Destroy

CTRL+D to exit the sandbox, then from host:

cast destroy <sandbox-name> --yes   # Remove worktree and container

Prerequisites

Docker 20.10+, Git 2.x+, Bash 4+, tmux 3+, Python 3.10+. Linux and macOS supported natively; Windows requires WSL2. macOS ships Bash 3.2 — install 4+ via brew install bash.

Limitations

  • Not a targeted-attack boundary — defends against supply-chain attacks and AI mistakes, not a determined human attacker with host-level Docker access
  • Requires Docker — no native process isolation
  • Linux/macOS — Windows requires WSL2
  • No GPU passthrough — needs additional Docker configuration

Documentation

Document Description
Getting Started Installation and first sandbox
Commands Full command reference
Workflows Common patterns and recipes
Configuration API keys, plugins, and config files
Architecture Technical design and diagrams
Security Model Threat model, defenses, and hardening
Operations Proxy operations runbook
Observability Metrics and debugging
Contributing For contributors

Support

License

MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

foundry_sandbox-0.20.13.tar.gz (757.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

foundry_sandbox-0.20.13-py3-none-any.whl (167.8 kB view details)

Uploaded Python 3

File details

Details for the file foundry_sandbox-0.20.13.tar.gz.

File metadata

  • Download URL: foundry_sandbox-0.20.13.tar.gz
  • Upload date:
  • Size: 757.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for foundry_sandbox-0.20.13.tar.gz
Algorithm Hash digest
SHA256 9017ed9ce93dee34c9a65ca358f62e014e5cf436f66bdb99c4915576c2353008
MD5 10ed09ba1a1c8c6746b05a3c8977f43e
BLAKE2b-256 de28dc69637def8ec21c03e2c1e8b0ac63267a3a98e466485d894d7b398a6903

See more details on using hashes here.

Provenance

The following attestation bundles were made for foundry_sandbox-0.20.13.tar.gz:

Publisher: release.yml on foundry-works/foundry-sandbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file foundry_sandbox-0.20.13-py3-none-any.whl.

File metadata

File hashes

Hashes for foundry_sandbox-0.20.13-py3-none-any.whl
Algorithm Hash digest
SHA256 2ba38cda4705ef97173d5b72617d33683d5aa67dad8a7e870e6974e868292fba
MD5 37c1e56f073cacc12bb8866b24d79882
BLAKE2b-256 2cffa8e27796ff6a2fa10c95ff184e2e27e1cd3ffbd56a0d9af057b6edc6a9d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for foundry_sandbox-0.20.13-py3-none-any.whl:

Publisher: release.yml on foundry-works/foundry-sandbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page