[BUG] File-watch mechanism invalidates read state between Read and Write/Edit tool calls
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
File-watcher mechanism invalidates "read" state between Read and Write/Edit tool calls, even when no external file
modifications have occurred. This makes iterative file editing workflows impossible.
The file-watcher issue we've been experiencing is definitely something that
should be reported to the Claude Code team, especially since:
- It's blocking normal iterative development workflows
- The "read" state is being invalidated even when no external changes occur
- It forces awkward workarounds like writing to temporary files
Actual Behavior
- Read state is cleared/invalidated between tool calls
- Every Write/Edit requires a fresh Read, even when no changes occurred
- Even reading again doesn't always help - subsequent Edit still fails with "unexpectedly modified"
What Should Happen?
- After reading a file, should be able to Edit or Write to it in the same session
- File-watcher should only invalidate read state when an actual external modification is detected
- Multiple Read→Edit cycles should work without issues
Error Messages/Logs
Steps to Reproduce
- Setup: Have a file in a Git repository (e.g., test.c)
- Step 1 - Read the file:
Use Read tool on test.c
Result: File contents successfully read
- Step 2 - Attempt to edit the file (same session, no external changes):
Use Edit tool on test.c to change one line
Result: Error "File has been unexpectedly modified. Read it again before attempting to write it."
- Alternative Step 2 - Attempt to write to the file:
Use Write tool on test.c with new contents
Result: Error "File has not been read yet. Read it first before writing to it."
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.25 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗