agentleFS
patbaumgartnerpatbaumgartner/clean-code-skill/skills/clean-code/SKILL.md

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

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.
  • SKB3002Skill

    intelligent-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

  • SKB3002Skill

    nextjs-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

  • xfstudioSkill

    bash-pro

    Master of defensive Bash scripting for production automation, CI/CD

    Also in 4 projects that use this

  • xfstudioSkill

    code-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-diceSkill

    clean-code-review

    Multi-agent clean code audit — each principle gets its own agent

    Also in 3 projects that use this

  • goca-seSkill

    batch-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

    1. superplanehq/superplane★ 10ksame name
    2. vudovn/ag-kit★ 8.2ksame name
    3. vudovn/antigravity-kit★ 8.2ksame name
    4. Openpanel-dev/openpanel★ 7.3ksame name
    5. ciembor/agent-rules-books★ 2.8ksame name
    6. wondelai/skills★ 2.7ksame name
    7. decebals/claude-code-java★ 763same name
    8. operately/operately★ 618same name
    9. liza-mas/liza★ 418same name
    10. 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.

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
  1. Distinctive:

    Prefer the simplest thing: No speculative abstractions, unused parameters, or "future-proof" layers (Simple Design rule 4, G12).

    line 29
  2. Very specific:

    If the request is ambiguous, default to write when producing code and review when shown existing code.

    line 42
  3. Distinctive:

    If a name hides a side effect, rename it (N7, G20).

    line 53
  4. Distinctive:

    Do one thing at one level of abstraction.

    line 57
  5. Distinctive:

    No history, authorship, or ticket trails in comments (C1).

    line 66
  6. Distinctive:

    Never commit commented-out code (C5).

    line 67
  7. Distinctive:

    Do not return or pass null where a special-case object, empty collection, or option type fits.

    line 72
  8. Distinctive:

    Test boundaries explicitly (G3, T5).

    line 74
  9. Distinctive:

    Remove duplication first; it is the root of most smells (G5), then fix abstraction levels (G6).

    line 78
  10. Distinctive:

    Prefer polymorphism over repeated type switches (G23).

    line 82
  11. Distinctive:

    Test the behavior you add or change.

    line 86
  12. Distinctive:

    Never skip or weaken a test to get green.

    line 88
  13. Distinctive:

    Keep one command to build and one to test (E1, E2).

    line 89
  14. Distinctive:

    When you are the one generating code, also follow references/ai-assisted-coding.md: search for existing helpers before adding new ones, …

    line 111

“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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

  1. 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.
  2. Project conventions win. Existing style, linters, and formatters beat these rules (G11, G24). Match the surrounding code; do not reformat unrelated lines.
  3. 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.
  4. Prove behavior is preserved. Refactor only under passing tests. If none exist, add characterization tests first or say plainly that the change is unverified.
  5. Name the rule. Cite codes when reviewing or reporting (G5, F3, N1) so the user can look them up in references/catalog.md.
  6. 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 thisRead first
New or changed codeApply the checklist below while writing; run the testsreferences/principles.md
A review of code or a diffFindings by severity, each with a rule code and a fixreferences/review.md
A cleanup or refactorSmall verified steps, one smell at a timereferences/refactor.md
An explanation of a rule, term, or techniqueAnswer from the catalog, glossary, or patternsreferences/catalog.md, references/glossary.md, references/patterns.md
"Any quick wins?" while editingBoy Scout pass: one or two safe improvements in the touched codethis 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.

LanguageReference
Pythonreferences/languages/python.md
TypeScript / JavaScriptreferences/languages/typescript.md
Javareferences/languages/java.md
Kotlinreferences/languages/kotlin.md
Goreferences/languages/go.md
Rustreferences/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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.