Antigravity Swarm Remove AI Slops
Use this skill when the user asks to remove slop, clean generated-looking code, deslop a branch, remove noisy comments, simplify over-defensive logic, or tidy recent AI-assisted changes.
The invariant: behavior is locked before cleanup. A checklist is not safety. A passing characterization or regression check is the safety mechanism.
Inputs
- Default scope: changed files in the current branch compared with the merge base of
main.
- Optional scope: an explicit file list from the user or from an ASW plan.
- Accepted file types: source, tests, docs, installer scripts, hook scripts, and configuration files owned by the current change.
- Excluded file types: deleted files, binaries, vendored directories, generated output, lockfiles unless the lockfile is the requested surface.
What this skill does
This skill cleans a bounded set of files while preserving behavior.
It does four things:
- Determines scope.
- Locks current behavior with tests or characterization checks.
- Runs categorized cleanup in safe order.
- Verifies with quality gates and an ASW review.
It does not:
- change public APIs unless the user explicitly asked,
- remove validation at external boundaries,
- rewrite architecture for taste,
- optimize code when behavior equivalence is not obvious,
- claim completion from green tests alone.
Categories
1. Obvious Comments
Remove:
- comments that restate the next line,
- trivial docstrings on self-explanatory functions,
- section banners,
- commented-out code,
- vague TODOs without owner or issue,
- notes that expose internal process instead of product behavior.
Keep:
- comments explaining why,
- issue links,
- algorithm notes,
- regex explanations,
- boundary or compatibility constraints,
- BDD markers in tests.
2. Over-Defensive Code
Remove or simplify:
- null checks for guaranteed values,
- default values for required parameters,
- broad catches around code that cannot throw,
- duplicated validation after a trusted parse step,
- stale compatibility shims no longer documented or tested,
- empty catches and log-only catches that swallow unknown failures.
Keep:
- validation at user input, network, filesystem, subprocess, database, and external API boundaries,
- nullable data handling,
- top-level CLI or server boundary error handling with explicit reporting,
- security checks.
When narrowing broad catches, handle known errors and rethrow unknown errors.
3. Excessive Complexity
Look for:
- nesting deeper than three levels,
- nested ternaries,
- boolean expressions with four or more predicates,
- long parameter lists,
- functions doing several responsibilities,
- type or variant discrimination through long conditional chains,
- generic catch-all object shapes where a typed shape is known.
Preferred cleanup:
- guard clauses,
- named intermediate values,
- small responsibility extraction,
- exhaustive variant handling in the local language,
- typed input parsing at the boundary.
Skip when:
- the pattern is established and clearer in this codebase,
- the path is performance-critical and intentionally shaped,
- the simplification would require a behavior proof you do not have.
4. Needless Abstraction
Remove:
- pass-through wrappers,
- single-use helpers that hide simple code,
- speculative interfaces,
- factories that only call constructors,
- indirection created only because future changes might happen.
Keep:
- abstractions with multiple implementations,
- test seams that reduce real coupling,
- framework-required boundaries,
- public extension points.
5. Boundary Violations
Flag and fix only when safe:
- UI or command layer importing storage internals,
- hook scripts owning installer policy,
- package tests depending on private reference trees,
- docs claiming behavior not covered by the package,
- pure-named functions with hidden side effects.
When unsure, report the boundary issue and skip the edit.
6. Dead Code
Remove:
- unused imports,
- unused private helpers,
- unreachable branches,
- stale feature flags,
- debug output,
- removed-code comments,
- orphaned exports not referenced by docs, tests, package manifests, or dynamic lookup.
Keep:
- dynamic dispatch targets,
- plugin manifest entries,
- public exports,
- intentional rollback flags with evidence.
7. Duplication
Remove:
- copy-pasted branches with trivial differences,
- repeated literal sequences,
- redundant helpers doing the same thing,
- duplicated package or hook path logic.
Keep:
- similar code with different intent,
- local duplication that is clearer than premature sharing.
8. Performance Equivalences
Apply only when behavior equivalence is obvious:
- list scan to set lookup,
- repeated computation in a loop hoisted outside,
- eager collection to lazy iteration,
- string concatenation in loop to join,
- repeated API or database calls batched when result ordering and errors stay the same,
- redundant clones or deep copies removed,
- repeated length checks cached when the collection cannot mutate.
Do not:
- alter algorithms with subtle correctness conditions,
- micro-optimize without a benchmark,
- change ordering, exception timing, or side effects.
9. Missing Tests
If changed behavior is uncovered, add the narrowest regression test before cleanup. The fix is not to remove code; the fix is to lock behavior.
Tests should pin observable outputs, public errors, package contents, generated files, or CLI text rather than private implementation details.
10. Oversized Modules
Any source file over 250 pure lines is a design smell unless it is a clearly self-contained script.
Measure pure lines by excluding blanks and comments.
When oversized files are in scope:
- Identify responsibilities.
- Name target files by concept, never
utils, helpers, common, or numbered chunks.
- Preserve public imports and package paths.
- Extract one responsibility at a time.
- Re-run tests and diagnostics after each extraction.
- Report any intentionally unsplit file with evidence.
Do not split generated output. Do not split by token count.
Quality Gates
Run every applicable gate. Mark genuinely absent gates as N/A with a reason.
| Gate |
Pass condition |
| Behavior lock |
relevant tests or characterization checks green before cleanup |
| Regression tests |
all relevant tests green after cleanup |
| Full suite |
project test runner green, or pre-existing failures named |
| Lint/format |
zero new errors |
| Typecheck/diagnostics |
zero new diagnostics in changed files |
| Package surface |
npm or plugin package excludes private/runtime material |
| Manual QA |
real CLI, hook, installer, browser, HTTP, or desktop surface exercised when user-visible behavior changed |
| Review |
ASW reviewer has no blockers |
Process
Phase 0: Plan
Create a short cleanup plan before editing:
Scope:
- file
Behavior lock:
- test or characterization command
Cleanup order:
- comments -> dead code -> defensive -> duplication -> complexity -> abstraction/boundary -> performance -> oversized modules
Risk:
- low | medium | high
Phase 1: Determine scope
If the user passed paths, use those paths.
Otherwise inspect the branch diff:
git diff "$(git merge-base main HEAD)"..HEAD --name-only
Filter:
- deleted files,
- binary files,
- generated output,
- vendored directories,
- lockfiles unless they are the requested surface.
List final scope before cleanup.
Phase 2: Lock behavior
For each in-scope source file:
- Identify observable behavior.
- Find existing tests.
- Add a characterization test if coverage is weak.
- Run the relevant test and confirm it is green before editing.
If no green baseline can be established, stop and report. Do not clean uncovered behavior.
Phase 3: Cleanup plan
For each file, list categories and order:
File: path
Categories: comments, dead code, defensive
Order: comments -> dead code -> defensive
Risk: low
Behavior lock: command/test id
Phase 4: Parallel cleanup
For multiple independent files, use Antigravity subagents in batches of up to five.
Per-file lane message should include:
- exact file,
- categories to evaluate,
- behavior lock evidence,
- cleanup order,
- hard constraints,
- report format.
Hard constraints for each lane:
- preserve behavior,
- do not change public API signatures,
- do not remove type hints,
- do not introduce dependencies,
- skip uncertain performance changes,
- keep diff minimal.
If a lane fails, collect successful lanes, retry the failed file once, then escalate.
Phase 5: Verify
Run the quality gates. Then walk the critical review checklist:
Safety:
- no functional logic accidentally removed,
- all boundary error handling preserved,
- types and imports intact,
- public APIs stable.
Behavior:
- return values unchanged,
- side effects unchanged,
- exception behavior unchanged,
- edge cases preserved.
Quality:
- removed code was genuine slop,
- remaining code follows project conventions,
- no orphaned references,
- no subtle performance changes,
- no speculative abstraction added.
Phase 6: Fix issues
If a gate fails:
- Identify the exact hunk.
- Explain why it failed.
- Revert only that hunk.
- Apply a safer edit if genuine slop remains.
- Re-run the failing gate.
- Stop after repeated failure and report the file, attempts, and hypothesis.
Output Format
AI SLOP REMOVAL REPORT
======================
Scope:
Files:
Behavior Lock:
- Existing coverage:
- Tests added:
- Baseline status:
Cleanup Plan:
- path: categories in order
Per-File Results:
path
- Category: change summary
- Skipped: preserved for safety
Quality Gates:
- Behavior lock:
- Regression tests:
- Full suite:
- Lint:
- Typecheck:
- Package surface:
- Manual QA:
- Review:
Critical Review:
- Safety:
- Behavior:
- Quality:
Issues Found & Fixed:
- None | details
Remaining Risks / Deferred:
- None | details
Final Status: CLEAN | ISSUES FIXED | REQUIRES ATTENTION
Anti-Patterns
- Skipping behavior lock.
- Bundling unrelated refactors.
- Calling a performance change safe without obvious equivalence.
- Silently skipping gates.
- Removing comments that explain why.
- Touching files outside scope.
- Deleting tests or weakening assertions.
- Calling green tests completion without a real surface when users observe the behavior.
Final Rule
When in doubt, skip the cleanup and report the suspected slop. False negatives are better than broken behavior.
Source: wjgoarxiv/antigravity-swarm — distributed by TomeVault.
1---2name: asw-remove-ai-slops3description: Remove AI-looking code smells from branch changes or explicit files. Lock behavior with regression tests first, run categorized cleanup in bounded Antigravity lanes, then verify with quality gates. Use when this capability is needed.4---56# Antigravity Swarm Remove AI Slops78Use this skill when the user asks to remove slop, clean generated-looking code, deslop a branch, remove noisy comments, simplify over-defensive logic, or tidy recent AI-assisted changes.910The invariant: behavior is locked before cleanup. A checklist is not safety. A passing characterization or regression check is the safety mechanism.1112## Inputs1314- Default scope: changed files in the current branch compared with the merge base of `main`.15- Optional scope: an explicit file list from the user or from an ASW plan.16- Accepted file types: source, tests, docs, installer scripts, hook scripts, and configuration files owned by the current change.17- Excluded file types: deleted files, binaries, vendored directories, generated output, lockfiles unless the lockfile is the requested surface.1819## What this skill does2021This skill cleans a bounded set of files while preserving behavior.2223It does four things:24251. Determines scope.262. Locks current behavior with tests or characterization checks.273. Runs categorized cleanup in safe order.284. Verifies with quality gates and an ASW review.2930It does not:3132- change public APIs unless the user explicitly asked,33- remove validation at external boundaries,34- rewrite architecture for taste,35- optimize code when behavior equivalence is not obvious,36- claim completion from green tests alone.3738## Categories3940### 1. Obvious Comments4142Remove:4344- comments that restate the next line,45- trivial docstrings on self-explanatory functions,46- section banners,47- commented-out code,48- vague TODOs without owner or issue,49- notes that expose internal process instead of product behavior.5051Keep:5253- comments explaining why,54- issue links,55- algorithm notes,56- regex explanations,57- boundary or compatibility constraints,58- BDD markers in tests.5960### 2. Over-Defensive Code6162Remove or simplify:6364- null checks for guaranteed values,65- default values for required parameters,66- broad catches around code that cannot throw,67- duplicated validation after a trusted parse step,68- stale compatibility shims no longer documented or tested,69- empty catches and log-only catches that swallow unknown failures.7071Keep:7273- validation at user input, network, filesystem, subprocess, database, and external API boundaries,74- nullable data handling,75- top-level CLI or server boundary error handling with explicit reporting,76- security checks.7778When narrowing broad catches, handle known errors and rethrow unknown errors.7980### 3. Excessive Complexity8182Look for:8384- nesting deeper than three levels,85- nested ternaries,86- boolean expressions with four or more predicates,87- long parameter lists,88- functions doing several responsibilities,89- type or variant discrimination through long conditional chains,90- generic catch-all object shapes where a typed shape is known.9192Preferred cleanup:9394- guard clauses,95- named intermediate values,96- small responsibility extraction,97- exhaustive variant handling in the local language,98- typed input parsing at the boundary.99100Skip when:101102- the pattern is established and clearer in this codebase,103- the path is performance-critical and intentionally shaped,104- the simplification would require a behavior proof you do not have.105106### 4. Needless Abstraction107108Remove:109110- pass-through wrappers,111- single-use helpers that hide simple code,112- speculative interfaces,113- factories that only call constructors,114- indirection created only because future changes might happen.115116Keep:117118- abstractions with multiple implementations,119- test seams that reduce real coupling,120- framework-required boundaries,121- public extension points.122123### 5. Boundary Violations124125Flag and fix only when safe:126127- UI or command layer importing storage internals,128- hook scripts owning installer policy,129- package tests depending on private reference trees,130- docs claiming behavior not covered by the package,131- pure-named functions with hidden side effects.132133When unsure, report the boundary issue and skip the edit.134135### 6. Dead Code136137Remove:138139- unused imports,140- unused private helpers,141- unreachable branches,142- stale feature flags,143- debug output,144- removed-code comments,145- orphaned exports not referenced by docs, tests, package manifests, or dynamic lookup.146147Keep:148149- dynamic dispatch targets,150- plugin manifest entries,151- public exports,152- intentional rollback flags with evidence.153154### 7. Duplication155156Remove:157158- copy-pasted branches with trivial differences,159- repeated literal sequences,160- redundant helpers doing the same thing,161- duplicated package or hook path logic.162163Keep:164165- similar code with different intent,166- local duplication that is clearer than premature sharing.167168### 8. Performance Equivalences169170Apply only when behavior equivalence is obvious:171172- list scan to set lookup,173- repeated computation in a loop hoisted outside,174- eager collection to lazy iteration,175- string concatenation in loop to join,176- repeated API or database calls batched when result ordering and errors stay the same,177- redundant clones or deep copies removed,178- repeated length checks cached when the collection cannot mutate.179180Do not:181182- alter algorithms with subtle correctness conditions,183- micro-optimize without a benchmark,184- change ordering, exception timing, or side effects.185186### 9. Missing Tests187188If changed behavior is uncovered, add the narrowest regression test before cleanup. The fix is not to remove code; the fix is to lock behavior.189190Tests should pin observable outputs, public errors, package contents, generated files, or CLI text rather than private implementation details.191192### 10. Oversized Modules193194Any source file over 250 pure lines is a design smell unless it is a clearly self-contained script.195196Measure pure lines by excluding blanks and comments.197198When oversized files are in scope:1992001. Identify responsibilities.2012. Name target files by concept, never `utils`, `helpers`, `common`, or numbered chunks.2023. Preserve public imports and package paths.2034. Extract one responsibility at a time.2045. Re-run tests and diagnostics after each extraction.2056. Report any intentionally unsplit file with evidence.206207Do not split generated output. Do not split by token count.208209## Quality Gates210211Run every applicable gate. Mark genuinely absent gates as `N/A` with a reason.212213| Gate | Pass condition |214|---|---|215| Behavior lock | relevant tests or characterization checks green before cleanup |216| Regression tests | all relevant tests green after cleanup |217| Full suite | project test runner green, or pre-existing failures named |218| Lint/format | zero new errors |219| Typecheck/diagnostics | zero new diagnostics in changed files |220| Package surface | npm or plugin package excludes private/runtime material |221| Manual QA | real CLI, hook, installer, browser, HTTP, or desktop surface exercised when user-visible behavior changed |222| Review | ASW reviewer has no blockers |223224## Process225226### Phase 0: Plan227228Create a short cleanup plan before editing:229230```text231Scope:232- file233234Behavior lock:235- test or characterization command236237Cleanup order:238- comments -> dead code -> defensive -> duplication -> complexity -> abstraction/boundary -> performance -> oversized modules239240Risk:241- low | medium | high242```243244### Phase 1: Determine scope245246If the user passed paths, use those paths.247248Otherwise inspect the branch diff:249250```bash251git diff "$(git merge-base main HEAD)"..HEAD --name-only252```253254Filter:255256- deleted files,257- binary files,258- generated output,259- vendored directories,260- lockfiles unless they are the requested surface.261262List final scope before cleanup.263264### Phase 2: Lock behavior265266For each in-scope source file:2672681. Identify observable behavior.2692. Find existing tests.2703. Add a characterization test if coverage is weak.2714. Run the relevant test and confirm it is green before editing.272273If no green baseline can be established, stop and report. Do not clean uncovered behavior.274275### Phase 3: Cleanup plan276277For each file, list categories and order:278279```text280File: path281Categories: comments, dead code, defensive282Order: comments -> dead code -> defensive283Risk: low284Behavior lock: command/test id285```286287### Phase 4: Parallel cleanup288289For multiple independent files, use Antigravity subagents in batches of up to five.290291Per-file lane message should include:292293- exact file,294- categories to evaluate,295- behavior lock evidence,296- cleanup order,297- hard constraints,298- report format.299300Hard constraints for each lane:301302- preserve behavior,303- do not change public API signatures,304- do not remove type hints,305- do not introduce dependencies,306- skip uncertain performance changes,307- keep diff minimal.308309If a lane fails, collect successful lanes, retry the failed file once, then escalate.310311### Phase 5: Verify312313Run the quality gates. Then walk the critical review checklist:314315Safety:316317- no functional logic accidentally removed,318- all boundary error handling preserved,319- types and imports intact,320- public APIs stable.321322Behavior:323324- return values unchanged,325- side effects unchanged,326- exception behavior unchanged,327- edge cases preserved.328329Quality:330331- removed code was genuine slop,332- remaining code follows project conventions,333- no orphaned references,334- no subtle performance changes,335- no speculative abstraction added.336337### Phase 6: Fix issues338339If a gate fails:3403411. Identify the exact hunk.3422. Explain why it failed.3433. Revert only that hunk.3444. Apply a safer edit if genuine slop remains.3455. Re-run the failing gate.3466. Stop after repeated failure and report the file, attempts, and hypothesis.347348## Output Format349350```text351AI SLOP REMOVAL REPORT352======================353354Scope:355Files:356357Behavior Lock:358- Existing coverage:359- Tests added:360- Baseline status:361362Cleanup Plan:363- path: categories in order364365Per-File Results:366path367- Category: change summary368- Skipped: preserved for safety369370Quality Gates:371- Behavior lock:372- Regression tests:373- Full suite:374- Lint:375- Typecheck:376- Package surface:377- Manual QA:378- Review:379380Critical Review:381- Safety:382- Behavior:383- Quality:384385Issues Found & Fixed:386- None | details387388Remaining Risks / Deferred:389- None | details390391Final Status: CLEAN | ISSUES FIXED | REQUIRES ATTENTION392```393394## Anti-Patterns395396- Skipping behavior lock.397- Bundling unrelated refactors.398- Calling a performance change safe without obvious equivalence.399- Silently skipping gates.400- Removing comments that explain why.401- Touching files outside scope.402- Deleting tests or weakening assertions.403- Calling green tests completion without a real surface when users observe the behavior.404405## Final Rule406407When in doubt, skip the cleanup and report the suspected slop. False negatives are better than broken behavior.408409---410> Source: [wjgoarxiv/antigravity-swarm](https://github.com/wjgoarxiv/antigravity-swarm) — distributed by [TomeVault](https://tomevault.io).411<!-- tomevault:4.0:skill_md:2026-06-17 -->