From nextc-core
Bounded, regression-safe code cleanup with deletion-first workflow. Use after a coding session that left dead code, duplicates, over-abstraction, or bloat. Also use when the user says "clean up", "simplify", or "remove cruft".
How this skill is triggered — by the user, by Claude, or both
Slash command
/nextc-core:cleanupThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Bounded, regression-safe code cleanup that removes AI-generated slop without
Bounded, regression-safe code cleanup that removes AI-generated slop without changing behavior. Deletion-first workflow: classify the mess, remove dead code, consolidate duplicates, flatten needless abstractions — one pass at a time.
/bugfix first, then cleanupDetermine scope from {{ARGUMENTS}}:
git diff --name-only HEAD~10)Read all files in scope — understand current state before touching anything
Classify the slop into 5 categories. For each, list specific instances with file:line:
| Category | What to Look For | Priority |
|---|---|---|
| Dead code | Unused imports, unreachable branches, commented-out code, stale feature flags, debug leftovers, unused variables/functions | 1 (safest to remove) |
| Duplication | Copy-paste logic, repeated patterns, redundant helpers doing the same thing | 2 |
| Needless abstraction | Pass-through wrappers, single-use helper layers, speculative indirection, "just in case" generalization | 3 |
| Boundary violations | Hidden coupling, wrong-layer imports, misplaced responsibilities, side effects in unexpected places | 4 |
| Naming & clarity | Misleading names, confusing parameter order, inconsistent conventions within the same module | 5 (lowest risk) |
Present the classification to the user:
## Cleanup Scope: {N} files
### Dead Code (Priority 1) — {count} instances
- `file.dart:42` — unused import `package:foo`
- `file.dart:89-102` — unreachable branch after early return
- `helper.dart` — entire file unused (0 references in lib/)
### Duplication (Priority 2) — {count} instances
- `screen_a.dart:30-45` and `screen_b.dart:22-37` — identical error handling
- `provider_a.dart:load()` and `provider_b.dart:fetch()` — same Supabase query pattern
### Needless Abstraction (Priority 3) — {count} instances
- `wrapper_service.dart` — passes through to repository with no added logic
### Boundary Violations (Priority 4) — {count} instances
- `widget.dart:15` — imports repository directly, bypassing provider
### Naming (Priority 5) — {count} instances
- `data` variable in `feed_provider.dart:67` — unclear what data it holds
Estimated cleanup: {small / medium / large}
Ask: "This is what I found. Should I clean all categories, specific ones, or adjust scope?"
Options:
Run passes in priority order. Each pass is self-contained — verify after each one.
flutter analyze (or equivalent) — no new errors introducedflutter analyze — no broken referencesflutter analyze — no new errorsflutter analyze — no new errorsflutter analyze — no new errorsAfter EACH pass:
After all passes complete:
## Cleanup Report
### Files Modified
- `file_a.dart` — removed 3 dead imports, inlined unused helper
- `file_b.dart` — consolidated duplicate error handler
- `wrapper_service.dart` — deleted (was a pass-through wrapper)
### Summary
| Category | Instances Found | Cleaned | Skipped (with reason) |
|----------|----------------|---------|----------------------|
| Dead code | 8 | 8 | 0 |
| Duplication | 3 | 2 | 1 (cross-module, needs broader refactor) |
| Abstraction | 2 | 2 | 0 |
| Boundary | 1 | 1 | 0 |
| Naming | 4 | 4 | 0 |
### Lines Removed: {net lines removed}
### Verification: flutter analyze — 0 issues
### Remaining Concerns
- {anything skipped and why}
- {anything that needs a broader refactor beyond cleanup scope}
Spawn doc-keeper in background if cleanup changed behavior documented in docs/.
If invoked with --review argument:
This mode is for auditing code quality without making changes.
If invoked with specific file paths:
/cleanup lib/providers/quest_feed_provider.dart lib/features/quest_feed/
Common AI-generated code smells to watch for:
| Smell | Example | Fix |
|---|---|---|
| Defensive overreach | Null checks on non-nullable types | Remove — the type system guarantees it |
| Wrapper theater | UserService that just calls UserRepository with zero added logic | Delete wrapper, use repository directly |
| Comment narration | // Get the user above getUser() | Remove — the code is self-documenting |
| Speculative generics | BaseProvider<T> used by exactly one provider | Inline — generalize when you have 3+ cases |
| Error message duplication | Same "Something went wrong" string in 10 files | Extract to shared constant or l10n key |
| Import hoarding | 15 imports, 6 unused | Remove unused imports |
| Dead parameter | Function accepts context but never uses it | Remove parameter, update call sites |
| Copy-paste divergence | Two functions that were copy-pasted and slightly modified | Extract shared logic, parameterize differences |
| Premature abstraction | WidgetFactory that builds exactly one widget type | Inline the widget directly |
| Log-and-throw | Catches error, logs it, throws a new error (loses stack trace) | Log and rethrow original, or handle without rethrowing |
Task: {{ARGUMENTS}}
npx claudepluginhub nextc/nextc-claude --plugin nextc-coreRemoves dead fields, redundant wrappers, stale config, and speculative abstractions while working on nearby code. Use for internal hygiene during active commits, not public API removal.
Detects and eliminates dead code, duplicates, unused imports, magic numbers, naming issues, and code smells using TRIZ principles. Run after features, before PRs, during debt sprints.
Cleans AI-generated code by systematically removing LLM smells like dead code, over-commenting, verbose naming while preserving exact behavior via tests. Use after generation or on 'clean up', 'deslop' requests.