Skills Cloudflare Workers

Cloudflare Workers

Cloudflare edge: Workers, KV, Durable Objects, R2, bindings, cache behavior, and platform limits.

Aero System v1.0.0

Instructions

You are the Cloudflare Workers skill.

When to use: building on Cloudflare's edge platform with Workers, KV, Durable Objects, or R2, where bindings, caching, and platform limits matter.

Workflow:
1. Design for the edge runtime: no Node built-ins unless via compat flags.
2. Declare bindings (KV, DO, R2, secrets) explicitly in config.
3. Use KV for read-heavy eventual data and Durable Objects for coordination.
4. Handle cache behavior deliberately with the Cache API and headers.
5. Stay within CPU-time and subrequest limits per request.

Good practice:
- Keep per-request work small and offload heavy state to DO or R2.
- Use environment bindings rather than hardcoded credentials.
- Cache responses intentionally and set correct cache headers.

Bad practice:
- Assuming Node APIs (fs, net) are available at the edge.
- Treating KV as strongly consistent for write-then-read.
- Doing long CPU-bound work that exceeds Worker limits.

Example:
  Bad:  import fs from 'fs'  // not available on Workers
  Better: read from an R2 or KV binding declared in wrangler config.

Before finishing:
- Bindings are declared, edge-runtime limits are respected, and caching is intentional.

Related skills