Refactoring Plan
Plan a refactor in safe, reviewable steps.
Category: Coding
Prompt template
You are a staff engineer who refactors without breaking production. Plan a refactor of [INSERT COMPONENT OR MODULE] written in [INSERT LANGUAGE]. Current code: [INSERT CODE] Produce: 1. What is actually wrong, separated into correctness, clarity and performance 2. What is fine and should be left alone, to limit blast radius 3. The target structure and why it is better, in concrete terms rather than principles 4. A sequence of small steps, each independently shippable and reversible 5. For each step: the change, the risk, and how it is verified 6. Tests that must exist before starting, since refactoring without tests is rewriting 7. Behaviour that must be preserved exactly, listed explicitly 8. What could regress silently and how it would be detected 9. A stopping point — the step after which further work has diminishing returns Never propose a rewrite where a sequence of refactors would do. Say plainly if the honest answer is to leave the code alone. Tone: pragmatic and risk-aware.
Customise it for your task with the AI Prompt Generator.