Agent Sandboxes
Skill2 starsChanged 9 months agoMITView on GitHub
Operate E2B agent sandboxes using the CLI. Use when user needs to run code in isolation, test packages, execute commands safely, or work with binary files in a sandbox environment. Keywords: sandbox, e2b, isolated environment, run code, test code, safe execution.
- Pipes a download into a shell
- Reads credentials
- Installs packages
1 other project uses a version of this.
Adopted by
Most recently taken up by
- disler/agent-sandbox-skillword for word, first seen Nov 29, 2025
Other versions1 project uses a version of this.
Word for word · 1
- disler/agent-sandbox-skill★ 388100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository239 other files it gives its agents.
- claude-code-docs/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- claude-code-docs/llms.txtllms.txt
- agent-native-architectureSkill
- claude-apiSkill
- embedding-strategiesSkill
- fal-ai-mediaSkill
- gemini-imagegenSkill
- hybrid-search-implementationSkill
- langchain-architectureSkill
- llm-evaluationSkill
- ml-pipeline-workflowSkill
- prompt-engineering-patternsSkill
- rag-implementationSkill
- similarity-search-patternsSkill
- vector-index-tuningSkill
- api-design-principlesSkill
- api-designSkill
- architecture-patternsSkill
- cqrs-implementationSkill
- event-store-designSkill
- fastapi-templatesSkill
- microservices-patternsSkill
- openapi-spec-generationSkill
- projection-patternsSkill
- saga-orchestrationSkill
- api-conventionsSkill
- andrew-kane-gem-writerSkill
- angular-migrationSkill
- auth-implementation-patternsSkill
- backend-patternsSkill
- bazel-build-optimizationSkill
- coding-standardsSkill
- database-migrationSkill
- debugging-strategiesSkill
- dependency-upgradeSkill
- dhh-rails-styleSkill
- dotnet-backend-patternsSkill
- dspy-rubySkill
- error-handling-patternsSkill
- monorepo-managementSkill
- nodejs-backend-patternsSkill
- nx-workspace-patternsSkill
- react-modernizationSkill
- temporal-python-testingSkill
- turborepo-cachingSkill
- workflow-orchestration-patternsSkill
- defi-protocol-templatesSkill
- nft-standardsSkill
- solidity-securitySkill
- web3-testingSkill
- backtesting-frameworksSkill
- billing-automationSkill
- competitive-landscapeSkill
- data-storytellingSkill
- employment-contract-templatesSkill
- investor-materialsSkill
- investor-outreachSkill
- kpi-dashboard-designSkill
- market-sizing-analysisSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
38 rules. About 0 are common, 13 are distinctive, and 25 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
25
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 19
Before using sandbox operations, validate the environment:
- Distinctive: line 27
If missing, instruct the user:
- Very specific: line 47
Always validate E2B_API_KEY first: - Don't proceed without it
- Very specific: line 48
Change directory to SANDBOX_CLI_PATH: - All commands must be run from there
- Very specific: line 51
Binary files: - Use upload/download for images, PDFs, executables
- Distinctive: line 70
Use agent sandboxes when the user needs to:
- Very specific: line 89
Get CLI Help: Use sbx --help to see all available commands and options:
- Very specific: line 115
Important: All commands must be run from SANDBOX_CLI_PATH directory.
- Very specific: line 137
For parallel agents: Use --port flag with unique ports (9222-9999).
- Very specific: line 143
Always use
--timeout TIMEOUT_DURATION_IN_SECONDS: when initializing (unless the user specifies a different timeout) - Very specific: line 176
Always start by checking for the E2B_API_KEY:
- Distinctive: line 183
If not found, stop and request the user to add their API key.
- Distinctive: line 187
Create a new sandbox and capture the sandbox ID from the output:
- Distinctive: line 214
Use the appropriate command based on the task, using the sandbox ID you captured:
- Very specific: line 313
Use --background flag to keep server running
- Distinctive: line 314
Port 5173 is the default: - use this unless you have a specific reason not to
- Distinctive: line 315
Ensure your frontend code is configured for the same port
- Very specific: line 319
CRITICAL: Always use the get-host command to retrieve the actual public URL.
- Very specific: line 335
Always use --port 5173 to match your server port
- Distinctive: line 337
Use the exact URL returned by this command
- Distinctive: line 338
Do NOT construct URLs manually (they will fail)
- Very specific: line 395
If you built a frontend or web application, use get-host to retrieve the public URL:
- Very specific: line 402
Do NOT construct the URL manually: - always use the get-host command.
- Very specific: line 421
Note: Always get the actual URL using sbx sandbox get-host <sandbox_id> --port 5173 - never construct it manually.
- Distinctive: line 429
Progressive Disclosure: Read only the example you need for your specific task.
- Very specific: line 471
CLI Help: Run uv run sbx --help for interactive command reference
- Very specific: line 479
Run uv run sbx --help for all available commands
- Very specific: line 480
Run uv run sbx <command> --help for specific command details
- Distinctive: line 481
All commands have built-in help documentation
- Very specific: line 484
Check .env file exists in project root
- Very specific: line 485
Verify key is set: grep E2B_API_KEY .env
- Very specific: line 486
Add key if missing: echo "E2B_API_KEY=key" >> .env
- Distinctive: line 489
Ensure you're in the sandbox_cli directory
- Very specific: line 490
Run with uv run sbx instead of just sbx
- Very specific: line 494
Use --timeout flag on long-running exec commands
- Very specific: line 497
Use --root flag for system operations
- Very specific: line 498
Check file paths are in /home/user/ directory
- Very specific: line 501
Use uv run sbx --help to see command structure
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent Sandboxes
This skill provides access to E2B sandboxes through a streamlined CLI for safe code execution and file operations in isolated environments.
Variables
- E2B_API_KEY: The environment variable containing the E2B API key (stored in the environment file)
- SANDBOX_CLI_PATH:
.claude/skills/agent-sandboxes/sandbox_cli/ - ENVIRONMENT_FILE_PATH:
../../../../.env - TIMEOUT_DURATION_IN_SECONDS:
43200(12 hours)
Prerequisites
Before using sandbox operations, validate the environment:
Check for E2B_API_KEY:
# Verify the API key is set grep "E2B_API_KEY" `ENVIRONMENT_FILE_PATH`If missing, instruct the user:
Error: E2B_API_KEY not found in .env file Please add your E2B API key to the .env file in the project root: echo "E2B_API_KEY=your_api_key_here" >> .env Get your API key from: https://e2b.dev/docs- Verify CLI is available:
The sandbox CLI is located at
SANDBOX_CLI_PATHThe.envfile is automatically loaded from the project root.
Instructions
- IMPORTANT: Don't create files locally, always use the sandbox. Only do this if the user explicitly asks you to do so.
- ALWAYS USE --timeout TIMEOUT_DURATION_IN_SECONDS
- CAPTURE AND REMEMBER SANDBOX ID - Store it in your context, don't use shell variables or files
- Multi-agent safe - Each agent tracks its own sandbox ID independently
- Always validate E2B_API_KEY first - Don't proceed without it
- Change directory to SANDBOX_CLI_PATH - All commands must be run from there
- Use --shell for complex commands - Enables pipes, redirections, wildcards
- Use --cwd instead of cd - More reliable for working directory changes
- Binary files - Use
upload/downloadfor images, PDFs, executables - Never delete the sandbox unless you're explicitly asked to do so - Sandboxes auto-timeout after TIMEOUT_DURATION_IN_SECONDS
Template Tiers
Pre-built templates with different resource levels. Use --template flag with sbx init:
| Template | vCPU | RAM | Cost | Best For |
fullstack-vue-fastapi-node22 | 2 | 2GB | $0.13/hr | Simple apps (default) |
fullstack-vue-fastapi-node22-lite | 2 | 4GB | $0.15/hr | Browser tests |
fullstack-vue-fastapi-node22-standard | 4 | 4GB | $0.27/hr | Parallel builds |
fullstack-vue-fastapi-node22-heavy | 4 | 8GB | $0.33/hr | Multi-browser |
fullstack-vue-fastapi-node22-max | 8 | 8GB | $0.44/hr | Fastest |
Build new templates: uv run build_template.py --tier <tier> or --list-tiers to see options.
When to Use Sandboxes
Use agent sandboxes when the user needs to:
- Run untrusted or experimental code safely
- Test packages or dependencies without affecting the local system
- Execute system commands in an isolated environment
- Work with binary files (images, PDFs, executables)
- Clone and test repositories in isolation
- Install and test different package versions
- Run long-running processes without blocking
CLI Overview
The sandbox CLI has four core command groups:
sbx init- Quick sandbox initializationsbx sandbox- Lifecycle management (create, connect, kill, pause, extend-lifetime, info)sbx files- File operations (ls, read, write, upload, download, rm, mkdir, mv)sbx exec- Unified command execution (the most powerful command)sbx browser- Browser automation for UI validation (visual testing)
Get CLI Help: Use sbx --help to see all available commands and options:
cd SANDBOX_CLI_PATH
uv run sbx --help # Main help
uv run sbx init --help # Help for init command
uv run sbx sandbox --help # Help for sandbox commands
uv run sbx files --help # Help for file operations
uv run sbx exec --help # Help for exec commandKey Command: sbx exec
The exec command is the primary interface for running commands in sandboxes:
uv run sbx exec $SANDBOX_ID "command" [options]
Options:
--cwd PATH Working directory
--env KEY=VALUE Environment variables (multiple allowed)
--root Run as root user
--shell Enable shell features (pipes, redirections, wildcards)
--timeout SECONDS Command timeout (default: 60)
--background Run command in backgroundImportant: All commands must be run from SANDBOX_CLI_PATH directory.
Key Command: sbx browser
Browser automation for visual validation of sandbox applications using Playwright's isolated Chromium.
Commands (all support --port PORT for parallel agents):
sbx browser init # First-time setup (once per machine)
sbx browser start [--headed] # Start browser (--headed shows window)
sbx browser nav <url> # Navigate to URL
sbx browser eval <code> # Run JavaScript, returns result
sbx browser screenshot [--path P] [--full] # Screenshot (--full for entire page)
sbx browser click <selector> # Click element by CSS selector
sbx browser type <selector> <text> # Type text into input field
sbx browser scroll <direction> # up | down | top | bottom
sbx browser a11y # Get accessibility tree (JSON)
sbx browser dom [--full] # Get DOM (--full for raw HTML)
sbx browser status # Check if browser is running
sbx browser close # Close browser and kill processFor parallel agents: Use --port flag with unique ports (9222-9999).
Multi-Agent Considerations
CRITICAL: Multiple agents may be running sandboxes simultaneously. Each agent MUST:
- Always use
--timeout TIMEOUT_DURATION_IN_SECONDSwhen initializing (unless the user specifies a different timeout) - Capture the sandbox ID from
sbx initoutput and remember it in your context - DO NOT use shell variables like
export SANDBOX_ID=...(conflicts with other agents) - DO NOT rely on
.sandbox_idfile (gets overwritten by other agents) - Track the sandbox ID yourself and use it directly in all subsequent commands
- Report the sandbox ID to the user when done
Example of proper ID handling:
# When you run this:
uv run sbx init
# Capture the sandbox ID from output (e.g., "sbx_abc123def456")
# Store it in YOUR context/memory as: sandbox_id = "sbx_abc123def456"
# Then use it directly in all commands:
uv run sbx exec sbx_abc123def456 "python --version"
uv run sbx files write sbx_abc123def456 /home/user/test.py "print('hello')"Cookbook
Extended documentation for specific features. Read these when you need to use the feature.
| Feature | When to Read | Documentation |
| Browser Automation | When validating UIs, taking screenshots, or interacting with web pages | cookbook/browser.md |
Workflow
Step 1: Validate Environment
Always start by checking for the E2B_API_KEY:
cd SANDBOX_CLI_PATH
grep "E2B_API_KEY" `ENVIRONMENT_FILE_PATH`If not found, stop and request the user to add their API key.
Step 2: Initialize Sandbox and Capture ID
Create a new sandbox and capture the sandbox ID from the output:
cd SANDBOX_CLI_PATH
uv run sbx init --timeout TIMEOUT_DURATION_IN_SECONDSCRITICAL:
- Always use
--timeout TIMEOUT_DURATION_IN_SECONDS - The command will output a sandbox ID (e.g.,
sbx_abc123def456) - Capture this ID and remember it in your context
- DO NOT use environment variables or files to store it
- Use this exact ID in all subsequent commands
Additional options (optional):
--template NAME- Use a specific template (default: base)--env KEY=VALUE- Set environment variables
Example:
uv run sbx init --timeout TIMEOUT_DURATION_IN_SECONDS
# Output: Created sandbox: sbx_abc123def456
# YOU remember: sandbox_id = "sbx_abc123def456"Step 3: Perform Operations
Use the appropriate command based on the task, using the sandbox ID you captured:
Run commands (replace <sandbox_id> with your captured ID):
uv run sbx exec <sandbox_id> "python --version"
uv run sbx exec <sandbox_id> "pip list" --cwd /home/user/projectFile operations:
uv run sbx files write <sandbox_id> /home/user/script.py "print('hello')"
uv run sbx files read <sandbox_id> /home/user/output.txt
uv run sbx files upload <sandbox_id> ./local.png /home/user/image.png
uv run sbx files edit <sandbox_id> /home/user/config.ts --old "old text" --new "new text"
uv run sbx files edit <sandbox_id> /home/user/config.ts --old "find" --new "replace" --allDownload directories (clone sandbox code locally):
# Download directory (excludes .venv, node_modules, .git, __pycache__ by default)
uv run sbx files download-dir <sandbox_id> /home/user/project ./local/project
# Include everything (no exclusions)
uv run sbx files download-dir <sandbox_id> /home/user/project ./local/project --allIMPORTANT - Writing Files with Special Characters:
The sbx files write command has limitations with special characters like brackets [] when passing content as an argument due to shell glob expansion. Use one of these workarounds:
Option 1: Use --stdin flag (recommended):
# Pipe content through stdin to avoid shell escaping issues
echo 'const arr = [1, 2, 3]; const val = obj["key"];' | uv run sbx files write <sandbox_id> /home/user/file.js --stdin
# Or with heredoc
uv run sbx files write <sandbox_id> /home/user/file.js --stdin << 'EOF'
const arr = [1, 2, 3];
const value = obj["key"];
EOFOption 2: Write locally, then upload:
# Write file locally first (using Write tool)
# Then upload to sandbox - bypasses shell escaping entirely
uv run sbx files upload <sandbox_id> ./local/file.js /home/user/file.jsOption 3: Use sbx exec with heredoc or Python:
# Use cat heredoc for complex content
uv run sbx exec <sandbox_id> "cat > /home/user/file.js << 'EOF'
const arr = [1, 2, 3];
const value = obj['key'];
EOF
" --shell
# Or use Python to write files
uv run sbx exec <sandbox_id> "python3 << 'EOF'
with open('/home/user/file.js', 'w') as f:
f.write('''const arr = [1, 2, 3];
const value = obj[\"key\"];''')
EOF
" --shellInstall packages:
# Install uv package manager
uv run sbx exec <sandbox_id> "curl -LsSf https://astral.sh/uv/install.sh | sh" --shell --timeout 120
# Install Python packages
uv run sbx exec <sandbox_id> "/home/user/.local/bin/uv pip install --system requests"Step 4: Expose Frontend (If Applicable)
When building applications with a frontend/UI, create a lightweight server to host your work and expose it:
4.1: Start the Server
Always default to port 5173 and ensure your frontend is configured to use this port:
# For Python/Flask
uv run sbx exec <sandbox_id> "python -m http.server 5173" --background --cwd /home/user/project
# For Node/React (Vite)
uv run sbx exec <sandbox_id> "npm run dev -- --port 5173" --background --cwd /home/user/project
# For static HTML/CSS/JS
uv run sbx exec <sandbox_id> "python -m http.server 5173" --background --cwd /home/user/dist
# For a custom Python server
uv run sbx files write <sandbox_id> /home/user/server.py "from flask import Flask; app = Flask(__name__); app.run(host='0.0.0.0', port=5173)"
uv run sbx exec <sandbox_id> "python /home/user/server.py" --backgroundKey points:
- Use
--backgroundflag to keep server running - Port 5173 is the default - use this unless you have a specific reason not to
- Ensure your frontend code is configured for the same port
4.2: Get the Exposed URL
CRITICAL: Always use the get-host command to retrieve the actual public URL. Do NOT try to construct or infer the URL.
uv run sbx sandbox get-host <sandbox_id> --port 5173This command returns the authoritative public URL (format: https://5173-<sandbox_id>.e2b.app).
Example:
uv run sbx sandbox get-host sbx_abc123def456 --port 5173
# Output: https://5173-sbx_abc123def456.e2b.app
# YOU capture and remember this URL in your contextImportant:
- Always use
--port 5173to match your server port - Capture the URL in your context/memory (not shell variables)
- Use the exact URL returned by this command
- Do NOT construct URLs manually (they will fail)
4.3: Verify It's Working
Get the URL using get-host and test it:
# Get the URL (captures output: https://5173-<sandbox_id>.e2b.app)
uv run sbx sandbox get-host <sandbox_id> --port 5173
# YOU remember the URL in your context, then test it
curl https://5173-<sandbox_id>.e2b.appNote: Capture the URL from get-host output and remember it in your context. Use the exact URL in subsequent commands.
Important:
- The server must listen on
0.0.0.0(notlocalhostor127.0.0.1) - Port must match between server and frontend configuration
- The sandbox will remain alive until TIMEOUT_DURATION_IN_SECONDS
Pausing, Resuming, and Extending Sandboxes
Pause a sandbox (beta feature):
uv run sbx sandbox pause <sandbox_id>Resume a paused sandbox (use connect):
uv run sbx sandbox connect <sandbox_id>Extend sandbox lifetime (adds time to remaining):
uv run sbx sandbox extend-lifetime <sandbox_id> <seconds_to_add>Examples:
# Add 1 hour to remaining time
uv run sbx sandbox extend-lifetime <sandbox_id> 3600
# Add 3 hours
uv run sbx sandbox extend-lifetime <sandbox_id> 10800
# Add 12 hours
uv run sbx sandbox extend-lifetime <sandbox_id> 43200The extend-lifetime command adds the specified seconds to the remaining lifetime. If a sandbox has 30m left and you add 1h, it will have 1h 30m remaining.
Step 5: Report Results
Report the results to the user with the sandbox information:
5.1: Get the Sandbox URL (if frontend/web app)
If you built a frontend or web application, use get-host to retrieve the public URL:
uv run sbx sandbox get-host <sandbox_id> --port 5173This returns the actual URL (e.g., https://5173-<sandbox_id>.e2b.app).
Do NOT construct the URL manually - always use the get-host command.
5.2: Report to User
Provide the user with:
- The sandbox ID - So they can reference it if needed
- The URL (if applicable) - So they can access the application
- Timeout information - Let them know the sandbox timeout (TIMEOUT_DURATION_IN_SECONDS)
Example report:
✓ Sandbox created successfully!
Sandbox ID: sbx_abc123def456
Application URL: [Use: uv run sbx sandbox get-host sbx_abc123def456 --port 5173]
Your sandbox will automatically terminate after TIMEOUT_DURATION_IN_SECONDS.Note: Always get the actual URL using sbx sandbox get-host <sandbox_id> --port 5173 - never construct it manually.
IMPORTANT:
- Never delete the sandbox unless you're explicitly asked to do so
- Sandboxes will automatically timeout after TIMEOUT_DURATION_IN_SECONDS
Examples
Progressive Disclosure: Read only the example you need for your specific task.
Example 1: Run Python Code Safely
Read when: User needs to run/test Python code in isolation. See: examples/01_run_python_code.md
Covers: Basic sandbox workflow, writing scripts, executing Python code, capturing sandbox ID.
Example 2: Test a Package
Read when: User needs to install and test Python packages. See: examples/02_test_package.md
Covers: Installing uv package manager, installing Python packages, testing package functionality.
Example 3: Clone and Test Repository
Read when: User needs to clone a GitHub repo and run tests or commands in it. See: examples/03_clone_and_test_repo.md
Covers: Git operations, using --cwd flag, running commands in repository context, longer timeouts.
Example 4: Process Binary Files
Read when: User needs to upload, process, or download binary files (images, PDFs). See: examples/04_process_binary_files.md
Covers: Binary file upload/download, image processing, using appropriate file operations for binary vs text.
Example 5: Host Frontend Application
Read when: User wants to build a web app, UI, dashboard, or any frontend accessible via browser. See: examples/05_host_frontend.md
Covers: Exposing frontends, using port 5173, starting servers in background, getting public URLs, keeping sandboxes alive.
Reference
Built-in CLI Help:
cd SANDBOX_CLI_PATH
uv run sbx --help # Overview of all commands
uv run sbx <command> --help # Detailed help for specific commandFor complete command reference and advanced usage, see:
- CLI Help: Run
uv run sbx --helpfor interactive command reference - Full documentation:
SANDBOX_CLI_PATH/README.md - Architecture details: Command groups, modules, and design principles
- Advanced examples: Multi-step workflows, git operations, package management
Troubleshooting
"Need help with a command":
- Run
uv run sbx --helpfor all available commands - Run
uv run sbx <command> --helpfor specific command details - All commands have built-in help documentation
"E2B_API_KEY not found":
- Check
.envfile exists in project root - Verify key is set:
grep E2B_API_KEY .env - Add key if missing:
echo "E2B_API_KEY=key" >> .env
"Command not found: sbx":
- Ensure you're in the sandbox_cli directory
- Run with
uv run sbxinstead of justsbx
"Sandbox timeout":
- Increase timeout:
sbx init --timeout 900 - Use
--timeoutflag on long-running exec commands
"Permission denied":
- Use
--rootflag for system operations - Check file paths are in
/home/user/directory
"Forgot command syntax":
- Use
uv run sbx --helpto see command structure - Each command group has detailed help with examples
Browser issues: See cookbook/browser.md for troubleshooting.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

