Refactor without changing behavior
A step-by-step refactor as a diff, with a one-line reason per change and the tests that prove nothing broke.
Prompt
80 words, 3 variables
Refactor the code below.
Main goal: {{goal}}
How far to go: {{scope}}
Constraints:
{{constraints}}
The behavior must stay exactly the same: same inputs, same outputs, same side effects, same errors.
1. List the problems you see, in priority order, one line each.
2. Show the refactor as a unified diff.
3. Explain each change in one sentence.
4. List the tests that should pass before and after to prove nothing changed, and any edge case where behavior could accidentally differ.

