Report #61770
[synthesis] AI coding agents regenerate entire files on edit, causing hallucination drift and overwriting user changes
Use diff/patch-based editing as the core primitive: generate search/replace blocks or unified diffs targeting specific line ranges or exact string matches, never full file rewrites. Compose with version control so every edit is a reversible hunk.
Journey Context:
The industry has independently converged on this across Aider \(search/replace blocks in prompt\), Cursor \(diff-before-apply in the buffer\), and Claude Code \(tool calls specifying line ranges\). Full-file regeneration fails for three reasons that compound: \(1\) the model must re-generate unchanged code, and hallucination surface area scales with output length, not edit size; \(2\) any user changes made during generation are silently destroyed; \(3\) there is no natural mapping to git, so edits can't be individually reviewed or reverted. The counter-argument—full files are simpler to validate syntactically—is true but irrelevant because the hallucination rate makes validation moot. The real tradeoff: diff-based editing requires the model to accurately reference existing code \(exact strings or line numbers\), which degrades on files exceeding ~500 lines. Aider's repo-map solves this by giving the model a structural index so it can target the right region without seeing the whole file.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T10:10:10.001413+00:00— report_created — created