/clean-code:clean-codefrom clean-code
Applies Robert Martin's Clean Code catalog to Python code during review, refactoring, or cleanup. Covers naming, functions, comments, DRY, boundary conditions, and tests.
Ships in clean-code. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
"Always leave the campground cleaner than you found it." — Robert Baden-Powell
"Always check a module in cleaner than when you checked it out." — Robert C. Martin, Clean Code
Load the chapter that matches the work. Rule IDs (N1, C5, G25, F3, T9...) are defined in these files:
| Chapter | When |
|---|---|
| references/full-catalog.md | Reviewing any Python -- the complete rule index (master) |
| references/names.md | Naming variables, functions, classes, modules |
| references/comments.md | Writing or editing comments and docstrings |
| references/functions.md | Creating or refactoring functions |
| references/general.md | Code quality review -- DRY, intent, abstractions |
| references/tests.md | Writing or reviewing tests |
You don't have to make every module perfect. You simply have to make it a little bit better than when you found it.
If we all followed this simple rule:
Every time you touch code, look for at least one small improvement:
# You're asked to fix a bug in this function:
def proc(d, x, flag=False):
# process data
for i in d:
if i > 0:
if flag:
x.append(i * 1.0825) # tax
else:
x.append(i)
return x
# Don't just fix the bug and leave.
# Leave it cleaner:
TAX_RATE = 0.0825
def process_positive_values(
values: list[float],
apply_tax: bool = False
) -> list[float]:
"""Filter positive values, optionally applying tax."""
rate = 1 + TAX_RATE if apply_tax else 1
return [v * rate for v in values if v > 0]
What changed:
Don't:
Do:
Apply cleanup only when the task IS cleanup (review, refactor, "clean this up" asks). When writing or fixing code, follow these rules for the NEW code you write; do not expand the diff with drive-by improvements to adjacent code the user didn't ask about.
When reviewing code:
Every piece of code you touch gets a little better. Not perfect—just better.
Over time, better compounds into excellent.
What SKILL.md sets; muted values are Claude Code's defaults
Also trigger on: "while you're at it", "any quick wins", "improve this a bit", "anything else obviously wrong"; single-letter or cryptic identifiers (`d`, `x`, `proc`), Hungarian notation (`str_name`, `lst_users`), `I`-prefixed classes, names hiding side effects, or asks like "rename this", "clearer name"; commented-out code blocks, TODO/FIXME banners, metadata in comments, redundant comments (`i += 1 # increment i`), stale docstrings; functions with 4+ parameters, boolean flag parameters, argument mutation, dead helpers, "too many arguments", "split this function"; duplicated logic (G5), magic numbers (G25), long if/elif chains (G23), train wrecks like `a.b.c.d` (G36), clever one-liners (G16); slow or flaky tests, skip-marked tests, happy-path-only tests, missing boundary cases, "coverage gap", "edge case", "did we test".
Three short reads, in order
Other plugins' skills for the same job
npx claudepluginhub sagargupta16/claude-skills --plugin clean-code