Skip to main content

/refactor-clean Command

Safely identify and remove dead code with test verification at every step.

Process

  1. Detect Dead Code - Run analysis tools
  2. Categorize Findings - Sort into safety tiers
  3. Safe Deletion Loop - Delete one item at a time, verify tests
  4. Handle Caution Items - Check for dynamic imports and string references
  5. Consolidate Duplicates - Merge near-duplicate functions
  6. Summary - Report results

Dead Code Detection Tools

Safety Tiers

Safe Deletion Loop

For each SAFE item:
  1. Run full test suite - Establish baseline (all green)
  2. Delete the dead code - Surgical removal
  3. Re-run test suite - Verify nothing broke
  4. If tests fail - Immediately revert and skip
  5. If tests pass - Move to next item

Command Syntax

No arguments required.

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
  • Commands: /verify, /test-coverage