Safely identify and remove dead code with test verification at every step.
From clarcnpx claudepluginhub marvinrichter/clarc --plugin clarc/refactorOrchestrates refactoring for specified scope: assesses architecture and issues, plans incremental transformations with risk mitigation, provides code change guides with examples, validation tests, and monitoring plan.
/refactorSystematically refactors specified code area: identifies smells, ensures test coverage, plans and applies atomic changes with per-step verification.
/refactorPerforms safe incremental refactoring on code, scores SOLID principles compliance (0-100 total), detects smells via grep/bash, visualizes technical debt, and prioritizes fixes with examples.
/refactorPerforms safe incremental refactoring on identified code issues; scores SOLID compliance (0-100 per principle); visualizes technical debt and prioritizes fixes.
/refactorSafely refactors code gradually, quantitatively scores SOLID principles adherence (0-100 per principle), detects smells and debt, and prioritizes improvements with techniques like Extract Method.
/refactorRefactors code step-by-step using techniques like Extract Method and polymorphism, scores SOLID principles quantitatively, visualizes technical debt, and prioritizes improvements.
Safely identify and remove dead code with test verification at every step.
This command delegates to the refactor-cleaner agent, which runs analysis tools (knip, depcheck, ts-prune, vulture) to identify dead code, presents a dry-run plan for confirmation, and only then removes code with test verification at every step.
Run analysis tools based on project type:
| Tool | What It Finds | Command |
|---|---|---|
| knip | Unused exports, files, dependencies | npx knip |
| depcheck | Unused npm dependencies | npx depcheck |
| ts-prune | Unused TypeScript exports | npx ts-prune |
| vulture | Unused Python code | vulture src/ |
| deadcode | Unused Go code | deadcode ./... |
| cargo-udeps | Unused Rust dependencies | cargo +nightly udeps |
If no tool is available, use Grep to find exports with zero imports:
# Find exports, then check if they're imported anywhere
Sort findings into safety tiers:
| Tier | Examples | Action |
|---|---|---|
| SAFE | Unused utilities, test helpers, internal functions | Delete with confidence |
| CAUTION | Components, API routes, middleware | Verify no dynamic imports or external consumers |
| DANGER | Config files, entry points, type definitions | Investigate before touching |
For each SAFE item:
git checkout -- <file> and skip this itemBefore deleting CAUTION items:
import(), require(), __import__After removing dead code, look for:
Report results:
Dead Code Cleanup
──────────────────────────────
Deleted: 12 unused functions
3 unused files
5 unused dependencies
Skipped: 2 items (tests failed)
Saved: ~450 lines removed
──────────────────────────────
All tests passing ✅
/tdd — add or update tests after refactoring/code-review — review refactored code/verify — confirm build + tests pass after refactor