3 -description: "Use when the user asks to desloppy, clean up, simplify, refactor, or review a specific file, directory, diff, or code scope for messy/sloppy code, code smells, technical debt, duplication, complexity, or overengineering."
3 +description: "Use when cleaning or refactoring existing code to remove accidental complexity, duplication, needless indirection, weak types, or overengineering without changing behavior."
6 -#
Find ugliest slop in code and fix it 8 +Slop works, but costs too much to read, change, or trust.
10 -Use for broad cleanup/refactor reviews of existing code when the user wants the
11 -agent to find high-impact slop.
13 -Do not use for normal feature work, exact bug fixes, formatting-only changes, or
14 -cases where the user already specified the exact change to make.
12 +- Existing code only.
13 +- Preserve observable behavior, public APIs, error meaning, security boundaries, accessibility, and relevant performance behavior.
14 +- No features, unrelated bug fixes, weakened tests, or scope creep.
15 +- Deletion beats addition.
18 -1. **Scan** - Find the ugliest code
19 -2. **Identify** - What makes it slop?
20 - (nesting, long functions, magic numbers, no types)
21 -3. **Propose** - Pick 1-3 slops with highest impact
22 -4. **Approve** - Report minimal and terse first; wait for approval
23 -5. **Fix** - Rewrite cleanly, with project code style
24 -6. **Verify** - Run tests after fixes and create regression tests beforehand, to
25 - make sure to not break old behavior
19 +- One scope is one place or one cross-cutting seam.
21 +- State scope in one sentence.
22 +- Cannot enumerate callers, tests, and affected boundaries → shrink scope.
27 -Focus on ugly code. Read the relevant reference before proposing fixes:
29 -- `references/deep-nesting.md` — deep nesting → flatten
30 -- `references/long-functions.md` — long functions → analyze before extracting
31 -- `references/single-use-functions.md` — single use functions → inline
32 -- `references/magic-values.md` — magic values → name them or express relationships
33 -- `references/missing-types-docs.md` — missing types/docs → add them
34 -- `references/poor-error-handling.md` — poor error handling → fix it
35 -- `references/overengineered-error-handling.md` — overengineered error
37 -- `references/legacy-overengineering.md` — "legacy" or "backwards
38 - compatibility" → verify the need
39 -- `references/complexity.md` — complexity → disentangle dependencies
40 -- `references/duplication.md` — duplication → remove only when changes should
42 -- `references/poor-patterns.md` — poor patterns → challenge mechanical Clean
26 +1. Read scope in full, then callers, tests, public API, and project instructions.
27 +2. Read only references triggered by code:
28 + - `references/deep-nesting.md` → flatten control flow
29 + - `references/long-functions.md` → separate jobs only when separation helps
30 + - `references/single-use-functions.md` → remove single-use indirection
31 + - `references/magic-values.md` → expose hidden meaning or relationships
32 + - `references/missing-types-docs.md` → sharpen types; remove noisy comments
33 + - `references/poor-error-handling.md` → preserve useful error information
34 + - `references/overengineered-error-handling.md` → remove excess machinery
35 + - `references/legacy-overengineering.md` → verify compatibility claims
36 + - `references/complexity.md` → disentangle dependencies
37 + - `references/duplication.md` → unify knowledge that must change together
38 + - `references/poor-patterns.md` → remove unearned ceremony
39 +3. Run smallest project-defined gates covering scope.
40 + Keep pre-existing failures visible.
41 +4. Choose highest-impact behavior-preserving cleanup inside scope.
42 +5. Existing tests do not prove preserved behavior → add focused proof before refactoring.
43 + Never change test expectations merely to make refactor pass.
44 +6. Make smallest surgical change.
45 + Second scope appears → leave it.
46 +7. Run relevant project-defined gates again.
45 -Add confidence level to each proposed slop fix:
47 -- **SAFE** - unlikely to introduce breaking changes
48 -- **RISKY** - likely to introduce breaking changes
50 +- Project instructions, source, tests, and project-defined gates outrank this skill.
51 +- `references/*.md` provide local, conditional guidance.
52 +- No other skill required.