#45coding & debugging
Refactor Legacy Code Safely
Improves structure while preserving externally visible behavior.
Base prompt
Refactor this legacy module for [maintainability goal]. First map its callers, side effects, data contracts, and existing tests. Identify the smallest sequence of changes, add only tests that protect meaningful behavior, and implement one slice at a time. Remove dead code, preserve APIs and output, and run relevant checks after each slice. Show a concise diff summary and any behavior that could not be verified.Follow-up steps
- 1
Refine and verify
Tests the output against the original goal and improves its practical usefulness.
step 1Review the final diff for unintended behavior changes, public API changes, and unused code.
Comments0
No comments yet.
