workers-best-practices
Production guardrails and anti-pattern checklists for Workers.
Developer Setup
Setup & Installation
npx skills add https://github.com/cloudflare/skills --skill workers-best-practicesnpx skills add https://github.com/cloudflare/skills --skill workers-best-practicesOverview
What This Skill Does
Audits Worker configurations, wrangler secrets, unawaited loops, static memory bounds, and global cache hazards.
Application
When to use this Skill
- Reviewing and auditing Cloudflare Workers code for production readiness.
- Configuring wrangler.jsonc with accurate worker bindings and environments.
- Avoiding common anti-patterns such as unawaited floating promises or globally stateful caches.
- Securing confidential environment keys and secret tokens.
- Enabling worker logs and observability metrics via Cloudflare dashboards.
Documentation
Show Skills.md file
Your knowledge of Cloudflare Workers APIs, types, and configuration may be outdated. Prefer retrieval over pre-training for any Workers code task — writing or reviewing.
Retrieval Sources
Fetch the latest versions before writing or reviewing Workers code. Do not rely on baked-in knowledge for API signatures, config fields, or binding shapes.
| Source | How to retrieve | Use for |
|---|---|---|
| Workers best practices | Fetch https://developers.cloudflare.com/workers/best-practices/workers-best-practices/ |
Canonical rules, patterns, anti-patterns |
| Workers types | See references/review.md for retrieval steps |
API signatures, handler types, binding types |
| Wrangler config schema | node_modules/wrangler/config-schema.json |
Config fields, binding shapes, allowed values |
| Cloudflare docs | Search tool or https://developers.cloudflare.com/workers/ |
API reference, compatibility dates/flags |
FIRST: Fetch Latest References
Before reviewing or writing Workers code, retrieve the current best practices page and relevant type definitions. If the project's node_modules has an older version, prefer the latest published version.
# Fetch latest workers types
mkdir -p /tmp/workers-types-latest && \
npm pack @cloudflare/workers-types --pack-destination /tmp/workers-types-latest && \
tar -xzf /tmp/workers-types-latest/cloudflare-workers-types-*.tgz -C /tmp/workers-types-latest
# Types at /tmp/workers-types-latest/package/index.d.ts
Recommendations