Provides secure, isolated VM environments for executing AI-generated code or system scripts.

Install

mkdir -p .claude/skills/e2b && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/13184" && unzip -o skill.zip -d .claude/skills/e2b && rm skill.zip

Installs to .claude/skills/e2b

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Execute AI-generated code in secure isolated E2B cloud sandboxes (SDK v2). Use for running Python/JavaScript/TypeScript/R/Java/Bash code, managing sandbox lifecycle (create, pause, resume, kill, list, connect), running coding agents (Claude Code, Codex, AMP, OpenCode) in sandboxes, git operations inside sandboxes, code contexts for parallel isolated execution, monitoring metrics (CPU, memory, disk), MCP gateway integration (200+ tools), uploading/downloading files, storage bucket mounting (S3, GCS, R2), streaming command output, SSH/PTY access, custom templates with Build System 2.0, and integrating LLMs with code execution capabilities.
645 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Intermediate

Key capabilities

  • Execute AI-generated code in isolated cloud sandboxes
  • Manage sandbox lifecycle (create, pause, resume, kill, list, connect)
  • Run Python, JavaScript, TypeScript, R, Java, and Bash code
  • Perform git operations inside sandboxes
  • Upload and download files to/from sandboxes
  • Integrate LLMs with code execution capabilities

How it works

The skill provides an interface to E2B cloud sandboxes, which are isolated VMs for executing AI-generated code. It manages the sandbox lifecycle, allows multi-language code execution, file operations, and git commands, and integrates with LLMs.

Inputs & outputs

You give it
Code (Python, JS, etc.), git commands, file content, sandbox lifecycle commands
You get back
Code execution results, file system changes, git operation outcomes, sandbox status, LLM tool outputs

When to use e2b

  • Run AI code safely
  • Execute system scripts
  • Isolated environment testing

About this skill

E2B Sandbox Skill

Secure isolated cloud VMs for executing AI-generated code. Sandboxes start in ~150ms with full code execution, filesystem, git, and network access.

SDK v2 Breaking Change: Python uses Sandbox.create() — not Sandbox(). Secured access is enabled by default.

Quick Reference

FeatureReference
Getting startedquickstart.md
Lifecycle & securitysandbox-lifecycle.md
Code execution & contextscode-interpreting.md
File operationsfilesystem.md
Git operationsgit-integration.md
Coding agentsagents.md
Monitoring & eventsmonitoring-and-events.md
Persistence (pause/resume)persistence.md
MCP Gateway (200+ tools)mcp-gateway.md
Custom templatescustom-templates.md
Advanced (SSH, PTY, buckets, proxy)advanced-sandbox.md

Installation

Two packages available — use e2b for base sandbox features, e2b-code-interpreter when you need run_code() (Jupyter-style execution):

# Python — base sandbox (filesystem, commands, git, processes)
pip install e2b

# Python — code interpreter (adds run_code with charts, multi-language)
pip install e2b-code-interpreter

# JavaScript/TypeScript — base sandbox
npm i e2b

# JavaScript/TypeScript — code interpreter
npm i @e2b/code-interpreter

Required environment variable:

E2B_API_KEY=e2b_***  # Get from https://e2b.dev/dashboard?tab=keys

Core Patterns

Pattern 1: One-shot Code Execution

from e2b_code_interpreter import Sandbox

sandbox = Sandbox.create()
execution = sandbox.run_code('print("Hello from E2B!")')
print(execution.text)
sandbox.kill()
import { Sandbox } from '@e2b/code-interpreter'

const sandbox = await Sandbox.create()
const execution = await sandbox.runCode('console.log("Hello!")')
console.log(execution.text)
await sandbox.kill()

Pattern 2: Multi-language Execution

sandbox.run_code('import pandas as pd; df.describe()')       # Python (default)
sandbox.run_code('await fetch(url)', language='js')           # JavaScript
sandbox.run_code('const x: number = 42', language='ts')       # TypeScript
sandbox.run_code('summary(mtcars)', language='r')             # R
sandbox.run_code('System.out.println("hi")', language='java') # Java
sandbox.run_code('ls -la /home/user', language='bash')        # Bash

Pattern 3: File Upload + Analysis

sandbox.files.write('/home/user/data.csv', csv_content)

execution = sandbox.run_code('''
import pandas as pd
df = pd.read_csv('/home/user/data.csv')
df.describe()
''')

result = sandbox.files.read('/home/user/output.png')

Pattern 4: Code Contexts (Isolated Parallel Execution)

ctx_a = sandbox.create_code_context(cwd='/home/user/project-a')
ctx_b = sandbox.create_code_context(cwd='/home/user/project-b')

result_a = sandbox.run_code('import pandas; print("A")', context=ctx_a)
result_b = sandbox.run_code('import numpy; print("B")', context=ctx_b)

Pattern 5: Git Operations

from e2b import Sandbox

sandbox = Sandbox.create()
sandbox.git.clone('https://github.com/user/repo.git', '/home/user/repo',
                  username='user', password=os.environ['GITHUB_TOKEN'])
sandbox.git.checkout_branch('/home/user/repo', 'feature-branch')
sandbox.git.add('/home/user/repo')
sandbox.git.commit('/home/user/repo', 'fix: update config')
sandbox.git.push('/home/user/repo', username='user', password=os.environ['GITHUB_TOKEN'])

Pattern 6: Running Coding Agents

from e2b import Sandbox

sandbox = Sandbox.create(
    template='claude',
    envs={'ANTHROPIC_API_KEY': os.environ['ANTHROPIC_API_KEY']},
    timeout=300
)
result = sandbox.commands.run(
    'claude -p "Write a hello world server" --dangerously-skip-permissions',
    timeout=120
)
print(result.stdout)

See agents.md for Codex, AMP, OpenCode, and more patterns.

Pattern 7: LLM Tool Integration

from anthropic import Anthropic
from e2b_code_interpreter import Sandbox

tools = [{
    "name": "execute_python",
    "description": "Execute python code in sandbox",
    "input_schema": {
        "type": "object",
        "properties": {
            "code": {"type": "string", "description": "Python code to execute"}
        },
        "required": ["code"]
    }
}]

client = Anthropic()
message = client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Calculate 2+2"}],
    tools=tools
)

if message.stop_reason == "tool_use":
    tool_use = next(b for b in message.content if b.type == "tool_use")
    sandbox = Sandbox.create()
    result = sandbox.run_code(tool_use.input['code'])
    print(result.text)
    sandbox.kill()

Pattern 8: MCP Gateway

from e2b import Sandbox

sandbox = Sandbox.create(
    mcp={
        'github': {'githubPersonalAccessToken': os.environ['GITHUB_TOKEN']},
        'slack': {'botToken': os.environ['SLACK_BOT_TOKEN']}
    }
)
mcp_url = sandbox.get_mcp_url()
mcp_token = sandbox.get_mcp_token()

See mcp-gateway.md for 200+ available integrations.

Pattern 9: Persistence (Pause/Resume)

sandbox = Sandbox.create(auto_pause=True, timeout=600)
sandbox.run_code(code)
sandbox.pause()
saved_id = sandbox.sandbox_id

# Later: Resume
sandbox = Sandbox.connect(saved_id)

Pattern 10: Custom Template (Build System 2.0)

import { Template, waitForPort } from 'e2b'

const template = Template()
  .fromPythonImage('3.12')
  .pipInstall(['pandas', 'numpy', 'matplotlib'])
  .copy('./app', '/home/user/app')
  .setStartCmd('python /home/user/app/server.py', waitForPort(3000))

await Template.build(template, { name: 'my-data-template' })

API Quick Reference

Sandbox Lifecycle

# Create (SDK v2 — always use .create())
sandbox = Sandbox.create()                          # Default 5 min timeout
sandbox = Sandbox.create(timeout=300)               # Custom timeout (seconds)
sandbox = Sandbox.create(envs={'KEY': 'val'})       # With env vars
sandbox = Sandbox.create(metadata={'user': '123'})  # With metadata
sandbox = Sandbox.create(template='my-template')    # Custom template
sandbox = Sandbox.create(secure=False)              # Disable secured access

# Info & timeout
info = sandbox.get_info()
sandbox.set_timeout(60)

# Kill
sandbox.kill()
Sandbox.kill(sandbox_id)

Sandbox Discovery

paginator = Sandbox.list()                                          # List all
sandboxes = paginator.next_items()
paginator = Sandbox.list(query={'state': ['running', 'paused']})    # Filter by state
paginator = Sandbox.list(query={'metadata': {'userId': '123'}})     # Filter by metadata
sandbox = Sandbox.connect(sandbox_id)                               # Connect to existing

Code Execution

execution = sandbox.run_code(code, language='python', envs={'VAR': 'val'})
execution.text          # Combined output
execution.logs.stdout   # Standard output
execution.logs.stderr   # Standard error
execution.results       # Rich results (charts, tables)
execution.error         # Runtime errors

Commands

result = sandbox.commands.run('ls -la')
result = sandbox.commands.run('cmd', envs={'VAR': 'val'})
result = sandbox.commands.run('cmd', background=True)
result = sandbox.commands.run('cmd', on_stdout=callback, on_stderr=callback)

Files

sandbox.files.write('/home/user/file.txt', content)     # Write single file
sandbox.files.write_files([('/path/a', data_a), ...])    # Write multiple files
content = sandbox.files.read('/home/user/file.txt')      # Read file
info = sandbox.files.get_info('/home/user/file.txt')     # File metadata
files = sandbox.files.list('/home/user')                 # List directory
watcher = sandbox.files.watch_dir('/path')               # Watch changes

Git

sandbox.git.clone(url, path, username=..., password=...)
sandbox.git.branches(path)
sandbox.git.create_branch(path, 'branch-name')
sandbox.git.checkout_branch(path, 'branch-name')
sandbox.git.add(path)
sandbox.git.commit(path, 'message')
sandbox.git.push(path, username=..., password=...)
sandbox.git.pull(path)

Code Contexts

ctx = sandbox.create_code_context(cwd='/path', language='python')
result = sandbox.run_code('print("isolated")', context=ctx)
contexts = sandbox.list_code_contexts()
sandbox.remove_code_context(ctx.id)

Monitoring

metrics = sandbox.get_metrics()
# Returns list of SandboxMetric: cpu_used_pct, cpu_count, mem_used, mem_total, disk_used, disk_total

Python vs JavaScript API

OperationPythonJavaScript
CreateSandbox.create()await Sandbox.create()
Timeoutset_timeout(60)setTimeout(60000) (ms)
Run coderun_code(code)await runCode(code)
Killkill()await kill()
Pausepause()await pause()
Git clonegit.clone(url, path)await git.clone(url, path)
Code contextcreate_code_context()await createCodeContext()

Packages: e2b vs e2b-code-interpreter

Featuree2be2b-code-interpreter
Sandbox lifecycleYesYes (inherits)
Commands (commands.run)YesYes
FilesystemYesYes
Git integrationYesYes
run_code() (Jupyter)NoYes
Charts/visualizationsNoYes
Code contextsNoYes
Coding agent templatesYesNo (use e2b)

Use e2b for: running agents, s


Content truncated.

When not to use it

  • When a local execution environment is sufficient and isolation is not required
  • When persistent storage beyond the sandbox lifecycle is needed without mounting buckets
  • When the `e2b-code-interpreter` package is not installed for `run_code()` functionality

Prerequisites

E2B_API_KEY

Limitations

  • Requires an E2B API key
  • Python `Sandbox()` is a breaking change, use `Sandbox.create()`
  • The `e2b` package does not include `run_code()` (Jupyter-style execution)

How it compares

This skill offers secure, isolated cloud sandboxes for executing AI-generated code with full filesystem, git, and network access, supporting multiple languages and LLM integration, which is more secure and versatile than running code direct

Compared to similar skills

e2b side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
e2b (this skill)05moCautionIntermediate
container-security-testing17moReviewIntermediate
fix-cves16moNo flagsIntermediate
sca-trivy16moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

container-security-testing

Ed1s0nZ

容器安全测试的专业技能和方法论

14

fix-cves

okteto

Fix all CVEs in the Okteto CLI Docker image by scanning with Trivy and updating vulnerable dependencies and binaries

12

sca-trivy

rohunj

Software Composition Analysis (SCA) and container vulnerability scanning using Aqua Trivy for identifying CVE vulnerabilities in dependencies, container images, IaC misconfigurations, and license compliance risks. Use when: (1) Scanning container images and filesystems for vulnerabilities and misconfigurations, (2) Analyzing dependencies for known CVEs across multiple languages (Go, Python, Node.js, Java, etc.), (3) Detecting IaC security issues in Terraform, Kubernetes, Dockerfile, (4) Integrating vulnerability scanning into CI/CD pipelines with SARIF output, (5) Generating Software Bill of Materials (SBOM) in CycloneDX or SPDX format, (6) Prioritizing remediation by CVSS score and exploitability.

12

go-vuln-remediate

infobloxopen

Run Wiz-based vulnerability scan and automatic Go module remediation for containerized Go services in the konk repository. Use when you need to build images, scan CVEs, patch vulnerable dependencies in go.mod/go.sum across konk-service and konk-provision modules, validate builds, and prepare a PR su

00

run-manual-docker-security-scan

torrust

Guide for running a manual Docker security scan for the tracker runtime image and documenting results. Covers build, Trivy scan, CVE triage, per-CVE catalog updates, and scan history updates. Use when asked to run a manual container scan, triage Docker CVEs, or refresh security scan docs.

00

gcp-cloud-run

aj-geddes

Deploy containerized applications on Google Cloud Run with automatic scaling, traffic management, and service mesh integration. Use for container-based serverless computing.

5107

Search skills

Search the agent skills registry