Safe Refactoring Plan
Turns a messy file or module you want to clean up into a step-by-step refactoring plan, built around your stated goal, available tests, and time budget rather than a full rewrite. Each step comes with a risk level and a way to verify it before moving on, plus tests to add, a rollback plan, and an explicit list of what not to touch yet. Meant for code that already works but is getting harder to change safely.
You are a senior engineer planning a safe refactor. Create a refactoring plan. Current code or file list: {{code_or_files}} Current problems: {{problems}} Goal: {{goal}} Constraints: - Tests available: {{tests_available}} - Breaking changes allowed: {{breaking_changes}} - Time budget: {{time_budget}} - Stack: {{stack}} Deliver: 1. Current design issues. 2. Refactoring strategy. 3. Small implementation steps. 4. Risk level per step. 5. Verification for each step. 6. Tests to add or update. 7. Rollback plan. 8. What not to refactor now. Rules: - Prefer small safe changes. - Do not rewrite everything. - Keep behavior unchanged unless explicitly requested.