{"name":"apply-cloudflare-workers-practices","description":"Checks Cloudflare Workers code against the current Workers docs rather than memory: compatibility date, generated types, logs, traces, streaming, secrets, and request lifetime. Use when the user is writing a Worker, reviewing Workers code, or asks for Workers best practices and runtime limits. Hosting a site on Cloudflare is a different task.","category":"backend","tags":["cloudflare","typescript","code-review"],"models":["any"],"proven":false,"passing_families":0,"model_testing":"Not yet model-tested; testing Jan 2027","url":"https://theskillvault.ai/skills/apply-cloudflare-workers-practices","api_url":"https://theskillvault.ai/api/skills/apply-cloudflare-workers-practices","raw_url":"https://theskillvault.ai/api/skills/apply-cloudflare-workers-practices/raw","body":"# Review Cloudflare Workers code\n\nWorkers APIs, limits, and config fields change. Do not answer from memory. Read the current page, then the project's wrangler config and generated types.\n\n## When to use\n- You are writing a Worker handler, a binding, or Worker config.\n- You are reviewing Worker code before it runs in production.\n- The user asks for Workers best practices or a runtime limit.\n\n## When not to use\n- They want to host or deploy a site. Use deploy-site-to-cloudflare.\n- The work is a Durable Object class. Use build-cloudflare-durable-objects.\n- The work is a Turnstile widget. Use add-cloudflare-turnstile.\n\n## Steps\n1. Read the project's wrangler file, its compatibility date, and its generated types. That configured date is the baseline. A newer type package does not override it.\n2. Open the doc that matches the question before you state an API, a limit, a config key, or a flag. Start at https://developers.cloudflare.com/workers/best-practices/workers-best-practices/ or the product page in the Cloudflare docs directory. If the page and this skill disagree, follow the page and name it.\n3. For a new Worker, set compatibility_date to the day you ship. For an existing Worker, read the compatibility changelog before you move the date, then run the tests that cover the change.\n4. For production, enable logs and traces. Set both observability.enabled and observability.traces.enabled. The pinned guide says the top-level flag alone does not enable traces. Confirm that on the current logs and traces pages. Log structured JSON. Pick a sampling rate that fits the traffic.\n5. If the Worker runs several sequential queries against one regional database, set placement to that region before deploy. If the region is unknown, ask. Do not invent one. Leave an existing placement unless the user wants it changed.\n6. Check the handler against the gotchas below. Fix the ones this change touches. A narrow edit does not need a full Workers audit.\n7. Type-check binding and handler edits. Run the project's runtime tests when behavior changes.\n\n## Gotchas\n- Do not buffer an unbounded body with a full text or arrayBuffer read. Stream it, or you can exhaust memory.\n- Do not hard-code a secret in source or in wrangler vars. Use wrangler secret. A secret in git must be rotated.\n- Do not use Math.random for a token or an id. Use crypto.randomUUID or crypto.getRandomValues.\n- Do not start async work and drop the promise. Await it, return it, or pass it to ctx.waitUntil. Call ctx.waitUntil on ctx. Do not destructure the method off ctx, or you lose the receiver.\n- Do not store one request's data in a module-level variable. Isolates are reused. Pass the data in.\n- Prefer a binding when it does the job. A REST call to the Cloudflare API adds a network hop and a token you must store.\n- Do not use passThroughOnException as your general error handler. It can hide a Worker failure by forwarding to the origin. Return an explicit error response.\n- Do not hand-write an Env type that copies bindings. Generate types with wrangler types so they cannot drift.\n- Do not compare secret strings with a normal equality check. Use the timing-safe Web Crypto pattern from the current docs.\n- Do not silence a mismatch with a double cast. Fix the contract. Do not type Env or the handler as any.\n- Do not implements a platform base class. Extend it so you keep the runtime behavior, this.ctx, and this.env.\n- Inside a platform class, read bindings on this.env. A free env name is not the binding.\n- Queues, Workflow steps, storage, and WebSockets do not share one serialization rule. Check the API you are calling.\n\n## Portability\nIf you use a framework adapter on Workers, the same runtime rules apply and only the file names change. Another host is out of scope. This skill does not deploy.\n\n## Example prompt\n\"Review this Cloudflare Worker against the current docs. Do not guess the API. Check the compatibility date, logs, traces, streaming, and secrets.\"\n\n## Done when\n- Every API or limit claim cites a current docs page or the project's generated types.\n- Logs and traces are both configured when the user is preparing production, or the user declined them.\n- Secrets are not in source. Async work is tied to the request or to ctx.waitUntil.\n- Unbounded bodies are streamed. Placement matches a known region, or the user was asked.\n- The change was type-checked, and the relevant runtime tests were run or their absence was stated.\n\n---\nModified from \"workers-best-practices\" in cloudflare/skills (Apache-2.0). Attribute to Cloudflare (cloudflare/skills). The upstream LICENSE keeps the unfilled template line. See LICENSE.txt.","files":["LICENSE.txt","NOTICE.txt"],"license":"Apache-2.0","license_name":"Apache License 2.0","license_url":"https://www.apache.org/licenses/LICENSE-2.0","attribution":"Based on work by Cloudflare (cloudflare/skills) (Copyright [yyyy] [name of copyright owner]. The cloudflare/skills LICENSE keeps that Apache template line unfilled. Attribute this skill to Cloudflare (cloudflare/skills)., Apache License 2.0), https://github.com/cloudflare/skills/tree/ff191de7d903788eceaf516a514ae7d3b56b924a/skills/workers-best-practices; adapted by TheSkillVault, https://theskillvault.ai","install":{"claude_code":"curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/apply-cloudflare-workers-practices/raw' -o ~/'.claude/skills/apply-cloudflare-workers-practices/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/apply-cloudflare-workers-practices/files/LICENSE.txt' -o ~/'.claude/skills/apply-cloudflare-workers-practices/LICENSE.txt' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/apply-cloudflare-workers-practices/files/NOTICE.txt' -o ~/'.claude/skills/apply-cloudflare-workers-practices/NOTICE.txt'","cursor":"curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/apply-cloudflare-workers-practices/raw' -o '.cursor/skills/apply-cloudflare-workers-practices/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/apply-cloudflare-workers-practices/files/LICENSE.txt' -o '.cursor/skills/apply-cloudflare-workers-practices/LICENSE.txt' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/apply-cloudflare-workers-practices/files/NOTICE.txt' -o '.cursor/skills/apply-cloudflare-workers-practices/NOTICE.txt'","agents":"curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/apply-cloudflare-workers-practices/raw' -o '.agents/skills/apply-cloudflare-workers-practices/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/apply-cloudflare-workers-practices/files/LICENSE.txt' -o '.agents/skills/apply-cloudflare-workers-practices/LICENSE.txt' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/apply-cloudflare-workers-practices/files/NOTICE.txt' -o '.agents/skills/apply-cloudflare-workers-practices/NOTICE.txt'","mcp_url":"https://theskillvault.ai/mcp","cursor_mcp_deeplink":"cursor://anysphere.cursor-deeplink/mcp/install?name=theskillvault&config=eyJ1cmwiOiJodHRwczovL3RoZXNraWxsdmF1bHQuYWkvbWNwIn0%3D","mcp_config":{"mcpServers":{"theskillvault":{"url":"https://theskillvault.ai/mcp"}}}},"bundles":[],"tested_on":[{"family":"chatgpt","name":"ChatGPT","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"claude","name":"Claude","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"gemini","name":"Gemini","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"grok","name":"Grok","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"llama","name":"Llama","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"deepseek","name":"DeepSeek","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"mistral","name":"Mistral","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"qwen","name":"Qwen","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"kimi","name":"Kimi K","outcome":null,"date":null,"source":null,"counts":false,"stale":false}],"proven_rule":{"threshold":5,"window_days":365,"computed_at":"2026-11-29T03:42:30.374Z"}}