workers-best-practices

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

Updated May 23, 2026
One-click install
npx skills add https://github.com/kveperedo/website --skill workers-best-practices-kveperedo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: workers-best-practices
Source: https://github.com/kveperedo/website/tree/main/.agents/skills/workers-best-practices
Command: npx skills add https://github.com/kveperedo/website --skill workers-best-practices-kveperedo

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 unbounded response buffering that cause production failures. ## Core Features & Use Cases - Best-Practice Rule Enforcement: Checks configuration, request handling, architecture, observability, and security rules such as compatibility_date freshness, nodejs_compat, streaming, waitUntil usage, and Hyperdrive for database connections. - Structured Code Review Workflow: Follows an eight-step review process covering type validation, config validation, binding-code consistency, serialization boundaries, and severity-rated findings with file and line evidence. - Retrieval-First Verification: Fetches the latest @cloudflare/workers-types, wrangler config schema, and Cloudflare docs before flagging issues instead of relying on outdated training knowledge. - Use Case: When reviewing a pull request that adds a new Worker with a Durable Object and a Queue binding, load this Skill to verify binding access patterns, detect floating promises, and confirm the wrangler.jsonc config matches the code. ## Quick Start Review my Cloudflare Worker code and wrangler.jsonc for best-practice violations and 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?▼

Follow the eight-step review workflow: retrieve the latest workers types and wrangler schema, read full files, check types and binding access, validate config, check patterns like streaming and floating promises, verify security, and run tsc and lint checks. Findings are reported with severity, file, and line evidence.

What are common Cloudflare Workers anti-patterns to avoid?▼

Key anti-patterns include awaiting response.text() on unbounded data, hardcoded secrets in config, Math.random() for tokens, floating promises without await or waitUntil, module-level mutable request state, calling the Cloudflare REST API from inside a Worker, and destructuring ctx which loses the this binding.

Should I use wrangler.toml or wrangler.jsonc for Worker configuration?▼

Use wrangler.jsonc for new projects because newer Cloudflare features are JSON-only and JSONC supports comments for documenting config decisions. wrangler.toml is legacy and acceptable in existing projects but should be flagged in new ones.

How do I access bindings in Cloudflare Workers correctly?▼

In module export handlers like fetch, access bindings via the env parameter (env.X). In classes extending platform base classes like DurableObject, WorkerEntrypoint, or Workflow, use this.env.X. Mixing these patterns is the most common binding error.

Why does my Cloudflare Worker crash on large responses?▼

Workers have a 128 MB memory limit, so buffering entire bodies with await response.text() or arrayBuffer() crashes on large payloads. Stream data through using TransformStream or pass response.body directly to the new Response instead.

When should I use Hyperdrive for database connections in Workers?▼

Always use Hyperdrive for external PostgreSQL or MySQL connections from a Worker. It maintains a regional connection pool that eliminates per-request TCP, TLS, and auth overhead of 300-500ms, and requires the nodejs_compat compatibility flag.