clean-code
Skill0 starsChanged 14 days agoApache-2.0View on GitHub
Use when writing, refactoring, or reviewing code at the function, class, and module level: naming, function design, SOLID, error handling, tests, and code smells.
108 other projects use a version of this.
Adopted by
Most recently taken up by
- sbluemin/fleet-harnesstheir own version, first seen Nov 8, 2026
- MammadovEshgin/clean-code-skilltheir own version, first seen Nov 8, 2026
- Mahesh-Bishnoi/skillstheir own version, first seen Nov 8, 2026
- Bruno-Cunha-Souza/ValarMindSkillstheir own version, first seen Nov 8, 2026
- kana-consultant/kana-best-practice-engineeringtheir own version, first seen Nov 8, 2026
- uwuclxdy/agenticattheir own version, first seen Nov 8, 2026
Used with
Projects with it also use intelligent-routing, nextjs-react-expert 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.
SKB3002Skillintelligent-routing
Automatic agent selection and intelligent task routing. Analyzes user requests and automatically selects the best specialist agent(s) without requiring explicit user mentions.
Also in 5 projects that use this
SKB3002Skillnextjs-react-expert
React and Next.js performance optimization from Vercel Engineering. Use when building React components, optimizing performance, eliminating waterfalls, reducing bundle size, reviewing code for performance issues, or implementing server/client-side optimizations.
Also in 3 projects that use this
xfstudioSkillbash-pro
Master of defensive Bash scripting for production automation, CI/CD
Also in 4 projects that use this
xfstudioSkillcode-refactoring-tech-debt
You are a technical debt expert specializing in identifying, quantifying, and prioritizing technical debt in software projects. Analyze the codebase to uncover debt, assess its impact, and create acti
Also in 4 projects that use this
flying-diceSkillclean-code-review
Multi-agent clean code audit — each principle gets its own agent
Also in 3 projects that use this
goca-seSkillbatch-operations
Apply a change safely across many files — refactors touching more than 5 files, library or API migrations, project-wide renames of symbols/imports/paths, or adding boilerplate to many files. Use when "do it all at once" risks context overflow or silent failures.
Also in 3 projects that use this
- +4 more from xfstudio
Other versions108 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 108
- superplanehq/superplane★ 9.1ksame name
- vudovn/ag-kit★ 8.2ksame name
- vudovn/antigravity-kit★ 8.2ksame name
- Openpanel-dev/openpanel★ 7.3ksame name
- ciembor/agent-rules-books★ 2.8ksame name
- wondelai/skills★ 2.6ksame name
- decebals/claude-code-java★ 763same name
- operately/operately★ 618same name
- liza-mas/liza★ 418same name
- Mindrally/skills★ 275same name
98 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 repository5 other files it gives its agents.
- architecture-diagramSkill
- refactor-proposalSkill
- software-architectureSkill
- software-designSkill
- tddSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
35 rules. 0 are common, 26 are distinctive, and 9 are very specific to this project.
0
Common
Most of the 101 edited versions we read keep these.
26
Distinctive
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
When principles conflict, choose deliberately and state the trade-off in one line (see Tensions).
- Distinctive: line 14
When reviewing, order findings by severity: correctness, then design, then readability, then style.
- Very specific: line 18
Avoid abbreviations, type encodings, and noise words (Manager, Data, Info, Helper) unless they are real domain terms.
- Very specific: line 20
Use one word per concept across the codebase.
- Distinctive: line 25
Keep functions small. If you need a comment or blank line to separate sections, extract a function.
- Distinctive: line 26
Use three parameters or fewer.
- Distinctive: line 27
Don't use boolean flag arguments.
- Distinctive: line 28
Avoid hidden side effects.
- Distinctive: line 29
Prefer returning new values to mutating arguments.
- Distinctive: line 36
ISP: prefer small, client-specific interfaces to fat ones.
- Distinctive: line 42
Prefer composition to inheritance.
- Distinctive: line 44
Prefer immutability: final fields and value objects.
- Very specific: line 45
Avoid primitive obsession.
- Distinctive: line 49
KISS: use the simplest design that works.
- Distinctive: line 50
YAGNI: don't build for requirements you don't have yet.
- Distinctive: line 52
Boy Scout rule: leave code cleaner than you found it.
- Distinctive: line 53
No magic numbers or strings.
- Distinctive: line 57
Delete commented-out code, redundant comments, and change-log comments.
- Distinctive: line 58
Every TODO needs an owner or a ticket.
- Very specific: line 62
Don't return null. Return Optional, an empty collection, or a Null Object.
- Very specific: line 65
Never swallow exceptions. Catch generic Exception only at a top-level boundary.
- Distinctive: line 66
Keep try blocks small and separate error handling from the happy path.
- Distinctive: line 67
Don't use exceptions for control flow.
- Distinctive: line 70
Follow FIRST: fast, independent, repeatable, self-validating, and timely.
- Distinctive: line 72
Test behavior through the public API, not implementation details.
- Distinctive: line 77
Follow the project's formatter and linter.
- Distinctive: line 78
Keep related code close together and order it top-down, callers before callees.
- Distinctive: line 82
Keep concurrency mechanics separate from business logic.
- Distinctive: line 100
Small functions vs. readability: don't fragment logic into one-line wrappers that force constant jumping between functions.
- Distinctive: line 102
Performance vs. clarity: write for clarity first. Optimize measured hotspots and comment why.
- Very specific: line 105
Use constructor injection with final fields.
- Distinctive: line 106
Keep controllers thin: map HTTP to DTOs and delegate to services.
- Very specific: line 107
Never expose JPA entities through the API.
- Very specific: line 108
Put @Transactional at the service or use-case boundary, not on controllers.
- Very specific: line 109
Use Optional only as a return type, never for fields or parameters.
“Common” is measured: kept by at least 6 in 10 of the 101 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
Apply this skill whenever you produce or review code. System structure questions (service boundaries, layering across the system, data ownership) belong to the software-architecture skill. For the test-first workflow, use the tdd skill. For the reasoning behind a design choice (is this good design, is it over-engineered, which non-functional requirements matter), use the software-design skill. When planning or reviewing a refactor, use the refactor-proposal skill.
How to apply
- Make it correct and covered by tests first. Then clean it.
- Walk every section below. Fix what matters and don't gold-plate.
- When principles conflict, choose deliberately and state the trade-off in one line (see Tensions).
- When reviewing, order findings by severity: correctness, then design, then readability, then style. Name the principle and show the fix in code.
Naming
- Names reveal intent: what it is and why it exists, not how it works.
- Avoid abbreviations, type encodings, and noise words (
Manager,Data,Info,Helper) unless they are real domain terms. - Classes are nouns, methods are verbs, and booleans read as predicates (
isActive,hasExpired). - Use one word per concept across the codebase. Pick one of
get,fetch, orretrieve. - Name length grows with scope. Short names are fine for tiny scopes, and wide scopes need descriptive names.
Functions
- A function does one thing at one level of abstraction. Read top-down (stepdown rule).
- Keep functions small. If you need a comment or blank line to separate sections, extract a function.
- Use three parameters or fewer. Group related ones into a parameter object.
- Don't use boolean flag arguments. Split into two well-named methods.
- Avoid hidden side effects. Apply command-query separation: a function either changes state or returns a value.
- Prefer returning new values to mutating arguments.
Classes and modules
SOLID
- SRP: one reason to change, meaning one actor or stakeholder.
- OCP: extend behavior by adding types or strategies, not by editing switch statements.
- LSP: subtypes honor the base contract. Don't override a method only to throw
UnsupportedOperationException. - ISP: prefer small, client-specific interfaces to fat ones.
- DIP: depend on abstractions. High-level policy never imports low-level detail.
Also
- High cohesion inside a unit, low coupling between units.
- Law of Demeter: talk to direct collaborators. Avoid chains like
a.getB().getC().doX(). - Prefer composition to inheritance.
- Tell, don't ask: put behavior next to the data it uses. Getters and setters that expose internals are fine only on DTOs.
- Prefer immutability: final fields and value objects.
- Avoid primitive obsession. Introduce value types such as
EmailAddress,Money, andOrderId.
General principles
- DRY applies to knowledge, not text. Two similar code blocks that change for different reasons are not duplication.
- KISS: use the simplest design that works.
- YAGNI: don't build for requirements you don't have yet.
- Least astonishment: code does what its name and signature suggest.
- Boy Scout rule: leave code cleaner than you found it. Keep refactors in separate commits from behavior changes.
- No magic numbers or strings. Use named constants or enums.
Comments
- Code explains how. Comments explain why: constraints, non-obvious decisions, warnings, and public API contracts.
- Delete commented-out code, redundant comments, and change-log comments.
- Every TODO needs an owner or a ticket.
Error handling
- Throw exceptions rather than returning error codes.
- Don't return null. Return
Optional, an empty collection, or a Null Object. - Fail fast and validate input at boundaries.
- Throw specific exception types with useful context.
- Never swallow exceptions. Catch generic
Exceptiononly at a top-level boundary. - Keep try blocks small and separate error handling from the happy path.
- Don't use exceptions for control flow.
Tests
- Follow FIRST: fast, independent, repeatable, self-validating, and timely.
- Each test covers one behavior, uses Arrange-Act-Assert, and has a descriptive name (
shouldRejectOrder_whenStockIsInsufficient). - Test behavior through the public API, not implementation details.
- Hold test code to production standards.
- Design for testability: inject dependencies and avoid static or global state.
Formatting
- Follow the project's formatter and linter. Consistency beats personal preference.
- Keep related code close together and order it top-down, callers before callees.
Concurrency (when relevant)
- Minimize shared mutable state. Prefer immutable data and thread confinement.
- Keep concurrency mechanics separate from business logic.
Code smells and refactorings
| Smell | Refactoring |
| Long method | Extract Method |
| Large class / god service | Extract Class, split by use case |
| Long parameter list | Introduce Parameter Object |
| Feature envy | Move Method |
| Data clumps, primitive obsession | Introduce Value Object |
| Switch on type | Replace Conditional with Polymorphism |
| Shotgun surgery | Move related logic together |
| Divergent change | Split by reason to change |
| Message chains | Hide Delegate |
| Speculative generality, dead code | Delete it |
Tensions between principles
- DRY vs. decoupling: across module or service boundaries, accept duplication rather than create shared coupling.
- Small functions vs. readability: don't fragment logic into one-line wrappers that force constant jumping between functions.
- Abstraction vs. YAGNI: introduce an abstraction at the second or third concrete case (rule of three), not the first.
- Performance vs. clarity: write for clarity first. Optimize measured hotspots and comment why.
Java / Spring Boot notes
- Use constructor injection with
finalfields. Don't use field@Autowired. - Keep controllers thin: map HTTP to DTOs and delegate to services.
- Never expose JPA entities through the API. Map them to DTOs, and use
records for DTOs and value objects. - Put
@Transactionalat the service or use-case boundary, not on controllers. - Use
Optionalonly as a return type, never for fields or parameters. - Centralize exception-to-HTTP mapping in
@RestControllerAdvice. - Split god services by use case.
Review output format
For each finding, give:
- the location
- the principle it violates
- the problem
- the suggested fix, in code
End with the top three priorities. Skip anything the formatter already handles.
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.

