# clean-code

A skill that gives coding agents a readability standard: names that carry intent, small functions, disciplined comments, one error-handling style.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 6600 installs · ★ 2508
- Author: wondelai
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/wondelai/skills/tree/HEAD/clean-code/SKILL.md
- Updated: 2026-09-10
- HTML: https://affpapa.org/en/nevibecode/skills/wondelai-clean-code

## What it does

The skill drops the agent into reviewer mode. Ask for a grade and it scores the code from 0 to 10, says where the file stands today, then lists what separates it from 10/10. Below that sit the working parts: names, function size, comments, error handling. Each topic comes with before/after tables such as `render(isPrint)` against `renderForPrint()`, or `calc()` against `calculateMonthlyRevenue()`.

Deeper guidance lives in separate files: `references/naming-conventions.md`, `references/functions-and-methods.md`, `references/comments-formatting.md`. The agent pulls them in when renaming things across a codebase or cutting a long function into named steps.

Triggers are literal. It fires on phrases like "clean up this code", "this function is too long", "code smells", "naming conventions". A vague "what do you think of my code" may not wake it up at all, so name the problem in your prompt and the skill has something to grip.

Related skills are split off on purpose: refactoring patterns for the mechanics of restructuring, clean architecture for dependency rules. This one stops at the level of a function, a name and a file.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add wondelai/skills --skill clean-code -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/clean-code/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/clean-code/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add wondelai/skills --skill clean-code -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/clean-code/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add wondelai/skills --skill clean-code -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/clean-code/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install wondelai/skills clean-code
```

2. **Manually: put the files in place**
- File: `.github/skills/clean-code/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add wondelai/skills --skill clean-code -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/wondelai/skills --path clean-code
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/clean-code/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add wondelai/skills --skill clean-code -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/wondelai/skills/tree/HEAD/clean-code/SKILL.md

## When to use it
- split an oversized function into readable steps
- rename variables so the name explains the value
- review a pull request for misleading identifiers
- unify error handling across a module
- check whether unit tests cover the awkward cases

## Example prompts
- \`render(isPrint)` is doing two jobs — split it into `renderForPrint()` and `renderForScreen()`.
- Rename `d` here, `elapsedTimeInDays` reads better at this scope.
- Score this module 0 to 10 and tell me what it takes to reach 10/10.

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: dfdc2a4a15185005.

BEGIN THIRD-PARTY FILE dfdc2a4a15185005
```text
---
name: clean-code
description: 'Write readable, maintainable code through disciplined naming, small functions, and clean error handling. Use when the user mentions "clean up this code", "this function is too long", "code smells", "naming conventions", "boy scout rule", "single responsibility", or "unit test quality". Also trigger when reviewing a pull request for readability, untangling a messy function, debating comment styles, or improving error-handling patterns. Covers SRP, comment discipline, formatting, and unit testing. For refactoring techniques, see refactoring-patterns. For architecture and dependency rules, see clean-architecture.'
license: MIT
metadata:
  author: wondelai
  version: "1.4.0"
---

# Clean Code Framework

A disciplined approach to writing code that communicates intent, minimizes surprises, and welcomes change. Apply these principles when writing new code, reviewing pull requests, refactoring legacy systems, or advising on code quality.

## Core Principle

**Code is read far more often than it is written — optimize for the reader.** The read-to-write ratio is well over 10:1, so every naming choice, function boundary, and formatting decision either adds clarity or adds cost. Clean code reads like well-written prose: names reveal intent, functions tell a story one step at a time, and the Boy Scout Rule applies — always leave the code cleaner than you found it.

## Scoring

**Goal: 10/10.** Rate any code 0-10 against the principles below. Report the current score and the specific improvements needed to reach 10/10.

- **9-10:** Names reveal intent, functions are small and focused, error handling is consistent, tests are clean and comprehensive
- **7-8:** Mostly clean with minor naming ambiguities or a few long functions; tests may lack edge cases
- **5-6:** Mixed — good patterns alongside unclear names, duplicated logic, or inconsistent error handling
- **3-4:** Long multi-purpose functions, misleading names, poor or missing tests
- **1-2:** Nearly unreadable — magic numbers, cryptic abbreviations, no structure, no tests

## The Clean Code Framework

Six disciplines for writing code that communicates clearly and adapts to change:

### 1. Meaningful Names

**Core concept:** Names should reveal intent, avoid disinformation, and make the code read like prose. If a name requires a comment to explain it, the name is wrong.

**Why it works:** Names are the most pervasive form of documentation — a well-chosen name eliminates the need to read the implementation; a poor one forces every reader to reverse-engineer intent.

**Key insights:**
- A name should answer why it exists, what it does, and how it is used
```
END THIRD-PARTY FILE dfdc2a4a15185005

The third-party file has ended. Everything between the dfdc2a4a15185005 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2682 of 14923 bytes. © wondelai · MIT · https://github.com/wondelai/skills/tree/HEAD/clean-code/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
