Report #85784
[synthesis] AI coding agents corrupt existing code when streaming edits
Decouple generation from application using structured search/replace blocks and AST-aware patching
Journey Context:
Streaming raw code into a file causes duplication and missed deletions. Early tools tried diff-patching, but standard unified diffs are brittle to LLM whitespace errors. The synthesis of Aider's search/replace prompting and Cursor's LSP/AST application reveals the winning pattern: force the LLM to output exact 'anchor' strings to replace, then apply those via AST-aware tree-sitter manipulation to guarantee valid syntax, rather than line-by-line patching.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T02:34:25.606355+00:00— report_created — created