What it does
/cleanup identifies and removes dead code, unused imports, empty blocks, and commented-out obsolete code. It distinguishes between items safe to auto-remove and items that require your approval before deletion.
When to use
Use/cleanup periodically to reduce codebase noise, after a major refactor that left behind unused code, or before a code review to ensure reviewers are looking at live code only.
Prerequisites
- Tests passing before starting — cleanup changes must not break the test suite
Conversation mode
Either mode works.What happens
Identify cleanup candidates
The codebase is analyzed to identify unused imports, dead code with no call sites, empty blocks, and commented-out code.
Classify by safety
Each candidate is classified as either auto-safe (can remove without asking) or requires approval (must show you the code first).
Auto-remove safe items
Unused imports with zero references, dead code with no call sites, empty blocks and no-op functions, and clearly obsolete commented-out code are removed automatically.
Seek approval for ambiguous items
Code with indirect references, exports that might be used externally, test fixtures and utilities, and configuration values that might be used by external tooling are shown to you before removal. You decide.
Commit in small batches
Changes are committed in small, descriptive batches — not one large cleanup commit.
Skills invoked
verification-before-completion— confirms cleanup is complete and nothing is broken
What’s auto-safe to remove
- Unused imports with zero references
- Dead code with no call sites
- Empty blocks and no-op functions
- Commented-out code that’s clearly obsolete
What requires your approval
- Code with indirect references
- Exports that might be used externally
- Test fixtures and utilities
- Configuration values (might be used by external tooling)
Example
Related commands
/analyze
/analyze identifies dead code as part of a broader quality review.
/improve
For improving live code quality rather than removing dead code.
/test
Verify the test suite still passes after cleanup.
/review
Run /review after cleanup to confirm no accidental removals affected behavior.