clean-code
Skill1 starsChanged 5 days agoMITView on GitHub
Applies Robert C. Martin's Clean Code principles when writing, reviewing, or refactoring code in any language - intention-revealing names, small single-purpose functions, honest comments, error handling, SRP/OCP/DIP, tests (TDD, F.I.R.S.T.), and the named smell catalog (C, E, F, G1-G36, N, T). Use whenever code is created, edited, reviewed, or refactored; when asked for a clean-code review, cleanup, or "boy scout" pass; or when the user mentions code smells, readability, maintainability, technical debt, or a rule code such as G5 or F3.
120 other projects use a version of this.
Adopted by
Most recently taken up by
- travissmithv1/claude-skillstheir own version, first seen Nov 16, 2026
- kiaramaldonado/my-favorite-claude-skillstheir own version, first seen Nov 16, 2026
- Ajustor/claude-skillstheir own version, first seen Nov 16, 2026
- Ivan-propio/claude-skillstheir own version, first seen Nov 16, 2026
- michagrandel/skillstheir own version, first seen Nov 16, 2026
- mlschodkowski/skillstheir own version, first seen Nov 16, 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 versions120 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 120
- superplanehq/superplane★ 10ksame 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.7ksame name
- decebals/claude-code-java★ 763same name
- operately/operately★ 618same name
- liza-mas/liza★ 418same name
- Mindrally/skills★ 275same name
110 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 repositoryOne other file it gives its agents.
- AGENTS.mdAGENTS.md
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. 0 are common, 13 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 113 edited versions we read keep these.
13
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 29
Prefer the simplest thing: No speculative abstractions, unused parameters, or "future-proof" layers (Simple Design rule 4, G12).
- Very specific: line 42
If the request is ambiguous, default to write when producing code and review when shown existing code.
- Distinctive: line 53
If a name hides a side effect, rename it (N7, G20).
- Distinctive: line 57
Do one thing at one level of abstraction.
- Distinctive: line 66
No history, authorship, or ticket trails in comments (C1).
- Distinctive: line 67
Never commit commented-out code (C5).
- Distinctive: line 72
Do not return or pass null where a special-case object, empty collection, or option type fits.
- Distinctive: line 74
Test boundaries explicitly (G3, T5).
- Distinctive: line 78
Remove duplication first; it is the root of most smells (G5), then fix abstraction levels (G6).
- Distinctive: line 82
Prefer polymorphism over repeated type switches (G23).
- Distinctive: line 86
Test the behavior you add or change.
- Distinctive: line 88
Never skip or weaken a test to get green.
- Distinctive: line 89
Keep one command to build and one to test (E1, E2).
- Distinctive: line 111
When you are the one generating code, also follow references/ai-assisted-coding.md: search for existing helpers before adding new ones, …
“Common” is measured: kept by at least 6 in 10 of the 113 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
Make code that is easy to read, change, and test. Finish the requested task first, then leave the code you touched a little cleaner than you found it (the Boy Scout Rule).
Operating rules
- Scope discipline. Clean up only what you touch or what blocks the task. Never start an unrequested rewrite, and never mix behavior changes with pure refactoring in one step.
- Project conventions win. Existing style, linters, and formatters beat these rules (G11, G24). Match the surrounding code; do not reformat unrelated lines.
- Rules are heuristics. "Max three arguments" and "small functions" guide judgment; they are not laws. Explain a deliberate exception in one short line instead of contorting code.
- Prove behavior is preserved. Refactor only under passing tests. If none exist, add characterization tests first or say plainly that the change is unverified.
- Name the rule. Cite codes when reviewing or reporting (
G5,F3,N1) so the user can look them up in references/catalog.md. - Prefer the simplest thing. No speculative abstractions, unused parameters, or "future-proof" layers (Simple Design rule 4, G12).
Pick a mode
| The user wants... | Do this | Read first |
| New or changed code | Apply the checklist below while writing; run the tests | references/principles.md |
| A review of code or a diff | Findings by severity, each with a rule code and a fix | references/review.md |
| A cleanup or refactor | Small verified steps, one smell at a time | references/refactor.md |
| An explanation of a rule, term, or technique | Answer from the catalog, glossary, or patterns | references/catalog.md, references/glossary.md, references/patterns.md |
| "Any quick wins?" while editing | Boy Scout pass: one or two safe improvements in the touched code | this file |
If the request is ambiguous, default to write when producing code and review when
shown existing code. Anything after the skill name (for example review src/billing) is the
target; treat it as a path, a rule code, or a topic as appropriate.
Checklist while writing
Names
- Reveal intent; avoid disinformation and noise words; make names pronounceable and searchable (N1, N4).
- Classes and types are nouns, functions are verbs; one word per concept (N3).
- Name length grows with scope (N5); no type or scope encodings unless the language demands them (N6).
- If a name hides a side effect, rename it (N7, G20).
Functions
- Do one thing at one level of abstraction; extract until the body reads like prose (G30, G34).
- Few arguments (F1); no flag arguments (F3); no output arguments (F2); no selector arguments (G15).
- A function either does something or answers something, not both (command-query separation).
- Guard clauses over deep nesting; encapsulate conditions in named predicates (G28, G29).
- Replace magic numbers and strings with named constants or enums (G25); delete dead code (F4, G9).
Comments
- Explain why or warn of consequences; never narrate what the code already says (C3).
- No history, authorship, or ticket trails in comments (C1); delete stale ones (C2).
- Never commit commented-out code (C5).
Errors and boundaries
- Signal failure with the language's idiomatic mechanism and add context; never swallow errors (G4).
- Do not return or pass null where a special-case object, empty collection, or option type fits.
- Wrap third-party APIs behind your own seam so vendor change stays local.
- Test boundaries explicitly (G3, T5); name every assumption (G26).
Structure
- Remove duplication first; it is the root of most smells (G5), then fix abstraction levels (G6).
- Small classes with one reason to change (SRP); extend, do not modify (OCP); depend on abstractions (DIP).
- Hide data, expose behavior; do not navigate through strangers (G14, G36).
- Construct dependencies at the edge (
main, factories, DI) and inject them. - Prefer polymorphism over repeated type switches (G23).
Tests
- Test the behavior you add or change; one concept per test (T1, T3).
- Fast, Independent, Repeatable, Self-validating, Timely (F.I.R.S.T.) (T9).
- Never skip or weaken a test to get green; an ignored test is an open question (T4, G4).
- Keep one command to build and one to test (E1, E2).
Language adaptation
Detect the language from the files at hand and read the matching file before writing or reviewing a substantial change. Where a language idiom contradicts a generic rule, the idiom wins.
| Language | Reference |
| Python | references/languages/python.md |
| TypeScript / JavaScript | references/languages/typescript.md |
| Java | references/languages/java.md |
| Kotlin | references/languages/kotlin.md |
| Go | references/languages/go.md |
| Rust | references/languages/rust.md |
| C# | references/languages/csharp.md |
For any other language, apply the generic checklist and follow that ecosystem's formatter, linter, and naming conventions.
Working with AI-generated code
When you are the one generating code, also follow references/ai-assisted-coding.md: search for existing helpers before adding new ones, keep diffs small and reviewable, never invent APIs, and never silence a failing check to finish faster.
Reporting what you did
End a task with a short note, not a lecture:
- Edits:
Cleaned up: extracted SECONDS_PER_DAY (G25), removed dead branch (G9). - Reviews: findings grouped by severity using the format in references/review.md.
- Skipped work:
Left as is: the 120-line parse() function is out of scope (G30); worth a follow-up.
Scope and limits
This is an independent, condensed aid for applying principles popularized by Robert C. Martin. It restates the named heuristics and frameworks in original words and does not reproduce the book's text, code, or structure. Read Clean Code: A Handbook of Agile Software Craftsmanship (Prentice Hall, 2008) for the authoritative treatment. Not affiliated with or endorsed by the author or publisher. See references/principles.md for the principles and NOTICE for credits.
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.

