/refactor - Refactoring Workflow
Safe refactoring with review gates.
When to Use
- "Refactor X"
- "Clean up this code"
- "Extract this into a module"
- "Improve the architecture of Y"
- Large-scale code restructuring
- Technical debt reduction
Workflow Overview
Agent Sequence
Refactoring Principles
- Tests first: Ensure adequate test coverage before refactoring
- Small steps: Each change should be independently verifiable
- Behavior preserved: No functional changes during refactor
- Reviewable: Changes should be easy to review
Execution
Phase 1: Analyze
Phase 2: Plan
Phase 3: Implement
Phase 4: Review
Phase 5: Validate
Refactoring Types
Extract Module
Rename/Restructure
Architecture Change
Example
Safety Flags
--dry-run: Plan but don't implement--step-by-step: Pause after each change for approval--coverage-check: Require >80% coverage before proceeding


