clean-code
Skill36 starsChanged 6 months agoMITView on GitHub
Applies principles from Robert C. Martin's 'Clean Code'. Use when writing, reviewing, or refactoring code to ensure high quality, readability, and maintainability. Covers naming, functions, comments, formatting, error handling, unit tests, classes, and code smells. Language-agnostic — applies to Java, TypeScript, Python, Dart, and all workspace stacks.
63 other projects use a version of this, 8 of them edited.
Adopted by
Most recently taken up by
- superplanehq/superplanetheir own version, first seen Oct 5, 2026
- JeffreyFerreiras/ai-skillstheir own version, first seen Oct 5, 2026
- sbluemin/fleet-harnesstheir own version, first seen Oct 4, 2026
- jd-solanki/krutrimboxtheir own version, first seen Sep 27, 2026
- samirpatil2000/skillstheir own version, first seen Sep 26, 2026
- btseee/clean-code-skillstheir own version, first seen Sep 25, 2026
Used with
Projects with it also use 2d-games, 3d-games and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
tiendatworkSkill2d-games
2D game development principles. Sprites, tilemaps, physics, camera.
Also in 3 projects that use this
tiendatworkSkill3d-games
3D game development principles. Rendering, shaders, physics, cameras.
Also in 3 projects that use this
MindrallySkillclean-architecture
Guidelines for implementing Clean Architecture patterns in Flutter and Go applications, with emphasis on separation of concerns, dependency rules, and testability.
Also in 7 projects that use this
ratacatSkilldesign-patterns
Use when designing software architecture, refactoring code structure, solving recurring design problems, or when code exhibits symptoms like tight coupling, rigid hierarchies, scattered responsibilities, or difficult-to-test components. Also use when choosing between architectural approaches or reviewing code for structural improvements.
Also in 5 projects that use this
kayamanSkillsolid-principles
Enforces SOLID principles (SRP, OCP, LSP, ISP, DIP) in object-oriented and multi-paradigm code. Use when designing classes and interfaces, evaluating responsibility assignment, reviewing code for coupling issues, applying dependency inversion, refactoring fat interfaces, or checking that subtypes are truly substitutable.
Also in 3 projects that use this
DIL8654Skilllogging-patterns
Keep logs structured, correlated, low-noise, and safe for production support. Use when adding operational logging, reviewing observability, or improving diagnostics in .NET services.
Also in 3 projects that use this
- +6 more from tiendatwork
Other versions63 projects use a version of this.
Word for word · 0
None found.
Edited · 8
- jackjin1997/ClawForge★ 1375% same
- PanPanFR/oh-my-kilo★ 1265% same
- PanPanFR/oh-my-openkilo★ 913% same
- AbdulSamad94/Legalyze-AI★ 268% same
- AbdulSamad94/Personal-Portfolio★ 268% same
- ronrefael/sonde★ 274% same
- muhammadrivaldy/agent-skills★ 073% same
- TheHiddenDeveloper/jarvis-skills★ 068% same
Wrote their own version · 55
- superplanehq/superplane★ 7.7ksame name
- ciembor/agent-rules-books★ 2.9ksame name
- wondelai/skills★ 2.3ksame name
- decebals/claude-code-java★ 747same name
- Mindrally/skills★ 266same name
- xenitV1/claude-code-maestro★ 229same name
- techygarg/lattice★ 197same name
- ratacat/claude-skills★ 56same name
- DGouron/review-flow★ 44same name
- VoDaiLocz/kilo-kit-mcp★ 27same name
45 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository157 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- a2ui-angularSkill
- accessibility-auditSkill
- adk-deploy-guideSkill
- adk-dev-guideSkill
- adk-eval-guideSkill
- adk-observability-guideSkill
- agentic-ai-coding-standardSkill
- agentic-ai-devSkill
- ai-auditSkill
- ai-chatSkill
- ai-decision-recordSkill
- ai-incident-responseSkill
- ai-launch-checkSkill
- ai-playbookSkill
- angular-best-practicesSkill
- angularSkill
- angular-spaSkill
- angular-ui-patternsSkill
- api-design-principlesSkill
- app-store-optimizationSkill
- architect-reviewSkill
- architecture-decision-recordsSkill
- architecture-designSkill
- asc-cli-usageSkill
- asc-crash-triageSkill
- asc-id-resolverSkill
- asc-release-flowSkill
- asc-signing-setupSkill
- asc-submission-healthSkill
- asc-testflight-orchestrationSkill
- browser-testingSkill
- changelog-generatorSkill
- claude-actions-auditorSkill
- codebase-onboardingSkill
- code-explainerSkill
- code-reviewerSkill
- code-simplifierSkill
- comment-analyzerSkill
- database-schema-designerSkill
- ddd-architectSkill
- decision-frameworksSkill
- dedup-code-agentSkill
- deployment-ci-cdSkill
- design-systemSkill
- dockerSkill
- documentation-generationSkill
- domain-finderSkill
- error-detectiveSkill
- eval-guideSkill
- feature-forgeSkill
- firebase-basicsSkill
- firebase-hosting-basicsSkill
- fixing-accessibilitySkill
- fixing-motion-performanceSkill
- flutter-animationsSkill
- flutter-genuiSkill
- flutter-mobileSkill
- flutter-security-expertSkill
- frontend-designSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. 0 are common, 8 are distinctive, and 6 are very specific to this project.
0
Common
Most of the 59 edited versions we read keep these.
8
Distinctive
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 31
Writing new code: Ensure high quality from the start.
- Very specific: line 38
Avoid Disinformation: Don't use accountList if it's actually a Map.
- Very specific: line 39
Make Meaningful Distinctions: Avoid ProductData vs ProductInfo.
- Very specific: line 40
Use Pronounceable/Searchable Names: Avoid genymdhms.
- Very specific: line 41
Class Names: Use nouns (Customer, WikiPage).
- Very specific: line 42
Method Names: Use verbs (postPayment, deletePage).
- Distinctive: line 47
One Level of Abstraction: Don't mix high-level business logic with low-level details (like regex).
- Distinctive: line 92
Don't write production code until you have a failing unit test.
- Distinctive: line 93
Don't write more of a unit test than is sufficient to fail.
- Distinctive: line 94
Don't write more production code than is sufficient to pass the failing test.
- Very specific: line 112
Don't: use single-letter variable names outside of loop counters (i, j) — name by intent
- Distinctive: line 113
Don't: write functions longer than ~20 lines — extract until each function does one thing
- Distinctive: line 115
Don't: write a comment that restates what the code does — rewrite the code to be self-explanatory
- Distinctive: line 121
After applying any clean code refactor, run the following to confirm nothing regressed:
“Common” is measured: kept by at least 6 in 10 of the 59 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Clean Code Skill
Iron Law: Before applying any principle, READ the relevant source file first. Do not refactor or flag issues based on memory — verify the actual code (file:line) before making any claim.
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
- Writing new code: Ensure high quality from the start.
- Reviewing Pull Requests: Provide constructive, principle-based feedback.
- Refactoring legacy code: Identify and remove code smells.
- Improving team standards: 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 — introduce a parameter object.
- 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 in code.
- Explain Yourself in Code:
# BAD: comment explains intent that code should express if employee.flags & HOURLY and employee.age > 65: # GOOD: code expresses intent directly if employee.isEligibleForFullBenefits(): - Good Comments: Legal, informative (regex intent), clarification (external library behavior), TODOs (with ticket).
- 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.
- 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 objects it manipulates.
// BAD — violates Law of Demeter String city = order.getCustomer().getAddress().getCity(); // GOOD — delegate to the object String city = order.getCustomerCity(); - Data Transfer Objects (DTO): Classes with public variables and no functions — already enforced in NestJS/Spring patterns.
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: Forces the caller to null-check every time — throw or return an error state instead.
- Don't Pass Null: Leads to
NullPointerException/NullError. Validate at boundaries.
This section reinforces
code-standards.mderror handling rules ("No Silent Failures"). These are consistent — not conflicting.
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: Code should read like a top-down narrative — callers before callees.
9. Smells and Heuristics
- Rigidity: Hard to change because every change cascades.
- Fragility: Breaks in many places when changed.
- Immobility: Hard to reuse in another context.
- Viscosity: Hard to do the right thing; wrong things are easier.
- Needless Complexity/Repetition: More code than needed.
Anti-Patterns to Avoid
Don't do these — they are the most common clean code violations in this codebase.
- Don't use single-letter variable names outside of loop counters (
i,j) — name by intent - Don't write functions longer than ~20 lines — extract until each function does one thing
- Don't return
nullor an empty list on error — throw or return an explicit error state - Don't write a comment that restates what the code does — rewrite the code to be self-explanatory
- Don't pass more than 2–3 arguments to a function — introduce a parameter object instead
- Don't mix abstraction levels in one function (e.g., high-level business logic + raw SQL in the same method)
Verify Step
After applying any clean code refactor, run the following to confirm nothing regressed:
# Run all tests — refactors must not change behavior
# Java
mvn test
# NestJS / Angular
npm test
# Python
uv run pytest
# Flutter / Dart
flutter testAlso check:
git diff— confirm no behavior-changing lines snuck into a "rename only" refactorgrep -n "as any\|: any\b" <changed files>— zero newanytypes in TypeScriptflutter analyze— zero new warnings in Dart
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 (3+ = needs parameter object)?
- Is there a failing test for this change?
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

