Clean code
Apply Robert C. Martin (Uncle Bob) Clean Code principles — meaningful names, small single-purpose functions, comment discipline, error handling, and code-smell heuristics — to transform code that works into code that is clean. USE WHEN reviewing a PR for maintainability, refactoring legacy code, or aligning a team on readability standards.From its SKILL.md
npx -y skills add Sheshiyer/skill-clusters --skill clean-codeAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
4.8 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it
Clean Code Skill
This skill embodies the principles of "Clean Code" by Robert C. Martin (Uncle Bob). Use it to transform "code that works" into "code that is clean."
🧠 Core Philosophy
"Code is clean if it can be read, and enhanced by a developer other than its original author." — Grady Booch
When to Use
Use this skill when:
- Writing new code: To ensure high quality from the start.
- Reviewing Pull Requests: To provide constructive, principle-based feedback.
- Refactoring legacy code: To identify and remove code smells.
- Improving team standards: To align on industry-standard best practices.
1. Meaningful Names
- Use Intention-Revealing Names:
elapsedTimeInDaysinstead ofd. - Avoid Disinformation: Don't use
accountListif it's actually aMap. - Make Meaningful Distinctions: Avoid
ProductDatavsProductInfo. - Use Pronounceable/Searchable Names: Avoid
genymdhms. - Class Names: Use nouns (
Customer,WikiPage). AvoidManager,Data. - Method Names: Use verbs (
postPayment,deletePage).
2. Functions
- Small!: Functions should be shorter than you think.
- Do One Thing: A function should do only one thing, and do it well.
- One Level of Abstraction: Don't mix high-level business logic with low-level details (like regex).
- Descriptive Names:
isPasswordValidis better thancheck. - Arguments: 0 is ideal, 1-2 is okay, 3+ requires a very strong justification.
- No Side Effects: Functions shouldn't secretly change global state.
3. Comments
- Don't Comment Bad Code—Rewrite It: Most comments are a sign of failure to express ourselves in code.
- Explain Yourself in Code:
vs# Check if employee is eligible for full benefits if employee.flags & HOURLY and employee.age > 65:if employee.isEligibleForFullBenefits(): - Good Comments: Legal, Informative (regex intent), Clarification (external libraries), TODOs.
- Bad Comments: Mumbling, Redundant, Misleading, Mandated, Noise, Position Markers.
4. Formatting
- The Newspaper Metaphor: High-level concepts at the top, details at the bottom.
- Vertical Density: Related lines should be close to each other.
- Distance: Variables should be declared near their usage.
- Indentation: Essential for structural readability.
5. Objects and Data Structures
- Data Abstraction: Hide the implementation behind interfaces.
- The Law of Demeter: A module should not know about the innards of the objects it manipulates. Avoid
a.getB().getC().doSomething(). - Data Transfer Objects (DTO): Classes with public variables and no functions.
6. Error Handling
- Use Exceptions instead of Return Codes: Keeps logic clean.
- Write Try-Catch-Finally First: Defines the scope of the operation.
- Don't Return Null: It forces the caller to check for null every time.
- Don't Pass Null: Leads to
NullPointerException.
7. Unit Tests
- The Three Laws of TDD:
- Don't write production code until you have a failing unit test.
- Don't write more of a unit test than is sufficient to fail.
- Don't write more production code than is sufficient to pass the failing test.
- F.I.R.S.T. Principles: Fast, Independent, Repeatable, Self-Validating, Timely.
8. Classes
- Small!: Classes should have a single responsibility (SRP).
- The Stepdown Rule: We want the code to read like a top-down narrative.
9. Smells and Heuristics
- Rigidity: Hard to change.
- Fragility: Breaks in many places.
- Immobility: Hard to reuse.
- Viscosity: Hard to do the right thing.
- Needless Complexity/Repetition.
🛠️ Implementation Checklist
- Is this function smaller than 20 lines?
- Does this function do exactly one thing?
- Are all names searchable and intention-revealing?
- Have I avoided comments by making the code clearer?
- Am I passing too many arguments?
- Is there a failing test for this change?
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.
Gives 0 of the 12 instructions most refactoring skills give in ~1.1k tokens
Counted across 521 of the 525 authors here whose files we hold, read 2026-08-07
- Run tests after each changein 52 of 521
- Run the full test suite after each stepin 32 of 521
- Preserve external behaviorin 27 of 521, across 24 files
- Remove dead codein 26 of 521
- Write tests before refactoringin 26 of 521, across 25 files
- Make small incremental changesin 19 of 521, across 16 files
- Break the implementation into tiny commitsin 18 of 521, across 5 files
- Ask the user about alternative optionsin 17 of 521, across 4 files
- Create a GitHub issue with the planin 17 of 521, across 4 files
- Explore the repository to verify assertionsin 17 of 521, across 4 files
- Interview the user about the refactorin 16 of 521, across 3 files
- Check the codebase for test coveragein 16 of 521, across 3 files
Said here and by no other author read
- use exceptions instead of return codes
- make functions do exactly one thing
- do not return null
- encapsulate implementation behind interfaces
- rewrite bad code instead of commenting it
- declare variables near their usage
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.