workers-best-practices

Reviews and authors Cloudflare Workers code against production best practices and anti-patterns.

13|1|Updated Feb 9, 2026
One-click install
npx skills add https://github.com/vedang/dotagents --skill workers-best-practices-vedang
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: workers-best-practices
Source: https://github.com/vedang/dotagents/tree/main/specific_skills/workers-best-practices
Command: npx skills add https://github.com/vedang/dotagents --skill workers-best-practices-vedang

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Cloudflare Workers APIs, types, and wrangler configuration change frequently, so code written from stale knowledge often contains anti-patterns like floating promises, global request state, hardcoded secrets, and misconfigured bindings that cause runtime failures or security issues. ## Core Features & Use Cases - Best-Practice Enforcement: Checks Workers code against canonical rules covering streaming, waitUntil usage, bindings over REST APIs, Hyperdrive, observability, and Web Crypto security. - Type and Config Validation: Verifies Env binding types, handler signatures, wrangler.jsonc fields, compatibility dates, and binding-code consistency using retrieved schemas rather than guesswork. - Anti-Pattern Detection: Flags issues like await response.text() on unbounded data, Math.random() for tokens, destructured ctx, and implements on platform base classes. - Use Case: When reviewing a pull request that adds a new Worker with KV bindings, load this skill to validate the wrangler config, check binding access patterns, and catch floating promises before merge. ## Quick Start Review my Cloudflare Worker code and wrangler.jsonc for best-practice violations and common anti-patterns.

Frequently Asked Questions about workers-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I review Cloudflare Workers code for best practices?

Fetch the latest Workers best practices page, workers-types package, and wrangler config schema first, then check types, config, patterns, and security in order. Validate with `npx tsc --noEmit` and lint for no-floating-promises.

What are common Cloudflare Workers anti-patterns to avoid?

Key anti-patterns include buffering unbounded responses with `await response.text()`, hardcoded secrets, `Math.random()` for tokens, floating promises, module-level mutable request state, and calling the Cloudflare REST API instead of using bindings.

Should I use wrangler.toml or wrangler.jsonc for Workers config?

Use wrangler.jsonc for new projects because newer Workers features are JSON-only and JSONC supports comments. TOML is legacy and should be flagged in new projects, though it remains acceptable in existing ones.

Why does destructuring ctx cause Illegal invocation in Workers?

Destructuring `const { waitUntil } = ctx` loses the `this` binding that the method depends on, throwing "Illegal invocation" at runtime. Always call `ctx.waitUntil()` directly on the context object.

How do I access bindings in Durable Objects versus module handlers?

Module export handlers like fetch access bindings via the `env` parameter as `env.X`. Classes extending platform base classes like DurableObject or WorkerEntrypoint must use `this.env.X` instead.

When should I not rely on this skill's built-in knowledge?

Never rely on pre-trained knowledge for API signatures, config fields, or binding shapes, since these change with compatibility dates. The skill mandates retrieving the latest docs, types, and wrangler schema before flagging anything.