Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Reviews and authors Cloudflare Workers code against production best practices. Load when writing new Workers, reviewing Worker code, configuring wrangler.jsonc, or checking for common Workers anti-patterns (streaming, floating promises, global state, secrets, bindings, observability). Biases towards retrieval from Cloudflare docs over pre-trained knowledge.
.claude/skills/kunanonj-cursor-cf-marketplace-workers-best-practices/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-03 | ✓→✗ | ▼ Worse | 12% | 0% |
| case-23 | ✓→✗ | ▼ Worse | 28% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 99% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 111% | 0% |
| case-06 | ✓→✓ | = Same ✓ | 36% | 0% |
Your knowledge of Cloudflare Workers APIs, types, and configuration may be outdated. Prefer retrieval over pre-training for any Workers code task — writing or reviewing.
Fetch the latest versions before writing or reviewing Workers code. Do not rely on baked-in knowledge for API signatures, config fields, or binding shapes.
| Source | How to retrieve | Use for | |--------|----------------|---------| | Workers best practices | Fetch https://developers.cloudflare.com/workers/best-practices/workers-best-practices/ | Canonical rules, patterns, anti-patterns | | Workers types | See references/review.md for retrieval steps | API signatures, handler types, binding types | | Wrangler config schema | node_modules/wrangler/config-schema.json | Config fields, binding shapes, allowed values | | Cloudflare docs | Search tool or https://developers.cloudflare.com/workers/ | API reference, compatibility dates/flags |
Before reviewing or writing Workers code, retrieve the current best practices page and relevant type definitions. If the project's node_modules has an older version, prefer the latest published version.
bash# Fetch latest workers types mkdir -p /tmp/workers-types-latest && \ npm pack @cloudflare/workers-types --pack-destination /tmp/workers-types-latest && \ tar -xzf /tmp/workers-types-latest/cloudflare-workers-types-*.tgz -C /tmp/workers-types-latest # Types at /tmp/workers-types-latest/package/index.d.ts
references/rules.md — all best practice rules with code examples and anti-patternsreferences/review.md — type validation, config validation, binding access patterns, review process| Rule | Summary | |------|---------| | Compatibility date | Set compatibility_date to today on new projects; update periodically on existing ones | | nodejs_compat | Enable the nodejs_compat flag — many libraries depend on Node.js built-ins | | wrangler types | Run wrangler types to generate Env — never hand-write binding interfaces | | Secrets | Use wrangler secret put, never hardcode secrets in config or source | | wrangler.jsonc | Use JSONC config for non-secret settings — newer features are JSON-only |
| Rule | Summary | |------|---------| | Streaming | Stream large/unknown payloads — never await response.text() on unbounded data | | waitUntil | Use ctx.waitUntil() for post-response work; do not destructure ctx |
| Rule | Summary | |------|---------| | Bindings over REST | Use in-process bindings (KV, R2, D1, Queues) — not the Cloudflare REST API | | Queues & Workflows | Move async/background work off the critical path | | Service bindings | Use service bindings for Worker-to-Worker calls — not public HTTP | | Hyperdrive | Always use Hyperdrive for external PostgreSQL/MySQL connections |
| Rule | Summary | |------|---------| | Logs & Traces | Enable observability in config with head_sampling_rate; use structured JSON logging |
| Rule | Summary | |------|---------| | No global request state | Never store request-scoped data in module-level variables | | Floating promises | Every Promise must be awaited, returned, voided, or passed to ctx.waitUntil() |
| Rule | Summary | |------|---------| | Web Crypto | Use crypto.randomUUID() / crypto.getRandomValues() — never Math.random() for security | | No passThroughOnException | Use explicit try/catch with structured error responses |
| Anti-pattern | Why it matters | |-------------|----------------| | await response.text() on unbounded data | Memory exhaustion — 128 MB limit | | Hardcoded secrets in source or config | Credential leak via version control | | Math.random() for tokens/IDs | Predictable, not cryptographically secure | | Bare fetch() without await or waitUntil | Floating promise — dropped result, swallowed error | | Module-level mutable variables for request state | Cross-request data leaks, stale state, I/O errors | | Cloudflare REST API from inside a Worker | Unnecessary network hop, auth overhead, added latency | | ctx.passThroughOnException() as error handling | Hides bugs, makes debugging impossible | | Hand-written Env interface | Drifts from actual wrangler config bindings | | Direct string comparison for secret values | Timing side-channel — use crypto.subtle.timingSafeEqual | | Destructuring ctx (const { waitUntil } = ctx) | Loses this binding — throws "Illegal invocation" at runtime | | any on Env or handler params | Defeats type safety for all binding access | | as unknown as T double-cast | Hides real type incompatibilities — fix the design | | implements on platform base classes (instead of extends) | Legacy — loses this.ctx, this.env. Applies to DurableObject, WorkerEntrypoint, Workflow | | env.X inside platform base class | Should be this.env.X in classes extending DurableObject, WorkerEntrypoint, etc. |
any, no unsafe casts (see references/review.md)npx tsc --noEmit, lint for no-floating-promisesreferences/rules.md for each rule's correct patternThis skill covers Workers-specific best practices and code review. For related topics:
durable-objects skillwrangler skill| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 15,423 | 16,937 | +10% | 1 | 1 | 0% | 3,454 | 5,512 | +60% | 0 | 0 | — |
case-02 | fail→fail | 12,495 | 14,180 | +13% | 1 | 1 | 0% | 1,249 | 3,427 | +174% | 0 | 0 | — |
case-03 | pass→fail | 8,366 | 5,393 | -36% | 1 | 1 | 0% | 1,743 | 1,946 | +12% | 0 | 0 | — |
case-04 | pass→pass | 7,163 | 6,161 | -14% | 1 | 1 | 0% | 1,437 | 2,864 | +99% | 0 | 0 | — |
case-05 | pass→pass | 9,016 | 11,361 | +26% | 1 | 1 | 0% | 1,977 | 4,180 | +111% | 0 | 0 | — |
case-06 | pass→pass | 8,375 | 3,404 | -59% | 1 | 1 | 0% | 1,666 | 2,263 | +36% | 0 | 0 | — |
case-07 | pass→pass | 7,597 | 5,673 | -25% | 1 | 1 | 0% | 1,741 | 2,626 | +51% | 0 | 0 | — |
case-08 | pass→pass | 11,222 | 9,290 | -17% | 1 | 1 | 0% | 2,252 | 3,614 | +60% | 0 | 0 | — |
case-09 | pass→pass | 10,688 | 7,876 | -26% | 1 | 1 | 0% | 2,273 | 3,269 | +44% | 0 | 0 | — |
case-10 | pass→pass | 10,262 | 6,634 | -35% | 1 | 1 | 0% | 1,950 | 2,762 | +42% | 0 | 0 | — |
case-11 | pass→pass | 6,463 | 5,856 | -9% | 1 | 1 | 0% | 1,302 | 2,771 | +113% | 0 | 0 | — |
case-12 | pass→pass | 9,624 | 6,206 | -36% | 1 | 1 | 0% | 1,643 | 2,784 | +69% | 0 | 0 | — |
case-13 | pass→pass | 13,109 | 7,735 | -41% | 1 | 1 | 0% | 2,340 | 3,284 | +40% | 0 | 0 | — |
case-14 | pass→pass | 10,562 | 6,186 | -41% | 1 | 1 | 0% | 2,129 | 2,875 | +35% | 0 | 0 | — |
case-15 | pass→pass | 12,730 | 11,422 | -10% | 1 | 1 | 0% | 2,263 | 3,836 | +70% | 0 | 0 | — |
case-16 | pass→pass | 6,628 | 3,857 | -42% | 1 | 1 | 0% | 1,293 | 2,319 | +79% | 0 | 0 | — |
case-17 | pass→pass | 10,330 | 5,748 | -44% | 1 | 1 | 0% | 2,163 | 2,810 | +30% | 0 | 0 | — |
case-18 | pass→pass | 11,045 | 4,948 | -55% | 1 | 1 | 0% | 2,073 | 2,566 | +24% | 0 | 0 | — |
case-19 | pass→pass | 5,589 | 3,203 | -43% | 1 | 1 | 0% | 1,080 | 2,254 | +109% | 0 | 0 | — |
case-20 | pass→pass | 7,851 | 6,704 | -15% | 1 | 1 | 0% | 1,546 | 2,930 | +90% | 0 | 0 | — |
case-21 | pass→pass | 18,231 | 13,472 | -26% | 1 | 1 | 0% | 3,180 | 4,437 | +40% | 0 | 0 | — |
case-22 | pass→pass | 13,939 | 22,014 | +58% | 1 | 1 | 0% | 2,916 | 6,495 | +123% | 0 | 0 | — |
case-23 | pass→fail | 15,153 | 14,906 | -2% | 1 | 1 | 0% | 3,131 | 4,018 | +28% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted, and 21 counted toward the lift figure. The other 2 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of -9 percentage points is the difference between those two pass rates over the 21 comparable cases. 2 cases got worse with the skill loaded, and they are included in that figure.
Other measured skills in the registry, with their headline benchmark lift.