匠人学院 JR Academy
ai-engineerJR Academy

Run Claude Code in an isolated E2B cloud sandbox

Use an E2B sandbox to run Claude Code in an isolated cloud environment for agent testing, system commands and database operations.

AI EngineerSandboxSecurityCloud environments
E2B and Claude Code sandbox cover
Contents

E2B and Claude Code sandbox

An E2B sandbox gives Claude Code a separate cloud environment for running system commands, trying unfamiliar dependencies and testing agents. The sandbox keeps these experiments away from your local development setup and can be cleaned up afterwards.

Benefits

  • Isolation: Run commands in the cloud without giving the sandbox access to your local files.
  • Local configuration: Test changes without modifying your own machine.
  • Clean environment: Start from Ubuntu with Claude Code.
  • Remote execution: Run heavier workloads in the cloud.
  • Cleanup: Failed experiments can be removed with the sandbox.

Prerequisites

Quick start

BASH
npx claude-code-templates@latest --sandbox e2b \
  --e2b-api-key your_e2b_key \
  --anthropic-api-key your_anthropic_key \
  --prompt "Create a React todo app with TypeScript"

Run a specific agent

BASH
npx claude-code-templates@latest --sandbox e2b \
  --e2b-api-key your_e2b_key \
  --anthropic-api-key your_anthropic_key \
  --agent development-team/frontend-developer \
  --prompt "Create a modern todo app with TypeScript and Tailwind"

Common uses

  • Test system configuration changes in an isolated environment.
  • Run security checks on your own software.
  • Rehearse database migrations and rollbacks.
  • Try unfamiliar packages before installing them locally.

Directory layout after installation

TEXT
your-project/
├── .claude/
│   └── sandbox/
│       ├── e2b-launcher.py
│       ├── requirements.txt
│       └── .env.example
└── sandbox-xxxxxxxx/
    ├── index.html
    └── src/

Further reading

Related certifications

Start with a few sample questions or a free chapter. The exam guide covers what the exam tests; the question bank lets you practise by exam domain.

Related learning resources

Continue reading

Done reading? Next steps