/code-cleanup:cleanup-code [scope] [--dimensions d1,d2,...] [--changed]from code-cleanup
Systematically cleans up codebase across 11 quality dimensions including dead code, duplication, weak types, circular deps, and more. Uses confidence scoring and build/test verification.
Ships in code-cleanup. 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.
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:
# 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: N
A 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-code
Security-focused:
/cleanup-code --dimensions security,async
Changed files only:
/cleanup-code src/api/ --changed
Single dimension deep-dive:
/cleanup-code --dimensions dead
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
code-quality, cleanup, refactoring, dead-code, deduplication, type-safety
npx claudepluginhub jeremylongshore/tons-of-skills-marketplace --plugin code-cleanupOther plugins' skills for the same job