clean-code
Skill0 starsChanged 9 days agoMITView on GitHub
Use when the user types /clean-code, asks to audit or tidy a project's code, or a file or folder has grown too long or crowded. Also holds the writing rules for code this skill writes itself.
- Reads credentials
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 repository12 other files it gives its agents.
- chrome-bidiSkill
- claude-model-effortSkill
- clean-commitsSkill
- drive-projectSkill
- limited-runSkill
- other-model-effortSkill
- progress-boardSkill
- resource-guardSkill
- stop-resume-agentsSkill
- strip-ai-tracesSkill
- using-git-worktreesSkill
- writing-skillsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. 0 are common, 5 are distinctive, and 8 are very specific to this project.
0
Common
Most of the 101 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 27
Read-only until plan_check.py prints plan ok: nothing written in the project apart from .ia/ and graphify-out/.
- Distinctive: line 37
No attribution to any AI tool anywhere.
- Distinctive: line 47
No dead code: unimported files, unused imports and symbols, commented-out code, unreferenced images.
- Distinctive: line 50
Look-alike code is merged, both locations proven.
- Very specific: line 61
No LLM fingerprint: reference/fingerprint.md (attribution cap for an attribution to any AI tool).
- Very specific: line 63
No comment in code. Lines a tool reads stay: linter and compiler directives, shebang, imposed licence header, bundler magic comments, and …
- Very specific: line 66
Every identifier in English: reference/naming.md.
- Very specific: line 67
Every variable optimised: reference/variables.md.
- Very specific: line 71
Every image WebP, cropped to its box, at 1x and 2x.
- Very specific: line 130
Read. Up to reader_threshold files, read them yourself.
- Very specific: line 135
Verify: one fresh Agent call (never a fork), prompt from verify-brief.md with its <...> filled.
- Distinctive: line 160
Check its files have not moved since the plan (git status, git diff).
- Distinctive: line 177
After the last step, measure, verify and score again on the same scope.
“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
An audit measures a scope against rules 0 to 19, keeps the findings a fresh agent confirmed, and turns them into a note out of 20. Below 20 it writes a plan, asks how much to apply, and applies it step by step, one commit per step.
<skill> is this skill's base directory. Call scripts by absolute path with python -I, from the
project root: python -I "<skill>/scripts/measure.py" src. They never crash: on failure they print
what to do by hand.
Everything the audit writes goes to .ia/clean-code/<run>/ at the project root (measure.json,
findings.json, score.json, plan.md), plus an optional config.json next to the runs holding
the thresholds. The scripts add .ia/ to .git/info/exclude. Outside git, or when the project must
stay untouched, measure.py --out <folder> puts the run elsewhere and the other scripts take
--run <run folder>. Scratch files go to <temp>/claude-skills/clean-code-<run>, deleted at the
end. Delete nothing you did not create.
Rules that never bend
These hold in every mode, whatever the user asks.
- Read-only until
plan_check.pyprintsplan ok: nothing written in the project apart from.ia/andgraphify-out/. - Scope first: the
/clean-codeargument, else one question. In doubt, the narrowest. Outside the scope, findings are reported, never fixed. - A finding needs
file:lineand a proof. Verdicts come from a fresh agent that never saw the measuring, never from you. - The repository is shared with other sessions: commit only your own paths, never
git add ., never on a red check, never push, no stash, revert or clean on changes you did not make. - Removed code is deleted, git keeps it. Outside git, move it to
old/. - Visual checks go through the
chrome-bidiskill, headless. - No attribution to any AI tool anywhere. Pushed history is never rewritten: the user decides.
The rules
Defaults of the thresholds in brackets. "Script" means a module under scripts/checks/.
- A bad practice outside the grid, weighed 0.5 to 3 points. A secret in a tracked file is rule 0
with the
secretcap, lifted only by the verifier for a placeholder or sample value. - At most
max_lines[150] lines per file, tests included, test data excepted. Script. - One file, one job.
- No dead code: unimported files, unused imports and symbols, commented-out code, unreferenced images. Script, confirmed by reading.
- At most
max_files[8] code files per folder, unless the framework imposes the layout. Script. - Look-alike code is merged, both locations proven.
max_function_lines[40],max_params[4],max_nesting[3], one job per function. Script.- Names say what they hold, one word per concept:
reference/naming.md. - Errors handled, state immutable by default, strict types: no
any, no silenced check, no swallowed error (swallowedcap when it hides a failure on a path that matters). Script. - Everything testable through the public API is tested. Script for "no test at all".
- Dev and test code never ships: debug output, seeds, fixtures, test accounts (
test-in-prodcap when it reaches the production build). Script. - Nothing built into production that it does not need.
- Lint, format, typecheck, build and tests are configured and pass. The
buildcap is for a failing typecheck or build; a failing suite is a finding without cap. Script for the config. - No LLM fingerprint:
reference/fingerprint.md(attributioncap for an attribution to any AI tool). Script. - No comment in code. Lines a tool reads stay: linter and compiler directives, shebang, imposed
licence header, bundler magic comments, and doc comments of the public API (files exported by
the manifest and paths listed in
public_api). Script. - Every identifier in English:
reference/naming.md. Script. - Every variable optimised:
reference/variables.md. - Text shown to the user lives in the translation files, same keys in every language. Only when the project already has them. Script.
- As few hardcoded values as possible:
reference/values.md. Script. - Every image WebP, cropped to its box, at 1x and 2x; an SVG stays SVG:
reference/images.md. Script, live boxes throughchrome-bidi.
score.py starts from 20 and deducts only for confirmed findings:
| Rule | Deduction |
| 0 | the points of each finding |
| 1 | share of code files over the limit: 0.5 under 10 %, 3 over 40 %, linear between |
| 14, 15, 18 | 2 times the share of files carrying the defect |
| 12 | 1 per finding, 2 at most |
| 2, 5, 9, 10 | 0.5 per finding, 2 at most |
| 11 | 0.5 per finding, 1 at most |
| 3, 6, 8, 13, 16, 17, 19 | 0.25 per finding, 2 at most |
| 4, 7 | 0.25 per finding, 1 at most |
Caps hold the note down, the lowest wins: secret 5, build 8, swallowed, test-in-prod and
attribution 10. The note is rounded to the half point.
Writing code
Rules 14 to 19 and the size limits bind every line this skill writes. Paste this into the prompt of every subagent that writes code:
Code rules for this task:
- No comment in the code, except lines a tool reads (linter directives, shebang, licence header)
and doc comments of the public API. What a comment would explain goes into a name.
- Every identifier in English. Text shown to the user keeps its language.
- No hardcoded value: compute it, read it from config, or name it once.
- Every variable optimised: cheapest correct type, right structure, nothing allocated in a hot
loop, const by default, smallest scope.
- If the project has translation files, user-facing text goes there in every language at once, same
keys. Existing gaps are reported, not filled.
- Images go in as WebP cropped to their box at 1x and 2x through <skill>/scripts/apply/fit_image.py.
- A file stays under 150 lines and a folder under 8 code files: split before crossing.
- Visual checks go through chrome-bidi, headless.
- Typecheck, lint and tests run through the project's package manager, never npx.
- Defects in code you did not touch are reported, not fixed.
- No `shortcut:` or other note comment either: name the shortcut in your reply.A comment your change makes false leaves with the code it described. Other existing comments wait for a clean-code pass, so a diff never mixes a fix and a comment sweep.
Audit
In this order, each step ending before the next.
- Scope: the
/clean-codeargument, elseAskUserQuestion: whole project, then each app or top folder, narrowest first. - Measure:
python -I "<skill>/scripts/measure.py" <scope>. It prints the run folder, candidates by rule and, pastreader_threshold[150] code files, the reader batches. - Images, when the scope has some and the project renders pages: measure live boxes, then measure
again with
--boxesbefore any verdict (reference/images.md). - Commands, one heavy process at a time, low priority, two workers at most: typecheck without
cache, linter with
--max-warnings 0, the build only when it writes outside the tree, the test suite. A failure is a rule 12 finding with its output. A command that cannot run isfindings.py unmeasured --rule 12 --why "<reason>", never installed. - Read. Up to
reader_thresholdfiles, read them yourself. Past that, map the scope first withgraphify update <scope>whengraphifyis on the PATH: no model call, it writes or refreshes<scope>/graphify-out/, which measure.py keeps out of git and out of the measure. Then one agent per batch,readersat most [4], prompt fromreader-brief.md, all in one message. Every reading rule ends with findings,findings.py checked --rule <n> --why "..."orfindings.py unmeasured --rule <n> --why "...". - Verify: one fresh Agent call (never a fork), prompt from
verify-brief.mdwith its<...>filled. Disagree with a verdict only by sending it back with the proof it missed. - Score:
python -I "<skill>/scripts/score.py". It refuses while a candidate has no verdict or a reading rule is uncovered. At 20, stop: no plan, no question. - Plan: write
<run>/plan.mdfromplan-template.md, in English, then runpython -I "<skill>/scripts/plan_check.py"until it printsplan ok. - Print the note alone as a heading,
# 12/20, with no word around it, then apply the whole plan without asking.
Apply
Steps run in phase order; splitting files comes last, once the tests guard it.
| Phase | Rules |
| 1 | 12 |
| 2 | 9 |
| 3 | 0, 3, 7, 8, 13 to 19 |
| 4 | 5, 6 |
| 5 | 1, 2, 4 (git mv) |
| 6 | 10, 11, secrets |
For each step of the plan:
- Check its files have not moved since the plan (
git status,git diff). One that moved belongs to another session: skip it and say so. - Change the listed files only, then run the step's check and the tests of the touched files.
- Green: commit through the
clean-commitsskill as a caller, with the step'sFiles:paths only (deleted ones included), no push. Without that skill, stop and say so. - Red: restore the step's own files, report the output, continue only with steps that do not depend on it.
At the end of each phase, run the typecheck without cache and the full suite. Red: revert the
phase's step commits newest first with git revert --no-edit until it turns green. The last one
reverted broke it: report its output. Bring back the newer ones by reverting their revert commits
and run the suite again; one that turns it red goes back out and is reported with the culprit.
A secret moves to the environment with a sample entry in .env.example. If it was ever committed it
has leaked: ask whether to rotate it, and never print it. A UI step ends with before and after
screenshots at phone and desktop widths.
After the last step, measure, verify and score again on the same scope.
Report
The note after alone as a heading, # 17/20, then in the user's language each step with its commit
hash, the raw output of the last full suite, and what is left with its reason. A question comes
only for what the user alone decides, such as rotating a leaked secret.
Files
A new module in scripts/checks/ with a check(files, root, config) function joins the measure.
Tests: python -I -B -m unittest discover -s tests -p "test_*.py" from this folder.
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.

