cloudflare-worker-base
This skill scaffolds and configures Cloudflare Workers projects (Hono, Vite, Static Assets) and includes deploy/debug agents and templates. It contains explicit shell commands (npm, git, npx wrangler deploy, curl), network calls (https://api.datadoghq.com/api/v1/logs, https://cloudflare-worker-base-test.webfonts.workers.dev) and secret handling (wrangler secret put, CLOUDFLARE_API_TOKEN).
Cloudflare Worker Base Stack
Status: ✅ Production Ready Last Updated: 2026-01-03 Production Example: https://cloudflare-worker-base-test.webfonts.workers.dev
What This Skill Does
Sets up production-ready Cloudflare Workers projects with:
- Hono v4.11.3 for routing
- @cloudflare/vite-plugin v1.17.1 for development
- Wrangler v4.54.0 with auto-provisioning
- Workers Static Assets for frontend files
- Workers RPC for service-to-service calls
- ES Module format (correct export pattern)
- wrangler.jsonc configuration (preferred over .toml)
Prevents 8 documented issues that commonly break Workers projects.
Auto-Trigger Keywords
Claude automatically uses this skill when you mention:
Technologies
- Cloudflare Workers
- CF Workers
- Hono
- Wrangler
- Workers Static Assets
- @cloudflare/vite-plugin
- wrangler.jsonc
- ES Module Worker
- Serverless Cloudflare
- Edge computing
- Workers RPC
- WorkerEntrypoint
- Service bindings
- Auto-provisioning
Use Cases
- Create Cloudflare Worker
- Set up Hono routing
- Configure Vite for Workers
- Add Static Assets to Worker
- Deploy with Wrangler
- Initialize Workers project
- Scaffold CF Worker
- Workers with frontend
- Call Worker from Worker
- Split Worker into microservices
- Auto-provision D1/R2/KV bindings
Common Errors (Triggers Prevention)
- "Cannot read properties of undefined"
- "Static Assets 404"
- "A hanging Promise was canceled"
- "Handler does not export"
- API routes return HTML instead of JSON
- SPA fallback intercepts API
- Deployment fails non-deterministically
- HMR crashes during development
- Routing not working
- Build fails with Vite
- 404 for fingerprinted assets during gradual rollout
- 429 errors with run_worker_first on free tier
Known Issues Prevented
| Issue | Error Message | Source | Prevention |
|---|---|---|---|
| #1: Export Syntax | "Cannot read properties of undefined (reading 'map')" | hono #3955 | Use export default app |
| #2: Routing Conflicts | API routes return index.html | workers-sdk #8879 | run_worker_first: ["/api/*"] |
| #3: Scheduled Handler | "Handler does not export scheduled()" | vite-plugins #275 | Module Worker format when needed |
| #4: HMR Race | "A hanging Promise was canceled" | workers-sdk #9518 | Use vite-plugin@1.13.13+ |
| #5: Upload Race | Non-deterministic deployment failures | workers-sdk #7555 | Wrangler 4.x+ with retry |
| #6: Format Confusion | Using deprecated Service Worker format | Cloudflare migration guide | ES Module format |
| #7: Gradual Rollouts | 404 for fingerprinted assets during deployment | CF Static Assets Docs | Avoid gradual rollouts with fingerprinted assets |
| #8: Free Tier 429 | 429 errors with run_worker_first | CF Billing Docs | Minimize patterns or upgrade to Paid |
Quick Start
# 1. Scaffold project
npm create cloudflare@latest my-worker -- --type hello-world --ts --git --deploy false --framework none
# 2. Install dependencies
cd my-worker
npm install hono@4.11.3
npm install -D @cloudflare/vite-plugin@1.17.1 vite@7.2.4
# 3. Configure (see SKILL.md for full setup)
# 4. Dev & Deploy
npm run dev
npm run deploy
Full instructions: See SKILL.md
Token Savings Estimate
Without this skill: ~8,000 tokens (documentation lookups + trial-and-error fixing errors) With this skill: ~3,000 tokens (direct implementation with correct patterns)
Savings: ~60% token reduction + prevents all 8 documented errors on first attempt
Included Agents
This skill includes 4 companion agents for common workflows:
| Agent | Purpose | Trigger Phrases |
|---|---|---|
| cloudflare-deploy | Build → deploy → verify | "deploy to cloudflare", "deploy this worker" |
| d1-migration | Local → test → remote migrations | "run migrations", "update d1 schema" |
| cloudflare-debug | Diagnose worker issues | "debug this worker", "why is it failing" |
| worker-scaffold | Create new projects | "create a new worker", "scaffold cloudflare project" |
To install all agents:
cp ~/.claude/skills/cloudflare-worker-base/agents/*.md ~/.claude/agents/
Why use agents? Context hygiene. Each agent runs in isolated context—verbose build logs, migration outputs, and debug traces don't bloat your main conversation. You get a clean summary instead of 500+ lines of tool output.
File Structure
cloudflare-worker-base/
├── SKILL.md # Full instructions (read this first)
├── README.md # This file
├── agents/ # Companion agents
│ ├── cloudflare-deploy.md # Build → deploy → verify
│ ├── d1-migration.md # Local → test → remote migrations
│ ├── cloudflare-debug.md # Diagnose worker issues
│ └── worker-scaffold.md # Create new projects
├── templates/ # Copy-ready files
│ ├── wrangler.jsonc # Worker configuration
│ ├── vite.config.ts # Vite + plugin setup
│ ├── package.json # Dependencies
│ ├── tsconfig.json # TypeScript config
│ ├── src/
│ │ └── index.ts # Hono app with API routes
│ └── public/ # Static assets example
│ ├── index.html
│ ├── styles.css
│ └── script.js
└── reference/ # Deep-dive docs
├── architecture.md # Export patterns, routing, Static Assets
├── common-issues.md # All 6 issues with troubleshooting
└── deployment.md # Wrangler, CI/CD, production tips
Package Versions (Verified 2026-01-03)
| Package | Version | Status |
|---|---|---|
| wrangler | 4.54.0 | ✅ Latest stable |
| @cloudflare/workers-types | 4.20260103.0 | ✅ Latest |
| hono | 4.11.3 | ✅ Latest stable |
| @cloudflare/vite-plugin | 1.17.1 | ✅ Latest |
| vite | 7.2.4 | ✅ Latest stable |
| typescript | 5.9.3+ | ✅ Standard |
When to Use This Skill
✅ Use this skill when:
- Creating a new Cloudflare Workers project
- Adding Vite to an existing Worker
- Setting up Hono routing
- Configuring Static Assets with Workers
- Encountering any of the 8 documented errors
- Need production-ready Worker template
- Want to avoid common Workers pitfalls
- Setting up Workers RPC / service bindings
- Want auto-provisioned D1/R2/KV bindings
❌ Don't use this skill for:
- Cloudflare Pages projects (use Workers with Static Assets instead)
- Adding D1/KV/R2 bindings (covered in separate
cloudflare-servicesskill) - Authentication setup (covered in
clerk-authskill) - React/Vue framework setup (those have dedicated skills)
Official Documentation
- Cloudflare Workers: https://developers.cloudflare.com/workers/
- Static Assets: https://developers.cloudflare.com/workers/static-assets/
- Vite Plugin: https://developers.cloudflare.com/workers/vite-plugin/
- Hono: https://hono.dev/docs/getting-started/cloudflare-workers
- Wrangler Configuration: https://developers.cloudflare.com/workers/wrangler/configuration/
Research Validation
- ✅ All packages verified on npm (2026-01-03)
- ✅ All 8 issues have documented sources
- ✅ Working example deployed: https://cloudflare-worker-base-test.webfonts.workers.dev
- ✅ Build time: ~45 minutes (0 errors)
- ✅ Research log:
/home/jez/Documents/claude-skills/planning/research-logs/cloudflare-worker-base.md
Next Steps After Using This Skill
- Add Database: Use
cloudflare-servicesskill to add D1/KV/R2 - Add Authentication: Use
clerk-authskill for user management - Add Frontend Framework: Use
vite-reactorvite-vueskills - Set up CI/CD: See
reference/deployment.mdfor GitHub Actions examples
Production Tested: ✅ Error Rate: 0 Build Success Rate: 100% Token Efficiency: ~60% savings
Ready to use! Start with SKILL.md for full setup instructions.