workers-best-practices
Reviews and authors Cloudflare Workers code against production best practices. Load when writing new Workers, reviewing Worker code, configuring wrangler.jsonc, or checking for common Workers anti-patterns (streaming, floating promises, global state, secrets, bindings, observability). Biases towards retrieval from Cloudflare docs over pre-trained knowledge.
Security Assessment
Detected risks:
About workers-best-practices
The 'workers-best-practices' skill is designed to assist developers in reviewing and authoring Cloudflare Workers code by ensuring adherence to production best practices. It addresses common pitfalls and anti-patterns that can arise during the development process, such as improper handling of asynchronous operations, misuse of global state, and security vulnerabilities. By emphasizing the importance of retrieving the latest information from Cloudflare's documentation, this skill helps maintain code quality and compatibility with the evolving Cloudflare Workers ecosystem.
Key features of this skill include a comprehensive set of rules and guidelines that cover various aspects of Cloudflare Workers development, including configuration, request and response handling, architecture, observability, code patterns, and security. The skill encourages developers to fetch the latest references and type definitions before writing or reviewing code, ensuring that they are working with the most current information. Additionally, it provides quick reference tables for best practices, making it easy for users to find relevant rules and summaries at a glance.
This skill is particularly useful for developers working with Cloudflare Workers who want to ensure their code is efficient, secure, and maintainable. It is ideal for both new projects and existing codebases that require review and updates. By following the best practices outlined in this skill, developers can improve their coding standards, reduce the likelihood of bugs, and enhance the overall performance of their Cloudflare Workers applications.
FAQ
How do I retrieve the latest best practices for Cloudflare Workers?
You can fetch the latest best practices by visiting the URL: https://developers.cloudflare.com/workers/best-practices/workers-best-practices/.
What should I do if my project has an older version of workers types?
You should prefer the latest published version by fetching the latest workers types using the provided npm commands.
Are there any specific configurations I need to set for new projects?
Yes, you should set the 'compatibility_date' to today and enable the 'nodejs_compat' flag.
Can I hardcode secrets in my Cloudflare Workers code?
No, you should use 'wrangler secret put' to manage secrets securely.
What are some common anti-patterns to avoid when using Cloudflare Workers?
Common anti-patterns include using global request state, not awaiting promises, and hardcoding sensitive information.
Install workers-best-practices
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
cloudflare/skills