Edit tool fails with 'File has been unexpectedly modified' on Windows even when file is unchanged
Resolved 💬 10 comments Opened Dec 3, 2025 by khadkutamaihaine Closed Feb 12, 2026
Environment
- Claude Code version: 2.0.57
- OS: Windows 10/11 (MINGW64_NT-10.0-26200)
- Git: With
core.autocrlf=true(global)
Description
The Edit tool consistently fails with "File has been unexpectedly modified" error on Windows, even when:
- The file has pure LF line endings (verified with
filecommand) - The file hash is stable between Read and Edit calls (verified with
md5sum) - No external process is modifying the file (timestamp unchanged)
.gitattributesenforceseol=lf
Steps to Reproduce
- On Windows, read any file with the Read tool
- Immediately attempt to edit the same file with the Edit tool
- Error occurs: "File has been unexpectedly modified"
Investigation Results
# File state between Read and Edit:
$ file pyproject.toml
pyproject.toml: ASCII text # No CRLF
$ md5sum pyproject.toml # Before Read
01adcf30cef4009c1e2045c156f7b7d6
$ md5sum pyproject.toml # After Read, before Edit
01adcf30cef4009c1e2045c156f7b7d6 # IDENTICAL - file unchanged
$ git ls-files --eol pyproject.toml
i/lf w/lf attr/text eol=lf # Both index and working dir have LF
Workaround
Use python -c or cat >> via Bash tool instead of Edit tool:
python -c "content='...'; open('file.md','a').write(content)"
Hypothesis
The Edit tool's internal checksum mechanism may be caching content incorrectly or comparing against a stale version on Windows. The error occurs even when:
- File content is byte-for-byte identical (same md5sum)
- No CRLF/LF conversion is happening
- File timestamps are stable
This issue has 10 comments on GitHub. Read the full discussion on GitHub ↗