remove-ai-slops
Cleans AI-generated code smells while preserving behavior.
remove-ai-slops removes AI-generated code smells from branch changes or an explicit file list while strictly preserving behavior. Its core safety invariant is simple: before deleting a line, lock current behavior with passing regression tests. A checklist is not the safety net. Passing tests are.
The triggers include "remove ai slops", "clean ai code", "deslop", and "cleanup AI generated".
remove-ai-slops is an orchestrator. It determines the scope, locks behavior with regression tests first, splits category-based cleanup across parallel workers, and verifies the result with quality gates. In Codex, OpenCode-style deep examples are not called directly. They are translated into worker sub-agents with self-contained messages.
Scope
- Default: branch diff against
merge-base main; no arguments needed. - Optional: explicit file list from the caller, such as the changed file set from a loop workflow.
Deleted, binary, generated, and vendored files are filtered out.
Slop Categories
This Skill evaluates major slop categories by group.
| Group | Categories |
|---|---|
| Style | Obvious comments, excessive defensive code, unnecessary complexity. |
| Structure | Needless abstractions, boundary violations, dead code. |
| Hidden cost | Duplication, behavior-equivalent performance cleanup. |
| Behavior coverage | Missing tests. |
| Structure, size | Oversized modules over 250 pure LOC. |
Each category has explicit KEEP rules. Comments that explain why, validation at system boundaries, abstractions that create real boundaries, and intentional patterns are preserved. Performance changes are applied only when behavioral equivalence is obvious; otherwise they are skipped. Oversized modules are not treated as a simple warning. They trigger a real modular refactor, and new files must be named after the concept they own. Never use names such as utils, helpers, common, or part_1.
Process
Determine Scope
If file paths were provided, they are the scope. Otherwise, use the branch diff.
git diff $(git merge-base main HEAD)..HEAD --name-onlyLock Behavior With Regression Tests
For each file in scope, identify observable behavior, find existing coverage, and write the narrowest regression test that locks current behavior before editing. The baseline must be green. If a green baseline cannot be established, stop and report it.
Plan, Then Parallel Cleanup
Write a cleanup plan from safer to riskier categories: comments, dead code, defensive code, duplication, complexity, abstraction/boundary, performance, tests, oversized modules. Then run file-level workers in batches of at most five. If a file fails, retry once. If it still fails, escalate.
Verify With Quality Gates
Run regression tests, lint, typecheck through both LSP diagnostics and the project type checker, unit/integration tests, and static/security scans. Gates that are truly not applicable must be reported as N/A; do not silently skip them. Then review the safety, behavior, and quality checklist.
Fix Issues
If a gate fails, revert the problematic change with a targeted edit or checkout, reapply only what can be proven safe, and rerun the gates. If the same file fails three times, stop and escalate.
Antipatterns
- Skipping the regression-test step. Deleting code on uncovered ground is a delayed behavior change.
- Mixing unrelated refactors into a cleanup commit.
- Disguising algorithm changes as performance cleanup.
- Silent skips. Say
N/Aand why. - Removing comments that explain why.
- Touching files outside the agreed scope.