Best use case
E2B Sandbox is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
## Overview
Teams using E2B Sandbox should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/e2b-sandbox/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How E2B Sandbox Compares
| Feature / Agent | E2B Sandbox | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
## Overview
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# E2B Sandbox
## Overview
E2B provides cloud sandboxes for running AI-generated code safely. Each sandbox is an isolated microVM — the AI agent can execute code, install packages, read/write files, and run processes without any risk to your infrastructure. Spins up in ~150ms, supports any language, and shuts down automatically. The building block for code interpreters, AI coding agents, and data analysis tools.
## When to Use
- AI agent needs to execute code (Python, JS, bash, etc.)
- Running untrusted or AI-generated code safely
- Building a code interpreter or data analysis assistant
- Need isolated environments for each user/session
- AI agent that needs filesystem + process control
## Instructions
### Setup
```bash
npm install @e2b/code-interpreter
# Or for full sandbox control:
npm install e2b
```
### Code Interpreter (Quickstart)
```typescript
// interpreter.ts — Run code in a sandbox with results
import { CodeInterpreter } from "@e2b/code-interpreter";
const sandbox = await CodeInterpreter.create({
apiKey: process.env.E2B_API_KEY,
});
// Execute Python code
const result = await sandbox.notebook.execCell(`
import pandas as pd
import numpy as np
# Generate sample data
data = pd.DataFrame({
'date': pd.date_range('2026-01-01', periods=30),
'revenue': np.random.uniform(1000, 5000, 30),
'users': np.random.randint(100, 1000, 30),
})
print(f"Total revenue: ${data['revenue'].sum():,.2f}")
print(f"Average users: {data['users'].mean():.0f}")
data.describe()
`);
console.log(result.text); // Printed output
console.log(result.results); // Rich results (DataFrames, plots)
// Execute JavaScript
const jsResult = await sandbox.notebook.execCell(`
const response = await fetch('https://api.github.com/repos/e2b-dev/e2b');
const data = await response.json();
console.log(\`Stars: \${data.stargazers_count}\`);
`, { language: "javascript" });
await sandbox.close();
```
### Full Sandbox Control
```typescript
// sandbox.ts — Full filesystem + process control
import { Sandbox } from "e2b";
const sandbox = await Sandbox.create({
template: "base", // or custom template
apiKey: process.env.E2B_API_KEY,
});
// Write files
await sandbox.filesystem.write("/home/user/app.py", `
import json
data = {"status": "ok", "message": "Hello from sandbox!"}
print(json.dumps(data))
`);
// Run processes
const proc = await sandbox.process.start({
cmd: "python3 /home/user/app.py",
});
await proc.wait();
console.log(proc.output.stdout); // {"status": "ok", ...}
// Install packages
await sandbox.process.start({ cmd: "pip install requests beautifulsoup4" }).wait();
// Read files
const content = await sandbox.filesystem.read("/home/user/output.txt");
// List directory
const files = await sandbox.filesystem.list("/home/user/");
await sandbox.close();
```
### Custom Sandbox Templates
```dockerfile
# e2b.Dockerfile — Custom sandbox with pre-installed tools
FROM e2b/base:latest
RUN pip install pandas numpy matplotlib scikit-learn
RUN npm install -g typescript tsx
COPY ./scripts /home/user/scripts
```
```bash
# Build and deploy custom template
e2b template build -n my-data-sandbox
# Now use: Sandbox.create({ template: "my-data-sandbox" })
```
### Integration with LLM Agents
```typescript
// agent.ts — AI agent with code execution capability
import OpenAI from "openai";
import { CodeInterpreter } from "@e2b/code-interpreter";
const openai = new OpenAI();
const sandbox = await CodeInterpreter.create();
const messages = [
{
role: "system" as const,
content: "You are a data analyst. Write Python code to answer questions. Use pandas for data manipulation.",
},
{
role: "user" as const,
content: "Analyze this CSV and find the top 5 customers by revenue.",
},
];
// Upload data to sandbox
await sandbox.filesystem.write("/home/user/data.csv", csvData);
// Get code from LLM
const response = await openai.chat.completions.create({
model: "gpt-4o",
messages,
});
const code = extractCodeFromResponse(response.choices[0].message.content!);
// Execute in sandbox safely
const result = await sandbox.notebook.execCell(code);
console.log(result.text);
await sandbox.close();
```
## Examples
### Example 1: Build a code interpreter chatbot
**User prompt:** "Build a chatbot where users can ask data questions and it runs Python to answer."
The agent will create an E2B sandbox per conversation, pass user questions to an LLM for code generation, execute the code safely, and return results with visualizations.
### Example 2: AI coding agent with file access
**User prompt:** "My AI agent needs to write, test, and fix code autonomously."
The agent will set up E2B sandboxes where the AI can create files, run tests, read error output, and iterate until tests pass — all safely isolated.
## Guidelines
- **One sandbox per session** — isolate users/conversations from each other
- **150ms cold start** — fast enough for interactive use
- **Auto-shutdown** — sandboxes close after timeout (default 5 min)
- **Custom templates for speed** — pre-install packages to avoid install time
- **File upload/download** — `filesystem.write()` and `filesystem.read()`
- **Streaming output** — `process.start()` with `onStdout` callback
- **24h max lifetime** — sandboxes are ephemeral, not persistent servers
- **Network access** — sandboxes can fetch URLs (useful for API calls)
- **No GPU** — CPU-only sandboxes (use modal.com for GPU workloads)
- **Free tier: 100 sandbox hours/month** — enough for developmentRelated Skills
sandbox-npm-install
Install npm packages in a Docker sandbox environment. Use this skill whenever you need to install, reinstall, or update node_modules inside a container where the workspace is mounted via virtiofs. Native binaries (esbuild, lightningcss, rollup) crash on virtiofs, so packages must be installed on the local ext4 filesystem and symlinked back.
when-configuring-sandbox-security-use-sandbox-configurator
Configure Claude Code sandbox security with file system and network isolation boundaries. Ensures safe code execution with proper access controls and resource limits.
sandbox-configurator
Configure Claude Code sandbox security with file system and network isolation boundaries
python-sandbox
在沙盒环境中执行Python代码,用于数据分析、可视化和生成Excel、Word、PDF等文件。支持数据清洗、统计分析、机器学习、图表生成、文档自动化等复杂工作流。
code-validation-sandbox
Validate code examples across the 4-Layer Teaching Method with intelligent strategy selection. Use when validating Python/Node/Rust code in book chapters. NOT for production deployment testing.
E2B — Sandboxed Code Execution for AI
You are an expert in E2B, the cloud platform for running AI-generated code in secure sandboxes. You help developers give AI agents the ability to execute code, install packages, read/write files, and run long processes in isolated cloud environments — each sandbox is a lightweight VM that boots in ~150ms with full Linux, filesystem, and networking.
Agent Sandbox
## Overview
lever-sandbox-automation
Automate Lever Sandbox tasks via Rube MCP (Composio). Always search tools first for current schemas.
Daily Logs
Record the user's daily activities, progress, decisions, and learnings in a structured, chronological format.
Socratic Method: The Dialectic Engine
This skill transforms Claude into a Socratic agent — a cognitive partner who guides
Sokratische Methode: Die Dialektik-Maschine
Dieser Skill verwandelt Claude in einen sokratischen Agenten — einen kognitiven Partner, der Nutzende durch systematisches Fragen zur Wissensentdeckung führt, anstatt direkt zu instruieren.
College Football Data (CFB)
Before writing queries, consult `references/api-reference.md` for endpoints, conference IDs, team IDs, and data shapes.