| name | refactor-clean |
| description | Remove dead code, unused dependencies, and reduce complexity. Invokes the refactor-cleaner agent. |
| user-invocable | true |
/refactor-clean - Dead Code Removal
Invoke the refactor-cleaner agent to clean up the codebase.
Usage
/refactor-clean # Full codebase scan
/refactor-clean src/ # Scan specific directory
/refactor-clean --deps # Focus on unused dependencies
/refactor-clean --imports # Focus on unused imports only
What Gets Cleaned
- Dead Code - Unused functions, variables, and exports
- Unused Dependencies - Packages in package.json not imported anywhere
- Unused Imports - Import statements with no references
- TODO/FIXME Audit - Stale comments that should be resolved or tracked
- Complexity Hotspots - Functions over 50 lines, files over 500 lines
Safety Guarantees
- Tests must pass before any refactoring begins
- One change at a time with test verification
- Code is removed completely (never commented out)
- All callers are verified before removing functions
- Refactoring commits are kept separate from feature commits
Output
## Refactoring Report
### Dead Code Found
| Type | Location | Action |
|------|----------|--------|
| Unused function | file:line | Removed |
| Unused import | file:line | Removed |
### Metrics
- Dead code removed: X lines
- Dependencies cleaned: Y packages
- Complexity reduced: Z functions simplified
When to Use
- After completing a feature (cleanup pass)
- Before major releases
- When onboarding new team members (reduce confusion)
- Periodically (monthly codebase hygiene)