Claude Code
Run Claude Code in its own sandbox with a real filesystem, terminal and git. The prebuilt claude template has it installed, so it can work unattended and you collect the diff.
- E2B
- Prebuilt claude sandbox template
- e2b
- TypeScript, Python
Get started
Paste the prompt into your coding agent, or follow the steps yourself.
Paste this into your coding agent
Run Claude Code in an E2B sandbox from this project.
- 1.Install the e2b SDK using the project's package manager.
- 2.The SDK needs the E2B_API_KEY environment variable, and Claude Code needs ANTHROPIC_API_KEY. If E2B_API_KEY isn't set, ask me for my API key from https://console.e2b.dev/?tab=keys. Never hardcode either key.
- 3.Follow the Claude Code guide at https://docs.e2b.dev/agents/claude-code: create a sandbox from the claude template, pass ANTHROPIC_API_KEY in envs, and run claude -p with --dangerously-skip-permissions and a command timeout of 0. Kill the sandbox in a finally block.
- 4.Run one task and show me the output that came from the sandbox.
Or set it up yourself
1. Install the E2B SDK
2. Set your API keys
3. Run Claude Code headless
4. Work on a repository
What runs in the sandbox
Claude Code and every command it runs live in the sandbox, away from your machine and its files.
- The claude CLI, auto-approving its own tool calls. The sandbox contains them, so it can't touch your host.
- The repo you clone and everything Claude Code writes. Read results back with files.read() or git diff.
- Conversations persist in the sandbox. Pass --resume with the session ID to send a follow-up task.
- Internet access is on by default. Restrict outbound traffic with network rules for untrusted input or secrets.
More coding agents
Other coding agents that run in E2B sandboxes.
- OpenAI CodexRun OpenAI's Codex CLI headless in a sandbox and collect the diff when it's done.
- OpenCodeRun OpenCode in a sandbox, or keep it local and point its workspaces at E2B with the @e2b/opencode plugin.
- Gemini CLIRun Google's Gemini CLI in a sandbox with full filesystem, terminal, and git access.
