Edit tool fails with 'File has been unexpectedly modified' immediately after Read
Description
When attempting to edit a file immediately after reading it, the Edit tool fails with:
File has been unexpectedly modified. Read it again before attempting to write it.
This happens even when:
- The file was just read moments before
- No other processes are modifying the file
- Multiple retry attempts with fresh reads all fail
Steps to Reproduce
- Read a markdown file (e.g., SESSION_LOG.md)
- Immediately attempt to Edit the same file
- Error occurs even though file content hasn't changed
Environment
- Claude Code version: Latest
- Model: claude-opus-4-5-20250929
- OS: Windows 10/11
- File type: Markdown (.md)
Expected Behavior
Edit should succeed when file content matches what was just read.
Actual Behavior
Edit fails repeatedly claiming file was modified, even with immediate retry after fresh read.
Workaround
None found - had to abandon the edit operation.
Generated with Claude Code
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/11976
- https://github.com/anthropics/claude-code/issues/10437
- https://github.com/anthropics/claude-code/issues/11684
This issue will be automatically closed as a duplicate in 3 days.
- If your issue is a duplicate, please close it and 👍 the existing issue instead
- To prevent auto-closure, add a comment or 👎 this comment
🤖 Generated with Claude Code
This is happening to me and is incredibly annoying. Happening on VSCode and Terminal...
happening to me a lot too. sometimes it'll be fine, then all of a sudden I start getting these errors and don't see way to make them stop.
Getting this quite a bit as of this morning (just updated to 2.0.55 - I think I was still on 2.0.52 until restarting this morning)
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
Just received this error several times. Version 2.0.76.
Update(supercharge_comparison_v2.py) ⎿ Error: File has been unexpectedly modified. Read it again before attempting to write it.
● Read(supercharge_comparison_v2.py) ⎿ Read 82 lines
● Update(supercharge_comparison_v2.py) ⎿ Error: File has been unexpectedly modified. Read it again before attempting to write it.
● Read(supercharge_comparison_v2.py) ⎿ Read 611 lines
● Update(supercharge_comparison_v2.py) ⎿ Error: File has been unexpectedly modified. Read it again before attempting to write it.
● The file keeps getting modified externally. Let me just run a quick analysis directly:
I read in similar issues that telling Claude to use backslashes instead of forward slashes in Windows paths, this fixes the issue. I just tested and this appears to be true.
I'm getting the same error, Error: File has been unexpectedly modified. Read it again before attempting to write it.
Actually, the issue started when the conversation has compacted automatically or manually. Once it is compacted, the issue has started.