Use when navigating the codebase for the first time, adding a new client method, adding a new container handler/service, or understanding how a request flows from Worker through the Sandbox DO into the container. Covers the three-layer architecture, client pattern, container runtime structure, and monorepo layout. (project)
npx skills add https://github.com/cloudflare/sandbox-sdk --skill architecture
@cloudflare/sandbox (packages/sandbox/) — Public SDK published to npmSandbox class: Durable Object that manages the container lifecycleCommandClient, FileClient, ProcessClient, …)CodeInterpreter: high-level API for Python/JS with structured outputsproxyToSandbox(): request handler for preview URL routing@repo/shared (packages/shared/) — Internal shared utilitiespackages/shared/src/errors/) and logging@repo/sandbox-container (packages/sandbox-container/) — Container runtimecore/container.tsPrimary control path:
Worker
→ Sandbox DO (packages/sandbox)
→ ContainerControlClient (packages/sandbox/src/container-control/)
→ capnweb over /rpc WebSocket
→ SandboxControlAPI (packages/sandbox-container/src/control-plane/)
→ container services
→ Shell commands / filesystem
Route-based compatibility path:
Worker
→ Sandbox DO (packages/sandbox)
→ SandboxClient / clients/transport
→ Container HTTP API on port 3000 (packages/sandbox-container)
→ Router / handlers
→ container services
→ Shell commands / filesystem
Errors flow back the same path: container → Sandbox DO → Worker, using the custom error classes in packages/shared/src/errors/ keyed by the ErrorCode enum.
The primary Sandbox Durable Object to container control path is the container-control/control-plane path:
packages/sandbox/src/container-control/packages/sandbox-container/src/control-plane//rpc WebSocket routeControl-channel/transport-layer capabilities belong in this path. Treat capnweb/RPC as the current implementation detail, not the architectural boundary.
The shared @repo/shared SandboxAPI interface remains named SandboxAPI because it defines the current control API contract used by both sides.
packages/sandbox/src/clients/)packages/sandbox/src/clients/ and packages/sandbox/src/clients/transport/ implement the HTTP and custom WebSocket route-based compatibility API. Maintain these for compatibility, debugging, local development, fallback behavior, and bug fixes, but do not add new control-plane capabilities there by default.
The route-based client pattern is:
BaseHttpClient — abstract route-based HTTP/WebSocket client with shared request/response handlingSandboxClient — compatibility aggregator that exposes all specialized route-based clientsCommandClient — exec / execStreamFileClient — read, write, list, deleteProcessClient — start, stop, list, signalPortClient — port readiness streamsGitClient — clone, checkout, statusUtilityClient — ping, metadataInterpreterClient — code interpreter sessionsWhen maintaining route-based compatibility, add or extend specialized clients under packages/sandbox/src/clients/. DO-to-container control capabilities belong in packages/sandbox/src/container-control/ and packages/sandbox-container/src/control-plane/.
packages/sandbox-container/src/)core/container.ts) — manages service lifecycle and wiringcontrol-plane/) — primary container-side API called by the Sandbox DOhandlers/) — route-based compatibility handlers, thin layer that parses requestsservices/) — business logic (CommandService, FileService, ProcessService, …)managers/) — stateful coordinators such as ProcessManagerEntry point: packages/sandbox-container/src/index.ts starts a Bun HTTP server on port 3000.
When adding a new container control operation:
services/ for the business logic.packages/sandbox-container/src/control-plane/.packages/sandbox/src/container-control/.Only add a route handler in handlers/ and a route-based SDK client in packages/sandbox/src/clients/ when maintaining HTTP/WebSocket compatibility.
Uses npm workspaces + Turbo:
packages/sandbox — main SDK package (published)packages/shared — shared types and utilities (internal)packages/sandbox-container — container runtime (internal, bundled into image)examples/ — working example projectstooling/ — shared TypeScript configsturbo.json orchestrates dependency-aware builds.
exposePort() activates the port for the current runtime. Production preview URLs require a custom domain with wildcard DNS (*.yourdomain.com); .workers.dev does not support the required subdomain patterns.The container runtime uses Ubuntu 22.04 with:
When modifying packages/sandbox/Dockerfile:
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
Automatically creates user-facing changelogs from git commits by analyzing commit history, categorizing changes, and transforming technical commits into clear, customer-friendly release notes. Turns hours of manual changelog writing into minutes of automated generation.
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
Next.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification
Take cloudflare/architecture from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.