examples

作成者: cloudflare

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.

cloudflareのその他のスキル

workerd-api-review
cloudflare
workerdのコードレビューにおけるパフォーマンス最適化、API設計と互換性、セキュリティ脆弱性、標準仕様準拠。tcmalloc対応を含む…
official
workerd-safety-review
cloudflare
workerdのコードレビューにおけるメモリ安全性、スレッド安全性、並行性、および重要な検出パターン。V8/KJ境界の危険性、ライフタイム管理などをカバー。
official
module-registry
cloudflare
workerdでモジュールレジストリを扱う際に読み込む — モジュールの解決、コンパイル、評価、登録の読み取り、変更、デバッグ、またはレビュー…
official
reproduce
cloudflare
cloudflare/agentsのGitHub Issueを再現するために、最小限のAgents/Workerプロジェクトをスキャフォールディングし、一時的なCloudflareアカウントにデプロイして、その後報告する…
official
local-explorer
cloudflare
ローカルエクスプローラーまたはローカルAPIに製品/リソースを追加する方法。新しいローカルAPIやUIルートを実装する際に使用します。
official
commit-categories
cloudflare
コミットを変更ログや「新機能」サマリーに分類するためのルール。変更ログやwhats-newコマンドでコミットを分類する前に必ず読み込む必要があります。提供するのは…
official
architecture
cloudflare
コードベースを初めてナビゲートするとき、新しいクライアントメソッドを追加するとき、新しいコンテナハンドラ/サービスを追加するとき、またはリクエストの流れを理解するときに使用します…
official
changesets
cloudflare
チェンジセットを作成する際、リリースを準備する際、またはバージョンを上げる際に使用します。参照するパッケージ、ユーザー向けのチェンジセット説明の書き方などをカバーします。
official