Skip to main content
skill CX Codex

clean-code · sickn33 — Claude Code skill: what it does, how to install

This skill guides code writing, review, and refactoring around Clean Code principles. Use it for legacy changes, pull requests, and test-focused work.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add sickn33/agentic-awesome-skills --skill clean-code -a claude-code
Open on GitHub

What clean-code does

The skill reviews code through names, function size, argument counts, side effects, and class responsibilities. It asks the agent to separate business logic from low-level details, hide object internals behind interfaces, use exceptions for error handling, and avoid returning null when that pushes checks onto every caller.

Its guidance covers pull request review, new code, legacy refactoring, formatting, DTOs, the Law of Demeter, and unit tests based on TDD. A checklist also asks whether a function is under 20 lines, whether it does one thing, and whether a failing test exists for the change.

These are heuristics, not permission to alter behavior. The skill tells the agent to follow repository conventions, preserve necessary security and license comments, stay within scope, and verify relevant behavior. It can be installed for Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode.

What it helps with

  • rename unclear variables and methods
  • split large functions into smaller units
  • replace comments that hide unclear code
  • check refactoring with focused unit tests
  • spot rigid dependencies and repeated logic

Example prompts for the agent

  • Review this pull request using Clean Code principles and suggest changes that preserve behavior.
  • Refactor this legacy code with clearer names, smaller functions, and focused tests.
  • Check this function for excessive arguments, side effects, and mixed abstraction levels.

How to install clean-code

1Skills CLI (Vercel)

npx skills add sickn33/agentic-awesome-skills --skill clean-code -a claude-code

2Manually: put the files in place

~/.claude/skills/clean-code/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/clean-code/

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 Code?

Run npx skills add sickn33/agentic-awesome-skills --skill clean-code -a claude-code, then check ~/.claude/skills/clean-code/SKILL.md.

What does clean-code do?

It guides code writing and refactoring around meaningful names, small responsibilities, explicit error handling, readable formatting, and unit tests.

Can I use it for refactoring without changing behavior?

Yes. Its guidance says to preserve behavior, follow repository conventions, keep necessary security and license comments, and verify the relevant result with tests.

Source text

SKILL.md · MIT
---
name: clean-code
description: "This skill embodies the principles of \"Clean Code\" by Robert C. Martin (Uncle Bob). Use it to transform \"code that works\" into \"code that is clean.\""
risk: safe
source: "ClawForge (https://github.com/jackjin1997/ClawForge)"
date_added: "2026-02-27"
---

# Clean Code Skill

This skill embodies the principles of "Clean Code" by Robert C. Martin (Uncle Bob). Use it to transform "code that works" into "code that is clean."

## 🧠 Core Philosophy
> "Code is clean if it can be read, and enhanced by a developer other than its original author." — Grady Booch

## When to Use
Use this skill when:
- **Writing new code**: To ensure high quality from the start.
- **Reviewing Pull Requests**: To provide constructive, principle-based feedback.
- **Refactoring legacy code**: To identify and remove code smells.
- **Improving team standards**: To align on industry-standard best practices.

These are design heuristics, not universal language rules or authority to change behavior. Follow the actual repository conventions; exceptions versus result types, nullability, argument counts and test cadence depend on the language and task. Preserve necessary rationale, security and license comments. Refactor only within scope and verify the relevant behavior.

## 1. Meaningful Names
- **Use Intention-Revealing Names**: `elapsedTimeInDays` instead of `d`.
- **Avoid Disinformation**: Don't use `accountList` if it's actually a `Map`.
- **Make Meaningful Distinctions**: Avoid `ProductData` vs `ProductInfo`.
- **Use Pronounceable/Searchable Names**: Avoid `genymdhms`.
- **Class Names**: Use nouns (`Customer`, `WikiPage`). Avoid `Manager`, `Data`.
- **Method Names**: Use verbs (`postPayment`, `deletePage`).

## 2. Functions
- **Small!**: Functions should be shorter than you think.
- **Do One Thing**: A function should do only one thing, and do it well.
- **One Level of Abstraction**: Don't mix high-level business logic with low-level details (like regex).
- **Descriptive Names**: `isPasswordValid` is better than `check`.
- **Arguments**: 0 is ideal, 1-2 is okay, 3+ requires a very strong justification.
- **No Side Effects**: Functions shouldn't secretly change global state.

## 3. Comments
- **Don't Comment Bad Code—Rewrite It**: Most comments are a sign of failure to express ourselves in code.
- **Explain Yourself in Code**: 
  ```python
  # Check if employee is eligible for full benefits
  if employee.flags & HOURLY and employee.age > 65:
  ```
  vs
  ```python
  if employee.isEligibleForFullBenefits():
  ```
- **Good Comments**: Legal, Informative (regex intent), Clarification (external libraries), TODOs.
- **Bad Comments**: Mumbling, Redundant, Misleading, Mandated, Noise, Position Markers.

## 4. Formatting
- **The Newspaper Metaphor**: High-level concepts at the top, details at the bottom.
- **Vertical Density**: Related lines should be close to each other.
- **Distance**: Variables should be declared near their usage.
- **Indentation**: Essential for structural readability.

## 5. Objects and Data Structures
- **Data Abstraction**: Hide the implementation behind interfaces.
- **The Law of Demeter**: A module should not know about the innards of the objects it manipulates. Avoid `a.getB().getC().doSomething()`.
- **Data Transfer Objects (DTO)**: Classes with public variables and no functions.

## 6. Error Handling
- **Use Exceptions instead of Return Codes**: Keeps logic clean.
- **Write Try-Catch-Finally First**: Defines the scope of the operation.
- **Don't Return Null**: It forces the caller to check for null every time.
- **Don't Pass Null**: Leads to `NullPointerException`.

## 7. Unit Tests
- **The Three Laws of TDD**:
  1. Don't write production code until you have a failing unit test.
  2. Don't write more of a unit test than is sufficient to fail.
  3. Don't write more production code than is sufficient to pass the failing test.
- **F.I.R.S.T. Principles**: Fast, Independent, Repeatable, Self-Validating, Timely.

## 8. Classes
- **Small!**: Classes should have a single responsibility (SRP).
- **The Stepdown Rule**: We want the code to read like a top-down narrative.

## 9. Smells and Heuristics
- **Rigidity**: Hard to change.
- **Fragility**: Breaks in many places.
- **Immobility**: Hard to reuse.
- **Viscosity**: Hard to do the right thing.
- **Needless Complexity/Repetition**.

## 🛠️ Implementation Checklist
- [ ] Is this function smaller than 20 lines?
- [ ] Does this function do exactly one thing?
- [ ] Are all names searchable and intention-revealing?
- [ ] Have I avoided comments by making the code clearer?
- [ ] Am I passing too many arguments?
- [ ] Is there a failing test for this change?

## Example

**User request:**

> Refactor this working code for clearer names, smaller units, explicit errors, and preserved behavior; verify it with focused tests.

## Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.

© sickn33 · MIT · sickn33/agentic-awesome-skills

Similar skills

Everything for Code review and refactoring →

From the same set101

The whole set →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor