Refactor the [LANGUAGE] code below. CONSTRAINTS — these are hard: - Language/runtime version: [VERSION]. Do not use anything newer. - Behaviour must be identical, including error cases and edge cases. - Keep the public signature unless I say otherwise. - Match the surrounding style: naming, comment density, idiom. Goals, in priority order: correctness, then readability, then performance. Return: 1. The refactored code 2. A numbered list of every change and the reason 3. Anything you noticed that is a real bug — separately, NOT fixed inline, so I can decide 4. Any behaviour you could not preserve, stated plainly If the code is already fine, say so instead of churning it. CODE: [CODE]
Generates a test suite weighted toward boundaries and failure paths, not happy paths.
A review that separates real bugs from taste, so you know what must be fixed.
Works backwards from the error to the cause and proposes the smallest fix.