clean-code
Guidelines for clean, maintainable, human-readable code, applied when writing or reviewing code.
- Kind
- Rules
- Works with
- Cursor
- Source
- Awesome Cursor Rules @ b044f956f021
- Path
- rules/clean-code.mdc
- License
- CC0-1.0
- Jobs
- Implementation, Review
InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
# Clean Code Guidelines ## Constants Over Magic Numbers - Replace hard-coded values with named constants - Use descriptive constant names that explain the value's purpose - Keep constants at the top of the file or in a dedicated constants file ## Meaningful Names - Variables, functions, and classes should reveal their purpose - Names should explain why something exists and how it's used - Avoid abbreviations unless they're universally understood ## Smart Comments - Don't comment on what the code does - make the code self-documenting - Use comments to explain why something is done a certain way - Document APIs, complex algorithms, and non-obvious side effects ## Single Responsibility - Each function should do exactly one thing - Functions should be small and focused - If a function needs a comment to explain what it does, it should be split ## DRY (Don't Repeat Yourself) - Extract repeated code into reusable functions - Share common logic through proper abstraction - Maintain single sources of truth ## Clean Structure - Keep related code together - Organize code in a logical hierarchy - Use consistent file and folder naming conventions ## Encapsulation …