sandbox
БесплатноБез исполняемых скриптовНе проверенCreates isolated Linux MicroVMs using Vercel Sandbox SDK. Use when building code execution environments, running untrusted code, spinning up dev servers…
от vercel★ 356 звёзд на GitHubОб этом скилле
CRITICAL: Always Use Correct @vercel/sandbox Documentation
Your knowledge of @vercel/sandbox may be outdated.
Follow these instructions before starting on any sandbox-related tasks:
Official Resources
- Documentation: https://vercel.com/docs/vercel-sandbox
- SDK Reference: https://vercel.com/docs/vercel-sandbox/sdk-reference
- CLI Reference: https://vercel.com/docs/vercel-sandbox/cli-reference
- GitHub: https://github.com/vercel/sandbox
- REST API: https://vercel.com/docs/rest-api/sandboxes
What changed in v2
The @vercel/sandbox@2 SDK and sandbox@3 CLI replace anonymous, ephemeral
sandboxes with named, persistent sandboxes. Key differences from v1:
- Sandboxes are identified by
name(notsandboxId). Names are unique per project. - Sandboxes are persistent by default — when a sandbox stops, the SDK automatically snapshots it and restores the filesystem on the next resume.
- A Session is a single running VM instance inside a sandbox. SDK calls
like
runCommand,writeFiles, etc. automatically resume a stopped sandbox. - New methods:
Sandbox.getOrCreate,Sandbox.fork,sandbox.update,sandbox.delete,sandbox.listSessions,sandbox.listSnapshots,Snapshot.tree,defineSandboxProxy. - New params:
name,persistent,tags,onResume,snapshotExpiration,keepLastSnapshots, L7 network policy matchers,forwardURL. - Pagination uses cursor-based iterators (async-iterable) instead of
since/until. Sandbox.list({ since, until })→Sandbox.list({ cursor, namePrefix, sortBy, tags }).- v1 sandboxes are backfilled so the only required code change is using
nameinstead ofsandboxId.
Quick Reference
Essential imports:
// Core SDK
import {
Sandbox,
Session,
Snapshot,
Drive,
Command,
CommandFinished,
} from "@vercel/sandbox";
import { APIError, StreamError } from "@vercel/sandbox";
// For advanced network policy with credential brokering and L7 matchers
import type {
NetworkPolicy,
NetworkPolicyRule,
NetworkTransformer,
} from "@vercel/sandbox";
// For implementing a request-forwarding proxy (forwardURL)
import { defineSandboxProxy } from "@vercel/sandbox/proxy";
// For timeouts
import ms from "ms"; // e.g., ms("5m"), ms("1h")
Default image: Sandboxes use vercel/sandbox/universal:latest, an
Ubuntu-based image with Node.js 24, Bun, Python 3.14, coding agents, and common
development and debugging utilities.
Creating Sandboxes
Basic Creation
import { Sandbox } from "@vercel/sandbox";
const sandbox = await Sandbox.create({
name: "my-dev-env", // Optional, random if omitted. Unique per project.
resources: { vcpus: 4 }, // 2048 MB RAM per vCPU
ports: [3000], // Expose up to 15 ports
timeout: ms("10m"), // Default: 5 minutes
env: { NODE_ENV: "production" }, // Env vars inherited by all commands
tags: { env: "staging", team: "infra" }, // Up to 5 key:value tags
persistent: true, // Default: true. Auto-snapshots on stop, restores on resume.
snapshotExpiration: ms("7d"), // Default TTL for snapshots. Use 0 for no expiration.
region: "<region>", // Optional, defaults to iad1. Any Vercel region, e.g. sfo1, fra1, hnd1, syd1.
failoverRegions: ["<region>"], // Optional, e.g. ["sfo1", "fra1"]. Must not include `region`.
});
console.log(sandbox.name);
Retrieve an Existing Sandbox
// Retrieve by name. The sandbox will resume automatically the next time
// you run a command.
const sandbox = await Sandbox.get({ name: "my-dev-env" });
Get-or-Create (Idempotent)
Sandbox.getOrCreate is the recommended pattern for long-lived sandboxes.
const sandbox = await Sandbox.getOrCreate({
name: "my-workspace",
// Runs only the first time the sandbox is created.
onCreate: async (sbx) => {
await sbx.writeFiles([
{ path: "README.md", content: Buffer.from("# Hello") },
]);
await sbx.runCommand("npm", ["install"]);
},
// Runs every time the sandbox session is resumed (including after auto-resume).
onResume: async (sbx) => {
await sbx.runCommand({ cmd: "npm", args: ["run", "dev"], detached: true });
},
});
Behavior:
- If a sandbox with that
nameexists → resumes it and firesonResume. - If it does not exist → creates a fresh sandbox and fires
onCreate. - If the sandbox exists but its snapshot expired → deletes the stale sandbox,
re-creates it with the same name, and fires
onCreate.
Re-warming on Resume
Use onResume to restart background services or rehydrate caches whenever a
persistent sandbox's session is resumed:
const sandbox = await Sandbox.get({
name: "my-workspace",
onResume: async (sbx) => {
await sbx.runCommand({ cmd: "npm", args: ["run", "dev"], detached: true });
},
});
onResume also fires when a SDK call (e.g. runCommand, writeFiles)
auto-resumes a stopped sandbox.
With Git Source
`
Установить sandbox в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл sandbox?
Creates isolated Linux MicroVMs using Vercel Sandbox SDK. Use when building code execution environments, running untrusted code, spinning up dev servers, testing in isolation, streaming a sandbox desktop for graphical applications or computer-use agents, or when the user mentions "sandbox", "microvm", "isolated execution", or "@vercel/sandbox".
Как установить скилл sandbox?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл sandbox запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
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…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от 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…
от Anthropic