claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

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

Open ManuelMRosa opened this issue 2 months ago • 5 comments

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:

  1. The file was just read moments before
  2. No other processes are modifying the file
  3. Multiple retry attempts with fresh reads all fail

Steps to Reproduce

  1. Read a markdown file (e.g., SESSION_LOG.md)
  2. Immediately attempt to Edit the same file
  3. 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

ManuelMRosa avatar Nov 25 '25 05:11 ManuelMRosa

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/11976
  2. https://github.com/anthropics/claude-code/issues/10437
  3. 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

github-actions[bot] avatar Nov 25 '25 05:11 github-actions[bot]

This is happening to me and is incredibly annoying. Happening on VSCode and Terminal...

notstat avatar Nov 25 '25 16:11 notstat

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.

gbahns avatar Nov 25 '25 17:11 gbahns

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)

WeOnlyDoParts avatar Nov 28 '25 22:11 WeOnlyDoParts

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.

github-actions[bot] avatar Dec 29 '25 10:12 github-actions[bot]

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:

WeOnlyDoParts avatar Dec 30 '25 02:12 WeOnlyDoParts

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.

WeOnlyDoParts avatar Dec 30 '25 02:12 WeOnlyDoParts

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.

webmasterfsd avatar Jan 01 '26 03:01 webmasterfsd