skills/sandbox-migrate-to-next/SKILL.md
Use when porting a Cloudflare Sandbox app from stable @cloudflare/sandbox to @cloudflare/sandbox@next (Sandbox SDK 1.0 preview), or when the user asks to migrate or upgrade to Sandbox 1.0 / @next. Not for day-to-day stable work (sandbox-stable) or new @next apps (sandbox-next).
npx skillsauth add cloudflare/skills sandbox-migrate-to-nextInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
@next)Perform the port. Follow the steps in order. Depth lives in docs—fetch the linked page when a step needs detail.
Human guide: Migrate · 1.0 preview
New projects should start on @next (sandbox-next), not this skill. Day-to-day stable work → sandbox-stable. Deprecated-API cleanup without moving to @next → 2026 deprecation guide first if needed.
Existing apps should migrate when you can, so you are ready when 1.0 becomes the stable release. Do not force production cutover without the user agreeing.
Prefer installed @next types and the migrate doc over memory.
Stop after any step that needs a user decision.
@next line.@next control protocols are incompatible both ways; gradual rollout leaves a broken mixed window. In-flight container work can stop.await sandbox.exec(...) means process started, not command finished.timeout / AbortSignal cancel the wait only, not the process.gitCheckout on core, process stdin, string-exec completion helper).| Stable | @next |
| ------ | ------- |
| SANDBOX_TRANSPORT / transport / setTransport | Remove — RPC only |
| await sandbox.exec("cmd") → buffered result | await sandbox.exec(argv) → handle, then output / waits |
| execStream / startProcess | Same handle: logs, waitFor*, kill |
| Default / named sessions | Gone — cwd/env per launch, or one shell script |
| sandbox.terminal(request) / session terminal | createTerminal + terminal.connect(request) |
| xterm sessionId | terminalId |
| Interpreter methods on Sandbox | withInterpreter → sandbox.interpreter.* |
| gitCheckout | argv git via exec |
| String kill signals | Numeric only |
| Files, mounts, backups, ports, tunnels, proxyToSandbox | Mostly unchanged (ignore session/transport bits on stable pages) |
Depth: Migrate · after port, day-to-day → sandbox-next
rg 'SANDBOX_TRANSPORT|transport:|setTransport|enableDefaultSession|createSession|getSession|deleteSession|execStream\(|startProcess\(|killProcess\(|sandbox\.terminal\(|sessionId|gitCheckout\(|SandboxTransport|ExecutionSession'
Also: string exec(, cd then a later exec, bare createCodeContext / runCode on Sandbox.
--containers-rollout=immediate (live processes/terminals/streams may stop)?-python image variant?npm install @cloudflare/sandbox@next
FROM cloudflare/sandbox:next
# Python: cloudflare/sandbox:next-python
Same prerelease tag on Worker and image when not on floating next.
Apply replacements from the map. For each area, implement from the doc—not from stable habits:
| Area | Doc |
| ---- | --- |
| Commands / handles / waits | Processes · Processes API |
| cwd / env / secrets | Environment · Outbound traffic |
| Drop sessions | Migrate · Lifecycle |
| Terminals | Terminals |
| Interpreter | Interpreter |
| Errors | Errors |
| Durable job across requests | Process execution — lifetime / durability |
Commands (shape):
// Before (stable)
const result = await sandbox.exec("npm test");
// After (@next)
const process = await sandbox.exec(["/bin/bash", "-lc", "npm test"]);
const result = await process.output({ encoding: "utf8" });
const server = await sandbox.exec(["/bin/bash", "-lc", "npm run dev"], {
cwd: "/workspace/app",
});
await server.waitForPort(3000, { timeout: 60_000 });
await server.kill(); // numeric; default 15
Terminals (shape):
const terminal = await sandbox.createTerminal({ command: ["bash"], cwd: "/workspace" });
const t = await sandbox.getTerminal(terminal.id);
if (!t) return new Response("terminal gone", { status: 410 });
return t.connect(request, { cursor, cols, rows });
Interpreter (shape):
import { Sandbox as BaseSandbox } from "@cloudflare/sandbox";
import { withInterpreter } from "@cloudflare/sandbox/interpreter";
export class Sandbox extends BaseSandbox<Env> {
interpreter = withInterpreter(this);
}
Git (shape):
const clone = await sandbox.exec(
["git", "clone", "--depth", "1", "--", repoUrl, "/workspace/repo"],
{ cwd: "/workspace" },
);
const result = await clone.output({ encoding: "utf8" });
Delete transport settings entirely. Remove session APIs. Isolate users with separate sandbox IDs.
Staging/branch first. Production is one deploy of matching Worker + image:
npx wrangler deploy --containers-rollout=immediate
Leave rollout_active_grace_period at default 0 (or set 0 if raised). After cutover, pre-deploy process/terminal IDs are invalid. Details: Migrate · Container rollouts
@next line@nextexec + output({ encoding: "utf8" })--containers-rollout=immediateThen day-to-day work uses sandbox-next.
@next Worker with stable image (or reverse)await exec as command completioncd / exports persist across exec callsgitCheckout, process stdin, or undocumented APIssetEnvVars / launch envdevelopment
Reviews and authors Cloudflare Workers code against production best practices. Load when writing new Workers, reviewing Worker code, configuring wrangler.jsonc, or checking for common Workers anti-patterns (streaming, floating promises, global state, secrets, bindings, observability). Biases towards retrieval from Cloudflare docs over pre-trained knowledge.
development
Comprehensive Cloudflare platform skill covering Workers, Pages, storage (KV, D1, R2), AI (Workers AI, Vectorize, Agents SDK), feature flags (Flagship), networking (Tunnel, Spectrum), security (WAF, DDoS), and infrastructure-as-code (Terraform, Pulumi). Use for any Cloudflare development task. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.
development
Use when building or changing Cloudflare Sandbox apps on the current stable @cloudflare/sandbox package (default npm tag)—commands, sessions, files, ports, tunnels, terminals, bridge, production, or deprecated-API cleanup while staying on stable. Not for @cloudflare/sandbox@next (use sandbox-next) or for porting to 1.0 (use sandbox-migrate-to-next).
development
Use when building or changing Cloudflare Sandbox apps on @cloudflare/sandbox@next (Sandbox SDK 1.0 preview)—code execution, AI runners, interpreters, CI-like jobs, terminals, files, mounts, tunnels, preview URLs, lifecycle, or errors. Not for the default stable package (use sandbox-stable) or for porting stable to @next (use sandbox-migrate-to-next).