Overview
ZapDev uses E2B (Execute to Build) to provide isolated sandbox environments where AI agents can safely generate, test, and validate code without affecting your local system. Each code generation session runs in a dedicated, pre-configured sandbox with all necessary dependencies installed and ready to use.E2B sandboxes are Docker-based microVMs that boot in seconds and provide a full Linux environment with Node.js, npm, and framework-specific tooling.
How E2B Sandboxes Work
Sandbox Lifecycle
- Provisioning - When you start a generation, a fresh E2B sandbox is created
- Pre-warming - Framework template loads with dependencies pre-installed
- Code Generation - AI writes files directly into the sandbox filesystem
- Validation - Build and lint commands execute in the sandbox
- Cleanup - Sandbox terminates after generation completes
Pre-Warmed Templates
ZapDev uses custom E2B templates for each framework to eliminate cold start times:- Next.js Template
- Angular Template
- React Template
- Vue Template
- Svelte Template
Base Image: Port: 3000
node:21-slimPre-installed:- Next.js 15.3.3 with Turbopack
- Shadcn UI component library
- Tailwind CSS v4
- TypeScript strict mode
/compile_page.shSandbox File System
All code generation happens in the/home/user directory:
The AI uses relative paths only (e.g.,
app/page.tsx) when creating files. Absolute paths like /home/user/app/page.tsx are used internally for reading.Sandbox Operations
File Operations
AI agents interact with the sandbox filesystem through optimized tools:Terminal Commands
The AI can execute commands in the sandbox:Security & Isolation
E2B provides multiple layers of security:Isolation Guarantees
- ✅ Network isolation - No access to your local network
- ✅ Filesystem isolation - Cannot access your files
- ✅ Process isolation - Runs in dedicated microVM
- ✅ Resource limits - CPU/memory caps prevent abuse
- ✅ Automatic cleanup - Sandboxes are destroyed after use
What AI Can Do
- ✅ Write files to
/home/user - ✅ Install npm packages
- ✅ Run build/lint commands
- ✅ Read generated files
- ✅ Execute Node.js scripts
What AI Cannot Do
- ❌ Access your local filesystem
- ❌ Make external API calls
- ❌ Access environment variables (unless explicitly set)
- ❌ Modify system files outside
/home/user - ❌ Persist data after sandbox termination
Building Custom Templates
You can build your own E2B templates for custom environments:Prerequisites
Template Structure
Build & Deploy
Use in Code
Performance Optimizations
ZapDev implements several optimizations for faster sandboxes:Pre-Warming Strategy
Templates include startup scripts that pre-compile frameworks:Batch File Operations
Instead of writing files one-by-one (O(N) network calls), ZapDev uses Python scripts for batch operations:Parallel Validation
Build and lint checks run concurrently when possible:Sandbox Lifecycle Management
Creation
File Management
Process Execution
Cleanup
Cost & Resource Limits
E2B sandboxes have the following limits:| Resource | Free Tier | Pro Tier |
|---|---|---|
| Sandbox Lifetime | 5 minutes | 15 minutes |
| Memory | 512 MB | 2 GB |
| CPU | 1 core | 2 cores |
| Disk Space | 2 GB | 10 GB |
| Concurrent Sandboxes | 1 | 5 |
ZapDev automatically manages sandbox resources to stay within limits. Long-running generations may timeout on the free tier.
Troubleshooting
Sandbox takes too long to boot
Sandbox takes too long to boot
Cause: Template not pre-built or Docker not runningSolution:
- Ensure Docker is running locally
- Build template:
e2b template build --name your-template - Verify template exists:
e2b template list
Package installation fails
Package installation fails
Cause: Network issues or registry problemsSolution:
Build errors not auto-fixed
Build errors not auto-fixed
Cause: Complex TypeScript errors or missing dependenciesSolution: Check that dependencies are installed:
Ports remain closed (expected)
Ports remain closed (expected)
Cause: Dev servers don’t run in sandboxesSolution: This is normal. Code is validated via
npm run build, not runtime. Ports staying closed is expected behavior.Next Steps
AI Code Generation
Learn how AI agents generate code in sandboxes
Live Preview
See how generated code renders in real-time
File Explorer
Browse sandbox files with syntax highlighting
Multi-Framework Support
Explore all pre-configured templates