sandbox-next

Guides building Cloudflare Sandbox apps on the @cloudflare/sandbox@next 1.0 preview SDK.

Updated Oct 15, 2019
One-click install
npx skills add https://github.com/kkkaoru/dotfiles --skill sandbox-next-kkkaoru
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sandbox-next
Source: https://github.com/kkkaoru/dotfiles/tree/main/.agents/skills-stroage/sandbox-next
Command: npx skills add https://github.com/kkkaoru/dotfiles --skill sandbox-next-kkkaoru

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Cloudflare's Sandbox SDK 1.0 preview (@next) introduces breaking API changes versus the stable package, and outdated knowledge leads to wrong code. This Skill gates you onto the correct package line, enforces the non-negotiable API contract, 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 both match @cloudflare/sandbox@next, and redirects to sandbox-stable or sandbox-migrate-to-next when they do not. - API Contract Enforcement: Codifies rules for exec argv handles, terminals, interpreters, lifecycle, environment variables, and error handling so generated code matches the preview SDK. - Documentation Retrieval Map: Maps each task (processes, terminals, interpreter, 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 container. The Skill ensures you call sandbox.exec with an argv list, collect results via process.output(), and avoid removed stable APIs like string-exec or gitCheckout. ## Quick Start Ask the assistant to build a Cloudflare Worker that executes Python code in a sandbox using the @cloudflare/sandbox@next preview SDK.

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 SDK?

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 stable and @cloudflare/sandbox@next?

The @next line is the 1.0 preview with breaking changes: exec takes argv lists and returns handles, there is no implicit shell, and stable APIs like string-exec and gitCheckout are removed. Stable apps should use the sandbox-stable skill instead.

Can I use shell syntax like pipes in sandbox exec?

No, exec has no implicit shell, so shell syntax requires an explicit shell invocation such as ["/bin/bash", "-lc", script]. Each launch is independent, so pass cwd and env per launch rather than relying on prior cd or export.

Does sandbox.exec support interactive stdin for terminals?

Process handles have no stdin. For interactive use, create a terminal with sandbox.createTerminal and connect via terminal.connect(request), which supports write, resize, output, interrupt, and terminate.

Why does my sandbox process keep running after a timeout?

Local wait timeout or AbortSignal only cancels the client-side wait, not the remote process. Use process.kill(signal) or the remote timeout option on exec to actually terminate the process.

When should I not use the sandbox @next preview SDK?

Avoid it when your app depends on the default stable @cloudflare/sandbox package, when using the self-deployed bridge which remains on stable, or when you need removed stable APIs. Use sandbox-stable or sandbox-migrate-to-next in those cases.