Loading...
Loading...
Aggressively clean up a codebase by removing AI slop, dead code, weak types, defensive over-engineering, duplication, and legacy cruft. Orchestrates 8 specialized subagents in parallel to deduplicate code, consolidate types, kill unused code, untangle circular dependencies, strengthen weak types, remove unnecessary try/catch, delete deprecated/legacy paths, and strip unhelpful comments. Use when the user asks to 'clean up the codebase', 'remove slop', 'improve code quality', 'remove dead code', 'kill AI slop', 'tighten types', 'remove legacy code', 'deduplicate code', 'DRY this up', 'untangle dependencies', or wants a thorough code quality pass. Also use when the user mentions code smells, technical debt cleanup, or refactoring for clarity — even if they don't use the word 'slop'.
npx skill4agent add luongnv89/skills slop-codebranch="$(git rev-parse --abbrev-ref HEAD)"
git fetch origin
git pull --rebase origin "$branch"git stash push -u -m "pre-sync"
branch="$(git rev-parse --abbrev-ref HEAD)"
git fetch origin && git pull --rebase origin "$branch"
git stash poporigingit statuschore/slop-cleanup-YYYYMMDDmainmasterpackage.jsonpyproject.tomlgo.modCargo.tomlpom.xmlnpxpackage.jsonMakefilepyproject.toml┌─────────────────────────────────────────────┐
│ Main SKILL (Orchestrator) │
│ - Detect stack & tools │
│ - Create cleanup branch │
│ - Dispatch subagents in waves │
│ - Run tests between waves │
│ - Assemble final report │
└──────────────┬──────────────────────────────┘
│
┌─────────┴──────────┐
│ Wave 1 │ (analyze + narrow edits, run in parallel)
│ │
▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ Unused │ │ Circular │ │ Weak │ │ Slop/ │
│ Code │ │ Deps │ │ Types │ │ Comments │
│ (knip) │ │ (madge) │ │ │ │ │
└──────────┘ └──────────┘ └──────────┘ └──────────┘
↓ test + typecheck gate ↓
┌─────────────────────┐
│ Wave 2 │ (structural, needs Wave 1 done first)
│ │
▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ Dedupe/ │ │ Type │ │ Defensive│ │ Legacy/ │
│ DRY │ │ Consol. │ │ Prog. │ │ Deprec. │
└──────────┘ └──────────┘ └──────────┘ └──────────┘
↓ test + typecheck gate ↓
┌──────────────────────┐
│ Report Assembler │
│ SLOP_CLEANUP.md │
└──────────────────────┘agents/subagent_type: general-purpose| # | Wave | Subagent | Prompt file | Scope |
|---|---|---|---|---|
| 1 | 2 | Deduplicator | | Extract shared code; apply DRY only where it reduces complexity |
| 2 | 2 | Type Consolidator | | Merge duplicate type/interface/struct definitions into shared modules |
| 3 | 1 | Unused Code Killer | | Find and delete unreferenced code using knip/ts-prune/vulture/etc. |
| 4 | 1 | Circular Dep Untangler | | Detect and break circular dependencies using madge/dep-cruiser |
| 5 | 1 | Weak Type Strengthener | | Replace |
| 6 | 2 | Defensive Programming Remover | | Remove try/catch, fallbacks, and null-checks that hide errors |
| 7 | 2 | Legacy Code Remover | | Delete deprecated, fallback, and duplicated-by-migration code paths |
| 8 | 1 | Slop Comment Cleaner | | Remove AI-generated fluff, stubs, work-in-motion comments, LARP |
# Refuse if working tree is dirty
git diff-index --quiet HEAD -- || { echo "Commit or stash changes first"; exit 1; }
# Create cleanup branch
date_tag=$(date +%Y%m%d)
git checkout -b "chore/slop-cleanup-${date_tag}".slop-cleanup/wave-1/<subagent>.md.slop-cleanup/wave-2/<subagent>.mdSLOP_CLEANUP.md# Slop Cleanup Report
**Branch:** chore/slop-cleanup-YYYYMMDD
**Commits:** N (list with category and one-line summary)
**Tests:** ✓ passing | **Typecheck:** ✓ clean
## Summary
- Files deleted: N
- Lines removed: N
- Lines added: N
- Types consolidated: N
- Duplicates merged: N
- Try/catch removed: N
- Circular deps broken: N
- Weak types replaced: N
- Slop comments removed: N
## By Category
### 1. Unused Code (subagent 3)
...one-line commit summary, then findings table with file/line/what/why...
### 2. Circular Dependencies (subagent 4)
...
### (etc for all 8 categories)
## Risk Flags
Anything each subagent flagged as "delete at your own risk" (external callers unknown, reflective access, dynamic imports).
## Next Steps
- Review the branch
- Run a full regression suite
- Merge or cherry-pick categoriesSLOP_CLEANUP.md// removed legacy handlerif (!x) throw◆ Wave 1 (step 1 of 3 — parallel cleanup)
··································································
Unused code killer: √ pass (removed 47 symbols, 12 files)
Circular dep untangler: √ pass (broke 3 cycles)
Weak type strengthener: √ pass (replaced 89 anys with specific types)
Slop comment cleaner: √ pass (removed 234 slop comments)
Tests after wave: √ pass
Typecheck after wave: √ pass
____________________________
Result: PASS◆ Wave 2 (step 2 of 3 — structural consolidation)
··································································
Deduplicator: √ pass (merged 18 duplicate blocks)
Type consolidator: √ pass (moved 23 types to shared/)
Defensive programming remover: × fail — 3 tests broke, reverted
Legacy code remover: √ pass (deleted 2 fallback paths)
Tests after wave: × fail — blocked by defensive remover revert
____________________________
Result: PARTIAL◆ Final Report (step 3 of 3 — assembly)
··································································
SLOP_CLEANUP.md written: √ pass
All commits have messages: √ pass
Branch pushed: √ pass
Summary delivered to user: √ pass
____________________________
Result: PASS√×