cloudflare-bundler-apps
Fungsinya
Skill ini mengajari agent cara menyusun proyek agar bundler Cloudflare Worker membangunnya dengan rapi. Skill ini mencakup konfigurasi wrangler, tata letak folder, file statis, dan titik masuk server.
Kapan dipakai
- βSaat pengembang membuat kerangka atau mengubah proyek yang akan dibangun dengan bundler Cloudflare Worker.
- βSaat pratinjau menampilkan halaman kosong atau build gagal untuk proyek Cloudflare.
- βSaat proyek memerlukan aset statis yang disajikan bersama titik masuk server.
Link skill
https://github.com/cloudflare/vibesdk/blob/main/worker/agents/think/skills/app-file-structure/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βAtur proyek Cloudflare saya agar bundler membangunnya dan pratinjaunya menampilkan halaman tanpa error.β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent membaca konfigurasi wrangler untuk titik masuk utama, pengaturan kompatibilitas, dan folder aset, lalu menata proyek agar sesuai dengan aturan bundler. Agent memeriksa batas dependensi dan kesalahan umum yang menyebabkan halaman kosong.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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
Pertanyaan umum
Apa penyebab pratinjau kosong?
Skill ini mencantumkan kesalahan konfigurasi dan tata letak yang menyebabkan halaman kosong atau build gagal.
Apakah permintaan browser ditulis ulang?
Skill ini menyebutkan atribut HTML ditulis ulang untuk jalur pratinjau, tetapi fetch dan impor JavaScript tidak.
File konfigurasi apa yang dibaca?
Skill ini membaca wrangler.json, wrangler.jsonc, atau wrangler.toml.
Detail
Deskripsi asli dari pembuat
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
Popularitas
- Bintang GitHub
- 5.4k
- Peringkat
- #14846
- Lisensi
- MIT
- Diperbarui
- 21/10/2026
Komentar
- β¦
Skill lain dari repositori ini
app-ai-binding
5.4kMembantu agent Anda menambahkan fitur AI ke aplikasi yang dibuat dengan binding Workers AI bawaan, untuk chat, ringkasan, klasifikasi, pencarian, dan transkripsi.
frontend-design-landing-page
5.4kMembantu agent Anda mendesain halaman landing pemasaran yang hangat dan berfokus pada konversi, dengan bagian hero yang jelas, grid fitur, harga, dan ajakan bertindak.
frontend-design-saas
5.4kMembantu agent Anda mendesain antarmuka produk yang padat dan rapi, seperti dasbor, halaman pengaturan, layar penagihan, dan tabel data, dengan gaya SaaS yang tenang dan netral.
Skill serupa
api-connector-builder
280kMembuat agent Anda membangun koneksi API baru mengikuti pola yang sudah ada. Gunakan saat ingin menambah integrasi lagi tanpa membuat cara baru.
api-design
280kMembantu agent Anda merancang REST API sesuai praktik terbaik. Berguna untuk mengatur cara API berkomunikasi, menampilkan error, dan mengorganisasi data.
backend-patterns
280kMembantu agent Anda dengan pola arsitektur sisi server dan optimasi database. Berguna untuk membangun atau meninjau kode yang berjalan di server.