clean-code

Reviews and refactors code using naming, function, error-handling, and testing principles from Clean Code.

Updated Jul 8, 2026
One-click install
npx skills add https://github.com/HafidJoss/Lummy --skill clean-code-hafidjoss
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-code
Source: https://github.com/HafidJoss/Lummy/tree/main/agent/skills/clean-code
Command: npx skills add https://github.com/HafidJoss/Lummy --skill clean-code-hafidjoss

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Codebases accumulate unreadable functions, misleading names, scattered error handling, and fragile tests that slow every change. This Skill provides a disciplined framework for diagnosing code quality issues and applying targeted improvements based on Robert C. Martin's Clean Code principles. ## Core Features & Use Cases - Code Quality Scoring: Rates any code 0-10 against six disciplines (naming, functions, comments, error handling, testing, smells) and lists the specific improvements needed to reach 10/10. - Targeted Refactoring Guidance: Maps common code smells (flag arguments, feature envy, magic numbers, duplication) to concrete refactorings with before/after examples. - Deep Reference Library: Six reference documents cover naming conventions per language, function decomposition, comment discipline, exception strategy, and clean test patterns. - Use Case: When reviewing a pull request with a 60-line function that takes five arguments and returns null on failure, use this Skill to identify the smells, score the code, and get step-by-step extraction and error-handling fixes. ## Quick Start Review this function for clean code issues and suggest specific refactorings to improve its readability and error handling.

Frequently Asked Questions about clean-code

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor a long function into smaller pieces?

Apply the Extract Till You Drop technique: pull each identifiable step into a named function, use guard clauses for error cases at the top, and follow the Step-Down Rule so code reads from high-level to low-level. Functions should ideally be 4-10 lines doing one thing.

How to choose good variable and function names in code?

Names should reveal intent, answering why the thing exists, what it does, and how it is used. Use nouns for classes, verbs for methods, predicate phrasing like isActive for booleans, and make name length proportional to scope size.

Should I use exceptions or return codes for error handling?

Use exceptions rather than return codes, because return codes force callers to check immediately and clutter the happy path. Provide context in every exception, avoid returning or passing null, and wrap third-party APIs with exception types defined by the caller's needs.

What are the most common code smells to look for?

The highest-impact smells are duplication, functions with too many or flag arguments, feature envy, magic numbers, dead code, and mixed abstraction levels. Each smell maps to a targeted refactoring such as extracting shared logic or moving methods to the class owning the data.

When should I write comments in my code?

Write comments only to explain why, never what; the code itself should express the what through clear naming. Acceptable comments include legal headers, intent explanations, warnings of consequences, and ticketed TODOs, while redundant, misleading, and commented-out code should be deleted.

What makes a unit test clean and maintainable?

Clean tests follow the F.I.R.S.T. principles: Fast, Independent, Repeatable, Self-validating, and Timely. Each test covers one concept using Arrange-Act-Assert structure, descriptive names like shouldRejectExpiredToken, and builder helpers that read like a domain-specific language.