Skills Agentes

Sandbox Migrate To Next

Úsalo al portar una app Cloudflare Sandbox de @cloudflare/sandbox estable a @cloudflare/sandbox@next (Sandbox SDK 1.0 preview), o al migrar/actualizar a Sandbox 1.0 / @next.

Oficial
Estrellas
2.9k

en todo el repo

Actividad
60

0–100, la ruta de este skill

Actualizado
hace 3 meses

último commit aquí

Commits
1

últimos 90 días

Contexto
2k tok

70 tok en reposo

Paquete
1 archivo

8 KB

Instalar

Funciona con cualquier agente que lea SKILL.md

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

Se instala solo en este repositorio.

Qué hace

  • Guía la migración de una app Cloudflare Sandbox de @cloudflare/sandbox estable a @cloudflare/sandbox@next
  • Audita el código con un comando rg para detectar APIs obsoletas (transport, sesiones, execStream, gitCheckout, etc.)
  • Aplica el mapa de reemplazos: exec con argv y handles, createTerminal, withInterpreter, kill numérico
  • Guía el upgrade de package.json y Dockerfile a la misma línea @next, y el cutover con --containers-rollout=immediate
  • Valida el resultado: typecheck, smoke tests, grep de APIs eliminadas y ausencia de secretos en el entorno

Úsalo cuando

  • Se está portando una app Cloudflare Sandbox de @cloudflare/sandbox estable a @cloudflare/sandbox@next (Sandbox SDK 1.0 preview)
  • El usuario pide migrar o actualizar a Sandbox 1.0 / @next

No lo uses cuando

  • Trabajo cotidiano en la versión estable (usar sandbox-stable)
  • Apps nuevas que empiezan directamente en @next (usar sandbox-next)

Qué lo activa

Di cualquiera de estas frases y el agente debería cargar este skill.

  • “Migra mi app de Cloudflare Sandbox estable a @next”
  • “Quiero actualizar a Sandbox SDK 1.0 preview”
  • “Ayúdame a portar el código de sandbox.exec al nuevo formato de @next”

SKILL.md

En inglés

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 · 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

  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 · 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 → -python image 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

  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

Reproducido de cloudflare/skills bajo licencia Apache-2.0. Leer esta página en markdown.

Archivos

1 archivo en el paquete. Solo se lee SKILL.md al activarse — las referencias se cargan si el skill decide que las necesita.

Antes de instalar

Requiere acceso al código fuente y poder instalar @cloudflare/sandbox@next y la imagen cloudflare/sandbox:next.

Necesita en el PATH:npmnpxrg

Detalles

Creador
cloudflare
Licencia
Apache-2.0
Recursos incluidos
Solo SKILL.md
Código fuente
Ver SKILL.md

Etiquetas

Más de cloudflare/skills

Este repo incluye 13 skills. Si instalas uno, normalmente ya tienes los demás. Ver el pack skills entero y su comando de instalación

Configura Cloudflare Turnstile de extremo a extremo: crea el widget, lo inserta donde haga falta verificar bots, conecta el siteverify server-side y valida todo antes de reportar éxito.

Costo de contexto al activarse
7.2k tok
Tamaño del paquete
13 archivos
Última actualización
hace 3 meses
Oficialseguridad

Úsalo al construir apps de Cloudflare Sandbox sobre @cloudflare/sandbox@next: ejecución de código, AI runners, intérpretes, jobs CI, terminales, archivos, mounts, tunnels, preview URLs, lifecycle o errores.

Costo de contexto al activarse
1.8k tok
Tamaño del paquete
3 archivos
Última actualización
hace 3 meses
Oficialdevops infraestructura

Úsalo al construir o modificar apps de Cloudflare Sandbox sobre el paquete estable @cloudflare/sandbox: comandos, sesiones, ficheros, puertos, tunnels, terminales, bridge, producción o limpieza de APIs deprecated en stable.

Costo de contexto al activarse
2.3k tok
Tamaño del paquete
1 archivo
Última actualización
hace 3 meses
Oficialdevops infraestructura

Skill integral de la plataforma Cloudflare: Workers, Pages, almacenamiento (KV, D1, R2), IA, feature flags, redes, seguridad e infraestructura como código (Terraform, Pulumi).

Costo de contexto al activarse
2.2k tok
Tamaño del paquete
320 archivos
Última actualización
hace 4 meses
Oficialdevops infraestructura

Guía el trabajo de Zero Trust y SASE en Cloudflare One (Access, Gateway, WARP, Tunnel, WAN, DLP, CASB, device posture, identidad), priorizando siempre la documentación y esquemas de API actuales.

Costo de contexto al activarse
5.6k tok
Tamaño del paquete
1 archivo
Última actualización
hace 4 meses
Oficialdevops infraestructura

Planifica migraciones desde Zscaler ZIA/ZPA, Palo Alto, VPN heredada, SWG o SASE hacia Cloudflare One: evaluaciones, mapeo de políticas, planes de rollout y análisis de paridad/brechas.

Costo de contexto al activarse
3.1k tok
Tamaño del paquete
1 archivo
Última actualización
hace 4 meses
Oficialdevops infraestructura

Skills relacionados

Skill integral de la plataforma Cloudflare: Workers, Pages, almacenamiento (KV, D1, R2), IA, feature flags, redes, seguridad e infraestructura como código (Terraform, Pulumi).

Costo de contexto al activarse
2.2k tok
Tamaño del paquete
320 archivos
Última actualización
hace 4 meses
Oficialdevops infraestructura

Envía y recibe emails transaccionales con Cloudflare Email Service (Email Sending + Email Routing), vía binding de Workers, REST API, Agents SDK o wrangler.

Costo de contexto al activarse
2k tok
Tamaño del paquete
6 archivos
Última actualización
hace 6 meses
Oficialdevops infraestructura

Guía el trabajo de Zero Trust y SASE en Cloudflare One (Access, Gateway, WARP, Tunnel, WAN, DLP, CASB, device posture, identidad), priorizando siempre la documentación y esquemas de API actuales.

Costo de contexto al activarse
5.6k tok
Tamaño del paquete
1 archivo
Última actualización
hace 4 meses
Oficialdevops infraestructura