cleaning-existing-codebase

cleaning-existing-codebase is a skill for Claude Code from gg-mo/repo-hygiene. It costs 59 tokens per session (1,144 once invoked), scanned A, original, MIT.

A staged process for cleaning up an existing codebase, starting with a survey and waiting for approval before making broad changes.

In plain words
What is it for?
Use it to assess file sizes, documentation, tests, and other code-quality issues, then address them in small phases.
Why use it?
It prevents a cleanup request from turning into a large, hard-to-review change that fixes visible details while missing the main problems.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the repo-hygiene plugin — 9 skills, 1 hook shipped together

Good fit Use it to assess file sizes, documentation, tests, and other code-quality issues, then address them in small phases.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/gg-mo/repo-hygiene/cleaning-existing-codebase
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add gg-mo/repo-hygiene --skill cleaning-existing-codebase
Clone the repo
git clone --depth 1 https://github.com/gg-mo/repo-hygiene

Made for: Claude Code.

Or install repo-hygiene, the plugin that ships this one along with the rest of its 9 skills, 1 hook.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cleaning-existing-codebase

README.md
[![agentmods](https://agentmods.dev/badge/skills/gg-mo/repo-hygiene/cleaning-existing-codebase/github.svg)](https://agentmods.dev/skills/gg-mo/repo-hygiene/cleaning-existing-codebase)
Your own site
<a href="https://agentmods.dev/skills/gg-mo/repo-hygiene/cleaning-existing-codebase"><img src="https://agentmods.dev/badge/skills/gg-mo/repo-hygiene/cleaning-existing-codebase/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for cleaning-existing-codebase

Your own site · 80×15
<a href="https://agentmods.dev/skills/gg-mo/repo-hygiene/cleaning-existing-codebase"><img src="https://agentmods.dev/badge/skills/gg-mo/repo-hygiene/cleaning-existing-codebase.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 59 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,144 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00059 $0.01144
Opus 5 $0.00030 $0.00572
Sonnet 5 $0.00012 $0.00229
Haiku 4.5 $0.00006 $0.00114

Measured 9d ago against content hash b2565106f96e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

cleaning-existing-codebase scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/cleaning-existing-codebase/SKILL.md · 88 lines

How it starts

The opening of the file, as written. The whole thing — 88 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Cleaning an Existing Codebase

Overview

When a user asks to apply hygiene to an existing project, the seductive path is to start with the visible, mechanical work — docstrings on every file, README rewrite, dep pruning — and ship a 200-file diff. That optimizes for appearing thorough; it does NOT optimize for being useful. The god-class is usually the real liability; everything else is decoration.

Core principle: Survey, propose, get buy-in, work in small reviewable phases. Don't type any cleanup code until the user has approved a plan.

When To Use

  • User asks to "clean up" / "apply repo-hygiene" / "fix the hygiene of" an existing project
  • Onboarding into a long-running codebase with obvious hygiene debt
  • Tech-debt sprint where hygiene is the focus

The Process

1. Survey

Invoke repo-hygiene:orienting-to-repo first. Then quantify the hygiene gaps with concrete numbers:

  • File-size offenders — files >500 lines, ranked. find . -type f \( -name '*.py' -o -name '*.ts' -o -name '*.go' \) -exec wc -l {} + | sort -rn | head -20
  • Docstring coverage — sample 10 random functions across the codebase; how many have useful docstrings?
  • Test coverage — count test files vs source files. Run the suite if possible; capture pass rate and gaps.
  • Stale docsgit log -1 --format=%cs README.md CHANGELOG.md; spot-check the README against current code
  • Dead-code candidates — unused imports, unreferenced exports. Don't act yet; just note.
  • Dep hygiene — unused deps in requirements.txt / package.json

Output a concise inventory (~10 bullets with numbers). NOT a 5-page audit.

2. Propose a Phased Plan

Show the plan to the user BEFORE touching code. Default ordering, by leverage and dependency:

Phase Why this position
0 — Safety net Add a smoke test or characterization test for the biggest module BEFORE any refactor. Refactoring without tests is reckless.
1 — Cheap visibility wins Fix README, prune unused deps, add CHANGELOG entry. Reviewable in minutes; signals progress.
2 — Architecture Decompose god-files / god-classes. Highest risk; needs Phase 0 done first.
3 — Documentation sweep Docstrings across files. Last, so docs describe the SHAPE AFTER restructuring, not the moving target.
4 — Test backfill Coverage floor on changed code. Use repo-hygiene:testing-new-code per file.

Read the full file on GitHub · 88 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 88 lines · 59 tokens per session scan A b2565106f96e

Subscribe to this mod's changes

cleaning-existing-codebase is a skill published in the GitHub repository gg-mo/repo-hygiene (3 stars, last pushed 3mo ago), licensed MIT. It adds 59 tokens to every session and 1,144 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

recipe-front-review

Reviews completed frontend implementation for governing-source compliance, scope economy, repository quality, and security, then applies user-approved React corrections.

shinpr/claude-code-workflows · 29 tokens

new-skill

Scaffold a new brooks-lint analysis skill so it passes npm run validate and npm run evals on the first try — generates skills/{name}/SKILL.md (with the mandatory "Do NOT trigger for:" clause and a Process section citing guide step ranges) plus skills/{name}/{name}-guide.md (sequentially numbered steps), then appends…

hyhmrright/brooks-lint · 145 tokens

release

Cut a brooks-lint release: set the version in package.json, propagate it across all four plugin manifests and every version-bearing text file (README badges, docs site metadata), write the CHANGELOG entry, validate, then commit, push, tag, and publish the GitHub release. Triggers when the maintainer asks to "release"…

hyhmrright/brooks-lint · 135 tokens

brooks-audit

Architecture audit that maps module dependencies, checks layering integrity, and flags structural decay across a codebase, drawing on twelve classic engineering books. Triggers when: user asks to audit architecture, review folder/module structure, check for circular imports, understand how the codebase is organized…

hyhmrright/brooks-lint · 143 tokens

brooks-sweep

Full-sweep mode: runs a unified analysis across all quality dimensions — code decay, architecture, tech debt, and test quality — then applies fixes directly to the codebase. Safe changes are auto-applied; risky changes are confirmed before execution. Drawing on twelve classic engineering books. Triggers when: user…

hyhmrright/brooks-lint · 178 tokens

brooks-test

Test quality review drawing on twelve classic engineering books — with primary focus on xUnit Test Patterns, The Art of Unit Testing, How Google Tests Software, and Working Effectively with Legacy Code — that diagnoses structural problems in an existing test suite: brittleness, mock abuse, coverage illusions, slow…

hyhmrright/brooks-lint · 161 tokens