Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

sandbox-migrate-to-next — Claude Code skill: migrate to SDK 1.0

Skill guides migration of Cloudflare Sandbox applications from the stable @cloudflare/sandbox package to the prerelease @cloudflare/sandbox@next (SDK 1.0). Use it when preparing code for the future stable release.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add cloudflare/skills --skill sandbox-migrate-to-next -a claude-code
Open on GitHub

What sandbox-migrate-to-next does

The skill walks through migration step by step: audits source code for breaking changes, updates the package and container image, and rewrites code—from replacing exec calls to removing sessions and restructuring terminals. Key constraint: Worker and container must stay on the same @next line, or RPC protocols won't match.

The skill enforces hard rules of the new version: a process launched via exec is only a handle, not a buffered result; terminals now require explicit createTerminal setup; interpreters moved under withInterpreter. Production cutover demands immediate container rollout—gradual rollout leaves an incompatible window and fails.

The skill relies on official migration docs and does not invent APIs. If you're already on preview, use the sandbox-next skill for day-to-day work.

What it helps with

  • migrate an application from stable Sandbox to SDK 1.0 preview
  • update exec calls, terminals, and sessions to the new API shape
  • align Worker and container versions before production cutover
  • audit code for deprecated transport settings and session APIs
  • deploy migration to production with immediate rollout

Example prompts for the agent

  • Help me migrate my app to @cloudflare/sandbox@next, I have old exec calls and sessions
  • Audit my Sandbox code for SDK 1.0 compatibility and list what needs to change
  • Update my Dockerfile and package.json to sandbox@next, then help rewrite the process code

How to install sandbox-migrate-to-next

1Skills CLI (Vercel)

npx skills add cloudflare/skills --skill sandbox-migrate-to-next -a claude-code

2Manually: put the files in place

~/.claude/skills/sandbox-migrate-to-next/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/sandbox-migrate-to-next/

From the same set13

The whole set →
cloudflare cloudflare Helps coding agents pick the right Cloudflare products for applications, storage, and AI, while routing between cf CLI and Wrangler. Claude Code CX Codex Cursor +1 136,500installs wrangler cloudflare Runs and troubleshoots Wrangler CLI commands for Cloudflare Workers projects that use wrangler configuration files. Claude Code CX Codex Cursor +1 128,500installs workers-best-practices cloudflare Guides coding agents on production Cloudflare Workers standards, Wrangler typing, observability setup, and runtime anti-pattern checks. Claude Code CX Codex Cursor +1 124,900installs durable-objects cloudflare This skill helps build, debug, and review Cloudflare Durable Objects for state, coordination, and persistent connections. Claude Code CX Codex Cursor +1 109,700installs web-perf cloudflare Audit Core Web Vitals, diagnose rendering bottlenecks, and inspect network dependencies directly through your agent. Claude Code CX Codex Cursor +1 109,300installs agents-sdk cloudflare Helps build, debug, and review Cloudflare Agents SDK applications using the agents package and official documentation. Claude Code CX Codex Cursor +1 105,700installs cloudflare-email-service cloudflare A skill for Cloudflare Email Sending and Email Routing: it walks the agent through sending and receiving mail in Workers. Claude Code CX Codex Cursor +1 101,400installs cloudflare-one cloudflare Walks your agent through designing, configuring and troubleshooting Cloudflare One Zero Trust and SASE deployments. Useful when you need Access, Gateway or tunnel work done without digging through docs yourself. Claude Code CX Codex Cursor +1 92,200installs

Similar

dotnet-design-pattern-review official github Reviews selected C#/.NET code for design patterns and suggests improvements without editing files. Use it when you need an architecture-focused code review. GitHub Copilot 11,609installs api-design-principles Seth Hobson Use this skill to plan or review REST and GraphQL APIs. It helps when writing a specification or setting API conventions for a team. Claude Code CX Codex Cursor 30,348installs gemini-agents-api official google Manages Agent resources in Gemini Enterprise Agent Platform through its API. Use it when you need to configure an agent before starting conversations. Claude Code Gemini CLI CX Codex 9,466installs upgrade-stripe stripe Guides an agent through Stripe API, webhook, and SDK version upgrades. Use it when moving an integration to a target API version. Claude Code CX Codex Cursor +1 72,800installs postgresql-table-design Seth Hobson Helps design and review PostgreSQL schemas with guidance on data types, keys, constraints, indexes, and table partitioning. Claude Code CX Codex Cursor 27,780installs mcp-builder official anthropics This skill walks through building an MCP server in TypeScript or Python, from reading the protocol spec to writing tests and evaluation questions. Claude Code Claude.ai 130,949installs google-agents-cli-adk-code official Google A reference skill for building ADK agents with tools, callbacks, state, and workflows. Use it when an agent project needs concrete API patterns or code examples. Claude Code CX Codex Cursor +1 511,400installs lark-im larksuite This skill lets an agent work with Lark IM messages, chats, files, and interactive cards. Use it when coding tasks need access to team conversations. Claude Code CX Codex Cursor +1 472,300installs

Questions about sandbox-migrate-to-next

How do I install sandbox-migrate-to-next in Claude Code?

Run npx skills add cloudflare/skills --skill sandbox-migrate-to-next -a claude-code, then open ~/.claude/skills/sandbox-migrate-to-next/SKILL.md.

What does sandbox-migrate-to-next do?

It guides migration of Cloudflare Sandbox applications from @cloudflare/sandbox to the prerelease @cloudflare/sandbox@next (SDK 1.0). It audits your code, updates the package and container, rewrites APIs to the new shape, and prepares production cutover.

Why must the Worker and container be on the same @next version?

RPC protocols between them are incompatible both ways. Mismatched versions cause the app to fail. Production cutover is one synchronous deploy with --containers-rollout=immediate.

Source text

SKILL.md · Apache-2.0
---
name: sandbox-migrate-to-next
description: Migrate Cloudflare Sandbox apps from stable @cloudflare/sandbox to @cloudflare/sandbox@next (SDK 1.0 preview). Use sandbox-next for apps already on the preview.
---

# Migrate 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](https://developers.cloudflare.com/sandbox/sdk/migrate/index.md) · [1.0 preview](https://developers.cloudflare.com/sandbox/index.md)

**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](https://developers.cloudflare.com/sandbox/sdk/migrate/index.md) 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

1. **Review** hard rules and the replacement map  
2. **Audit** the codebase; list hits and target shapes  
3. **Clarify** with the user (cutover, bridge, Python image, unclear sites)  
4. **Upgrade** package, image, and code  
5. **Validate**  

Stop after any step that needs a user decision.

## Hard rules

- Worker package and container image must be the **same** `@next` line.  
- Production cutover uses **immediate** container rollout. Stable and `@next` control 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` / `AbortSignal` cancel the **wait only**, not the process.  
- No single retry loop for every error.  
- Do not invent APIs (`gitCheckout` on 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](https://developers.cloudflare.com/sandbox/sdk/migrate/index.md) · after port, day-to-day → **`sandbox-next`**

## Audit

```sh
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 → **`-python`** image variant?  
- Call sites not covered by the map?  

## Upgrade

### Package and image

```sh
npm install @cloudflare/sandbox@next
```

```dockerfile
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](https://developers.cloudflare.com/sandbox/index.md) · [Processes API](https://developers.cloudflare.com/sandbox/index.md) |
| `cwd` / `env` / secrets | [Environment](https://developers.cloudflare.com/sandbox/index.md) · [Outbound traffic](https://developers.cloudflare.com/sandbox/sdk/guides/outbound-traffic/index.md) |
| Drop sessions | [Migrate](https://developers.cloudflare.com/sandbox/sdk/migrate/index.md) · [Lifecycle](https://developers.cloudflare.com/sandbox/index.md) |
| Terminals | [Terminals](https://developers.cloudflare.com/sandbox/index.md) |
| Interpreter | [Interpreter](https://developers.cloudflare.com/sandbox/index.md) |
| Errors | [Errors](https://developers.cloudflare.com/sandbox/index.md) |
| Durable job across requests | [Process execution — lifetime / durability](https://developers.cloudflare.com/sandbox/index.md) |

**Commands (shape):**

```ts
// 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" });
```

```ts
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):**

```ts
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):**

```ts
import { Sandbox as BaseSandbox } from "@cloudflare/sandbox";
import { withInterpreter } from "@cloudflare/sandbox/interpreter";

export class Sandbox extends BaseSandbox<Env> {
  interpreter = withInterpreter(this);
}
```

**Git (shape):**

```ts
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:

```sh
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](https://developers.cloudflare.com/sandbox/sdk/migrate/index.md) · [Container rollouts](https://developers.cloudflare.com/containers/configuration/rollouts/index.md)

## Validate

1. Lockfile + Dockerfile on the same `@next` line  
2. Typecheck against `@next`  
3. Smoke argv `exec` + `output({ encoding: "utf8" })`  
4. Smoke long process / terminal / interpreter if used  
5. Errors distinguished: unavailable / interrupted-RPC / stale / local wait  
6. No live secrets in sandbox env  
7. Grep again for removed APIs  
8. Production used `--containers-rollout=immediate`  

Then day-to-day work uses **`sandbox-next`**.

## Red flags — stop and fix

- Mixing `@next` Worker with stable image (or reverse)  
- Gradual container rollout for this cutover  
- Treating `await exec` as command completion  
- Assuming `cd` / exports persist across `exec` calls  
- 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` / launch `env`  

© cloudflare · Apache-2.0 · cloudflare/skills

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor