clean-code
Skill0 starsChanged 3 months agoMITView on GitHub
Use when writing or reviewing any code, when deciding whether to extract a shared abstraction, when a file is growing large, or when the same logic appears in more than one place.
- Deletes or force-pushes
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
- nohemi20231/design-skillstheir 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
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 repository9 other files it gives its agents.
- accessibilitySkill
- component-designSkill
- documentationSkill
- feedback-and-performanceSkill
- mockupsSkill
- securitySkill
- spec-authoringSkill
- stack-selectionSkill
- testingSkill
The file
We split this skill into the rules it gives an agent
10 rules. 0 are common, 9 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 101 edited versions we read keep these.
9
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 13
Three occurrences, then extract: Not two.
- Distinctive: line 26
Ask: *when this changes, must every copy change together?* Yes means it is one thing.
- Distinctive: line 56
When you catch yourself writing a list of things that count, ask what they have in common, and encode that instead.
- Very specific: line 70
No abbreviations except genuinely universal ones.
- Distinctive: line 72
Never let a name become inaccurate.
- Distinctive: line 77
One reason to exist: If you cannot name a function without "and", it is doing two things.
- Distinctive: line 94
Write a comment when the reason is not visible from the code: a non-obvious constraint, a workaround for a specific bug, a deliberate …
- Distinctive: line 97
Do not write a comment that restates the line beneath it.
- Distinctive: line 108
Dependencies point one way: When a feature imports from another feature which imports back, neither can be understood, tested, or removed …
- Distinctive: line 133
Separate refactoring from behaviour change: Do one or the other in a change, never both — otherwise a reviewer cannot tell which edits were …
“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
The measure is not elegance. It is whether the next person — often you, six months on, with none of today's context — can read it, change it safely, and know they didn't break something.
Duplication
Three occurrences, then extract. Not two.
Two similar pieces of code are frequently coincidence. They look alike today and diverge next week, because they answer to different requirements. Extract at two and you get an abstraction with a boolean parameter, then two, then a shape nobody can follow that serves neither caller well.
The wrong abstraction costs more than the duplication it replaced, because duplication is easy to delete and a bad abstraction is load-bearing.
Duplicated knowledge is different from duplicated text. A tax rate, a validation rule, a status name — one authoritative definition, always, from the first occurrence. Two functions that happen to have the same five lines but answer to different rules are not duplication.
Ask: when this changes, must every copy change together? Yes means it is one thing. No means it is two things that currently look alike.
Enumerations go stale. Properties do not.
The most common way a correct-looking rule quietly stops being correct is that it was written as a list of the cases its author imagined, rather than as the property that actually distinguishes them.
The list is right on the day it is written. Then someone adds a case its author never pictured, and the rule silently stops covering it — while still reporting success, because from its own point of view nothing is wrong.
Three real examples from this codebase, all found by other people using it:
| Written as a list | The property underneath |
| Six copies of a frontmatter parser | There is one way to read frontmatter |
| A list of two files an approval hashes | Everything a design renders against is an input |
A regex matching "load the x and y skills" | Names are tokens; grammar varies |
reset\s+--hard, requiring the two adjacent | Shell flags interleave in any order |
The fourth is the one that cost most. git reset -q --hard is the same command as
git reset --hard, but the pattern required the tokens to be adjacent, so the -q form ran
unblocked and destroyed an hour of uncommitted work. The rule had been tested — against the one
spelling its author typed.
The third is the clearest. The pattern had an optional group for a second name, which consumed it without capturing it — so it checked one of two references and reported that everything resolved. It handled exactly the sentence its author had in mind.
When you catch yourself writing a list of things that count, ask what they have in common, and encode that instead. When you genuinely cannot — some enumerations are irreducible — say where the list came from, and add a check that it has not drifted from its source.
The tell: you are extending a list to fix a bug. Extending it fixes today's case and leaves tomorrow's.
Naming
Naming is the highest-leverage thing in this document. Most unreadable code is well-structured code with names that lie.
- Name what it is, not what it does internally.
activeSubscribers, notfilterUsersLoop - Say the unit:
timeoutMs,priceInCents,maxRetries - Booleans read as assertions:
isExpired,hasAccess,shouldRetry - No abbreviations except genuinely universal ones.
rescould be response, result, resource, or reserved - A long clear name beats a short cryptic one every time
- Never let a name become inaccurate. A renamed concept must be renamed everywhere — a stale name is worse than no name, because it is trusted
Functions
One reason to exist. If you cannot name a function without "and", it is doing two things.
Keep the levels of abstraction consistent. A function that orchestrates three high-level steps should not also contain string parsing. Mixed levels are what makes code exhausting to read.
Return early. Handle the edge cases and get out. Deeply nested conditionals hide the main path.
Prefer arguments to hidden state. A function whose result depends only on what it was given can be tested, moved, and reasoned about. One that reads ambient state cannot.
Boolean parameters are a smell. render(true) tells the reader nothing. It usually means two
functions wearing a trench coat.
Comments
Code says what. Comments say why.
Write a comment when the reason is not visible from the code: a non-obvious constraint, a workaround for a specific bug, a deliberate choice that looks wrong, an ordering that matters.
Do not write a comment that restates the line beneath it. Do not leave commented-out code — that is what version control is for. Do not write a comment that will go stale; if it must be true, assert it in a test.
The best comment is usually a better name.
Structure
Group by feature, not by kind. Everything belonging to one capability lives together. Directories named after technical layers force you to open five folders to understand one thing, and they make it impossible to see what a change touches.
Dependencies point one way. When a feature imports from another feature which imports back, neither can be understood, tested, or removed alone. Push shared things down into something both depend on.
Keep the public surface small. Export what callers need. Everything else stays private so it can be changed without an audit.
Errors
Fail loudly and early. An error swallowed silently becomes a bug report about wrong data six weeks later, with nothing to go on.
Handle it where you can do something about it. Catching an error only to log and rethrow adds noise. Catch it where there is a decision to make.
Error messages are for whoever reads them at 3am. Include what was being attempted and with what. "Request failed" is useless. Never expose internals to end users, and never hide them from logs.
Never catch everything and continue. A bare catch-all around a block hides the failure you most need to see.
Changing existing code
Match what is already there. Consistency beats your preference. A file written in one style and edited in another is harder to read than either style alone.
Separate refactoring from behaviour change. Do one or the other in a change, never both — otherwise a reviewer cannot tell which edits were meant to alter behaviour, and neither can you.
Leave it a little better. Fix the name you had to decipher. Do not rewrite the module while you are there — an unrelated large refactor buried in a small change is how regressions ship.
Delete dead code. Unreferenced functions, unused flags, commented-out blocks, TODOs from years ago. It is all in version control. Every line kept "just in case" is a line someone has to read and wonder about.
Reviewing your own work before calling it done
- Would someone with no context understand this?
- Does every name still mean what it says?
- Is anything here duplicated knowledge rather than duplicated text?
- Is there an abstraction extracted from only two cases?
- Are the errors handled where something can be done about them?
- Is there anything left in that is not being used?
- Does this match the surrounding code?
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.

