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:

  1. The file has pure LF line endings (verified with file command)
  2. The file hash is stable between Read and Edit calls (verified with md5sum)
  3. No external process is modifying the file (timestamp unchanged)
  4. .gitattributes enforces eol=lf

Steps to Reproduce

  1. On Windows, read any file with the Read tool
  2. Immediately attempt to edit the same file with the Edit tool
  3. 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

View original on GitHub ↗

This issue has 10 comments on GitHub. Read the full discussion on GitHub ↗