Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Comprehensive codebase cleanup across 11 quality dimensions: dead code, duplication, weak types, circular deps, defensive cruft, legacy code, AI slop, type consolidation, security, performance, and async patterns. Analyzes code with confidence scoring and verifies changes with build/test gates. Use when codebase has accumulated tech debt, after major feature work, before releases, or when code quality metrics are declining. Trigger with "/cleanup-code-code", "clean up the codebase", "remove dead
.claude/skills/jeremylongshore-cleanup-code/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-06 | ✗→✓ | ▲ Improved | 27% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 30% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 125% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 4% | 0% |
| case-14 | ✗→✓ | ▲ Improved | 40% | 0% |
Systematic code cleanup across 11 quality dimensions, ordered by risk. Each finding includes confidence scoring (HIGH/MEDIUM/LOW) and all changes are verified through build/test gates.
!git rev-parse --show-toplevel 2>/dev/null && echo "---" && git diff --stat HEAD~5 2>/dev/null | tail -5 !ls package.json pyproject.toml Cargo.toml go.mod Makefile 2>/dev/null | head -5 !cat package.json 2>/dev/null | head -3; echo "---"; ls tsconfig.json .eslintrc* 2>/dev/null
knip, madge, jscpd, ruff, bandit for tool-verified scanningThis skill orchestrates cleanup across 11 dimensions, each with a dedicated agent. Dimensions are ordered LOW → HIGH risk. See dimensions reference for full detection criteria, verification steps, and risk profiles.
The 11 Dimensions (by risk level):
| # | Dimension | Key | Risk | Auto-apply? | |---|-----------|-----|------|-------------| | 1 | Dead code removal | dead | LOW | Yes (after build) | | 2 | AI slop removal | slop | LOW | Comments only | | 3 | Weak type elimination | types | MED | Yes (after typecheck) | | 4 | Security cleanup | security | MED | Flag only | | 5 | Legacy code removal | legacy | MED | With confirmation | | 6 | Type consolidation | typecons | MED | Yes (after typecheck) | | 7 | Defensive code cleanup | defensive | MED | Flag only | | 8 | Performance optimization | perf | MED | Flag only | | 9 | DRY deduplication | dry | HIGH | Flag only (>=10 lines) | | 10 | Async pattern fixes | async | HIGH | Flag only | | 11 | Circular dep untangling | circular | HIGH | Flag only |
Before any changes:
git status --porcelain must be empty (or stash changes)git rev-parse HEAD as rollback pointParse user arguments to set scope:
cleanup src/api/ — limit to directory--changed flag — git diff --name-only HEAD~10--dimensions dead,types,securitycleanup --dimensions dryExclude from all scans: node_modules/, dist/, build/, .git/, vendor dirs, generated files.
For each selected dimension (in risk order):
Use tools reference for language-specific tool commands (knip, madge, ruff, jscpd, etc.).
After each auto-applied dimension:
text# TypeScript/JavaScript npx tsc --noEmit 2>&1 | tail -20 npm test 2>&1 | tail -30 # Python python3 -m py_compile <changed_files> python3 -m pytest --tb=short 2>&1 | tail -30 # General git diff --stat # Show what changed
If verification fails, revert that dimension: git checkout -- .
Produce a cleanup report in this format:
## Cleanup Report
**Scope:** [path or "full codebase"]
**Baseline:** [commit hash]
**Dimensions:** [list of dimensions run]
### Summary
| Dimension | Findings | Applied | Flagged | Confidence |
|-----------|----------|---------|---------|------------|
| dead | 12 | 10 | 2 | HIGH |
| types | 8 | 8 | 0 | HIGH |
| security | 3 | 0 | 3 | MEDIUM |
### Changes Applied
- [file:line] description of change
### Flagged for Review
- [file:line] description + reasoning + suggested fix
### Lines Removed: N | Lines Modified: N | Files Touched: NA structured cleanup report containing:
| Error | Recovery | |-------|----------| | Dirty git state | Ask user to commit or stash first | | Build fails after cleanup | git checkout -- . to revert dimension | | No test command found | Skip verification, flag all as "unverified" | | Tool not installed | Fall back to grep patterns (see references/patterns.md) | | Confidence unclear | Default to flag-only, never auto-apply |
Full cleanup:
/cleanup-codeSecurity-focused:
/cleanup-code --dimensions security,asyncChanged files only:
/cleanup-code src/api/ --changedSingle dimension deep-dive:
/cleanup-code --dimensions dead| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 20,277 | 5,489 | -73% | 1 | 1 | 0% | 4,324 | 1,783 | -59% | 0 | 0 | — |
case-02 | fail→fail | 14,616 | 12,050 | -18% | 1 | 1 | 0% | 1,577 | 1,911 | +21% | 0 | 0 | — |
case-03 | fail→fail | 19,476 | 4,698 | -76% | 1 | 1 | 0% | 3,463 | 1,725 | -50% | 0 | 0 | — |
case-04 | pass→pass | 13,602 | 4,714 | -65% | 1 | 1 | 0% | 2,164 | 2,275 | +5% | 0 | 0 | — |
case-05 | pass→pass | 9,759 | 4,483 | -54% | 1 | 1 | 0% | 1,690 | 2,308 | +37% | 0 | 0 | — |
case-06 | fail→pass | 9,879 | 5,294 | -46% | 1 | 1 | 0% | 1,656 | 2,108 | +27% | 0 | 0 | — |
case-07 | pass→pass | 11,304 | 20,429 | +81% | 1 | 1 | 0% | 1,817 | 2,901 | +60% | 0 | 0 | — |
case-08 | fail→pass | 10,356 | 2,601 | -75% | 1 | 1 | 0% | 1,489 | 1,941 | +30% | 0 | 0 | — |
case-09 | fail→pass | 5,370 | 2,842 | -47% | 1 | 1 | 0% | 856 | 1,924 | +125% | 0 | 0 | — |
case-10 | fail→pass | 10,757 | 2,339 | -78% | 1 | 1 | 0% | 1,852 | 1,923 | +4% | 0 | 0 | — |
case-11 | pass→pass | 14,324 | 6,986 | -51% | 1 | 1 | 0% | 2,308 | 2,624 | +14% | 0 | 0 | — |
case-12 | pass→pass | 10,046 | 5,455 | -46% | 1 | 1 | 0% | 1,653 | 2,375 | +44% | 0 | 0 | — |
case-13 | pass→pass | 6,407 | 2,791 | -56% | 1 | 1 | 0% | 978 | 1,967 | +101% | 0 | 0 | — |
case-18 | pass→pass | 3,596 | 1,161 | -68% | 1 | 1 | 0% | 531 | 1,703 | +221% | 0 | 0 | — |
case-14 | fail→pass | 8,884 | 3,109 | -65% | 1 | 1 | 0% | 1,317 | 1,844 | +40% | 0 | 0 | — |
case-15 | pass→pass | 11,699 | 2,696 | -77% | 1 | 1 | 0% | 2,120 | 1,930 | -9% | 0 | 0 | — |
case-16 | pass→pass | 10,462 | 4,124 | -61% | 1 | 1 | 0% | 1,595 | 2,140 | +34% | 0 | 0 | — |
case-17 | pass→pass | 10,151 | 4,565 | -55% | 1 | 1 | 0% | 1,653 | 2,228 | +35% | 0 | 0 | — |
case-19 | pass→pass | 7,161 | 2,018 | -72% | 1 | 1 | 0% | 1,153 | 1,796 | +56% | 0 | 0 | — |
case-20 | fail→fail | 8,990 | 2,164 | -76% | 1 | 1 | 0% | 1,268 | 1,806 | +42% | 0 | 0 | — |
case-21 | pass→pass | 10,716 | 4,929 | -54% | 1 | 1 | 0% | 1,721 | 2,159 | +25% | 0 | 0 | — |
case-22 | fail→fail | 9,410 | 20,605 | +119% | 1 | 1 | 0% | 1,761 | 3,922 | +123% | 0 | 0 | — |
case-23 | fail→fail | 10,888 | 11,627 | +7% | 1 | 1 | 0% | 2,111 | 3,770 | +79% | 0 | 0 | — |
case-24 | fail→fail | 17,944 | 7,456 | -58% | 1 | 1 | 0% | 4,245 | 1,737 | -59% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 24 cases were attempted, and 21 counted toward the lift figure. The other 3 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +21 percentage points is the difference between those two pass rates over the 21 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.