Claude-starter cleanup-all
Run all 8 cleanup skills in sequence: unused → cycles → dedupe → types → weak-types → defensive → legacy → slop. Each step verifies before the next runs; halts on first failure. Produces one consolidated report. Use when the user asks to clean up the whole codebase, run all cleanup skills, do a full code-quality pass, or sweep the repo.
git clone https://github.com/raintree-technology/claude-starter
T=$(mktemp -d) && git clone --depth=1 https://github.com/raintree-technology/claude-starter "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/code-quality/cleanup-all" ~/.claude/skills/raintree-technology-claude-starter-cleanup-all && rm -rf "$T"
skills/code-quality/cleanup-all/SKILL.mdOrchestrate the full cleanup pipeline. Runs each of the 8 cleanup skills in a deliberate order chosen so each step shrinks the surface for the next. Halts on first verify failure so you can investigate before the cascade continues.
Preflight
- Confirm intent: this will produce up to 8 separate commits and may touch many files. Show the user the planned order and ask confirmation if the working tree has any commits ahead of the upstream branch (might compound with their unpushed work).
- Git state: refuse on dirty working tree. Each child skill needs a clean baseline for its verify step.
- Create master report:
— child skill reports will be linked from this..claude/cleanup-reports/cleanup-all-{YYYY-MM-DD}.md - Estimate baseline: capture LOC, file count, dependency count, knip findings, madge cycles count, weak-type count. Used for before/after comparison at the end.
Execution Order
Each child skill is invoked via Skill tool. After each, run that skill's verify step. Halt the pipeline on any verify failure — do not proceed to the next step.
— delete dead code first. Less for everything downstream to scan.cleanup-unused
— fix the dependency graph next. Other refactors are safer in an acyclic graph.cleanup-cycles
— extract duplicates. Now that dead code is gone and graph is clean, real duplicates surface.cleanup-dedupe
— consolidate types. Often dedupe surfaces type duplication too.cleanup-types
— strengthen types. Easier with consolidated type modules in place.cleanup-weak-types
— remove pointless try/catch. Type strengthening sometimes makes catches obviously wrong.cleanup-defensive
— remove deprecated/fallback. Type changes may have already revealed dead branches.cleanup-legacy
— strip unhelpful comments last. Cosmetic, no logic change.cleanup-slop
Why this order
- Destructive then constructive then cosmetic. Deletion first reduces what later skills consider.
- Structure before contents. Cycles and unused are graph-level; dedupe and types are content-level; slop is line-level.
- Riskiest reversible-changes early when the diff is small and the human can review faster. Slop last because it's safest and produces the largest comment diff.
- Each step's commit is a clean revert point if the user wants to undo a single phase.
Per-step protocol
For each skill in order:
- Print:
▶ Running cleanup-X (step Y/8)… - Invoke the skill via the Skill tool with the same scope arg (if any).
- Wait for the skill to finish — it produces its own commit and verify result.
- If the skill's verify failed: HALT, print
✗ cleanup-X verify failed — halting pipeline. See report at <path>. - If verify passed: append findings count + LOC delta to master report, continue.
Master Report
Write
.claude/cleanup-reports/cleanup-all-{YYYY-MM-DD}.md:
# Full Cleanup — YYYY-MM-DD ## Baseline - LOC: N - Files: M - Dependencies: K - Cycles (madge): C - Weak types: W - Knip-flagged unused: U ## Pipeline Run | # | Skill | Status | Items removed | LOC delta | Commit | Report | |---|-------|--------|---------------|-----------|--------|--------| | 1 | cleanup-unused | ✓ | 12 (3 files, 8 exports, 1 dep) | -340 | abc1234 | [link](cleanup-unused-2026-04-16.md) | | 2 | cleanup-cycles | ✓ | 3 cycles broken | +12 (extracted leaves) | def5678 | [link](cleanup-cycles-2026-04-16.md) | | 3 | cleanup-dedupe | ✓ | 5 utils extracted | -180 | ... | ... | | 4 | cleanup-types | ✓ | 4 types consolidated | -60 | ... | ... | | 5 | cleanup-weak-types | ✓ | 22 weak types strengthened | 0 | ... | ... | | 6 | cleanup-defensive | ✗ HALTED | — | — | — | [link](cleanup-defensive-2026-04-16.md) | | 7 | cleanup-legacy | (not run — pipeline halted at step 6) | | | | | | 8 | cleanup-slop | (not run) | | | | | ## After (steps 1-5 only) - LOC: N - 568 - Files: M - 3 - Dependencies: K - 1 - Cycles: 0 - Weak types: W - 22 ## Halt Reason - Step 6 (`cleanup-defensive`) verify failed: 3 tests broke when removing 2 swallow-and-return-null catches in `services/payment.ts`. The hidden errors were real bugs. See child report for details. ## Next Steps 1. Review halted step's report. Decide whether the surfaced bugs need fixing now. 2. Re-run pipeline starting from the halted step: `/cleanup-defensive` then `/cleanup-legacy` then `/cleanup-slop`. ## Deferred Items [Aggregated MEDIUM/LOW findings across all run steps — N items requiring human review.]
After Completion (or Halt)
End-of-turn message:
- Steps completed: X / 8
- Total items removed: N
- Total LOC delta: -M
- Halt reason (if any) — quote first 2 lines from halted skill's verify failure.
- Path to master report.
- Next-step suggestion: either "all steps green — review master report" or "halted at step X — see report and decide next action."
NEVER
- Continue past a verify failure — the next skill might compound the breakage.
- Squash the per-skill commits — they're the rollback granularity.
- Auto-fix the halted skill's failure — that's a human decision (the failure may be a real bug worth investigating).
- Run on a dirty working tree — refuse and ask user to commit/stash.
- Run when the repo is mid-rebase, mid-merge, or mid-cherry-pick — git state will confuse the per-step commits.
- Skip the baseline measurement — without it, the master report has no before/after delta.