clean-code
Skill12 starsChanged 2 months agoMITView on GitHub
Use when writing, editing, reviewing, testing, planning, or refactoring code in any language or framework; creating files or deciding where code and folders belong; designing or changing module boundaries, layers, and dependencies; starting a new project; auditing or cleaning up an existing one; or compressing agent instruction files. Covers SOLID, design patterns, and the dependency rule.
135 other projects use a version of this.
Adopted by
Most recently taken up by
- JosefGisis/skillstheir own version, first seen Nov 29, 2026
- vjrivmon/Setup-Software-IAtheir own version, first seen Nov 29, 2026
- gromov0737/skillstheir own version, first seen Nov 29, 2026
- dayfinggg/openai-codex-agent-skillstheir own version, first seen Nov 29, 2026
- hybridlabor-api/aostheir own version, first seen Nov 29, 2026
- sbluemin/fleet-harnesstheir own version, first seen Nov 29, 2026
Used with
Projects with it also use intelligent-routing, designing-data-intensive-applications 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
ciemborSkilldesigning-data-intensive-applications
Apply Martin Kleppmann-inspired data-system rules when designing reliability, scalability, consistency, replication, transactions, streams, or schema evolution.
Also in 3 projects that use this
ciemborSkillimplementing-domain-driven-design
Apply Vaughn Vernon-inspired implementation DDD rules when building aggregates, domain events, repositories, application services, or context integrations.
Also in 3 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
- +1 more from xfstudio
- +1 more from ciembor
Other versions135 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 135
- superplanehq/superplane★ 10ksame name
- vudovn/ag-kit★ 8.2ksame name
- vudovn/antigravity-kit★ 8.2ksame name
- Openpanel-dev/openpanel★ 7.3ksame name
- wondelai/skills★ 2.8ksame name
- ciembor/agent-rules-books★ 2.8ksame name
- lightly-ai/lightly-studio★ 911same name
- decebals/claude-code-java★ 763same name
- operately/operately★ 621same name
- liza-mas/liza★ 418same name
125 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 repository4 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/clean-code.mdcCursor rule
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 125 edited versions we read keep these.
3
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 43
Edit surgically: every changed line traces to the request.
- Distinctive: line 63
Minimal code: Before writing code, stop at the first yes: Unneeded (YAGNI)?
- Distinctive: line 92
Never derive business objects from framework base classes or annotate them.
- Very specific: line 115
Read only what the task needs, from references/.
“Common” is measured: kept by at least 6 in 10 of the 125 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 And Clean Architecture
Before The First Edit: Load Context
You forget everything between sessions. scripts/ and references/ resolve from this file's
folder. Read in order; trivial edits (typo, comment) skip this gate and the review checklist.
- Stack.
.clean/context.json; missing: runscripts/detect_stack.py, or read manifests and file extensions. - Packs. Open each pack in
packsor under "Read next" with the file-read tool (naming a pack is not reading it), except framework packs whosepack_scopesexclude your area. By hand:clean-packsindex inreferences/framework-map.md; none: answer its adaptation questions. - Layers.
.clean/architecture.md; see Layer Rules. - Decisions.
.clean/decisions.md,.clean/ledger.md. Recorded decisions are settled; resume, never restart, campaigns in progress. - Structure. Your area's
.clean/structure.mdrows (grep path) orscripts/map_structure.py --path <area>; by hand, list the folder, open the two or three most similar files. - Project instructions.
AGENTS.md,CLAUDE.md,CONTRIBUTING.md,ARCHITECTURE.md,README.md.
On conflict, first wins: project instructions, recorded decisions, declared layers, local
conventions, framework pack, language pack, this skill. Only init, audit, new-project create
.clean/; plain sessions read it, offer to persist at the end.
Operating Loop
- Frame: behavior change, assumptions, smallest scope, success check. Ask only if ambiguity changes the implementation.
- Read nearby code, naming, tests, error style, framework idiom; search for existing implementations first.
- Place: owning unit; which side of which boundary.
- Edit surgically: every changed line traces to the request; targeted edits, never whole-file regeneration; remove what your change orphaned.
- Verify: narrowest meaningful check, then what the risk level owes (
review-checklist.md); bug: reproducer test first; refactor: tests before and after. Never claim success without running something. - Review the diff with
references/review-checklist.md, self-check included.
Rules That Always Apply
Placement. Role decides folder, per pack roles and project layout; mirror similar files. New
file only without a cohesive home, then fully wired: imports, exports, registration, routes, DI,
build config; unreferenced files are dead code. Never default to repository root or current
directory. Never create sibling variants (_v2, _new, _final, _copy) or grow junk drawers
(utils, helpers, common); name the concept. Narrowest access modifier.
One job per unit, every scale: needs "and" to describe? Split. Parsing, domain rules, persistence, external calls, presentation, wiring: separate homes. Orchestrators sequence collaborators, hold no business rules. New behavior goes to its owning unit, not the open file. Different actors' code stays apart, even if identical today.
Minimal code. Before writing code, stop at the first yes: Unneeded (YAGNI)? Write nothing. Already in the codebase? Reuse it. Standard library, platform, or installed dependency does it? Use that. One line? Write it. Else write the minimum. Never cut safety: validation, error handling, security, accessibility.
Code. Names reveal intent in project vocabulary, one word per concept. Functions: one thing,
one abstraction level, few arguments, no flag arguments. Comments: why, briefly. Never swallow
errors: handle where a decision can be made, keep causes, model expected outcomes as values. Tests:
Three Laws of TDD, F.I.R.S.T.; never weaken, skip, or delete failing tests. Verify every API
against installed versions in .clean/context.json, never memory. Deduplicate only copies that
must change together (DRY). Formatter owns formatting. Design priority: tests pass, no duplicated
knowledge, intent expressed, fewest elements.
Security. Validate and encode input at every trust boundary, parameterize queries, keep authorization beside the operation it protects, never put secrets in code, committed config, or logs.
Layer Rules, When Layers Are Declared
Strict when .clean/architecture.md declares layers: check with scripts/check_boundaries.py, or
read changed files' imports, naming each layer. Undeclared: follow the framework pack's idiomatic
structure; these rules guide judgement.
- The Dependency Rule: source dependencies point only inward, to higher-level policy; nothing inner names anything outer (class, function, variable, annotation, data format).
- Business rules highest; database, web, UI, framework, delivery mechanism are details behind policy-owned interfaces.
- SQL stays in data access. Rows, ORM types, framework request/response objects never travel inward; pass simple structures shaped for the inner side.
- Never derive business objects from framework base classes or annotate them; dependency-injection
wiring in
main. - Component graph acyclic; depend toward stability; split hard-to-test from easy-to-test; no speculative boundaries.
Commands
/clean-code <argument> (or $clean-code, @clean-code, /skill:clean-code) and plain language
route identically.
| Argument | Follow |
init (alias questions, "interview me") | references/init.md |
audit | references/audit-report.md; changes no code |
clean-up | references/project-refactor.md with .clean/ledger.md; no ledger: propose an audit (file count), await consent |
new-project <description> | references/new-project.md |
plan <task> | references/plan.md; edits nothing |
review [files] | references/review-checklist.md, The review Command; edits nothing |
compress [files] | references/compress.md; never touches the managed block |
| (none) | this file; references/session-protocol.md for multi-step or resumable work |
Load Plan
Read only what the task needs, from references/; long files via their Contents:
| Task | Read |
| Review; agent smells A1-A10 | review-checklist.md |
| Risk level: LOW, MEDIUM, HIGH | review-checklist.md, Risk Levels |
| Comment cleanup (C1-C5, G12) | comments.md |
| Architecture style, design pattern, data access | patterns.md |
| New dependency | framework-map.md, Dependencies And Package Idioms |
| New boundary, layer, framework, or database | architecture.md |
| Tests | tests.md |
| Concurrency | concurrency.md |
| Security, trust boundaries, data versus objects, performance | principles.md |
| Naming or triaging a smell | smell-triage.md; IDs (G17, N7, T5...) in chapter-map.md |
| A named rule, exactly | canon.md |
| State for the next session | memory-protocol.md |
| Worked examples, templates | examples.md |
| Host hooks, commands, install paths | host-matrix.md |
Scripts detect_stack.py, scan_repo.py, map_structure.py, check_boundaries.py, check_compression.py: flags, findings, exit codes; output is evidence, never a verdict | tools.md |
Scope Modes
Surgical (default): smallest slice; report unrelated smells, never fix them unless a requested
outcome needs it ("make the suite pass"): smallest fix, reported separately, never a weakened test.
Campaign (explicit request only): references/project-refactor.md; never a behavior change
inside a refactor batch.
Completion Checklist
- Packs read before the first edit.
- Task solved; each changed line traces to it and obeys the rules above.
- New files placed by role, wired; no sibling variant, duplicate, dead code, scratch file, or debug output.
- Tests cover the change; none weakened.
- Verification reported honestly: risk level, results, what did not run, remaining risk.
- Lasting decisions in
.clean/decisions.md; files added or moved and.clean/exists:scripts/map_structure.py --writerun.
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.

