workers-best-practices

Review and write Cloudflare Workers code against current APIs, configuration, and runtime best practices.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Cloudflare Workers APIs, types, and configuration options change frequently, so code written from stale knowledge breaks at runtime, leaks secrets, or fails under load. This Skill grounds Workers writing and review in the project's installed types, Wrangler schema, and retrieved Cloudflare documentation instead of outdated assumptions. ## Core Features & Use Cases - Anti-pattern detection: Flags buffering unbounded bodies, hardcoded secrets, floating promises, module-level request state, insecure randomness, and incorrect binding access (env.X vs this.env.X). - Configuration validation: Checks compatibility dates, nodejs_compat, generated Env types via wrangler types, secret handling, and observability settings for logs and traces. - Platform API and serialization checks: Verifies handler signatures, platform base classes, and serialization boundaries for Queues, Workflows, Durable Object storage, and WebSockets. - Use Case: When reviewing a pull request that adds a Queue producer to a Worker, the Skill verifies the message content type, confirms bindings match the Wrangler config, and flags any unawaited sends. ## Quick Start Ask the assistant to review your Worker code and Wrangler configuration for Cloudflare best practices 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?

Check binding access patterns, handler signatures, and configuration against the project's installed types and Wrangler schema, then retrieve current Cloudflare docs for anything uncertain. Flag anti-patterns like buffered unbounded bodies, floating promises, and hardcoded secrets.

What are common Cloudflare Workers anti-patterns to avoid?

Common anti-patterns include awaiting response.text() on unbounded data, Math.random() for security tokens, module-level mutable request state, destructuring ctx methods, and using REST APIs instead of bindings. Each has a documented preferred pattern such as streaming or crypto.randomUUID().

Should I use env.X or this.env.X to access Workers bindings?

Module export handlers like fetch, scheduled, and queue access bindings through the env parameter. Classes extending platform base classes such as WorkerEntrypoint, DurableObject, or Workflow access them through this.env.X instead.

Does Workers observability require separate trace configuration?

Yes, setting observability.enabled to true alone does not enable traces. You must also set observability.traces.enabled to true, and use head_sampling_rate to control log and trace volume.

Why does my Worker fail with Illegal invocation when using waitUntil?

Destructuring ctx, such as const { waitUntil } = ctx, loses the receiver binding and throws Illegal invocation at runtime. Always call ctx.waitUntil(...) directly on the context object.

When should I not use this Workers review approach?

Durable Objects specifics belong to the dedicated durable-objects skill, Workflow rules are covered by the Rules of Workflows documentation, and Wrangler CLI command usage belongs to the wrangler skill. This Skill covers Workers-specific code and configuration review only.