agentleFS
emvnuelemvnuel/skills/clean-code/SKILL.md

clean-code-principles

Skill2 starsChanged 11 months agoMITView on GitHub

Detects violations of Clean Code principles and suggests refactorings. Use when reviewing code quality, improving readability, or refactoring methods, classes, and modules.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Remove one piece of dead code

    line 203
  2. Distinctive:

    Add one missing null check

    line 204

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “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 Refactoring Detection

Identify opportunities to apply Clean Code principles based on Robert C. Martin's guidelines.


Naming

Meaningful Names

Detect: Single-letter variables, abbreviations, temp/data/info suffixes
Refactor: Intention-revealing names that explain purpose
Cookbook: meaningful-names.md

Pronounceable Names

Detect: Unpronounceable abbreviations (genymdhms, modymdhms)
Refactor: Names that can be discussed verbally
Cookbook: meaningful-names.md

Searchable Names

Detect: Magic numbers, single-letter constants
Refactor: Named constants with clear purpose
Cookbook: meaningful-names.md


Functions

Small Functions

Detect: Methods longer than 20 lines, multiple levels of abstraction
Refactor: Extract smaller, single-purpose functions
Cookbook: small-functions.md

Single Responsibility

Detect: Functions doing multiple unrelated tasks
Refactor: One function, one responsibility, one level of abstraction
Cookbook: small-functions.md

Few Arguments

Detect: Functions with more than 3 arguments
Refactor: Parameter objects, builder pattern, method extraction
Cookbook: function-arguments.md

No Side Effects

Detect: Functions that modify global state or input parameters
Refactor: Pure functions, explicit state changes
Cookbook: side-effects.md

Command Query Separation

Detect: Functions that both change state AND return values
Refactor: Separate commands (void) from queries (return value)
Cookbook: command-query-separation.md


Comments

Self-Documenting Code

Detect: Comments explaining "what" instead of code explaining itself
Refactor: Rename variables and extract methods to make intent clear
Cookbook: comments.md

Useful Comments

Detect: Commented-out code, redundant comments, changelog in code
Refactor: Legal/license comments, intent explanation, TODO with tickets
Cookbook: comments.md


Error Handling

Exceptions Over Error Codes

Detect: Methods returning error codes or status flags
Refactor: Throw specific, descriptive exceptions
Cookbook: error-handling.md

Unchecked Exceptions

Detect: Checked exceptions creating coupling
Refactor: Runtime exceptions with meaningful messages
Cookbook: error-handling.md

Don't Return Null

Detect: Methods returning null for error/empty cases
Refactor: Optional<T>, empty collections, Null Object pattern
Cookbook: null-handling.md

Don't Pass Null

Detect: null passed as method argument
Refactor: Overloaded methods, default values, Optional parameters
Cookbook: null-handling.md


Classes

Single Responsibility (SRP)

Detect: Classes with multiple reasons to change, mixed concerns
Refactor: Separate classes for distinct responsibilities
Cookbook: single-responsibility.md

Cohesion

Detect: Methods not using instance variables, unrelated fields
Refactor: Extract related fields/methods into new classes
Cookbook: cohesion.md

Small Classes

Detect: Classes with 200+ lines or 10+ methods
Refactor: Identify hidden responsibilities, extract collaborators
Cookbook: small-classes.md


Code Smells

Long Method

Detect: Methods exceeding 20 lines
Refactor: Extract Method until each does one thing
Cookbook: long-method.md

Primitive Obsession

Detect: Strings for emails/phone/money, parallel arrays
Refactor: Value objects, domain-specific types
Cookbook: primitive-obsession.md

Feature Envy

Detect: Method uses more data from other class than its own
Refactor: Move method to the class it envies
Cookbook: feature-envy.md

Data Clumps

Detect: Same group of parameters passed together repeatedly
Refactor: Parameter object or extract class
Cookbook: data-clumps.md

Divergent Change

Detect: Class changes for unrelated reasons
Refactor: Split class by responsibility
Cookbook: divergent-change.md

Shotgun Surgery

Detect: One change requires many small edits across classes
Refactor: Consolidate related logic into single class
Cookbook: shotgun-surgery.md


Quick Reference Table

PrincipleDetection SignalClean Code Solution
Meaningful NamesSingle-letter vars, abbreviationsIntention-revealing names
Small FunctionsMethods > 20 linesExtract, one level of abstraction
Few Arguments> 3 parametersParameter objects, builder
No Side EffectsModifies global/input statePure functions
Command Query Sep.Function changes state AND returnsSeparate commands from queries
Self-DocumentingComments explain "what"Rename, extract methods
ExceptionsError codes, status flagsSpecific exceptions
Don't Return NullNull for errors/emptyOptional, empty collections
Single ResponsibilityMultiple reasons to changeSeparate classes
CohesionMethods don't use instance varsExtract new classes
Long Method> 20 linesExtract Method
Primitive ObsessionStrings for domain typesValue objects
Feature EnvyUses external class dataMove method
Data ClumpsRepeated parameter groupsParameter object

Boy Scout Rule

Leave the code cleaner than you found it.

Apply opportunistic refactoring:

  1. Fix one naming issue
  2. Extract one long method
  3. Remove one piece of dead code
  4. Add one missing null check

Cookbook Index

Clean Code recipes with practical examples:

Naming: Meaningful Names

Functions: Small Functions · Function Arguments · Side Effects · Command Query Separation

Comments: Comments

Error Handling: Error Handling · Null Handling

Classes: Single Responsibility · Cohesion · Small Classes

Code Smells: Long Method · Primitive Obsession · Feature Envy · Data Clumps · Divergent Change · Shotgun Surgery

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.