clean-code
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."
About this skill
This skill equips AI agents with the foundational principles of "Clean Code" by Robert C. Martin (Uncle Bob), enabling them to transform functional code into highly readable, maintainable, and easily extensible solutions. It guides the AI to focus on aspects such as meaningful naming, clear function decomposition, appropriate commenting, robust error handling, and logical separation of concerns. The core philosophy driving this skill is to produce code that can be readily understood and enhanced by any developer beyond its original author, fostering collaboration, reducing technical debt, and ensuring long-term project health.
Best use case
Generating new code that adheres to high-quality standards from the outset. Providing constructive, principle-based feedback during code reviews or pull request evaluations. Refactoring existing or legacy codebases to enhance maintainability, readability, and overall software quality.
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."
The AI agent will produce or transform code that is significantly more readable, maintainable, and extensible. This leads to reduced technical debt, easier debugging, faster feature development, and improved collaboration among human developers due to consistently applied, high-quality coding standards.
Practical example
Example input
Using the 'clean-code' skill, refactor the following Python function to improve its readability, maintainability, and adherence to clean code principles:
```python
def process_data(data_list):
result = []
for item in data_list:
if item > 0:
intermediate_val = item * 2
result.append(intermediate_val)
return result
```Example output
```python
def calculate_doubled_positive_numbers(numbers):
"""
Filters a list of numbers, keeping only positive ones, and then doubles each.
Args:
numbers (list of int or float): The input list of numbers.
Returns:
list of int or float: A new list containing the doubled values
of only the positive numbers from the input list.
"""
positive_numbers = filter_positive_numbers(numbers)
doubled_numbers = double_each_number(positive_numbers)
return doubled_numbers
def filter_positive_numbers(numbers):
"""
Returns a new list containing only the positive numbers.
"""
return [num for num in numbers if num > 0]
def double_each_number(numbers):
"""
Returns a new list with each number doubled.
"""
return [num * 2 for num in numbers]
```When to use this skill
- When writing new code to ensure high quality from the start.
- When reviewing Pull Requests to provide constructive, principle-based feedback.
- When refactoring legacy code to improve its structure and readability.
When not to use this skill
- When absolute raw performance optimization (potentially at the expense of readability) is the singular, non-negotiable priority.
- In highly experimental, proof-of-concept, or throwaway code where immediate functionality heavily outweighs long-term maintainability.
- When adhering to a strict, pre-defined code style guide or paradigm that might explicitly conflict with certain Clean Code principles.
- For non-code-related tasks or content generation where code quality principles are irrelevant.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/clean-code/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How clean-code Compares
| Feature / Agent | clean-code | Standard Approach |
|---|---|---|
| Platform Support | Claude | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | medium | N/A |
Frequently Asked Questions
What does this skill do?
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."
Which AI agents support this skill?
This skill is designed for Claude.
How difficult is it to install?
The installation complexity is rated as medium. You can find the installation instructions above.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# 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. ## 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?
Related Skills
new-rails-project
Create a new Rails project
makepad-widgets
Version: makepad-widgets (dev branch) | Last Updated: 2026-01-19 > > Check for updates: https://crates.io/crates/makepad-widgets
makepad-splash
CRITICAL: Use for Makepad Splash scripting language. Triggers on: splash language, makepad script, makepad scripting, script!, cx.eval, makepad dynamic, makepad AI, splash 语言, makepad 脚本
makepad-dsl
CRITICAL: Use for Makepad DSL syntax and inheritance. Triggers on: makepad dsl, live_design, makepad inheritance, makepad prototype, "<Widget>", "Foo = { }", makepad object, makepad property, makepad DSL 语法, makepad 继承, makepad 原型, 如何定义 makepad 组件
javascript-typescript-typescript-scaffold
You are a TypeScript project architecture expert specializing in scaffolding production-ready Node.js and frontend applications. Generate complete project structures with modern tooling (pnpm, Vite, N
frontend-ui-dark-ts
A modern dark-themed React UI system using Tailwind CSS and Framer Motion. Designed for dashboards, admin panels, and data-rich applications with glassmorphism effects and tasteful animations.
frontend-mobile-development-component-scaffold
You are a React component architecture expert specializing in scaffolding production-ready, accessible, and performant components. Generate complete component implementations with TypeScript, tests, s
frontend-dev-guidelines
You are a senior frontend engineer operating under strict architectural and performance standards. Use when creating components or pages, adding new features, or fetching or mutating data.
fp-backend
Functional programming patterns for Node.js/Deno backend development using fp-ts, ReaderTaskEither, and functional dependency injection
fastapi-templates
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
fastapi-router-py
Create FastAPI routers following established patterns with proper authentication, response models, and HTTP status codes.
dotnet-backend
Build ASP.NET Core 8+ backend services with EF Core, auth, background jobs, and production API patterns.