clean-code · pproenca — Claude Code skill: 48 clean code rules
A skill that feeds the agent 48 rules on naming, functions, errors and tests, drawn from Robert C. Martin's book with modern fixes. Useful during reviews and refactors.
npx skills add pproenca/dot-skills --skill clean-code -a claude-codeWhat clean-code does
The skill splits into 10 categories ranked by impact: names, functions, comments, formatting, error handling, objects, boundaries, classes, unit tests and simple design. Every rule has a prefix such as name-, func- or cmt- and its own reference file with an explanation and code examples. The examples lean on Java, the principles do not.
Names and functions sit at CRITICAL, comments, formatting and errors at HIGH, the rest lower. The agent pulls the matching rule when you ask it to name a variable, shrink a function or write a test. There is also a template for adding your own rules.
The advice comes from the 2008 edition, so parts of it were rewritten to match current practice. If your project already has a style guide, the formatting rules here can clash with it — worth checking which one wins in your review.
What it helps with
- rename variables so the name states the intent
- split a long function into pieces at one abstraction level
- delete commented-out code and redundant comments
- wrap a third-party API and add learning tests for it
- rewrite a test that asserts several things at once
Example prompts for the agent
- review this module against clean-code and list the violations
- suggest names for these variables using name-intention-revealing
- break
processOrderdown following func-one-thing and func-small
How to install clean-code
1Skills CLI (Vercel)
npx skills add pproenca/dot-skills --skill clean-code -a claude-code2Manually: put the files in place
~/.claude/skills/clean-code/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/clean-code/
1Skills CLI (Vercel)
npx skills add pproenca/dot-skills --skill clean-code -a codex2Manually: put the files in place
.agents/skills/clean-code/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add pproenca/dot-skills --skill clean-code -a cursor2Manually: put the files in place
.cursor/skills/clean-code/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install pproenca/dot-skills clean-code2Manually: put the files in place
.github/skills/clean-code/SKILL.md1Skills CLI (Vercel)
npx skills add pproenca/dot-skills --skill clean-code -a gemini-cli2Platform CLI
gemini skills install https://github.com/pproenca/dot-skills --path skills/.experimental/clean-codeManually: put the files in place
.devin/skills/clean-code/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add pproenca/dot-skills --skill clean-code -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about clean-code
How do I install clean-code in Claude?
Run npx skills add pproenca/dot-skills --skill clean-code -a claude-code. The skill then lands in ~/.claude/skills/clean-code/SKILL.md.
What does the clean-code skill do?
It gives the agent 48 rules covering names, functions, comments, errors, classes and tests, and applies them while writing, reviewing or refactoring code.
How is it different from the Clean Code book?
It follows Robert C. Martin's book but rewrites the 2008 advice that no longer holds. The rules are grouped into 10 categories and ordered by impact.
Source text
SKILL.md · MIT
--- name: clean-code description: Use when writing, reviewing, or refactoring code for maintainability and readability. Triggers on code reviews, naming discussions, function design, error handling, and test writing. Based on Robert C. Martin's Clean Code handbook with modern corrections. --- # Robert C. Martin (Uncle Bob) Clean Code Best Practices Comprehensive software craftsmanship guide based on Robert C. Martin's "Clean Code: A Handbook of Agile Software Craftsmanship", updated with modern corrections where the original 2008 advice has been superseded. Contains 48 rules across 10 categories, prioritized by impact to guide code reviews, refactoring decisions, and new development. Examples are primarily in Java but principles are language-agnostic. ## When to Apply Reference these guidelines when: - Writing new functions, classes, or modules - Naming variables, functions, classes, or files - Reviewing code for maintainability issues - Refactoring existing code to improve clarity - Writing or improving unit tests - Wrapping third-party dependencies ## Rule Categories by Priority | Priority | Category | Impact | Prefix | |----------|----------|--------|--------| | 1 | Meaningful Names | CRITICAL | `name-` | | 2 | Functions | CRITICAL | `func-` | | 3 | Comments | HIGH | `cmt-` | | 4 | Formatting | HIGH | `fmt-` | | 5 | Error Handling | HIGH | `err-` | | 6 | Objects and Data Structures | MEDIUM-HIGH | `obj-` | | 7 | Boundaries | MEDIUM-HIGH | `bound-` | | 8 | Classes and Systems | MEDIUM-HIGH | `class-` | | 9 | Unit Tests | MEDIUM | `test-` | | 10 | Emergence and Simple Design | MEDIUM | `emerge-` | ## Quick Reference ### 1. Meaningful Names (CRITICAL) - [`name-intention-revealing`](references/name-intention-revealing.md) - Use names that reveal intent - [`name-avoid-disinformation`](references/name-avoid-disinformation.md) - Avoid misleading names - [`name-meaningful-distinctions`](references/name-meaningful-distinctions.md) - Make meaningful distinctions - [`name-pronounceable`](references/name-pronounceable.md) - Use pronounceable names - [`name-searchable`](references/name-searchable.md) - Use searchable names - [`name-avoid-encodings`](references/name-avoid-encodings.md) - Avoid encodings in names - [`name-class-noun`](references/name-class-noun.md) - Use noun phrases for class names - [`name-method-verb`](references/name-method-verb.md) - Use verb phrases for method names ### 2. Functions (CRITICAL) - [`func-small`](references/func-small.md) - Keep functions small - [`func-one-thing`](references/func-one-thing.md) - Functions should do one thing - [`func-abstraction-level`](references/func-abstraction-level.md) - Maintain one level of abstraction - [`func-minimize-arguments`](references/func-minimize-arguments.md) - Minimize function arguments - [`func-no-side-effects`](references/func-no-side-effects.md) - Avoid side effects - [`func-command-query-separation`](references/func-command-query-separation.md) - Separate commands from queries - [`func-dry`](references/func-dry.md) - Do not repeat yourself ### 3. Comments (HIGH) - [`cmt-express-in-code`](references/cmt-express-in-code.md) - Express yourself in code, not comments - [`cmt-explain-intent`](references/cmt-explain-intent.md) - Use comments to explain intent - [`cmt-avoid-redundant`](references/cmt-avoid-redundant.md) - Avoid redundant comments - [`cmt-avoid-commented-out-code`](references/cmt-avoid-commented-out-code.md) - Delete commented-out code - [`cmt-warning-consequences`](references/cmt-warning-consequences.md) - Use warning comments for consequences ### 4. Formatting (HIGH) - [`fmt-vertical-formatting`](references/fmt-vertical-formatting.md) - Use vertical formatting for readability - [`fmt-horizontal-alignment`](references/fmt-horizontal-alignment.md) - Avoid horizontal alignment - [`fmt-team-rules`](references/fmt-team-rules.md) - Follow team formatting rules - [`fmt-indentation`](references/fmt-indentation.md) - Respect indentation rules ### 5. Error Handling (HIGH) - [`err-use-exceptions`](references/err-use-exceptions.md) - Separate error handling from happy path - [`err-write-try-catch-first`](references/err-write-try-catch-first.md) - Write try-catch-finally first - [`err-provide-context`](references/err-provide-context.md) - Provide context with exceptions - [`err-define-by-caller-needs`](references/err-define-by-caller-needs.md) - Define exceptions by caller needs - [`err-avoid-null`](references/err-avoid-null.md) - Avoid returning and passing null ### 6. Objects and Data Structures (MEDIUM-HIGH) - [`obj-data-abstraction`](references/obj-data-abstraction.md) - Hide data behind abstractions - [`obj-data-object-asymmetry`](references/obj-data-object-asymmetry.md) - Understand data/object anti-symmetry - [`obj-law-of-demeter`](references/obj-law-of-demeter.md) - Follow the Law of Demeter - [`obj-avoid-hybrids`](references/obj-avoid-hybrids.md) - Avoid hybrid data-object structures - [`obj-dto`](references/obj-dto.md) - Use DTOs for data transfer ### 7. Boundaries (MEDIUM-HIGH) - [`bound-wrap-third-party`](references/bound-wrap-third-party.md) - Wrap third-party APIs - [`bound-learning-tests`](references/bound-learning-tests.md) - Write learning tests for third-party code ### 8. Classes and Systems (MEDIUM-HIGH) - [`class-small`](references/class-small.md) - Keep classes small - [`class-cohesion`](references/class-cohesion.md) - Maintain class cohesion - [`class-organize-for-change`](references/class-organize-for-change.md) - Organize classes for change - [`class-isolate-from-change`](references/class-isolate-from-change.md) - Isolate classes from change - [`class-separate-concerns`](references/class-separate-concerns.md) - Separate construction from use ### 9. Unit Tests (MEDIUM) - [`test-first-law`](references/test-first-law.md) - Follow the three laws of TDD - [`test-keep-clean`](references/test-keep-clean.md) - Keep tests clean - [`test-one-assert`](references/test-one-assert.md) - One concept per test - [`test-first-principles`](references/test-first-principles.md) - Follow FIRST principles - [`test-build-operate-check`](references/test-build-operate-check.md) - Use Build-Operate-Check pattern ### 10. Emergence and Simple Design (MEDIUM) - [`emerge-simple-design`](references/emerge-simple-design.md) - Follow the four rules of simple design - [`emerge-expressiveness`](references/emerge-expressiveness.md) - Maximize expressiveness ## How to Use Read individual reference files for detailed explanations and code examples: - [Section definitions](references/_sections.md) - Category structure and impact levels - [Rule template](assets/templates/_template.md) - Template for adding new rules ## Reference Files | File | Description | |------|-------------| | [references/_sections.md](references/_sections.md) | Category definitions and ordering | | [assets/templates/_template.md](assets/templates/_template.md) | Template for new rules | | [metadata.json](metadata.json) | Version and reference information |
© pproenca · MIT · pproenca/dot-skills
Similar skills
Everything for Code review and refactoring →clean-code by other authors comes first.