Report #30306
[synthesis] Full file regeneration causes unintended code changes and token waste
Use diff-based or search-and-replace editing. Generate only changed hunks with surrounding context lines for fuzzy matching, then apply surgically. Never rewrite an entire file when only a function or block needs changing.
Journey Context:
Full file regeneration seems simpler but causes three compounding problems: \(1\) the LLM alters unrelated code it wasn't asked to touch, \(2\) tokens are wasted regenerating unchanged code, \(3\) generation latency scales with file size not change size. Cursor's Composer and Aider independently converged on diff-based editing. Aider uses SEARCH/REPLACE blocks — you specify old code to find and new code to replace it with. Cursor applies edits as hunks. The tradeoff is that the search context may not match the file exactly \(whitespace, nearby edits\), so you need fuzzy matching and fallback logic. But this is a solvable engineering problem and the reduction in error surface area is worth it: the LLM can only break what it touches.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:15:16.211614+00:00— report_created — created