examples

Используйте при работе в каталоге examples/, запуске примера с wrangler dev, добавлении нового примера или ответах на вопросы о директивах EXPOSE и…

npx skills add https://github.com/cloudflare/sandbox-sdk --skill examples

Examples

The examples/ directory contains working sample apps that exercise the SDK end-to-end. They double as integration smoke tests and as reference material for users.

Running an Example

From inside an example directory (e.g. examples/minimal/):

npm run dev    # Start wrangler dev (builds Docker on first run)

The first run builds the container image, so it's slow. Subsequent runs reuse the image unless the SDK or Dockerfile changes. If you've changed the container runtime or SDK, run npm run docker:rebuild from the repo root before npm run dev.

Available Examples

ExampleDemonstrates
minimalSmallest possible Sandbox SDK setup
authenticationAuth-protected sandbox access
claude-codeRunning Claude Code inside a sandbox
code-interpreterCodeInterpreter API + Workers AI
codex / codex-app-serverOpenAI Codex integration patterns
collaborative-terminalMulti-user terminal sharing
openai-agentsOpenAI Agents SDK + Sandbox
opencodeOpenCode integration
time-machineSnapshot/restore patterns
typescript-validatorRunning tsc against user code
vite-sandboxVite dev server proxied through preview URLs
websocket-tunnelWebSocket transport / port exposure
alpineAlpine-based container variant

EXPOSE Directives

The Cloudflare containers primitive does not require EXPOSE directives — all ports are accessible in both local dev and production without them.

Including EXPOSE is still recommended in example Dockerfiles because it documents which ports the app uses (standard Docker convention). Don't add it expecting it to gate access; add it as documentation.

Adding a New Example

  1. Copy examples/minimal/ as a starting point.
  2. Update package.json name and any wrangler config (wrangler.jsonc) — class names, DO bindings, container image tag.
  3. Add a README.md with an # H1 title (the README scanner uses it) and a short description of what the example demonstrates.
  4. Make sure the example builds and npm run dev works from a clean checkout.
  5. If the example demonstrates a new SDK capability, link to it from packages/sandbox/README.md.

Local Development Tips

  • Examples link to @cloudflare/sandbox via the workspace, so SDK changes are picked up after a build (npm run build from repo root).
  • Container changes require npm run docker:rebuild to take effect.
  • If you hit stale-image issues, delete the container image (docker images | grep sandbox) and re-run npm run dev.

Больше skills от cloudflare

dependabot-review
cloudflare
Анализирует PR от Dependabot, чтобы определить, что именно изменилось в каждом обновлённом пакете и влияют ли эти изменения на данный репозиторий. Сообщает об изменённых API/методах,…
module-registry
cloudflare
Загружать при работе с реестром модулей в workerd — чтение, изменение, отладка или проверка разрешения модулей, компиляции, оценки или регистрации…
reproduce
cloudflare
Воспроизвести проблему из репозитория cloudflare/agents на GitHub, создав минимальный проект Agents/Worker и развернув его на временном аккаунте Cloudflare, затем сообщить…
local-explorer
cloudflare
Как добавлять продукты/ресурсы в локальный обозреватель или локальный API. Используйте при реализации новых локальных API или маршрутов пользовательского интерфейса в…
open-pr
cloudflare
Взять задачу из GitHub репозитория cloudflare/agents вместе с любыми результатами воспроизведения и с одного раза создать исправляющий PR — ветку, изменения, тесты, пуш и открыть PR, привязанный к задаче.
write-endpoints
cloudflare
Всеобъемлющее руководство по созданию конечных точек OpenAPI с помощью chanfana — определение схемы, проверка запросов, операции CRUD, интеграция с базой данных D1 и…
agents-sdk
cloudflare
Создавайте AI-агентов на Cloudflare Workers с помощью Agents SDK. Загружайте при создании stateful-агентов, долговечных рабочих процессов, приложений с WebSocket в реальном времени, запланированных задач,…
changelog
cloudflare
Создаёт, обновляет и просматривает записи журнала изменений продукта для сайта документации Cloudflare. Загружать при генерации MDX-файлов журнала изменений, редактировании существующих…