Claude rewrote a whole file for a one-function change
The user asked for one localized change and explicitly prohibited unrelated edits; the model returned a shortened replacement file.
What the user wanted
The actual target
Add retry logic to one API function while preserving the rest of a working TypeScript file byte-for-byte where possible.
What they asked
The instruction
Modify only requestWithRetry(). Keep every other export and comment. Do not refactor. Return the complete file only if you preserve all untouched content.
What the AI produced
The observable result
A cleaner, shorter file that implemented retries but removed two exports, compressed comments, and reorganized shared helpers.
Why
Why WWW assigns this verdict
The request allowed a complete-file response only under a preservation condition. The output broke that condition. This is not a case where “do not refactor” was merely implied.
What gave it away
The retry logic was correct, but unrelated exports vanished. Success on the requested function does not cancel failure on the protected file scope.
Fix
What to do next
- Reject the replacement file and recover the original before merging anything.
- Ask for a patch scoped to the named function, then review the changed-line count.
- If a full file is unavoidable, require an explicit inventory of preserved exports before the code block.
Repaired instruction
A safer retry
Patch requestWithRetry() only. Add exponential backoff for 429 and 503 responses, with at most three attempts. Preserve every other line, export, import, comment, and function. Return a unified diff. Do not output a replacement file or perform cleanup unrelated to retry behavior.
Model recommendation
Stay, retry, or switch?
Claude can handle the task. The relevant next test is whether a patch-only retry respects the same boundary; switch tools only if the failure repeats.
General lesson
What survives this one case
Judge code edits by the entire diff, not only by whether the requested feature appears somewhere in the new file.