clean-code
sickn33/agentic-awesome-skills
Transform working code into clean, maintainable code using Uncle Bob's proven principles.
What is clean-code?
This skill applies Robert C. Martin's Clean Code principles to refactor and improve existing code. Use it when writing new code, reviewing pull requests, refactoring legacy systems, or establishing team coding standards.
- Apply meaningful naming conventions to variables, functions, and classes
- Refactor functions to be small, focused, and do one thing well
- Replace comments with self-documenting code and remove code smells
- Enforce proper error handling with exceptions instead of return codes
- Structure code following the Law of Demeter and data abstraction patterns
- Identify and eliminate rigidity, fragility, and unnecessary complexity
How to install clean-code
npx skills add https://github.com/sickn33/agentic-awesome-skills --skill clean-codeHow to use clean-code
- 1.Review the code against the nine core Clean Code principles (naming, functions, comments, formatting, objects, error handling, tests, classes, smells)
- 2.Apply the implementation checklist: verify function size, single responsibility, searchable names, and test coverage
- 3.Refactor incrementally, starting with meaningful names and function decomposition
- 4.Replace problematic comments with clearer code or keep only legal/informative comments
- 5.Ensure error handling uses exceptions and avoids null returns/parameters
- 6.Run existing tests to verify behavior is preserved during refactoring
Use cases
- Refactoring legacy codebases to improve readability and maintainability
- Reviewing pull requests with principle-based feedback on code quality
- Writing new features with clean code practices from the start
- Establishing consistent coding standards across a development team
- Transforming working but poorly-structured code into production-ready implementations
- Software developers and engineers
- Code reviewers and technical leads
- Teams adopting or improving coding standards
- Developers learning or applying Clean Code principles
clean-code FAQ
Use this skill when code quality, maintainability, and team standards matter—during refactoring, code reviews, or establishing best practices. For throwaway prototypes, it may be overkill.
No. Clean Code principles are language-agnostic and apply to Python, JavaScript, Java, C#, and other languages.
This skill complements testing. It focuses on code structure and readability; tests verify correctness. Both are essential.
The checklist suggests under 20 lines as a guideline. More importantly, a function should do exactly one thing and fit on a screen without scrolling.
Yes. Start by refactoring for clarity and smaller functions, which often makes code easier to test. Write tests incrementally as you improve the code.
Full instructions (SKILL.md)
Source of truth, from sickn33/agentic-awesome-skills.
name: clean-code description: "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."" risk: safe source: "ClawForge (https://github.com/jackjin1997/ClawForge)" date_added: "2026-02-27"
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?
Example
User request:
Refactor this working code for clearer names, smaller units, explicit errors, and preserved behavior; verify it with focused tests.
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.
Related skills
More from sickn33/agentic-awesome-skills and the wider catalog.

code-refactoring-refactor-clean
Expert code refactoring using clean code principles and SOLID design patterns.

code-review-checklist
Systematic checklist for thorough code reviews covering functionality, security, performance, and maintainability.

context-compression
Compress agent conversation history while preserving task-critical information like file paths and decisions.

context-window-management
Optimize LLM context windows through summarization, trimming, routing, and token budgeting strategies.

conversation-memory
Persistent memory systems for LLM conversations with short-term, long-term, and entity-based storage.

copywriting
Write conversion-focused marketing copy with mandatory audience research and strict no-fabrication rules.