How Coding Agents Edit Files: Diffs, Snapshots, and Fast Apply
Kondasamy Jayaraman
Coding agents often break not on reasoning, but when they write files. The fix is a tug-of-war between diffs, snapshots, and faster merge models.
Based on reporting by Kondasamy Jayaraman — read the original for the full story.
Summary, retelling and take written by AI under human oversight; images are AI-generated illustrations. How we work · Report an error
The ugly part of coding agents is not the thinking. It’s the moment they touch disk. A model can design a clean refactor, handle edge cases, and still blow up on a 1,200-line file by miscounting line numbers, dropping braces, or mangling indentation. That boundary between planning and file editing is where a lot of the pain lives.
The source breaks modern tools into four ways of changing code: full rewrites, search-and-replace blocks, snapshot-anchored edits, and speculative fast apply. Each one is trying to dodge a different failure mode. Unified diffs look precise, but they force the model to do arithmetic it is bad at. Aider’s own benchmarks show that forcing strict unified diffs on complex files cut task completion from 59% to 26%. The same source says rewriting a 1,500-line file to change three lines can take about 5,000 tokens and 15 to 25 seconds.
So a lot of tools moved toward search-and-replace. Aider uses SEARCH and REPLACE blocks, where the harness finds the old text and swaps in the new text. Claude Code goes even stricter: its str_replace call only works when old_str matches one unique place in the file, and it rejects ambiguous matches like a plain return null;. OpenCode takes a different route, with a nine-stage matcher that relaxes from exact matches to whitespace-normalized and indentation-flexible passes, then runs formatters and LSP diagnostics after the edit.
The more defensive systems try to keep stale edits from landing on the wrong code. Oh My Pi uses Hashline snapshot tags and AST-aware PUT operations so it can reject writes if the file changed since the read. DeepSeek Harness does something similar in evaluation, using str_replace_editor and then synthesizing a final patch. And at the fast end, Cursor Instant Apply and Morph Fast Apply split the job in two: one model reasons about the change, another merges it quickly, with the source claiming speeds around 1,000 to 10,500+ tokens per second and high accuracy on file merges.
The pattern is pretty clear. Coding agents are less limited by “thinking” than by file surgery. The winning systems do not just generate better code; they choose a less stupid way to land it.
My take — AI-written commentary, not fact-checked reporting
This is the part of AI coding that matters most: not bigger models, better plumbing. The industry keeps selling brains, but the real product is a merge tool that won’t embarrass itself on tabs, hashes, and stale state. Open models still need better systems around them; otherwise they’re just confident interns with a patch command.
Read more about this at: Kondasamy Jayaraman