[BUG] Edit tool fails with "File has been unexpectedly modified" error immediately after Read
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?
The Edit tool consistently fails with "File has been unexpectedly modified" error even when using it immediately after a Read tool call, with no actual file modifications occurring
between the Read and Edit operations.
Environment
- OS: Windows 11
- Claude Code Version: [latest as of 2025-11-20]
- Editor: VS Code
- File System: NTFS
What Should Happen?
### Expected Behavior
The Edit tool should successfully apply the edit
when:
- The file content at edit time matches the
content that was read
- Only the specified
old_stringis being
replaced with new_string
- No other process has modified the actual file
content
The tool should use content-based verification
rather than timestamp-based verification. If the
file content matches what was read (or only has
the intended changes), the edit should proceed
regardless of mtime changes.
Error Messages/Logs
Steps to Reproduce
Reproduction Steps
- Use Read tool to read a file (e.g., MaterialMixingPanel.cpp)
- Immediately use Edit tool to modify the same file
- Error occurs: "File has been unexpectedly modified"
This happens even when:
- No other tools are used between Read and Edit
- VS Code is not actively being used
- No other processes are accessing the file
- The file content hasn't actually changed
Expected Behavior
The Edit tool should successfully modify the file when the content matches what was read.
Actual Behavior
Edit tool fails with "File has been unexpectedly modified" error, preventing any edits.
Claude Model
Sonnet (default)
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.0.46
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗