Skills
Skill 10 of 14
Build or maintain Cloudflare Sandbox apps on the stable @cloudflare/sandbox package.
2 minutes · 522 words · 6 sections
Install
npx skills add cloudflare/skills --skill sandbox-stablenpx skills add cloudflare/skills/plugin marketplace add cloudflare/skillsThe first command installs just this skill, by the name in its SKILL.md; the second installs the whole repository.
Isolated Linux environments on Cloudflare Containers, driven from Workers.
Prefer the main Sandbox docs and installed stable types over memory. This skill is a gate, a contract, and a retrieval map—not a full manual.
This line is the current stable default npm package. The main Sandbox documentation (opens in a new tab) describes it. Existing apps can stay here and keep shipping.
We recommend new projects on @cloudflare/sandbox@next with sandbox-next. When you can, plan a move with sandbox-migrate-to-next so you are ready when 1.0 becomes the stable release. Do not force that port unless the user asks.
Before writing code, inspect the app:
| Check | Must match |
|---|---|
| npm dependency | Default @cloudflare/sandbox (not @next / preview tags) |
| Container image | Matching stable image (not cloudflare/sandbox:next) |
| If you find… | Action |
|---|---|
@cloudflare/sandbox@next or a next image | Stop. Load sandbox-next. |
User wants to port to 1.0 / @next | Stop. Load sandbox-migrate-to-next. Do not half-apply preview APIs on a stable package. |
| Only cleaning deprecated stable APIs | Stay here; use the 2026 deprecation guide (opens in a new tab). That is not a move to @next. |
Never mix a stable Worker package with an @next container image (or the reverse).
Skills install: Agent setup (opens in a new tab) · cloudflare/skills (opens in a new tab)
await sandbox.exec(command) takes a command string and resolves when the command finishes, with buffered stdout / stderr / exitCode (and related fields).startProcess, execStream, and related helpers)—not the @next single-handle model. Open the Commands docs; do not invent @next output() handles on stable.enableDefaultSession, createSession). See Sessions docs when state must carry across calls.sandbox.terminal(request) and session/xterm helpers on stable—not preview createTerminal unless the package is @next.@next argv/process.output() APIs while the dependency is still stable.Minimal shape:
import { getSandbox, proxyToSandbox, Sandbox } from "@cloudflare/sandbox";
export { Sandbox };
const sandbox = getSandbox(env.Sandbox, "user-123");
const result = await sandbox.exec('python3 -c "print(2 + 2)"');
// result.stdout, result.exitCode, result.successFetch the page before implementing. Installed stable types win over guesses.
Update package + matching image first, then follow the guide. Typical search:
rg 'SANDBOX_TRANSPORT|transport:|exposePort\(|enableDefaultSession|execStream\(|readFileStream|writeFileStream'This path does not switch you to @next.
sandbox-migrate-to-next—do not force cutover unpromptedBuild or maintain Cloudflare Sandbox apps on the stable @cloudflare/sandbox package. Use sandbox-next for preview apps and sandbox-migrate-to-next for stable-to-preview migrations.
The verbatim description from this skill’s front matter — the string an agent matches on to decide whether to load it.
main, last pushed 22 September 2026.SKILL.md, not by matching a directory convention. One layout observed: skills/*/SKILL.md.h1 and no skipped levels:.claude-plugin/marketplace.json by Cloudflare, declaring 1 plugin. It is read for editorial metadata only — never as the skill index, which is always the repository tree./cloudflare/skills.md, and each skill at its own .md URL.