Official agent skill

Deno Sandbox SDK

by denoland in denoland/skills

Runs untrusted or AI-generated code in isolated Deno Sandbox microVMs using the @deno/sandbox SDK, with lifecycle, process and streaming guidance.

OfficialMITAuto-check passedDevelopment

Install Deno Sandbox SDK

skills CLI
$ npx skills add denoland/skills --skill deno-sandbox -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install denoland/skills deno-sandbox --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/denoland/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/deno-sandbox .claude/skills/deno-sandbox && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
deno-sandbox
GitHub stars
100
Token cost
~2.7k tokens
SKILL.md length
429 words
Files
1
Skills in repo
5
Repo updated
First seen
Licence
MIT

At a glance

Runs untrusted or AI-generated code in isolated Deno Sandbox microVMs using the @deno/sandbox SDK, with lifecycle, process and streaming guidance.

  • Building a feature that runs user-submitted code safely
  • SKILL.md covers Overview, When to Use Sandboxes, Scope Boundaries and Getting Started, plus 7 more sections
  • Calls deno
  • Executing AI-generated code in an isolated environment

What it does

Deno Sandboxes give each run its own Linux microVM, built on Firecracker, the same technology as AWS Lambda, with a separate filesystem, network and process space. The skill covers installing `jsr:@deno/sandbox` with `deno add`, creating a sandbox, and running commands with `spawn`, including piped stdin, streaming I/O for interactive processes and killing processes.

Sandboxes must be disposed when done, so examples always use the `await using` pattern and never show a bare create call. Scope is strict: it applies only to Deno Sandbox questions, and for Docker, vm2, Web Workers, Lambda isolation or other technologies the agent answers with that technology rather than suggesting Deno Sandboxes. It suits code playgrounds, running AI agent tool output, multi-tenant execution and isolated tests.

When your agent uses it

  • Building a feature that runs user-submitted code safely
  • Executing AI-generated code in an isolated environment
  • Creating a code playground or multi-tenant execution service in Deno

Example prompts

  • “Add a Deno Sandbox so our app can run user-submitted TypeScript safely.”
  • “Show how to spawn a process in a sandbox and stream its output.”
  • “Run the generated test script inside an isolated sandbox and kill it after a timeout.”

Requirements

  • Deno
  • The `@deno/sandbox` package from JSR

What it can do on your machine

Read from SKILL.md and the folder at commit d5f6ace. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • deno

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • deno.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Deno Sandbox SDK loads about 2.7k tokens when it runs. Until then it costs about 42 tokens; SKILL.md has 429 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~42
When it runs · the whole SKILL.md, loaded when a task matches
~2.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from denoland/skills at commit d5f6ace, republished under its MIT licence (© denoland). 429 words, ~2,656 tokens.

Download SKILL.mdSave it as .claude/skills/deno-sandbox/SKILL.md (or your agent's skills folder).
name
deno-sandbox
description
Use when building features that execute untrusted user code, AI-generated code, or need isolated code execution environments. Covers the @deno/sandbox SDK.
license
MIT
metadata.author
denoland
metadata.version
1.1

Deno Sandboxes

Overview

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

When to Use Sandboxes

Use Deno Sandboxes when you need to:

  • Run user-submitted code safely
  • Execute AI-generated code
  • Build code playground platforms
  • Create multi-tenant code execution environments
  • Run automated tests in isolation

Scope Boundaries

This skill applies only to Deno Sandbox (@deno/sandbox) questions. Follow these rules:

  • If the user asks about Docker containers, Node.js vm2/vm, Web Workers, AWS Lambda isolation, or any other isolation technology, answer using that technology directly. Do not suggest Deno Sandboxes as an alternative.
  • Do not include @deno/sandbox imports, Sandbox.create(), or sandbox.spawn() in responses about other isolation technologies.
  • Only recommend Deno Sandboxes when the user explicitly asks about them or is building code execution features in a Deno project.

Getting Started

Installation
bash
deno add jsr:@deno/sandbox
Basic Usage
typescript
import { Sandbox } from "@deno/sandbox";

// Create a sandbox (auto-disposed when scope ends)
await using sandbox = await Sandbox.create();

// Run a command
const child = await sandbox.spawn("echo", { args: ["Hello from sandbox!"] });
const output = await child.output();

console.log(new TextDecoder().decode(output.stdout));
// Output: Hello from sandbox!

Core Concepts

Sandbox Lifecycle

Sandboxes are resources that must be disposed when done. Always use await using for automatic cleanup:

typescript
await using sandbox = await Sandbox.create();
// Sandbox is automatically destroyed when this scope ends

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.

Running Processes

The spawn method runs commands inside the sandbox:

typescript
const child = await sandbox.spawn("deno", {
  args: ["run", "script.ts"],
  stdin: "piped", // Enable stdin
  stdout: "piped", // Capture stdout
  stderr: "piped", // Capture stderr
});

// Wait for completion and get output
const output = await child.output();
console.log("Exit code:", output.code);
console.log("Stdout:", new TextDecoder().decode(output.stdout));
console.log("Stderr:", new TextDecoder().decode(output.stderr));
Streaming I/O

For interactive processes or long-running commands:

typescript
const child = await sandbox.spawn("deno", {
  args: ["repl"],
  stdin: "piped",
  stdout: "piped",
});

// Write to stdin
const writer = child.stdin!.getWriter();
await writer.write(new TextEncoder().encode("console.log('Hello')\n"));
await writer.close();

// Read from stdout
const reader = child.stdout!.getReader();
while (true) {
  const { done, value } = await reader.read();
  if (done) break;
  console.log(new TextDecoder().decode(value));
}
Killing Processes
typescript
const child = await sandbox.spawn("sleep", { args: ["60"] });

// Kill with SIGTERM (default)
await child.kill();

// Or with specific signal
await child.kill("SIGKILL");

// Wait for exit
const status = await child.status;
console.log("Exited with signal:", status.signal);

Common Patterns

Running User Code Safely
typescript
import { Sandbox } from "@deno/sandbox";

async function runUserCode(code: string): Promise<string> {
  await using sandbox = await Sandbox.create();

  // Write user code to a file in the sandbox
  await sandbox.fs.writeFile("/tmp/user_code.ts", code);

  // Run with restricted permissions
  const child = await sandbox.spawn("deno", {
    args: [
      "run",
      "--allow-none", // No permissions
      "/tmp/user_code.ts",
    ],
    stdout: "piped",
    stderr: "piped",
  });

  const output = await child.output();

  if (output.code !== 0) {
    throw new Error(new TextDecoder().decode(output.stderr));
  }

  return new TextDecoder().decode(output.stdout);
}
Code Playground
typescript
import { Sandbox } from "@deno/sandbox";

interface ExecutionResult {
  success: boolean;
  output: string;
  error?: string;
  executionTime: number;
}

async function executePlayground(code: string): Promise<ExecutionResult> {
  const start = performance.now();

  await using sandbox = await Sandbox.create();

  await sandbox.fs.writeFile("/playground/main.ts", code);

  const child = await sandbox.spawn("deno", {
    args: ["run", "--allow-net", "/playground/main.ts"],
    stdout: "piped",
    stderr: "piped",
  });

  const output = await child.output();
  const executionTime = performance.now() - start;

  return {
    success: output.code === 0,
    output: new TextDecoder().decode(output.stdout),
    error: output.code !== 0
      ? new TextDecoder().decode(output.stderr)
      : undefined,
    executionTime,
  };
}
AI Agent Tool Execution
typescript
import { Sandbox } from "@deno/sandbox";

async function executeAgentTool(
  toolCode: string,
  input: unknown,
): Promise<unknown> {
  await using sandbox = await Sandbox.create();

  // Create a wrapper that handles input/output
  const wrapper = `
    const input = ${JSON.stringify(input)};
    const tool = await import("/tool.ts");
    const result = await tool.default(input);
    console.log(JSON.stringify(result));
  `;

  await sandbox.fs.writeFile("/tool.ts", toolCode);
  await sandbox.fs.writeFile("/run.ts", wrapper);

  const child = await sandbox.spawn("deno", {
    args: ["run", "--allow-net", "/run.ts"],
    stdout: "piped",
    stderr: "piped",
  });

  const output = await child.output();

  if (output.code !== 0) {
    throw new Error(new TextDecoder().decode(output.stderr));
  }

  return JSON.parse(new TextDecoder().decode(output.stdout));
}

Sandbox Features

Show full SKILL.md (179 more words)Show less
Resource Configuration

Sandboxes have configurable resources:

  • Default: 2 vCPUs, 512MB memory, 10GB disk
  • Startup time: Under 200ms
What's Included

Each sandbox comes with:

  • TypeScript/JavaScript runtime (Deno)
  • Full Linux environment
  • Network access (can be restricted)
  • Temporary filesystem
Security Features
  • Firecracker microVMs - Same technology as AWS Lambda
  • Full isolation - Separate kernel, filesystem, network
  • No data leakage - Sandboxes can't access host system
  • Enforced policies - Control outbound connections

Deploying Sandboxes

Sandboxes can be deployed directly to Deno Deploy:

bash
deno deploy --prod

The sandbox SDK works seamlessly in the Deno Deploy environment.

API Reference

For the complete API, run:

bash
deno doc jsr:@deno/sandbox

Key classes:

  • Sandbox - Main class for creating/managing sandboxes
  • ChildProcess - Represents a running process
  • Client - For managing Deploy resources (apps, volumes)

Quick Reference

TaskCode
Create sandboxawait using sandbox = await Sandbox.create()
Run commandsandbox.spawn("cmd", { args: [...] })
Get outputconst output = await child.output()
Write fileawait sandbox.fs.writeFile(path, content)
Read fileawait sandbox.fs.readFile(path)
Kill processawait child.kill()
Check statusconst status = await child.status

Common Mistakes

Forgetting automatic disposal

typescript
// ❌ Wrong - always use "await using" for sandbox creation
// Never write: const sandbox = await Sandbox.create() without "await using"

// ✅ Correct - use "await using" for automatic cleanup
await using sandbox = await Sandbox.create();
await sandbox.spawn("echo", { args: ["hello"] });
// sandbox automatically disposed when scope ends

Giving user code too many permissions

typescript
// ❌ Wrong - gives untrusted code full access
const child = await sandbox.spawn("deno", {
  args: ["run", "--allow-all", "/tmp/user_code.ts"],
});

// ✅ Correct - restrict permissions to what's needed
const child = await sandbox.spawn("deno", {
  args: ["run", "--allow-none", "/tmp/user_code.ts"], // No permissions
});

// Or if network is truly needed:
const child = await sandbox.spawn("deno", {
  args: ["run", "--allow-net", "/tmp/user_code.ts"], // Only network
});

Not handling process output properly

typescript
// ❌ Wrong - forgetting to pipe stdout/stderr
const child = await sandbox.spawn("deno", { args: ["run", "script.ts"] });
const output = await child.output();
// output.stdout is empty because we didn't pipe it!

// ✅ Correct - pipe the streams you need
const child = await sandbox.spawn("deno", {
  args: ["run", "script.ts"],
  stdout: "piped",
  stderr: "piped",
});
const output = await child.output();
console.log(new TextDecoder().decode(output.stdout));

Not setting timeouts for user code execution

typescript
// ❌ Wrong - user code could run forever
const child = await sandbox.spawn("deno", {
  args: ["run", "/tmp/user_code.ts"],
});
await child.output(); // Could hang indefinitely

// ✅ Correct - implement timeout handling
const child = await sandbox.spawn("deno", {
  args: ["run", "/tmp/user_code.ts"],
  stdout: "piped",
  stderr: "piped",
});

// Set a timeout to kill the process
const timeoutId = setTimeout(() => child.kill(), 5000); // 5 second limit

try {
  const output = await child.output();
  return output;
} finally {
  clearTimeout(timeoutId);
}

Trusting sandbox output without validation

typescript
// ❌ Wrong - directly using untrusted output as code
const result = await runUserCode(code);
// Never execute or inject untrusted output!

// ✅ Correct - validate and sanitize output
const result = await runUserCode(code);
try {
  const parsed = JSON.parse(result); // Parse as data, not code
  if (isValidResponse(parsed)) {
    return parsed;
  }
} catch {
  throw new Error("Invalid response from sandbox");
}

© denoland, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/deno-sandbox of denoland/skills.

Open the folder on GitHubat commit d5f6ace

Compare with similar skills

Deno Sandbox SDK next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Deno Sandbox SDK compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Deno Sandbox SDK this skilldenoland/skills100—~2.7kAutomated safety check: PassMIT
npm Supply Chain Securitybodadotsh/npm-security-best-practices858—~1kAutomated safety check: WarnMIT
Dddswamp-club/swamp646—~1.4kAutomated safety check: PassCustom licence
TS SDK Authormindfold-ai/Trellis15k—~6.1kAutomated safety check: PassMIT
Deno Scriptcataclysmbn/Cataclysm-BN1.3k—~1.8kAutomated safety check: PassCustom licence
evlog Framework Integrationevloghq/evlog1.9k—~5kAutomated safety check: NotesMIT

Similar skills

  • npm Supply Chain Security

    bodadotsh/npm-security-best-practices

    Applies safer package manager defaults and dependency vetting to JavaScript and TypeScript projects to reduce supply-chain attack risk.

    858 GitHub stars~1k tokensUpdated 9 days ago
    SecurityAuto-check: warnings
  • Ddd

    swamp-club/swamp

    Domain Driven Design guidance for TypeScript/Deno codebases.

    646 GitHub stars~1.4k tokensUpdated today
    DevelopmentAuto-check passed
  • TS SDK Author

    mindfold-ai/Trellis

    Design, build, verify, and publish production-grade TypeScript SDKs as npm packages inside a pnpm monorepo.

    15k GitHub stars~6.1k tokensUpdated 11 days ago
    DevelopmentAuto-check passed
  • Deno Script

    cataclysmbn/Cataclysm-BN

    Write or modify Cataclysm-BN Deno/TypeScript scripts. An agent skill from cataclysmbn/Cataclysm-BN.

    1.3k GitHub stars~1.8k tokensUpdated today
    DevelopmentAuto-check passed
  • Walks a contributor through adding a new HTTP framework integration to the evlog logging package: middleware source, build entry, exports, tests, example app and docs.

    1.9k GitHub stars~5k tokensUpdated today
    DevelopmentAuto-check: notes
  • Swpm Manage Commands Args

    deinsoftware/swpm

    Manage cmds and args props in SWPM package manager configs (src/packages/managers/.ts), including adding, modifying or removing command and argument mappings across npm, yarn, pnpm, bun, deno.

    125 GitHub stars~1.5k tokensUpdated 4 mo ago
    DevelopmentAuto-check passed

More from denoland/skills

  • Official

    Guides writing, running and configuring Deno 2.9+ projects: installing npm and JSR dependencies, permissions, config file precedence and the built-in fmt, lint, test and compile toolchain.

    100 GitHub stars~2.7k tokensUpdated 2 mo ago
    Auto-check passed
  • Official

    Chooses between running regular npm frontend frameworks under Deno and building with Fresh, Deno's island-architecture framework, with Fresh 2.x guidance.

    100 GitHub stars~783 tokensUpdated 2 mo ago
    Auto-check passed
  • Deno Deploy

    denoland/skills

    Official

    Guides deploying Deno apps with the deno deploy CLI, including pre-flight checks, environment variables, Deno KV, custom domains and the --tunnel flag for local development.

    100 GitHub stars~5.5k tokensUpdated 2 mo ago
    Auto-check: notes
  • Migrate to Deno

    denoland/skills

    Official

    Moves a Node.js, npm, Yarn, pnpm or Bun project to Deno in reversible steps, starting with Deno as the package manager and changing no code unless needed.

    100 GitHub stars~2.2k tokensUpdated 2 mo ago
    Auto-check: warnings

Works with

Questions about Deno Sandbox SDK

What does Deno Sandbox SDK do?

Runs untrusted or AI-generated code in isolated Deno Sandbox microVMs using the @deno/sandbox SDK, with lifecycle, process and streaming guidance. Deno Sandboxes give each run its own Linux microVM, built on Firecracker, the same technology as AWS Lambda, with a separate filesystem, network and process space. The skill covers installing `jsr:@deno/sandbox` with `deno add`, creating a sandbox, and running commands with `spawn`, including piped stdin, streaming I/O for interactive processes and killing processes.

When should I use Deno Sandbox SDK?

Deno Sandbox SDK fits situations like: building a feature that runs user-submitted code safely; executing AI-generated code in an isolated environment; creating a code playground or multi-tenant execution service in Deno.

How do I install Deno Sandbox SDK in Claude Code?

Run `npx skills add denoland/skills --skill deno-sandbox -a claude-code`. Or copy the skill folder (skills/deno-sandbox in denoland/skills) into .claude/skills/deno-sandbox in your project. Claude Code loads it when a task matches its description.

How do I install Deno Sandbox SDK in Codex?

Run `npx skills add denoland/skills --skill deno-sandbox -a codex`. Or copy the skill folder (skills/deno-sandbox in denoland/skills) into .agents/skills/deno-sandbox in your project. Codex loads it when a task matches its description.

Can I use Deno Sandbox SDK in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add denoland/skills --skill deno-sandbox -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/deno-sandbox, .gemini/skills/deno-sandbox, .github/skills/deno-sandbox and .opencode/skills/deno-sandbox in your project.

What does Deno Sandbox SDK need to run?

Going by SKILL.md and its folder, Deno Sandbox SDK needs the command-line tools its instructions call (deno). Our summary lists: Deno; The `@deno/sandbox` package from JSR.

Does Deno Sandbox SDK access the network?

SKILL.md names 1 domain. As links in the text: deno.com. This is read from the text; nothing was executed.

Is Deno Sandbox SDK safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Deno Sandbox SDK use?

Deno Sandbox SDK is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Deno Sandbox SDK use?

About 2.7k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Deno Sandbox SDK?

Skills that share tags, products or a category with Deno Sandbox SDK: npm Supply Chain Security (bodadotsh/npm-security-best-practices, 858 stars), Ddd (swamp-club/swamp, 646 stars), TS SDK Author (mindfold-ai/Trellis, 15k stars) and Deno Script (cataclysmbn/Cataclysm-BN, 1.3k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Deno Sandbox SDK?

denoland (a GitHub organization, an official publisher) maintains it in denoland/skills, which has 100 GitHub stars. The repository holds 5 skills in this directory. The repository was last updated on July 29, 2026.

Source: denoland/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.