askill
clean-code-principles

clean-code-principlesSafety 85Repository

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

1 stars
1.2k downloads
Updated 12/28/2025

Package Files

Loading 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

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

94/100Analyzed 2/10/2026

An exceptionally well-structured and actionable guide to Clean Code principles, providing specific detection signals and refactoring strategies across multiple categories.

85
98
100
95
92

Metadata

Licenseunknown
Version-
Updated12/28/2025
Publisheremvnuel

Tags

No tags yet.