Cloudflare Workers local development with Wrangler, Miniflare, hot reload, debugging. Use for project setup, wrangler.jsonc configuration, or encountering local dev, HMR, binding simulation errors.
SKILL.md
Cloudflare Workers Developer Experience
Local development setup with Wrangler, Miniflare, and modern tooling.
Quick Start
# Create new project
bunx create-cloudflare@latest my-worker
# Or from scratch
mkdir my-worker && cd my-worker
bun init -y
bun add -d wrangler @cloudflare/workers-types
# Start local development
bunx wrangler dev
Secure Installation
Scaffolding tools like bunx create-cloudflare download and execute remote code. Before running, follow supply chain security best practices:
Block post-install scripts — npm config set ignore-scripts true (or Bun: disabled by default)
Cooldown period — Wait 7 days for new package versions to be vetted by the community
Audit before installing — Run socket package score npm <pkg> or use socket npm install <pkg> to check packages
Load the dependency-upgrade skill for full security configuration including Socket CLI integration, cooldown setup, lockfile validation, and CI enforcement.
Always use wrangler dev for local testing - Simulates Cloudflare runtime accurately
Set compatibility_date - Controls runtime behavior, update quarterly
Use preview IDs for local dev - Separate from production bindings
Configure TypeScript properly - Use @cloudflare/workers-types
Enable source maps - Better error stacks in development
Top 6 Errors Prevented
Error
Symptom
Prevention
Module not found
Import errors on deploy
Set "moduleResolution": "bundler" in tsconfig
Binding undefined
env.KV is undefined locally
Add preview_id to KV namespace config
HMR not working
Changes not reflecting
Check port conflicts, use --local flag
D1 schema mismatch
Queries fail locally
Run migrations on local DB
Type errors
Missing binding types
Generate types with wrangler types
CORS issues
Browser blocking requests
Add CORS headers in dev handler
Local Development Workflow
# Start dev server (recommended)
bunx wrangler dev
# With live reload
bunx wrangler dev --live-reload
# Remote mode (use actual Cloudflare services)
bunx wrangler dev --remote
# Specify environment
bunx wrangler dev --env staging
# Custom port
bunx wrangler dev --port 3000
# Real-time logs from deployed worker
wrangler tail
# Filter by status
wrangler tail --status error
# Filter by method
wrangler tail --method POST
# JSON format for parsing
wrangler tail --format json