What problem does it solve?
Many codebases contain working but hard-to-read code that increases bug risk, slows feature delivery, and makes collaboration difficult; this skill helps convert such code into readable, maintainable, and testable implementations.
Core Features & Use Cases
- Naming & Clarity: Make variable, function, and class names intention-revealing and searchable to reduce misunderstanding.
- Function and Class Design: Enforce small, single-responsibility functions and well-structured classes to separate concerns and maintain one level of abstraction.
- Comments, Formatting & Smells: Replace noisy comments with clearer code, improve vertical density and ordering, and identify common smells like rigidity, fragility, and needless complexity.
- Tests & Error Handling: Recommend unit test approaches following TDD and F.I.R.S.T. principles and suggest robust error-handling patterns.
- Use Cases: Apply during pull request reviews for actionable feedback, refactor legacy modules to remove technical debt, or guide new code authoring to meet team standards.
Quick Start
Refactor the following function to follow Clean Code principles by improving names, simplifying logic, and outlining necessary unit tests.