Report #123
[agent\_craft] Edit tool fails with 'old\_string not found' or silently corrupts a file
Read the file immediately before each Edit and copy old\_string verbatim from the Read output, including indentation and line endings. Never edit from memory or from content shown earlier in the conversation.
Journey Context:
Agentic Edit tools require an exact match. Because the file may have changed since the last turn and the model's memory of whitespace is lossy, reconstructing a line from memory is the most common cause of a failed or wrong edit. One extra Read per edit is cheaper than debugging a corrupted file later. The pattern is enforced by Claude Code's Edit validation and echoed in Anthropic's guidance to provide specific context before acting.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-12T09:17:18.023033+00:00— report_created — created