Create a structured execution plan for refactoring code
Creates a step-by-step refactoring plan with analysis, preparation, execution, and validation phases. Use this before making structural code changes to ensure safe, incremental refactoring with proper test coverage.
/plugin marketplace add vavasilva/ralph-planner/plugin install ralph-planner@ralph-plannerCreate a structured execution plan for refactoring code.
description (required): Description of the refactoring goalYou are a planning assistant. Create a structured plan for refactoring: "$ARGUMENTS"
Generate a plan with these specific phases:
## Plan: Refactor [Component/area from description]
### Phase 1: Analysis
**Tasks:**
- [ ] Map current code structure and dependencies
- [ ] Identify specific improvements to make
- [ ] Document current behavior (what must NOT change)
- [ ] Identify risks and potential breaking changes
**Completion Criteria:** Current state documented, target state defined, risks identified
### Phase 2: Preparation
**Tasks:**
- [ ] Ensure adequate test coverage exists for affected code
- [ ] Add missing tests if coverage is insufficient
- [ ] Create backup/branch for safety
- [ ] Run all tests to establish baseline (all must pass)
**Completion Criteria:** Test coverage sufficient, all tests passing before changes
### Phase 3: Refactor
**Tasks:**
- [ ] Apply changes incrementally (small commits)
- [ ] [Specific refactoring tasks based on goal...]
- [ ] Run tests after each significant change
- [ ] Keep behavior identical - only structure changes
**Completion Criteria:** Refactoring complete, code matches target structure
### Phase 4: Validation
**Tasks:**
- [ ] Run full test suite
- [ ] Verify no functional behavior changes
- [ ] Review code meets stated goals
- [ ] Check performance hasn't degraded
**Completion Criteria:** All tests pass, behavior unchanged, goals met
---
**Total Tasks:** [count]
**Estimated Iterations:** [count × 3]
🏷️ **Promise Tag:** I will complete this refactoring when:
- All existing tests still pass
- No functional behavior has changed
- Code structure meets the stated goals
- No performance degradation
⚠️ **Completion Signal:** When ALL criteria above are met, output:
<promise>COMPLETE</promise>
IMPORTANT: Always include DONE condition with verifiable promises!
Ready to execute? Run:
/ralph-wiggum:ralph-loop [estimated iterations] "Refactor: [component]. DONE when: all existing tests pass, no behavior changes, code meets target structure"
/refactorRealiza refatoração segura e gradual de código, avaliando quantitativamente a aderência aos princípios SOLID. Visualiza dívida técnica e clarifica as prioridades de melhoria.