Purpose
Reduce AI-generated code bloat through systematic, smell-by-smell cleanup that preserves existing behavior and raises signal quality.
When to Use
- A code path works but feels bloated, noisy, repetitive, or over-abstracted.
- A user asks to "cleanup", "refactor", or "deslop" AI-generated output.
- Follow-up implementation left duplicate code, dead code, weak boundaries, or missing tests.
- A disciplined cleanup workflow is needed without broad rewrites.
- The user wants a reviewer-only anti-slop pass via
--review mode.
This skill accepts an optional file list scope. If a changed-files list is provided, keep the cleanup strictly bounded to those files. Do not silently expand a changed-file scope.
Inputs
- Codebase or module to clean (or explicit file list scope).
- Existing test suite (required — behavior must be locked before editing).
Workflow
Lock behavior with regression tests first
- Identify the behavior that must not change.
- Add or run targeted regression tests before touching cleanup candidates.
- If behavior is currently untested, write the narrowest test coverage needed first.
Create a cleanup plan before code
- List the specific smells to remove.
- Bound the pass to the requested files/scope.
- Order fixes from safest/highest-signal to riskiest.
- Do not start coding until the cleanup plan is explicit.
Categorize issues
- Duplication — repeated logic, copy-paste branches, redundant helpers
- Dead code — unused code, unreachable branches, stale flags, debug leftovers
- Needless abstraction — pass-through wrappers, speculative indirection, single-use helper layers
- Boundary violations — hidden coupling, leaky responsibilities, wrong-layer imports or side effects
- Missing tests — behavior not locked, weak regression coverage, gaps around edge cases
Execute passes one smell at a time
- Pass 1: Dead code deletion
- Pass 2: Duplicate removal
- Pass 3: Naming and error handling cleanup
- Pass 4: Test reinforcement
- Re-run targeted verification after each pass.
- Do not bundle unrelated refactors into the same edit set.
Run quality gates
- Regression tests stay green.
- Lint passes.
- Typecheck passes.
- Relevant unit/integration tests pass.
- Diff stays minimal and scoped.
- No new abstractions or dependencies unless explicitly required.
Review Mode (--review)
If invoked with a --review flag, operate as a reviewer-only pass:
- Do not start by editing files.
- Review the cleanup plan, changed files, and regression coverage.
- Check specifically for leftover dead code, duplicate logic, needless wrappers, and missing tests for preserved behavior.
- Produce a reviewer verdict with required follow-ups.
- Hand needed changes back to a separate writer pass instead of fixing and approving in one step.
Output
AI SLOP CLEANUP REPORT
======================
Scope: [files or feature area]
Behavior Lock: [targeted regression tests added/run]
Cleanup Plan: [bounded smells and order]
Passes Completed:
1. Dead code deletion - [concise fix]
2. Duplicate removal - [concise fix]
3. Naming/error handling cleanup - [concise fix]
4. Test reinforcement - [concise fix]
Quality Gates:
- Regression tests: PASS/FAIL
- Lint: PASS/FAIL
- Typecheck: PASS/FAIL
- Tests: PASS/FAIL
Changed Files:
- [path] - [simplification]
Remaining Risks:
- [none or short deferred item]
Verification
Failure Modes
- Editing before tests — Never clean up code whose behavior isn't locked by tests.
- Multi-smell passes — Bundling smell categories into one large refactor makes verification impossible.
- Scope creep — If given a file list scope, stay within it. Do not expand to adjacent files.
1---2name: ai-slop-cleaner3description: Use when a working code path feels bloated, noisy, or over-abstracted, when asked to clean up or deslop AI-generated code, or when a reviewer-only anti-slop pass is requested.4---56## Purpose78Reduce AI-generated code bloat through systematic, smell-by-smell cleanup that preserves existing behavior and raises signal quality.910## When to Use1112- A code path works but feels bloated, noisy, repetitive, or over-abstracted.13- A user asks to "cleanup", "refactor", or "deslop" AI-generated output.14- Follow-up implementation left duplicate code, dead code, weak boundaries, or missing tests.15- A disciplined cleanup workflow is needed without broad rewrites.16- The user wants a reviewer-only anti-slop pass via `--review` mode.1718This skill accepts an optional **file list scope**. If a changed-files list is provided, keep the cleanup strictly bounded to those files. Do not silently expand a changed-file scope.1920## Inputs2122- Codebase or module to clean (or explicit file list scope).23- Existing test suite (required — behavior must be locked before editing).2425## Workflow26271. **Lock behavior with regression tests first**28 - Identify the behavior that must not change.29 - Add or run targeted regression tests before touching cleanup candidates.30 - If behavior is currently untested, write the narrowest test coverage needed first.31322. **Create a cleanup plan before code**33 - List the specific smells to remove.34 - Bound the pass to the requested files/scope.35 - Order fixes from safest/highest-signal to riskiest.36 - Do not start coding until the cleanup plan is explicit.37383. **Categorize issues**39 - **Duplication** — repeated logic, copy-paste branches, redundant helpers40 - **Dead code** — unused code, unreachable branches, stale flags, debug leftovers41 - **Needless abstraction** — pass-through wrappers, speculative indirection, single-use helper layers42 - **Boundary violations** — hidden coupling, leaky responsibilities, wrong-layer imports or side effects43 - **Missing tests** — behavior not locked, weak regression coverage, gaps around edge cases44454. **Execute passes one smell at a time**46 - Pass 1: Dead code deletion47 - Pass 2: Duplicate removal48 - Pass 3: Naming and error handling cleanup49 - Pass 4: Test reinforcement50 - Re-run targeted verification after each pass.51 - Do not bundle unrelated refactors into the same edit set.52535. **Run quality gates**54 - Regression tests stay green.55 - Lint passes.56 - Typecheck passes.57 - Relevant unit/integration tests pass.58 - Diff stays minimal and scoped.59 - No new abstractions or dependencies unless explicitly required.6061## Review Mode (`--review`)6263If invoked with a `--review` flag, operate as a reviewer-only pass:641. Do **not** start by editing files.652. Review the cleanup plan, changed files, and regression coverage.663. Check specifically for leftover dead code, duplicate logic, needless wrappers, and missing tests for preserved behavior.674. Produce a reviewer verdict with required follow-ups.685. Hand needed changes back to a separate writer pass instead of fixing and approving in one step.6970## Output7172```73AI SLOP CLEANUP REPORT74======================7576Scope: [files or feature area]77Behavior Lock: [targeted regression tests added/run]78Cleanup Plan: [bounded smells and order]7980Passes Completed:811. Dead code deletion - [concise fix]822. Duplicate removal - [concise fix]833. Naming/error handling cleanup - [concise fix]844. Test reinforcement - [concise fix]8586Quality Gates:87- Regression tests: PASS/FAIL88- Lint: PASS/FAIL89- Typecheck: PASS/FAIL90- Tests: PASS/FAIL9192Changed Files:93- [path] - [simplification]9495Remaining Risks:96- [none or short deferred item]97```9899## Verification100101- [ ] Regression tests written or confirmed before any edits102- [ ] Cleanup plan explicit before coding started103- [ ] Each pass limited to one smell category104- [ ] Quality gates pass after each pass105- [ ] Diff is minimal and scoped — no unrelated changes106107## Failure Modes108109- **Editing before tests** — Never clean up code whose behavior isn't locked by tests.110- **Multi-smell passes** — Bundling smell categories into one large refactor makes verification impossible.111- **Scope creep** — If given a file list scope, stay within it. Do not expand to adjacent files.