workers-best-practices

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Cloudflare Workers APIs, types, and wrangler configuration change frequently, so pre-trained knowledge produces outdated or broken code. This Skill enforces retrieval-first review and authoring of Workers code, catching anti-patterns like floating promises, global request state, hardcoded secrets, and unbounded buffering before they reach production. ## Core Features & Use Cases - Retrieval-first workflow: Fetches the latest Workers best practices page, @cloudflare/workers-types, and the wrangler config schema before writing or reviewing code. - Rule-based code review: Checks configuration (compatibility_date, nodejs_compat, secrets, observability), request handling (streaming, waitUntil), architecture (bindings, Queues, Workflows, Hyperdrive), and security (Web Crypto, timing-safe comparisons). - Structured review output: Flags anti-patterns with severity levels (CRITICAL/HIGH/MEDIUM/LOW), file and line evidence, and suggested fixes. - Use Case: When reviewing a pull request that adds a new Worker with a Durable Object, load this Skill to verify binding access patterns, wrangler.jsonc consistency, and type correctness against the latest published types. ## Quick Start Ask the AI to review your Cloudflare Worker code and wrangler.jsonc against current Workers best practices using this Skill.

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?▼

Retrieve the latest Workers best practices page, workers types, and wrangler schema first, then check types, config, patterns, and security in order. Validate with npx tsc --noEmit and lint for no-floating-promises, and report findings with severity levels and line evidence.

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

Common anti-patterns include awaiting response.text() on unbounded data, hardcoded secrets, Math.random() for tokens, floating promises, module-level request state, and calling the Cloudflare REST API from inside a Worker 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 acceptable in existing projects but should be flagged in new ones.

Why does destructuring ctx throw Illegal invocation in Workers?▼

Destructuring ctx with const { waitUntil } = ctx loses the this binding, causing an Illegal invocation error at runtime. Always call ctx.waitUntil() directly on the ExecutionContext 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 such as DurableObject or WorkerEntrypoint access bindings via this.env.X 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, and requires the nodejs_compat flag.