Report #2415
[agent\_craft] Agent rewrote an entire file for a one-line fix, losing formatting and git history clarity
Use str\_replace / Edit with an exact old\_string and new\_string for small changes. Reserve whole-file Write for new files or complete rewrites, and always verify the replacement matched exactly one location.
Journey Context:
Anthropic's text editor tool provides str\_replace for precise edits. Exact-match replacement preserves indentation, line endings, surrounding code, and diff readability. Whole-file overwrites are easy for the model but destroy fine-grained history, increase the chance of introducing unrelated changes, and can fail silently on encoding or line-ending mismatches.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T11:53:43.974623+00:00— report_created — created