npx skills add ...
npx skills add denoland/skills --skill deno-sandbox
Use when building features that execute untrusted user code, AI-generated code, or need isolated code execution environments. Covers the @deno/sandbox SDK.
npx skills add denoland/skills --skill deno-sandbox
Deno Sandboxes provide secure, isolated environments for running untrusted code. Each sandbox runs in its own Linux microVM (using Firecracker, the same technology as AWS Lambda) with a separate filesystem, network, and process space. This makes them ideal for code playgrounds, AI agent tool execution, and multi-tenant applications.
Reference: https://deno.com/deploy/sandboxes
Use Deno Sandboxes when you need to:
This skill applies only to Deno Sandbox (@deno/sandbox) questions. Follow
these rules:
@deno/sandbox imports, Sandbox.create(), or
sandbox.spawn() in responses about other isolation technologies.Sandboxes are resources that must be disposed when done. Always use
await using for automatic cleanup:
CRITICAL: Never show const sandbox = await Sandbox.create() without
await using. Always use the await using pattern for sandbox creation. Do not
show manual disposal alternatives.
The spawn method runs commands inside the sandbox:
For interactive processes or long-running commands:
Sandboxes have configurable resources:
Each sandbox comes with:
Sandboxes can be deployed directly to Deno Deploy:
The sandbox SDK works seamlessly in the Deno Deploy environment.
For the complete API, run:
Key classes:
Sandbox - Main class for creating/managing sandboxesChildProcess - Represents a running processClient - For managing Deploy resources (apps, volumes)| Task | Code |
|---|---|
| Create sandbox | await using sandbox = await Sandbox.create() |
| Run command | sandbox.spawn("cmd", { args: [...] }) |
| Get output | const output = await child.output() |
| Write file | await sandbox.fs.writeFile(path, content) |
| Read file | await sandbox.fs.readFile(path) |
| Kill process | await child.kill() |
| Check status | const status = await child.status |
Forgetting automatic disposal
Giving user code too many permissions
Not handling process output properly
Not setting timeouts for user code execution
Trusting sandbox output without validation