Automated summary
This skill explains how to use E2B to run AI-generated Python or JavaScript in isolated cloud Linux sandboxes, including file handling, package installation, and rich outputs.
Strengths
- Walks through the full lifecycle: install, authenticate with E2B_API_KEY, create a sandbox, run code, and kill it.
- Covers practical agent workloads such as pip installs, file reads/writes, matplotlib charts returned as base64, and timeout extension.
- Provides concrete TypeScript examples plus a JavaScript variant with a network fetch.
- Warns against hardcoding the API key and explicitly cleans up sandboxes.
Limitations
- Relies on a third-party cloud service and API key, so it is unsuitable for offline or strictly on-premise environments.
- Despite the description, it does not actually show LangChain or CrewAI wiring, nor retry and error-handling strategies.
- Examples are TypeScript-first and do not cover sandbox persistence or more advanced resource cleanup.
Use it when an agent needs to execute untrusted code, analyze data, or generate charts without exposing the host machine.
Avoid it when code or data cannot leave your infrastructure, or when a simple local container is sufficient.
Security analysis
SafeThe skill is documentation for the E2B sandboxed code-execution SDK. It contains no destructive host commands, no obfuscated payloads, and no exfiltration of credentials; it explicitly advises keeping E2B_API_KEY in environment variables, never hardcoding it or shipping it in client bundles, and warns that sandbox outbound internet access is an attack surface. Code execution occurs in ephemeral remote VMs, which is the stated and legitimate purpose. The only "powerful" operations (pip install, arbitrary Python/JS in a sandbox) are scoped to the isolated environment, so there is no meaningful risk to a host machine from listing the skill.
No concerns found
How this analysis is madeExamples
Use E2B to create a sandbox, upload quarterly-revenue.csv, run a pandas analysis, return the matplotlib chart as a base64 PNG, and then kill the sandbox.Wire E2B code execution into my LangChain agent so it can install packages and run generated Python in an isolated sandbox, with a 10-minute timeout and cleanup.Run a JavaScript snippet in an E2B sandbox that fetches the GitHub repo stats and prints the star count.name: e2b description: >- E2B is a cloud platform that gives AI agents secure, isolated sandboxes — ephemeral Linux VMs with a filesystem, package managers, and internet access — to run AI-generated code safely. Use when a user wants an agent to execute Python or JavaScript, install packages, read/write files, or run a long process without risking the host machine, or wants to wire code execution into a LangChain, CrewAI, or custom agent loop. license: Apache-2.0 compatibility: "Node.js 20.18+ or Python 3.8+, an E2B API key" metadata: author: terminal-skills version: "1.1.0" category: data-ai tags: "sandbox, code-execution, ai-agents, cloud, e2b" repository: https://github.com/e2b-dev/E2B
E2B — Sandboxed Code Execution for AI
Overview
E2B runs AI-generated code inside short-lived, isolated cloud sandboxes rather than on the host machine. Each sandbox is a Linux VM created from a snapshot, with its own filesystem, package managers, and outbound internet access; it is destroyed when killed or when it times out. The @e2b/code-interpreter (JS/TS) and e2b-code-interpreter (Python) packages add a runCode method on top of the base E2B SDK that is purpose-built for data/AI workloads: it returns rich results (stdout/stderr, tracebacks, and rendered outputs like matplotlib charts as base64 images) instead of just an exit code.
Instructions
Install and authenticate
npm install @e2b/code-interpreter dotenv
Set E2B_API_KEY (from the E2B dashboard) as an environment variable — never hardcode it in source.
Run code in a sandbox
import { Sandbox } from "@e2b/code-interpreter";
const sandbox = await Sandbox.create(); // default timeout: 5 minutes
const result = await sandbox.runCode(`
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame({"x": range(10), "y": [i**2 for i in range(10)]})
plt.figure(figsize=(8, 5))
plt.plot(df.x, df.y)
plt.title("Quadratic Growth")
plt.savefig("/tmp/chart.png")
print(f"Data points: {len(df)}")
`);
console.log(result.logs.stdout); // ["Data points: 10"]
console.log(result.results); // [{ type: "png", data: "base64..." }]
await sandbox.kill();
Install packages, read/write files, extend the timeout
await sandbox.runCode("!pip install scikit-learn");
await sandbox.runCode(`
from sklearn.linear_model import LinearRegression
model = LinearRegression().fit([[1], [2], [3]], [1, 2, 3])
print(model.predict([[4]]))
`);
await sandbox.files.write("/tmp/sales.csv", csvContent);
const preview = await sandbox.runCode(
"import pandas as pd; print(pd.read_csv('/tmp/sales.csv').head())"
);
const chartBytes = await sandbox.files.read("/tmp/chart.png");
// Default lifetime is 5 minutes; extend it explicitly for longer jobs
// (max 1 hour on the Hobby plan, 24 hours on Pro).
await sandbox.setTimeout(10 * 60_000);
Run JavaScript instead of Python
const jsResult = await sandbox.runCode(
`
const response = await fetch('https://api.github.com/repos/e2b-dev/e2b');
const data = await response.json();
console.log(data.stargazers_count);
`,
{ language: "javascript" }
);
Examples
Example 1: "Let an agent analyze a CSV and return a chart"
import { Sandbox } from "@e2b/code-interpreter";
import { readFileSync } from "fs";
const sandbox = await Sandbox.create();
const csv = readFileSync("quarterly-revenue.csv");
await sandbox.files.write("/tmp/quarterly-revenue.csv", csv);
const analysis = await sandbox.runCode(`
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("/tmp/quarterly-revenue.csv")
plt.bar(df["quarter"], df["revenue"])
plt.savefig("/tmp/revenue.png")
print(df.describe())
`);
console.log(analysis.logs.stdout.join("\n"));
const [chart] = analysis.results.filter((r) => r.png);
await sandbox.kill();
The agent writes and runs arbitrary pandas/matplotlib code; analysis.results carries the chart back as a base64 PNG with no file download step needed.
Example 2: "Give a LangChain agent a code-execution tool"
import { Sandbox } from "@e2b/code-interpreter";
import { tool } from "@langchain/core/tools";
import { z } from "zod";
const sandbox = await Sandbox.create({ timeoutMs: 10 * 60_000 });
const runPython = tool(
async ({ code }) => {
const execution = await sandbox.runCode(code);
return execution.logs.stdout.join("\n") || execution.error?.value || "";
},
{
name: "run_python",
description: "Executes Python code in a sandboxed environment and returns stdout.",
schema: z.object({ code: z.string() }),
}
);
The agent calls run_python whenever it needs to compute something instead of guessing; the sandbox's isolation means a wrong or malicious snippet can't touch the host.
Guidelines
- A sandbox self-destructs after its timeout (default 5 minutes); call
sandbox.setTimeout()before it expires for long-running jobs, and alwayskill()sandboxes you're done with rather than relying on the timeout alone, since idle sandboxes still bill for uptime. - Never bake the
E2B_API_KEYinto committed code or client-side bundles — the key can create sandboxes and billed compute on your account. - Build a custom sandbox template (prebaked with your packages) when cold-installing dependencies on every run is too slow; the base template includes NumPy, Pandas, and Matplotlib but not arbitrary packages.
- Sandboxes have outbound internet access by default — treat that as an attack surface if you're running untrusted, user-submitted code, not just AI-generated code you've reviewed.
- Use
@e2b/code-interpreter'srunCodefor data/analysis workloads that need rich results (charts, tracebacks); use the basee2bSDK's shell commands (sandbox.commands.exec) for general-purpose process execution that doesn't need that return shape.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/sandboxed-code-execution-with-e2b-mwirmdw9/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/sandboxed-code-execution-with-e2b-mwirmdw9' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/sandboxed-code-execution-with-e2b-mwirmdw9/download' --output '.skill-downloads/sandboxed-code-execution-with-e2b-mwirmdw9/SKILL.md.part' && mv '.skill-downloads/sandboxed-code-execution-with-e2b-mwirmdw9/SKILL.md.part' '.skill-downloads/sandboxed-code-execution-with-e2b-mwirmdw9/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
Environment declared by the author: Node.js 20.18+ or Python 3.8+, an E2B API key
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/sandboxed-code-execution-with-e2b-mwirmdw9/SKILL.md' && test -s '.skill-downloads/sandboxed-code-execution-with-e2b-mwirmdw9/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/e2b' && cp -R '.skill-downloads/sandboxed-code-execution-with-e2b-mwirmdw9' '.claude/skills/e2b'Cursor
test -f '.skill-downloads/sandboxed-code-execution-with-e2b-mwirmdw9/SKILL.md' && test -s '.skill-downloads/sandboxed-code-execution-with-e2b-mwirmdw9/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/e2b' && cp -R '.skill-downloads/sandboxed-code-execution-with-e2b-mwirmdw9' '.cursor/skills/e2b'Codex
test -f '.skill-downloads/sandboxed-code-execution-with-e2b-mwirmdw9/SKILL.md' && test -s '.skill-downloads/sandboxed-code-execution-with-e2b-mwirmdw9/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/e2b' && cp -R '.skill-downloads/sandboxed-code-execution-with-e2b-mwirmdw9' '.agents/skills/e2b'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/sandboxed-code-execution-with-e2b-mwirmdw9'openskills read 'sandboxed-code-execution-with-e2b-mwirmdw9'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/sandboxed-code-execution-with-e2b-mwirmdw9/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
Create Interactive Maps with kepler.gl
Data & AI
Create interactive map visualizations and export standalone HTML using the keplergl Python package. Use to plot geospatial data from DataFrames, GeoJSON, or CSV.
Agent-Driven Parameter Optimization
Data & AI
Guide for optimizing configurable systems with a measurable objective, using bounded trials and evidence-based recommendations.
ICP Visitor Outreach
Data & AI
Identify signed-up users matching the ideal customer profile but stalled, and draft personalized outreach to re-engage them.