Report #59076
[synthesis] AI code edits overwrite user context or break existing code
Implement a shadow git workspace and generate structured search/replace diffs rather than full file rewrites.
Journey Context:
The naive approach to AI coding is to ask the LLM to rewrite the entire file. This fails on large files due to context limits and truncation, and destroys uncommitted local changes. Cursor's architecture and Aider's approach both reveal the winning pattern: the LLM should output structured edit blocks \(e.g., SEARCH/REPLACE or Apply blocks\). The outer system applies these patches in a shadow git workspace, computes a diff, and presents the diff to the user for approval. This preserves the user's unstaged changes and allows granular rollback.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:39:01.631910+00:00— report_created — created