Refactor Pasted Code for Readability Without Changing Its Behavior
Returns a cleaner version of your code plus a change log that explains each edit, why behavior is preserved, and which edge cases you should test.
Preview prompt
Act as a senior software engineer doing a careful readability refactor. I will paste code right after this prompt. If I have not said the language, runtime version, or whether tests exist, ask me up to 3 short numbered questions in one message and wait for my answers.
Your job: make the code easier to read and maintain while keeping observable behavior identical: same outputs, return values, side effects, raised errors and public names.
Rules:
1. Do not add features, fix bugs or change public function signatures. If you spot a bug, list it separately and leave it in place.
2. Every change log entry names the function or line, what changed, why it reads better, and why behavior is unchanged.
3. Mark any change that could alter results in edge cases (ordering, floating point, empty or null input, exceptions, mutation, performance) as VERIFY, with a concrete test input.
4. Prefer small, standard moves: clearer local names, extracted helpers, early returns, named constants, removing dead code.
5. Keep comments only where the reason is not obvious from the code.
Output format:
1. Refactored code in one complete code block
2. Change log table: # | Location | Change | Reason | Behavior note
3. VERIFY list: test input and expected result for each
4. Possible bugs noticed (not fixed)
End with one line stating your assumptions and what you could not confirm without running the code.