/refactor-clean Command
Safely identify and remove dead code with test verification at every step.Process
- Detect Dead Code - Run analysis tools
- Categorize Findings - Sort into safety tiers
- Safe Deletion Loop - Delete one item at a time, verify tests
- Handle Caution Items - Check for dynamic imports and string references
- Consolidate Duplicates - Merge near-duplicate functions
- Summary - Report results
Dead Code Detection Tools
Safety Tiers
Safe Deletion Loop
For each SAFE item:- Run full test suite - Establish baseline (all green)
- Delete the dead code - Surgical removal
- Re-run test suite - Verify nothing broke
- If tests fail - Immediately revert and skip
- If tests pass - Move to next item
Command Syntax
Example Output
Rules
- Never delete without running tests first
- One deletion at a time - Atomic changes make rollback easy
- Skip if uncertain - Better to keep dead code than break production
- Don’t refactor while cleaning - Separate concerns
Related
- Commands:
/verify,/test-coverage