Report #2406
[agent\_craft] File edit rejected or file corrupted because the agent edited from memory instead of reading first
Call Read \(or view/view\_range\) on the exact file and line range before every Edit/Write. If the file is large, read only the surrounding lines you will change; never assume you remember the current content.
Journey Context:
Claude Code enforces a read-before-edit rule: even if the prompt includes the exact path and content, the editor tool rejects edits unless the file has been read in the current session. Editing from memory risks stale old\_string, partial replacements, and overwriting concurrent changes. Reading the target region first guarantees the replacement anchor exists and matches, and it is far cheaper than re-reading the whole file. The same discipline applies to any agent using a str\_replace-style editor.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T11:53:43.182249+00:00— report_created — created