Edit tool fails with 'File has been unexpectedly modified' even immediately after Read

Resolved 💬 3 comments Opened Jan 27, 2026 by JeanStiletto Closed Jan 31, 2026

Version: Claude Code 2.1.1, Windows 10/11

Description

The Edit tool repeatedly failed with "File has been unexpectedly modified" for a specific file path, even when called immediately after a successful Read of that same file. The issue persisted across multiple Read→Edit attempts.

Steps that preceded the issue

  1. Multiple Grep calls targeting the file (src/Core/Models/Strings.cs)
  2. Read with offset/limit parameters
  3. Edit attempt → Error: "File has been unexpectedly modified"
  4. Fresh Read (full file) → Edit → Same error
  5. Repeated 5-6 times, always failing

Key observations

  • Copying the file to a new path and editing the copy worked immediately
  • Fresh test files (create → read → edit) worked fine
  • The original file eventually started working after external modification via PowerShell
  • Suggests internal per-path hash/state got corrupted

Expected behavior

Edit should succeed after a fresh Read of the same file

Additional context

  • File had CRLF line endings (verified), no BOM
  • File size: ~21KB, 361 lines
  • No external processes were modifying the file
  • Issue was specific to one file path - identical content at different path worked

View original on GitHub ↗

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