Communitygithub.com

cloudflare/sandbox-stable

Cloudflare Sandboxアプリを安定版の@cloudflare/sandboxパッケージで構築・保守します。プレビューアプリにはsandbox-next、安定版からプレビューへの移行にはsandbox-migrate-to-nextを使用してください。

sandbox-stable とは?

このスキルは、Cloudflare Containers上で隔離されたLinux環境を提供するSandbox SDKの安定版パッケージ(@cloudflare/sandbox)の使い方を定義します。Workersからサンドボックス内のプロセスを起動・管理し、コマンド実行、ファイル操作、環境変数設定、ポート公開、トンネル、セッション維持、インタラクティブターミナルなどを安定したAPIで実現します。主にCloudflare Workersプラットフォーム上で動作し、既存の安定版アプリの保守や、廃止予定APIのクリーンアップに適しています。新しいプロジェクトや1.0プレビュー機能が必要な場合は、sandbox-nextまたはsandbox-migrate-to-nextスキルを読み込むよう誘導します。このスキルは、コード生成前にパッケージラインを確認するゲート、安定版APIの非妥協ルール(コントラクト)、そしてタスクに応じた公式ドキュメントへのリンクマップを提供します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/cloudflare/skills/tree/main/skills/sandbox-stable

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Sandbox SDK — 安定版パッケージ

Cloudflare Containers上の隔離Linux環境。Workersから駆動します。

メインのSandboxドキュメントとインストール済みの安定版型定義を記憶より優先してください。 このスキルはゲート、契約、参照マップであり、完全なマニュアルではありません。

この行は現在の安定版デフォルトnpmパッケージです。メインのSandboxドキュメントに記載されています。既存のアプリはここに留まり、そのままリリースを続けられます。

新規プロジェクトには@cloudflare/sandbox@nextと**sandbox-nextをお勧めします。可能であればsandbox-migrate-to-next**を使って移行を計画し、1.0が安定版リリースになったときに備えてください。ユーザーが要求しない限り、その移行を強制しないでください。

1. ゲート — パッケージラインの確認

コードを書く前に、アプリを検査してください:

チェック項目一致条件
npm依存関係デフォルトの@cloudflare/sandbox(@next / プレビュータグではない)
コンテナイメージ対応する安定版イメージ(cloudflare/sandbox:nextではない)
発見した場合…アクション
@cloudflare/sandbox@next または nextイメージ停止。 **sandbox-next**を読み込んでください。
ユーザーが1.0 / @nextへの移植を希望停止。 **sandbox-migrate-to-next**を読み込んでください。安定版パッケージにプレビューAPIを中途半端に適用しないでください。
廃止予定の安定版APIのクリーンアップのみここに留まり、2026年廃止ガイドを使用してください。これは@nextへの移行ではありません。

安定版のWorkerパッケージと@nextコンテナイメージを混在させないでください(またはその逆)。

スキルのインストール:エージェント設定 · cloudflare/skills

2. 契約 — 非妥協ルール

  • await sandbox.exec(command)はコマンド文字列を受け取り、コマンドが終了したときに、バッファリングされたstdout / stderr / exitCode(および関連フィールド)とともに解決します。
  • 長時間実行やストリーミング処理には安定版のコマンドAPI(startProcess、execStream、および関連ヘルパー)を使用します。@nextのシングルハンドルモデルは使用しません。コマンドドキュメントを開き、安定版で@nextのoutput()ハンドルを発明しないでください。
  • セッションは、コマンド間で作業ディレクトリと環境を保持できます(デフォルトセッション / enableDefaultSession、createSession)。状態を呼び出し間で引き継ぐ必要がある場合は、セッションドキュメントを参照してください。
  • インタラクティブブラウザターミナルは、多くの場合、安定版では**sandbox.terminal(request)**とセッション/xtermヘルパーを使用します。パッケージが@nextでない限り、プレビュー版のcreateTerminalは使用しません。
  • トンネルや大規模/バイナリストリーミングを使用する場合は、RPCトランスポートを推奨します。HTTP/WebSocketトランスポートは非推奨です(以下のクリーンアップガイドを参照)。
  • ファイル、マウント、ポート、トンネル、バックアップ、ライフサイクル、インタプリタ:シグネチャについてはメインドキュメントを使用し、インストール済みの安定版型定義を信頼してください。
  • シークレット以外の設定はサンドボックス環境に、ライブ認証情報はWorkerに配置します。プロセスが外部APIを呼び出す場合は出力ハンドラを使用します。
  • 本番プレビューホスト名には、それらのURLパターンを使用する場合、カスタムドメインにワイルドカードDNSが必要です。
  • 依存関係が安定版のままである間は、@nextのargv/process.output() APIを適用しないでください。
  • 自己デプロイ型ブリッジは、安定版パッケージとイメージに留まります。ブリッジ

最小限の形状:

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.success

3. 参照 — タスクに応じたドキュメントを開く

実装前にページを取得してください。インストール済みの安定版型定義が推測より優先されます。

必要な操作…開くドキュメント
概要把握Sandbox概要
初めてのWorker、テンプレート、Dockerはじめに
exec、ストリーミング、バックグラウンドプロセスコマンドAPI · コマンド実行 · バックグラウンドプロセス · 出力ストリーミング
セッション / コマンド間のシェル状態セッションの概念 · セッションAPI
getSandboxオプション、スリープ、破棄ライフサイクルAPI · Sandboxオプション
環境変数環境変数
ファイルファイルAPI · ファイル管理 · ファイル監視
バケット / マウントストレージAPI · バケットマウント
バックアップバックアップAPI · バックアップと復元
ポート、プレビューURL、公開ポートAPI · サービスの公開
トンネルトンネルAPI
プロキシ / Workers接続プロキシリクエスト · Workers接続
ブラウザ / PTYターミナルターミナルAPI · ターミナルの概念 · ブラウザターミナル
コードインタプリタインタプリタAPI · コード実行
サンドボックス内のGitGitワークフロー
シークレット / 外部通信外部トラフィック
WebSocketWebSocket接続
Docker-in-DockerDocker in Docker
本番デプロイ本番デプロイメント
コンテナの概念コンテナ
ハウツー索引ガイド
API索引APIリファレンス
安定版に留まりつつ廃止予定のAPI2026年廃止ガイド
自己デプロイ型ブリッジブリッジ · ブリッジHTTP API
例(安定版/main)GitHub上のexamples
1.0プレビューでの新規作業sandbox-next · 1.0プレビュー
既存アプリを@nextに移植sandbox-migrate-to-next · 移行

廃止予定APIのクリーンアップ(安定版に留まる)

まずパッケージと対応するイメージを更新し、その後ガイドに従ってください。典型的な検索:

rg 'SANDBOX_TRANSPORT|transport:|exposePort\(|enableDefaultSession|execStream\(|readFileStream|writeFileStream'

このパスでは@nextに切り替わりません。

4. リリース前の確認

  • Workerパッケージとコンテナイメージが同じ安定版ラインであること
  • インストール済みの安定版型定義に対して型チェックが通ること
  • サンドボックス環境にライブシークレットがないこと
  • 非推奨のトランスポート/ヘルパーを使用している場合は、2026年廃止のクリーンアップを完了または追跡すること
  • チームが1.0への準備ができたら、**sandbox-migrate-to-next**を使用してください。促されずに強制カットオーバーを行わないでください。

Individual skills in this repo

This repo contains 15 individual skills — each has its own dedicated page.

cloudflare/agents-sdk

Build AI agents on Cloudflare Workers using the Agents SDK. Load when creating stateful agents, durable workflows, real-time WebSocket apps, scheduled tasks, MCP servers, chat applications, voice agents, or browser automation. Covers Agent class, state management, callable RPC, Workflows, durable execution, queues, retries, observability, and React hooks. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.

cloudflare/building-ai-agent-on-cloudflare

Builds AI agents on Cloudflare using the Agents SDK with state management, real-time WebSockets, scheduled tasks, tool integration, and chat capabilities. Generates production-ready agent code deployed to Workers. Use when: user wants to "build an agent", "AI agent", "chat agent", "stateful agent", mentions "Agents SDK", needs "real-time AI", "WebSocket AI", or asks about agent "state management", "scheduled tasks", or "tool calling". Biases towards retrieval from Cloudflare docs over pre-trained knowledge.

cloudflare/building-mcp-server-on-cloudflare

Builds remote MCP (Model Context Protocol) servers on Cloudflare Workers with tools, OAuth authentication, and production deployment. Generates server code, configures auth providers, and deploys to Workers. Use when: user wants to "build MCP server", "create MCP tools", "remote MCP", "deploy MCP", add "OAuth to MCP", or mentions Model Context Protocol on Cloudflare. Also triggers on "MCP authentication" or "MCP deployment". Biases towards retrieval from Cloudflare docs over pre-trained knowledge.

cloudflare/cloudflare

Comprehensive Cloudflare platform skill covering Workers, Pages, storage (KV, D1, R2), AI (Workers AI, Vectorize, Agents SDK), feature flags (Flagship), networking (Tunnel, Spectrum), security (WAF, DDoS), and infrastructure-as-code (Terraform, Pulumi). Use for any Cloudflare development task. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.

cloudflare/cloudflare-email-service

Send and receive transactional emails with Cloudflare Email Service (Email Sending + Email Routing). Use when building email sending (Workers binding or REST API), email routing, Agents SDK email handling, or integrating email into any app — Workers, Node.js, Python, Go, etc. Also use for email deliverability, SPF/DKIM/DMARC, wrangler email setup, MCP email tools, or when a coding agent needs to send emails. Even for simple requests like "add email to my Worker" — this skill has critical config details.

cloudflare/cloudflare-one

Design, configure, troubleshoot, or review Cloudflare One Zero Trust and SASE deployments. Use cloudflare-one-migrations for migration planning from other vendors.

cloudflare/durable-objects

Create and review Cloudflare Durable Objects. Use when building stateful coordination (chat rooms, multiplayer games, booking systems), implementing RPC methods, SQLite storage, alarms, WebSockets, or reviewing DO code for best practices. Covers Workers integration, wrangler config, and testing with Vitest. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.

cloudflare/sandbox-migrate-to-next

Migrate Cloudflare Sandbox apps from stable @cloudflare/sandbox to @cloudflare/sandbox@next (SDK 1.0 preview). Use sandbox-next for apps already on the preview.

cloudflare/sandbox-next

Build or maintain Cloudflare Sandbox apps on @cloudflare/sandbox@next (SDK 1.0 preview). Use sandbox-migrate-to-next when porting a stable app.

cloudflare/sandbox-sdk

Build sandboxed applications for secure code execution. Load when building AI code execution, code interpreters, CI/CD systems, interactive dev environments, or executing untrusted code. Covers Sandbox SDK lifecycle, commands, files, code interpreter, and preview URLs. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.

cloudflare/skills

Build, migrate, and deploy Next.js apps on Cloudflare Workers with vinext. Use when starting a Next.js project on Cloudflare, moving an existing app to Workers, choosing between vinext and OpenNext, or setting up vinext for Workers. For setup, migration, or deployment, install vinext's upstream skills with `npx skills add cloudflare/vinext` if missing, then read and follow the applicable skill and docs.

cloudflare/turnstile-spin

Set up, repair, or migrate to Cloudflare Turnstile bot verification in an existing frontend and backend, including server-side Siteverify.

cloudflare/web-perf

Analyzes web performance using Chrome DevTools MCP. Measures Core Web Vitals (LCP, INP, CLS) and supplementary metrics (FCP, TBT, Speed Index), identifies render-blocking resources, network dependency chains, layout shifts, caching issues, and accessibility gaps. Use when asked to audit, profile, debug, or optimize page load performance, Lighthouse scores, or site speed. Biases towards retrieval from current documentation over pre-trained knowledge.

cloudflare/workers-best-practices

Reviews and authors Cloudflare Workers code against production best practices. Load when writing new Workers, reviewing Worker code, configuring wrangler.jsonc, or checking for common Workers anti-patterns (streaming, floating promises, global state, secrets, bindings, observability). Biases towards retrieval from Cloudflare docs over pre-trained knowledge.

cloudflare/wrangler

Cloudflare Workers CLI for deploying, developing, and managing Workers, KV, R2, D1, Vectorize, Hyperdrive, Workers AI, Containers, Queues, Workflows, Pipelines, and Secrets Store. Load before running wrangler commands to ensure correct syntax and best practices. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.

関連スキル