cloudflare-bundler-apps
What it does
This skill teaches an agent how to structure a project so the Cloudflare worker bundler builds it cleanly. It covers the wrangler config, folder layout, static files, and the server entry point.
When to use it
- βWhen a developer scaffolds or changes a project that will be built with the Cloudflare worker bundler.
- βWhen a preview shows a blank page or a build failure for a Cloudflare project.
- βWhen a project needs static assets served alongside a server entry point.
Skill link
https://github.com/cloudflare/vibesdk/blob/main/worker/agents/think/skills/app-file-structure/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βSet up my Cloudflare project so the bundler builds it and the preview shows the page without errors.β
5 new skills a week. 1 minute to read.
How it works
The agent reads the wrangler config for the main entry, compatibility settings, and assets folder, then lays out the project to match the bundler's rules. It checks dependency limits and common mistakes that cause blank pages.
Technical content (original SKILL.md)
Original text by the author, straight from 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
FAQ
What causes a blank preview?
The skill lists config and layout mistakes that lead to blank pages or build failures.
Are browser requests rewritten?
The skill says HTML attributes are rewritten for the preview path, but JavaScript fetches and imports are not.
Which config files does it read?
It reads wrangler.json, wrangler.jsonc, or wrangler.toml.
Details
Original description by the author
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
Popularity
- GitHub stars
- 5.4k
- Ranking position
- #14846
- License
- MIT
- Updated
- 10/21/2026
Comments
- β¦
More skills from this repository
app-ai-binding
5.4kHelps your agent add AI features to a generated app with the built-in Workers AI binding, for chat, summaries, classification, search, and transcription.
frontend-design-landing-page
5.4kHelps your agent design a warm, conversion-focused marketing landing page with clear hero sections, feature grids, pricing, and calls to action.
frontend-design-saas
5.4kHelps your agent design dense, clean product interfaces such as dashboards, settings pages, billing screens, and data tables in a quiet, neutral SaaS style.
Similar skills
api-connector-builder
280kHas your agent build new API connections following the existing pattern. Use when you need to add one more integration without creating a new way of doing things.
api-design
280kHelps your agent design REST APIs following best practices. It's useful for defining how APIs communicate, how errors are shown, and how to organize data.
backend-patterns
280kHelps your agent with server-side architecture patterns and database optimization. It's useful for building or reviewing code that runs on the server.