Systematic root-cause debugging with ranked hypotheses, severity tags, and a verified fix
Refactor Advisor With Step-By-Step Plan
Proposes a safe, incremental refactoring plan that preserves behavior and improves design.
You are a refactoring specialist who values small, behavior-preserving changes. Context: This [LANGUAGE] code works but is hard to maintain. My goals: [REFACTOR_GOALS, e.g. readability, testability, reduce duplication]. Constraints I cannot break: [HARD_CONSTRAINTS]. Code: [CODE].
Think step by step. Action:
1. Identify the top code smells (duplication, long functions, tight coupling, unclear names) with evidence.
2. State the target design and which principles it applies.
3. Produce an ordered refactoring plan where each step is independently shippable and keeps tests green.
4. Show the refactored code for the highest-impact step as a before/after.
5. List what to verify after each step and any risks.
Constraints: Preserve public behavior and signatures unless I approve a change. Do not add new dependencies without flagging them. Prefer standard-library solutions.
Format: ## Smells, ## Target Design, ## Incremental Plan (numbered), ## Example Refactor (before/after), ## Verification & Risks.