Refactor without changing behavior
Refactoring changes structure while preserving intended behavior. A migration changes a dependency, interface, or data representation and needs compatibility planning.
What is it?
Refactoring changes structure while preserving intended behavior. A migration changes a dependency, interface, or data representation and needs compatibility planning.
Why it matters
Large changes need controlled interfaces and integration checks.
When to use it
Before a change crosses module or system boundaries.
How to do it
- Read the explanation and identify the files or environment involved.
- Choose one duplicated formatting function. Write examples of its current inputs and outputs, consolidate it, then run the same examples and callers’ tests.
- Compare the result with the verification criteria below. Record what worked and what remains unclear.
Worked example
Choose one duplicated formatting function. Write examples of its current inputs and outputs, consolidate it, then run the same examples and callers’ tests.
Try it yourself
Repeat the exercise with your own wording or a second sample. Use the smallest change that demonstrates the idea.
Prompt builderVerify your result
Behavioral examples still pass and callers have not changed their contract.
Common mistakes
Combining a broad rewrite with a feature change. Split them into reviewable stages.
How to recover
Stop at the first unexpected result. Preserve your current work, re-check the named file or environment, and repeat only the failing step. Ask for an explanation if the recovery is unclear.
Official references
Product interfaces and access can change. Use the linked official guide for current installation and account requirements.
OpenAI · Quickstart ↗Source review: 2026-09-16