sandbox-next

Build Cloudflare Sandbox applications on the @cloudflare/sandbox@next 1.0 preview package.

2.8k|267|Updated Dec 10, 2025
One-click install
npx skills add https://github.com/cloudflare/skills --skill sandbox-next
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sandbox-next
Source: https://github.com/cloudflare/skills/tree/main/skills/sandbox-next
Command: npx skills add https://github.com/cloudflare/skills --skill sandbox-next

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @cloudflare/sandbox, and includes references (resource) components.

What problem does it solve?

Cloudflare Sandbox SDK 1.0 preview (@cloudflare/sandbox@next) introduces breaking API changes versus the stable package, and outdated knowledge leads to wrong code. This Skill gates the correct package line, enforces the new process/terminal/interpreter contracts, and routes you to the right preview documentation before writing code.

Core Features & Use Cases

  • Package Line Gate: Verifies the npm dependency and container image are both on the @next preview line, and redirects to sandbox-stable or sandbox-migrate-to-next when they are not.
  • API Contract Enforcement: Codifies non-negotiable behaviors such as argv-based exec returning a process handle, no implicit shell, no process stdin, per-launch cwd/env, and explicit kill semantics.
  • Documentation Retrieval Map: Maps each task (processes, terminals, interpreter, lifecycle, environment, errors, files, mounts, tunnels, preview URLs) to the exact preview docs page, plus a quick-reference cheatsheet and examples index.
  • Use Case: You are building a Worker that runs Python code in an isolated sandbox. The Skill confirms you are on @next, gives you the correct exec/output pattern, and points you to the interpreter and lifecycle docs so you avoid removed stable APIs like gitCheckout or string-based exec.

Quick Start

Ask the agent to build a Cloudflare Worker that executes Python code in a sandbox using the @cloudflare/sandbox@next package and returns the output.

Frequently Asked Questions about sandbox-next

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run a command in a Cloudflare Sandbox with the @next package?

Call sandbox.exec with an argv array like ["python3", "-c", "print(2 + 2)"], which resolves when the process starts and returns a handle. Collect results with handle methods such as output(), logs(), waitForExit(), or kill().

What is the difference between sandbox-next and sandbox-stable?

sandbox-next targets the @cloudflare/sandbox@next 1.0 preview line with new process, terminal, and interpreter APIs, while sandbox-stable covers the default stable @cloudflare/sandbox package. Never mix an @next Worker package with a stable container image.

How do I migrate a stable Cloudflare Sandbox app to @next?

Use the sandbox-migrate-to-next skill, which is designed for porting stable apps to the @next preview line. The sandbox-next skill explicitly stops and redirects to that skill when a port is requested.

Can I use shell syntax like pipes in sandbox exec?

No, exec has no implicit shell and takes an argv list. To use shell syntax, invoke a shell explicitly, for example ["/bin/bash", "-lc", script], and pass cwd and env per launch since state does not persist between exec calls.

Why does my sandbox exec timeout not stop the process?

Local wait timeout and AbortSignal only cancel the wait, not the remote process. To stop the process, call the handle's kill(signal) method or set the remote timeout option on exec itself.

How do I get an interactive terminal in a Cloudflare Sandbox?

Process handles have no stdin, so use sandbox.createTerminal with a command argv, then terminal.connect(request) for interactive PTY sessions. Terminals support write, resize, output streaming, interrupt, and terminate.