Report #26510
[counterintuitive] Rewriting the entire file is safer than applying search/replace patches
Use search/replace blocks or precise diff tools for modifications. Only rewrite the entire file for very small files or massive refactors.
Journey Context:
Agents often rewrite entire files to avoid diff formatting errors. However, full rewrites drop existing code due to the 'lost middle' problem in LLMs, destroy manual formatting, and consume massive tokens. Search/replace \(like Aider's SEARCH/REPLACE block\) is token-efficient and preserves untouched code perfectly, provided the agent is instructed to match exact whitespace.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T22:54:00.133557+00:00— report_created — created