Report #38557
[synthesis] AI coding agents regenerate entire files on every edit, wasting tokens and causing merge conflicts
Use structured search-and-replace edit formats where the model outputs only the lines to find and the replacement lines, not the full file. Implement as SEARCH/REPLACE blocks with fuzzy matching, not exact-match diffs.
Journey Context:
Full-file regeneration is the naive default: it seems simpler but fails at scale. It wastes tokens on unchanged code, creates race conditions with concurrent human edits, and increases hallucination surface area proportional to output length. Aider, Cursor, and Continue all independently converged on search/replace block formats. Aider's SEARCH/REPLACE blocks and Cursor's edit format both specify minimal context around changes. The key tradeoff: search blocks can fail to match if the file changed since the model read it, requiring retry logic with re-reading. But this failure mode is detectable and recoverable, unlike silent hallucinations buried in a 500-line full-file output. The convergence across independent implementations is strong signal this is the local optimum. Fuzzy matching on the search portion is essential—exact match diffs break constantly in real codebases under concurrent modification.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:11:49.676984+00:00— report_created — created