cloudflare-bundler-apps
Skill này làm gì
Skill này dạy agent cách tổ chức dự án để bộ bundler của Cloudflare Worker build sạch. Skill bao gồm cấu hình wrangler, bố cục thư mục, file tĩnh và điểm vào của máy chủ.
Khi nào nên dùng
- ✓Khi nhà phát triển tạo khung hoặc thay đổi một dự án sẽ được build bằng bundler của Cloudflare Worker.
- ✓Khi bản xem trước hiện trang trắng hoặc build lỗi với một dự án Cloudflare.
- ✓Khi dự án cần phục vụ tài nguyên tĩnh cùng với điểm vào máy chủ.
Liên kết skill
https://github.com/cloudflare/vibesdk/blob/main/worker/agents/think/skills/app-file-structure/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Thiết lập dự án Cloudflare của tôi để bundler build được và bản xem trước hiện trang mà không có lỗi.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent đọc điểm vào chính, các thiết lập tương thích và thư mục tài nguyên trong cấu hình wrangler, rồi sắp xếp dự án theo quy tắc của bundler. Agent kiểm tra giới hạn phụ thuộc và các lỗi thường gây ra trang trắng.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
Điều gì gây ra bản xem trước trắng?
Skill liệt kê các lỗi cấu hình và bố cục dẫn tới trang trắng hoặc build lỗi.
Các yêu cầu từ trình duyệt có bị viết lại không?
Skill nói các thuộc tính HTML được viết lại cho đường dẫn xem trước, còn các lệnh fetch và import JavaScript thì không.
Nó đọc những file cấu hình nào?
Nó đọc wrangler.json, wrangler.jsonc hoặc wrangler.toml.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 5.4k
- Vị trí xếp hạng
- #14846
- Giấy phép
- MIT
- Cập nhật
- 21/10/2026
Bình luận
- …
Thêm skill từ kho mã này
app-ai-binding
5.4kGiúp agent của bạn thêm tính năng AI vào ứng dụng được tạo ra bằng binding AI có sẵn của Workers AI, cho chat, tóm tắt, phân loại, tìm kiếm và chuyển giọng nói thành văn bản.
frontend-design-landing-page
5.4kGiúp agent của bạn thiết kế trang đích tiếp thị ấm áp, tập trung vào chuyển đổi, với phần hero rõ ràng, lưới tính năng, bảng giá và các lời kêu gọi hành động.
frontend-design-saas
5.4kGiúp agent của bạn thiết kế giao diện sản phẩm dày đặc, gọn gàng như bảng điều khiển, trang cài đặt, màn hình thanh toán và bảng dữ liệu, theo phong cách SaaS trung tính và yên tĩnh.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.