
Migrate to Sandbox Next
OfficialFreeStreamline your Cloudflare Sandbox app upgrade process.
Free · Opens the source repo
What Migrate to Sandbox Next does
The Migrate to Sandbox Next skill is designed for developers looking to transition their Cloudflare Sandbox applications from the stable version to the upcoming Sandbox SDK 1.0 preview. This skill provides a structured workflow to ensure that the migration process is smooth and adheres to the necessary guidelines set by Cloudflare. It is particularly useful for existing applications that need to prepare for the eventual stable release of version 1.0. The skill outlines a step-by-step approach that includes reviewing hard rules, auditing the codebase, clarifying user intentions, upgrading packages, and validating the migration.
The migration process is not intended for day-to-day stable work or for new applications, which should start directly on the @next version. Instead, it serves as a bridge for those who have existing apps that need to be upgraded. The skill emphasizes the importance of user communication, ensuring that any production cutover is agreed upon before proceeding. This is crucial as the transition involves significant changes in how processes and commands are handled in the new version.
Developers will find a detailed replacement map that highlights the differences between the stable and @next versions, making it easier to adapt their code. The skill encourages developers to rely on the provided documentation rather than memory, ensuring that all changes are accurately implemented. By following the outlined workflow, developers can effectively prepare their applications for the new SDK and avoid potential pitfalls during the migration process.
When to use it
Use this skill when you need to upgrade an existing Cloudflare Sandbox app to the 1.0 preview version.
When not to use it
Do not use this skill for new projects or for day-to-day stable work with the stable version of the SDK.
What you can build with it
Upgrading an Existing App
A developer needs to prepare their existing Cloudflare Sandbox app for the upcoming SDK 1.0 release and uses this skill to ensure a smooth transition.
Preparing for Production Cutover
Before cutting over to the new version in production, a developer uses this skill to clarify user intentions and confirm necessary changes.
Auditing Codebase for Migration
A team audits their codebase using the skill's guidelines to identify necessary changes before upgrading to the `@next` version.
How to install Migrate to Sandbox Next
View source1. Install with the skills CLI
npx skills add cloudflare/skills/sandbox-migrate-to-next --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by cloudflareMigrate stable → Sandbox SDK 1.0 preview (@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.
Workflow
- Review hard rules and the replacement map
- Audit the codebase; list hits and target shapes
- Clarify with the user (cutover, bridge, Python image, unclear sites)
- Upgrade package, image, and code
- Validate
Stop after any step that needs a user decision.
Hard rules
- Worker package and container image must be the same
@nextline. - Production cutover uses immediate container rollout. Stable and
@nextcontrol protocols are incompatible both ways; gradual rollout leaves a broken mixed window. In-flight container work can stop. - After cutover,
await sandbox.exec(...)means process started, not command finished. - Argv is as-is (no implicit shell). Shell syntax needs an explicit shell binary.
- Process handles have no stdin → terminals for interactive input.
- Observation
timeout/AbortSignalcancel the wait only, not the process. - No single retry loop for every error.
- Do not invent APIs (
gitCheckouton core, process stdin, string-exec completion helper). - Self-deployed bridge stays on stable (not part of the preview line yet).
Replacement map
| 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
Audit
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.
Clarify (ask when needed)
- OK to cut production with
--containers-rollout=immediate(live processes/terminals/streams may stop)? - Self-deployed bridge? Leave on stable.
- Python interpreter →
-pythonimage variant? - Call sites not covered by the map?
Upgrade
Package and image
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.
Code by area
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.
Deploy cutover
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
Validate
- Lockfile + Dockerfile on the same
@nextline - Typecheck against
@next - Smoke argv
exec+output({ encoding: "utf8" }) - Smoke long process / terminal / interpreter if used
- Errors distinguished: unavailable / interrupted-RPC / stale / local wait
- No live secrets in sandbox env
- Grep again for removed APIs
- Production used
--containers-rollout=immediate
Then day-to-day work uses sandbox-next.
Red flags — stop and fix
- Mixing
@nextWorker with stable image (or reverse) - Gradual container rollout for this cutover
- Treating
await execas command completion - Assuming
cd/ exports persist acrossexeccalls - One retry wrapper for every error
- Inventing
gitCheckout, process stdin, or undocumented APIs - Keeping pre-cutover process/terminal IDs after deploy
- Forcing production cutover without user agreement
- Putting live secrets in
setEnvVars/ launchenv
Frequently asked questions about Migrate to Sandbox Next
Similar skills
WinMD API Search
Easily find and explore Windows desktop APIs.
WebMCPify
Transform any web app into an agent-ready platform.
Phoenix Tracing
Instrument LLM applications with OpenInference tracing.
Foundry Hosted Agent CopilotKit
Guidance for developing agentic web apps on Azure.
Power Automate Foundation
Connect AI agents to Power Automate seamlessly.
Power Automate Flow Builder
Efficiently build and deploy Power Automate flows programmatically.
