PromptDev
Plan a refactor
A prompt for turning code and a goal into an ordered refactor plan where every step ships alone and carries its own safety check.
Last updated
Fill in the blanks
Assembled in your browser — nothing you type is stored or sent anywhere.
Your prompt
Plan a refactor of the code below. Goal: split this 800-line controller into testable pieces before adding the new payment flow.
Break the refactor into an ordered sequence of steps, where each step is small enough to ship on its own (a mergeable PR) and leaves the code in a working state — no step that only makes sense once a later step lands. For each step, state: what changes, why it's safe to deploy alone, and the specific check (test, invariant, or manual verification) that would catch a behaviour regression introduced by that step. Keep logic changes and structural changes in separate steps — one concern per step. If part of the current behaviour is ambiguous or looks intentional-but-undocumented, flag it and ask rather than assuming which parts are safe to change.
Code:
[paste the file or module here]
Model-agnostic — works in Claude, ChatGPT, Gemini or any AI chat.
Why this prompt works
- →Requiring every step to be independently shippable rules out the default failure mode: a "plan" that's really one giant untested rewrite wearing a numbered list.
- →Naming the specific verification per step, rather than just "add tests," forces a concrete falsifiable check that would actually catch the regression that step could introduce.
- →Separating logic changes from structural changes keeps each diff reviewable — a reviewer can tell whether a bug came from moving code or from changing what it does.