workers-best-practices

Reviews and validates Cloudflare Workers code against current platform best practices.

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

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 can contain anti-patterns, misconfigured bindings, or missing observability. This Skill grounds Workers code review and authoring in the project's installed versions, generated types, and current Cloudflare documentation. ## Core Features & Use Cases - Anti-Pattern Detection: Flags common Workers mistakes such as buffering unbounded response bodies, hardcoded secrets, floating promises, module-level request state, and misuse of ctx.passThroughOnException(). - Configuration Review: Verifies compatibility_date, nodejs_compat, generated Env types via wrangler types, secret management, and observability settings for logs and traces. - Platform API Validation: Checks handler signatures, binding access patterns (env.X vs this.env.X), base class usage, and serialization boundaries for Queues, Workflows, Durable Objects, and WebSockets. - Use Case: When reviewing a pull request that adds a new Worker with a Queue binding, use this Skill to verify the binding types, message serialization format, error handling, and observability configuration before merging. ## Quick Start Review my Cloudflare Worker code and wrangler.jsonc for best-practice violations and outdated API usage.

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 the project's wrangler config, generated types, and compatibility settings as the baseline, then verify API and runtime claims against current Cloudflare documentation. Flag anti-patterns like buffering unbounded bodies, hardcoded secrets, and floating promises.

What are common Cloudflare Workers anti-patterns to avoid?

Common anti-patterns include awaiting response.text() on unbounded data, using Math.random() for security tokens, storing request state in module scope, calling Cloudflare REST APIs instead of bindings, and destructuring ctx which loses the this binding.

How do I enable logging and tracing for Cloudflare Workers?

Set observability.enabled and observability.traces.enabled to true in wrangler.jsonc; the top-level setting alone does not enable traces. Use structured JSON logging via console.log(JSON.stringify(...)) and configure head_sampling_rate for volume control.

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

Prefer wrangler.jsonc over wrangler.toml because newer features are JSON-only and JSONC supports comments for documenting configuration decisions. Flag wrangler.toml in new projects.

Why does my Worker fail with 'Cannot perform I/O on behalf of a different request'?

This error typically comes from mutable module-level state shared across requests, since Workers reuse isolates. Pass request state explicitly through function arguments instead of assigning to module-scope variables inside handlers.

When should I use Queues versus Workflows in Cloudflare Workers?

Use Queues for decoupled, single-step background jobs with at-least-once delivery and batching. Use Workflows for multi-step durable execution where each step's result is persisted and only failed steps retry, even over hours or days.