cloudflare-bundler-apps
できること
このスキルは、Cloudflare Worker のバンドラーがきれいにビルドできるよう、プロジェクトを構成する方法を説明します。wrangler の設定、フォルダーの構成、静的ファイル、サーバーの入口を扱います。
使う場面
- ✓開発者が、Cloudflare のバンドラーでビルドするプロジェクトを新しく作るか、変更するとき。
- ✓Cloudflare のプロジェクトのプレビューが白い画面やビルドの失敗を示すとき。
- ✓プロジェクトが、サーバーの入口と一緒に静的アセットを配信する必要があるとき。
スキルのリンク
https://github.com/cloudflare/vibesdk/blob/main/worker/agents/think/skills/app-file-structure/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“バンドラーでビルドでき、プレビューにエラーなくページが表示されるよう、私の Cloudflare プロジェクトを設定してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、メインの入口、互換性の設定、アセットのフォルダーを wrangler の設定から読み、バンドラーのルールに合うようプロジェクトを配置します。依存関係の上限と、白い画面の原因になる一般的な誤りを確認します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
This skill teaches how to build apps that deploy cleanly through the space deploy pipeline. Every project committed to a space is built by @cloudflare/worker-bundler (createApp when there are static assets, createWorker when there are none) and served on a Dynamic Worker via WorkerLoader. Get the conventions right and the preview "just works". Get them wrong and you get a blank page, a 500, or a Build failed error.
How the pipeline works
When deploy_space(branch) is called, the space DO:
- Reads every file from the branch's working tree (skipping
.git/). - Parses
wrangler.json/wrangler.jsonc/wrangler.tomlformain,compatibility_date,compatibility_flags, and[assets]. - If
[assets].directoryis set, files under that directory become static assets served host-side byhandleAssetRequest. Everything else is built into a Worker viacreateApp(withserver: <main>). - If no assets directory is configured, only
createWorker({ entryPoint: <main> })is run. The output is loaded as a Dynamic Worker; all requests go to the Worker. - Previews are served at
/space/:name/preview/:branch/*. Responses withcontent-type: text/htmlare run throughHTMLRewriter, which prefixes root-relativesrc/href/actionattributes with the preview base path. JS-side fetches and dynamic imports are NOT rewritten.
Practical consequences:
- You can rely on root-relative
src="/foo.js"andhref="/style.css"in HTML. They will be rewritten to the preview path automatically. - You cannot rely on root-relative paths inside JS strings:
fetch("/api/x"),new URL("/foo", location.origin), dynamicimport("/lib.js"). These hit the wrong path under the preview prefix. Use relative paths (./api/x,import.meta.url) or read the base path from<base href>/ a meta tag injected at build time. - The
<base href>tag is also rewritten if present — using it lets all relative URLs resolve against the preview path.
Project layout
A typical full-stack space project:
/
├── wrangler.json # required for non-trivial setups
├── package.json # npm deps (text-only packages, see limits below)
├── src/
│ └── index.ts # server entry: export default { fetch }
└── public/ # static assets directory (configurable)
├── index.html
├── app.js # compiled, no JSX
└── styles.css
A static-only SPA can skip src/ entirely — just wrangler.json + public/ is enough as long as main points to a minimal pass-through worker or you accept that all requests fall through assets.
Wrangler config
Minimum viable wrangler.json:
{
"main": "src/index.ts",
"compatibility_date": "2025-04-01",
"assets": {
"directory": "./public",
"html_handling": "auto-trailing-slash",
"not_found_handling": "single-page-application"
}
}
Notes:
mainis required when there's any server code. The bundler also auto-detectssrc/index.ts,src/index.js,index.ts,index.jsif missing.compatibility_datedefaults to2025-04-01if omitted. Set it explicitly for newer features.- Add
"compatibility_flags": ["nodejs_compat"]only if you actually need Node built-ins. assets.directoryis the only way to ship static files. Files outside this directory are bundled into the Worker or ignored — they will not be reachable via URL.html_handling: "auto-trailing-slash"is usually what you want for multi-page sites; SPAs should also setnot_found_handling: "single-page-application"so deep links returnindex.html.
TOML works too (wrangler.toml), but the parser only handles top-level scalar fields plus an [assets] table — no inline tables, no env overrides. Prefer JSON.
Server entry: one Durable Object class named App
Your entire backend is one Durable Object. Your main module exports
a class named App extending DurableObject. The platform loads it as
a Cloudflare Durable Object
Facet
of the host SpaceDO and forwards every non-asset request — including
WebSocket upgrades — to your App.fetch(request).
Do not export default { fetch }. A default fetch handler will be
ignored. There is no separate worker; the DO is the worker.
// src/index.ts
import { DurableObject } from "cloudflare:workers";
export class App extends DurableObject {
async fetch(request: Request): Promi
よくある質問
白いプレビューの原因は何ですか?
設定や構成の誤りで、白い画面やビルドの失敗につながるものが挙げられています。
ブラウザーのリクエストは書き換えられますか?
HTML の属性はプレビューの経路のために書き換えられますが、JavaScript の fetch や import は書き換えられないとされています。
どの設定ファイルを読みますか?
wrangler.json、wrangler.jsonc、wrangler.toml のいずれかを読みます。
詳細
作者による元の説明
Author Cloudflare Worker Bundler-compatible apps that build and preview correctly inside a space. Use this skill whenever you scaffold, modify, or deploy a project that will be built with `@cloudflare/worker-bundler` (i.e. anything served from `/space/:name/preview/:branch/`). Covers wrangler config, project layout, static asset rules, server entry conventions, npm dependency limits, and the most common cause of blank previews (JSX in browser scripts).
repo: cloudflare/vibesdk
人気
- GitHubのスター
- 5.4k
- ランキング
- #14846
- ライセンス
- MIT
- 更新日
- 2026/10/21
コメント
- …
このリポジトリの他のスキル
app-ai-binding
5.4kエージェントが、組み込みの Workers AI バインディングを使って、生成されたアプリに AI 機能を加えられるよう支援します。チャット、要約、分類、検索、文字起こしに対応します。
frontend-design-landing-page
5.4kエージェントが、明確なヒーローセクション、機能のグリッド、料金、行動への呼びかけを備えた、温かみがあり、コンバージョンを意識したマーケティングのランディングページをデザインできるよう支援します。
frontend-design-saas
5.4kエージェントが、ダッシュボード、設定画面、請求画面、データテーブルなどの、密度が高くすっきりした製品の画面を、落ち着いたニュートラルな SaaS のスタイルでデザインできるよう支援します。
似ているスキル
api-connector-builder
280kエージェントが既存のパターンに従って、新しいAPI連携を構築します。新しい方式を作らずに、もう一つ連携を追加したいときに使います。
api-design
280kエージェントがベストプラクティスに沿ってREST APIを設計できるようにします。APIの通信方法、エラーの表示方法、データの整理方法を決めるのに役立ちます。
backend-patterns
280kエージェントのサーバーサイドのアーキテクチャパターンとデータベースの最適化を支援します。サーバー上で動くコードを作成またはレビューするときに役立ちます。