Agent skill

Clean Code

by Mindrally in Mindrally/skills

Clean, maintainable, human-readable code principles combined with anti-over-engineering discipline: naming, single responsibility, DRY, and scoping changes to exactly what was requested.

Apache-2.0Auto-check passedDevelopment

Install Clean Code

skills CLI
$ npx skills add Mindrally/skills --skill clean-code -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Mindrally/skills clean-code --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Mindrally/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/clean-code .claude/skills/clean-code && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
clean-code
GitHub stars
267
Token cost
~1.8k tokens
SKILL.md length
984 words
Files
1
Skills in repo
34
Repo updated
First seen
Licence
Apache-2.0

At a glance

Clean, maintainable, human-readable code principles combined with anti-over-engineering discipline: naming, single responsibility, DRY, and scoping changes to exactly what was requested.

  • Works in 7 steps: Scope the change — Identify exactly what… → Reach for the simplest solution first —… → Name things for their purpose — Choose… → …
  • Writing new code
  • SKILL.md covers Workflow for Writing or…, Meaningful Names, Constants Over Magic Numbers and Smart Comments, plus 9 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Clean Code is an agent skill from Mindrally/skills. Clean, maintainable, human-readable code principles combined with anti-over-engineering discipline: naming, single responsibility, DRY, and scoping changes to exactly what was requested. Use when writing new code, refactoring existing code, reviewing code for quality, or deciding how much abstraction a change actually needs.

Its SKILL.md is about 1.8k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Code quality, Code simplification and Refactoring. The repository describes itself as: 255+ Claude Code skills converted from Cursor rules. Expert coding guidelines for every major framework and language. The licence is Apache-2.0.

When your agent uses it

  • Writing new code
  • Refactoring existing code
  • Reviewing code for quality
  • Deciding how much abstraction a change actually needs

Example prompts

  • “/clean-code”

Workflow steps

7 steps, taken from the first numbered list in SKILL.md.

  1. Scope the change — Identify exactly what was asked for. Note what's out of scope before writing anything.
  2. Reach for the simplest solution first — Prefer the direct, obvious implementation over a general or configurable one, unless a concrete…
  3. Name things for their purpose — Choose names that reveal intent before writing the body of a function or the shape of a type.
  4. Keep functions single-purpose — If a function needs a comment to explain what it does, split it.
  5. Remove duplication deliberately — Extract shared logic only once it's actually duplicated (see Rule of Three below), not preemptively.
  6. Write or update tests — Cover the new behavior and the edge cases it introduces.
  7. Verify scope before delivery — Confirm only the requested code changed, check for a simpler approach you might have missed, and confirm no…

What it can do on your machine

Read from SKILL.md and the folder at commit 9718410. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are javascript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Clean Code loads about 1.8k tokens when it runs. Until then it costs about 84 tokens; SKILL.md has 984 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~84
When it runs · the whole SKILL.md, loaded when a task matches
~1.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Mindrally/skills at commit 9718410, republished under its Apache-2.0 licence (© Mindrally). 984 words, ~1,825 tokens.

Download SKILL.mdSave it as .claude/skills/clean-code/SKILL.md (or your agent's skills folder).
name
clean-code
description
Clean, maintainable, human-readable code principles combined with anti-over-engineering discipline: naming, single responsibility, DRY, and scoping changes to exactly what was requested. Use when writing new code, refactoring existing code, reviewing code for quality, or deciding how much abstraction a change actually needs.

Clean Code

This skill covers writing code that is easy to read and change, and — just as important — avoiding the over-engineering that makes code harder to read and change in the name of "best practices." Both halves matter together: clean code is simple code, not merely well-decorated code.

Workflow for Writing or Reviewing Code

  1. Scope the change — Identify exactly what was asked for. Note what's out of scope before writing anything.
  2. Reach for the simplest solution first — Prefer the direct, obvious implementation over a general or configurable one, unless a concrete current need justifies more.
  3. Name things for their purpose — Choose names that reveal intent before writing the body of a function or the shape of a type.
  4. Keep functions single-purpose — If a function needs a comment to explain what it does, split it.
  5. Remove duplication deliberately — Extract shared logic only once it's actually duplicated (see Rule of Three below), not preemptively.
  6. Write or update tests — Cover the new behavior and the edge cases it introduces.
  7. Verify scope before delivery — Confirm only the requested code changed, check for a simpler approach you might have missed, and confirm no unrequested files were touched.

Meaningful Names

  • Variables, functions, and classes should reveal their purpose from the name alone.
  • Names should explain why something exists and how it's used, not just its type or contents (activeUserIds, not list1).
  • Avoid abbreviations unless they're universally understood in the domain (id, url — fine; usrCfgTmp — not fine).

Constants Over Magic Numbers

  • Replace hard-coded values with named constants (MAX_RETRY_COUNT = 3, not a bare 3 three call sites later).
  • Use descriptive constant names that explain the value's purpose, not just its value.
  • Keep constants at the top of the file or in a dedicated constants module when shared across files.

Smart Comments

  • Don't comment on what the code does — make the code self-documenting through naming and structure instead.
  • Use comments to explain why something is done a certain way, especially when the reason isn't visible in the code (a workaround for a library bug, a non-obvious ordering requirement).
  • Document public APIs, genuinely complex algorithms, and non-obvious side effects.

Single Responsibility

  • Each function should do exactly one thing.
  • Functions should be small and focused enough to be understood without scrolling.
  • If a function needs a comment to explain what it does, that's a signal to split it into named sub-functions instead.

DRY — Don't Repeat Yourself

  • Extract repeated code into reusable functions once the repetition is real, not anticipated.
  • Share common logic through a proper abstraction — a shared function or module, not copy-paste with tweaks.
  • Maintain a single source of truth for any given piece of business logic or configuration value.

Encapsulation

  • Hide implementation details behind a clear interface; callers shouldn't need to know how a thing works to use it.
  • Move nested conditionals into well-named functions or guard clauses instead of deep if/else trees.
js
// Before
function canCheckout(cart) {
  if (cart.items.length > 0) {
    if (cart.user.isVerified) {
      if (cart.total <= cart.user.creditLimit) {
        return true;
      }
    }
  }
  return false;
}

// After
function canCheckout(cart) {
  const hasItems = cart.items.length > 0;
  const isWithinCreditLimit = cart.total <= cart.user.creditLimit;
  return hasItems && cart.user.isVerified && isWithinCreditLimit;
}

Clean Structure

  • Keep related code together (a feature's components, hooks, and styles in one directory, not scattered by file type).
  • Organize code in a logical hierarchy that mirrors how the domain is understood.
  • Use consistent file and folder naming conventions across the codebase.
Show full SKILL.md (460 more words)Show less

Avoiding Over-Engineering

  • Only change what was asked. The simplest solution that satisfies the request comes first.
  • When the right level of abstraction is unclear, ask rather than guessing toward the more elaborate option.
  • Do not modify unrequested code, even if it looks improvable — a drive-by refactor in an unrelated function expands the review surface and the risk of the change.
  • Do not add abstractions (interfaces, factories, plugin systems, config layers) without a concrete, current need. A single implementation doesn't need an interface "in case" a second one shows up later — that's speculative generality (YAGNI: "You Aren't Gonna Need It").
  • Do not import a new dependency to solve a problem a few lines of existing code already solve.
  • Do not rewrite entire files for small changes — a targeted diff is easier to review and safer to ship than a full-file rewrite.
  • Do not add error handling for scenarios that cannot occur given the surrounding code's guarantees — defensive code for impossible states adds reading cost without adding safety.
Rule of Three
  • Tolerate duplication the first two times a pattern appears.
  • Extract an abstraction on the third occurrence, once the actual shape of the shared logic is clear — extracting after one or two instances often guesses wrong about what's actually shared.
Signs of Over-Engineering
  • A configuration option that has only ever been set to one value.
  • An interface with exactly one implementation and no test double that needs a second.
  • A generic options object accreting fields for hypothetical future callers.
  • A plugin/strategy pattern introduced before there are two strategies to switch between.

Code Quality Maintenance

  • Refactor continuously in small steps rather than deferring cleanup to a dedicated "refactor sprint."
  • Fix technical debt early, while the context for why the code looks the way it does is still fresh.
  • Leave code cleaner than you found it, scoped to the area you're already touching — not as license to refactor unrelated files.

Testing

  • Write a failing test before fixing a bug, so the fix is verified and the bug can't silently regress.
  • Keep tests readable and maintainable — a test that's harder to understand than the code it tests has failed at its job.
  • Test edge cases and error conditions explicitly, not just the happy path.

Version Control

  • Write clear, specific commit messages that explain why a change was made.
  • Make small, focused commits — one logical change per commit.
  • Use meaningful branch names that describe the work, not the author or the date.

Before Delivery Checklist

  • Only the requested code changed — no unrelated files touched.
  • No abstraction was added without a concrete need that exists today.
  • No dependency was added that duplicates something already available.
  • A simpler approach was considered and ruled out, not just skipped.
  • New behavior has test coverage, including at least one edge case.

© Mindrally, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in clean-code of Mindrally/skills.

Open the folder on GitHubat commit 9718410

Compare with similar skills

Clean Code next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Clean Code compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Clean Code this skillMindrally/skills267—~1.8kAutomated safety check: PassApache-2.0
Codebase Health Refactoringkucherenko/jscpd6.3k—~2.5kAutomated safety check: PassMIT
DRY Refactoring With jscpdkucherenko/jscpd6.3k—~2.1kAutomated safety check: PassMIT
Simplify Recent ChangesQwenLM/qwen-code28k—~1.3kAutomated safety check: PassApache-2.0
Rnd Code Simplifychendongqi/OPB-Skills125—~2.2kAutomated safety check: PassNone
AI Slop CleanerYeachan-Heo/oh-my-claudecode40k—~1.9kAutomated safety check: PassMIT

Similar skills

  • A three-part cleanup guided by jscpd: measure health, then fix duplicated code, remove dead code and simplify the most complex files, finishing by re-measuring the score.

    6.3k GitHub stars~2.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Removes copy-paste duplication found by jscpd, starting with exact clones and hotspots, then renamed and near-miss copies, using proven refactoring strategies.

    6.3k GitHub stars~2.1k tokensUpdated today
    DevelopmentAuto-check passed
  • Simplify Recent Changes

    QwenLM/qwen-code

    Reviews your uncommitted diff with three parallel passes for reuse, quality and efficiency, then applies the straightforward cleanups before a pull request.

    28k GitHub stars~1.3k tokensUpdated today
    DevelopmentAuto-check passed
  • Rnd Code Simplify

    chendongqi/OPB-Skills

    Expert code simplification and refactoring specialist that autonomously enhances code clarity, consistency, and maintainability while preserving exact functionality.

    125 GitHub stars~2.2k tokensUpdated 7 mo ago
    DevelopmentAuto-check passed
  • AI Slop Cleaner

    Yeachan-Heo/oh-my-claudecode

    Cleans up AI-generated code that works but is bloated or repetitive, locking behavior with tests first and deleting before adding, with a reviewer-only mode.

    40k GitHub stars~1.9k tokensUpdated today
    DevelopmentAuto-check passed
  • Review a git diff or explicit file scope for reuse, code quality, efficiency, clarity, and standards issues, then optionally apply safe Codex-driven fixes.

    4k GitHub stars~2k tokensUpdated 6 mo ago
    DevelopmentAuto-check passed

More from Mindrally/skills

All 34 skills in this repo
  • Analytics Data Analysis

    Mindrally/skills

    Best practices for analytics, data analysis, and visualization using Python, pandas, matplotlib, seaborn, and Jupyter notebooks.

    267 GitHub stars~1.6k tokensUpdated 1 mo ago
    Auto-check passed
  • Best practices for AutoML and hyperparameter search with Optuna, Ray Tune, and PyCaret, covering search-space design, validation splits, and leakage prevention.

    267 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Blender Python Addon

    Mindrally/skills

    Best practices for writing Blender Python add-ons using the bpy API, covering operators, panels, properties, registration, and API-safe scripting.

    267 GitHub stars~2.2k tokensUpdated 1 mo ago
    Auto-check passed
  • Expert guidelines for Chrome extension development with Manifest V3, covering security, performance, and best practices.

    267 GitHub stars~1.7k tokensUpdated 1 mo ago
    Auto-check passed
  • Design Systems

    Mindrally/skills

    Comprehensive design system guidelines for building consistent, accessible, and scalable component libraries.

    267 GitHub stars~1.8k tokensUpdated 1 mo ago
    Auto-check passed
  • Embedded Stm32

    Mindrally/skills

    Best practices for embedded C/C++ development on STM32 microcontrollers using the HAL, covering peripherals, DMA, interrupts, memory constraints, and hardware-focused testing.

    267 GitHub stars~2.3k tokensUpdated 1 mo ago
    Auto-check passed

Categories

Questions about Clean Code

What does Clean Code do?

Clean, maintainable, human-readable code principles combined with anti-over-engineering discipline: naming, single responsibility, DRY, and scoping changes to exactly what was requested. Clean Code is an agent skill from Mindrally/skills. Clean, maintainable, human-readable code principles combined with anti-over-engineering discipline: naming, single responsibility, DRY, and scoping changes to exactly what was requested.

When should I use Clean Code?

Clean Code fits situations like: writing new code; refactoring existing code; reviewing code for quality; deciding how much abstraction a change actually needs.

How do I install Clean Code in Claude Code?

Run `npx skills add Mindrally/skills --skill clean-code -a claude-code`. Or copy the skill folder (clean-code in Mindrally/skills) into .claude/skills/clean-code in your project. Claude Code loads it when a task matches its description.

How do I install Clean Code in Codex?

Run `npx skills add Mindrally/skills --skill clean-code -a codex`. Or copy the skill folder (clean-code in Mindrally/skills) into .agents/skills/clean-code in your project. Codex loads it when a task matches its description.

Can I use Clean Code in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Mindrally/skills --skill clean-code -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/clean-code, .gemini/skills/clean-code, .github/skills/clean-code and .opencode/skills/clean-code in your project.

What does Clean Code need to run?

SKILL.md names no scripts, command-line tools or credentials: Clean Code is instructions for the agent only.

Does Clean Code access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Clean Code safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Clean Code use?

Clean Code is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Clean Code use?

About 1.8k tokens (SKILL.md is roughly 7.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Clean Code?

Skills that share tags, products or a category with Clean Code: Codebase Health Refactoring (kucherenko/jscpd, 6.3k stars), DRY Refactoring With jscpd (kucherenko/jscpd, 6.3k stars), Simplify Recent Changes (QwenLM/qwen-code, 28k stars) and Rnd Code Simplify (chendongqi/OPB-Skills, 125 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Clean Code?

Mindrally (a GitHub organization) maintains it in Mindrally/skills, which has 267 GitHub stars. The repository holds 34 skills in this directory. The repository was last updated on September 3, 2026.

Source: Mindrally/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.