Cloudflare Workers
Use this skill to deliver Cloudflare Workers tasks with production-safe defaults and minimal setup churn.
Execute the workflow
- Classify the request.
- Bootstrap or inspect the project.
- Configure
wrangler.jsonc and bindings.
- Implement handlers and business logic.
- Validate locally and with tests.
- Deploy and verify in logs.
Classify the request
Identify the primary task before making changes:
- New project or scaffold
- Binding configuration or migration
- Runtime API usage
- Framework integration
- Deployment or CI/CD
- Debugging and observability
Use the routing table below to load only the needed reference file.
Route to references on demand
Load only one file at a time unless the task clearly spans multiple domains.
references/bindings.md: KV, R2, D1, Durable Objects, Queues, AI, Vectorize, Service Bindings, Browser Rendering, Hyperdrive, Analytics
references/runtime-apis.md: fetch, scheduled, queue, Cache API, HTMLRewriter, WebSockets, Streams, Crypto, Node compatibility
references/frameworks.md: React/Vite, Vue/Vite, Next.js, Astro, SvelteKit, Hono, React Router, Nuxt, Solid Start, Express adapters
references/patterns.md: API patterns, caching, auth, rate limiting, validation, repository patterns, RAG, performance, security
Bootstrap quickly
Prefer the bundled scaffold when the user wants a starter project:
bash scripts/scaffold-worker.sh <project-name> [api|spa|fullstack|hono]
Then run:
cd <project-name>
npm install
npx wrangler dev
Use npm create cloudflare@latest when the user explicitly asks for official templates.
Configure Wrangler correctly
Use wrangler.jsonc and always set:
name
main
compatibility_date
Apply these rules:
- Keep non-sensitive config in
vars
- Store secrets with
wrangler secret put
- Keep bindings in
wrangler.jsonc aligned with the Env interface in code
- Regenerate bindings types after changes with
npx wrangler types
Implement handlers with clear boundaries
Start with fetch; add scheduled and queue only if needed.
- Keep routing thin
- Move logic to modules/services
- Use
ctx.waitUntil for non-blocking async work
- Use prepared statements for D1
- Return explicit status codes and content types
Validate before deploy
Run a tight verification loop:
npx wrangler dev
npm test
npx wrangler deploy --dry-run
If bindings depend on remote resources, test with remote mode when necessary.
Deploy safely
Follow staged deployment:
- Deploy to staging environment.
- Run smoke checks on key routes.
- Deploy to production.
- Tail logs and confirm no regression.
Useful commands:
npx wrangler deploy
npx wrangler deploy -e staging
npx wrangler tail
Debug systematically
When debugging, execute this order:
- Confirm request path and method handling.
- Confirm binding names and IDs in
wrangler.jsonc.
- Confirm
Env interface matches configured bindings.
- Confirm secrets and environment-specific config.
- Re-run type generation and restart dev server.
- Tail logs and inspect failing requests.
Use production guardrails
- Never store secrets in
vars.
- Validate external input before use.
- Keep queue consumers idempotent.
- Define cache behavior intentionally.
- Limit per-request work and parallelize I/O with care.
Return useful outputs
When responding to users, provide concrete artifacts:
- Minimal patch-ready config snippets
- Exact command sequence for local run and deploy
- Clear list of required bindings and secrets
- Verification checklist (what to test and where to look)
1---2name: cloudflare-workers3description: Build and operate Cloudflare Workers applications end-to-end, including bootstrap, Wrangler setup, bindings (KV, R2, D1, Durable Objects, Queues, Workers AI, Vectorize), runtime APIs, framework integrations, testing, deployment, and observability. Use when users ask for Cloudflare Workers, Wrangler, edge functions, or Cloudflare Developer Platform integrations.4---56# Cloudflare Workers78Use this skill to deliver Cloudflare Workers tasks with production-safe defaults and minimal setup churn.910## Execute the workflow11121. Classify the request.132. Bootstrap or inspect the project.143. Configure `wrangler.jsonc` and bindings.154. Implement handlers and business logic.165. Validate locally and with tests.176. Deploy and verify in logs.1819## Classify the request2021Identify the primary task before making changes:2223- New project or scaffold24- Binding configuration or migration25- Runtime API usage26- Framework integration27- Deployment or CI/CD28- Debugging and observability2930Use the routing table below to load only the needed reference file.3132## Route to references on demand3334Load only one file at a time unless the task clearly spans multiple domains.3536- `references/bindings.md`: KV, R2, D1, Durable Objects, Queues, AI, Vectorize, Service Bindings, Browser Rendering, Hyperdrive, Analytics37- `references/runtime-apis.md`: `fetch`, `scheduled`, `queue`, Cache API, HTMLRewriter, WebSockets, Streams, Crypto, Node compatibility38- `references/frameworks.md`: React/Vite, Vue/Vite, Next.js, Astro, SvelteKit, Hono, React Router, Nuxt, Solid Start, Express adapters39- `references/patterns.md`: API patterns, caching, auth, rate limiting, validation, repository patterns, RAG, performance, security4041## Bootstrap quickly4243Prefer the bundled scaffold when the user wants a starter project:4445```bash46bash scripts/scaffold-worker.sh <project-name> [api|spa|fullstack|hono]47```4849Then run:5051```bash52cd <project-name>53npm install54npx wrangler dev55```5657Use `npm create cloudflare@latest` when the user explicitly asks for official templates.5859## Configure Wrangler correctly6061Use `wrangler.jsonc` and always set:6263- `name`64- `main`65- `compatibility_date`6667Apply these rules:6869- Keep non-sensitive config in `vars`70- Store secrets with `wrangler secret put`71- Keep bindings in `wrangler.jsonc` aligned with the `Env` interface in code72- Regenerate bindings types after changes with `npx wrangler types`7374## Implement handlers with clear boundaries7576Start with `fetch`; add `scheduled` and `queue` only if needed.7778- Keep routing thin79- Move logic to modules/services80- Use `ctx.waitUntil` for non-blocking async work81- Use prepared statements for D182- Return explicit status codes and content types8384## Validate before deploy8586Run a tight verification loop:8788```bash89npx wrangler dev90npm test91npx wrangler deploy --dry-run92```9394If bindings depend on remote resources, test with remote mode when necessary.9596## Deploy safely9798Follow staged deployment:991001. Deploy to staging environment.1012. Run smoke checks on key routes.1023. Deploy to production.1034. Tail logs and confirm no regression.104105Useful commands:106107```bash108npx wrangler deploy109npx wrangler deploy -e staging110npx wrangler tail111```112113## Debug systematically114115When debugging, execute this order:1161171. Confirm request path and method handling.1182. Confirm binding names and IDs in `wrangler.jsonc`.1193. Confirm `Env` interface matches configured bindings.1204. Confirm secrets and environment-specific config.1215. Re-run type generation and restart dev server.1226. Tail logs and inspect failing requests.123124## Use production guardrails125126- Never store secrets in `vars`.127- Validate external input before use.128- Keep queue consumers idempotent.129- Define cache behavior intentionally.130- Limit per-request work and parallelize I/O with care.131132## Return useful outputs133134When responding to users, provide concrete artifacts:135136- Minimal patch-ready config snippets137- Exact command sequence for local run and deploy138- Clear list of required bindings and secrets139- Verification checklist (what to test and where to look)