Agent Sandboxes
FreeRuns bundled scriptsNot checkedOperate 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…
About this skill
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/docsVerify 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 command
Key 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 background
Important: 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 scree
Install Agent Sandboxes in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
FAQ
What does the Agent Sandboxes skill do?
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.
How do I install the Agent Sandboxes skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the Agent Sandboxes skill run scripts?
Yes, this skill bundles executable scripts. Review the source before installing.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic