Guidelines for writing clean, maintainable, and human-readable code. Apply these rules when writing or reviewing code to ensure consistency and quality.
Add this skill
npx mdskills install PatrickJS/cursor-clean-codeWell-organized coding principles but lacks actionable instructions for when and how agents should apply them
1---2description: Guidelines for writing clean, maintainable, and human-readable code. Apply these rules when writing or reviewing code to ensure consistency and quality.3globs:4---5# Clean Code Guidelines67## Constants Over Magic Numbers8- Replace hard-coded values with named constants9- Use descriptive constant names that explain the value's purpose10- Keep constants at the top of the file or in a dedicated constants file1112## Meaningful Names13- Variables, functions, and classes should reveal their purpose14- Names should explain why something exists and how it's used15- Avoid abbreviations unless they're universally understood1617## Smart Comments18- Don't comment on what the code does - make the code self-documenting19- Use comments to explain why something is done a certain way20- Document APIs, complex algorithms, and non-obvious side effects2122## Single Responsibility23- Each function should do exactly one thing24- Functions should be small and focused25- If a function needs a comment to explain what it does, it should be split2627## DRY (Don't Repeat Yourself)28- Extract repeated code into reusable functions29- Share common logic through proper abstraction30- Maintain single sources of truth3132## Clean Structure33- Keep related code together34- Organize code in a logical hierarchy35- Use consistent file and folder naming conventions3637## Encapsulation38- Hide implementation details39- Expose clear interfaces40- Move nested conditionals into well-named functions4142## Code Quality Maintenance43- Refactor continuously44- Fix technical debt early45- Leave code cleaner than you found it4647## Testing48- Write tests before fixing bugs49- Keep tests readable and maintainable50- Test edge cases and error conditions5152## Version Control53- Write clear commit messages54- Make small, focused commits55- Use meaningful branch names
Full transparency — inspect the skill content before installing.