Repository navigation
[BUG] Edit tool fails with "File has been unexpectedly modified" when file hasn't changed (Windows) #17684
Copy link
Copy link
Closed as duplicate
Closed as duplicate
Copy link
Labels
duplicateThis issue or pull request already existsThis issue or pull request already exists
Description
Preflight Checklist
- I have searched existing issues and this hasn't been reported yet
- This is a single bug report (please file separate reports for different bugs)
- I am using the latest version of Claude Code
What's Wrong?
Description:
The Edit tool consistently fails with the error "File has been unexpectedly modified. Read it again before attempting to write it." even when:
- No editors are open
- No dev servers or file watchers running
- No manual edits being made
- File timestamp remains unchanged between Read and Edit calls
The issue accumulates over a session and temporarily resolves after restarting the PC.
Environment:
- OS: Windows 11
- Claude Code version: Latest (installed via npm)
- Node.js version: 18+
- Working directory: C:\Users[username]
- Target files: D:\Work[project] (different drive)
Observed Behavior:
● Read(D:\Work\project\src\file.ts)
⎿ Error reading file
● # Read succeeds
Read file D:/Work/project/src/file.ts
# Immediate Edit fails
Edit tool error: "File has been unexpectedly modified. Read it again before attempting to write it."
# Verify file wasn't modified
$ stat file.ts | grep Modify
Modify: 2026-01-12 04:04:01.268346800 -0800 # Timestamp unchanged
Verification that file is stable:
# File timestamp doesn't change on its own
$ stat file.ts | grep Modify
Modify: 2026-01-12 04:04:01.268346800 -0800
$ sleep 5
$ stat file.ts | grep Modify
Modify: 2026-01-12 04:04:01.268346800 -0800 # Same
Additional observations:
- Happens on ALL files after the bug starts occurring (tested .ts, .tsx, .json files)
- sed commands via Bash tool work fine as a workaround
- The Write tool (full file replacement) may also work
- Cross-drive scenario: Working directory on C:, files on D: drive
- Restarting PC temporarily fixes the issue
- Issue returns after ~30-60 minutes of usage
Expected Behavior:
Edit tool should succeed when the file hasn't been modified between Read and Edit calls.
Workarounds:
- Use sed via Bash tool for edits
- Restart Claude Code / PC
- Provide full file content for manual pasting
Possible Causes:
- File hash/checksum tracking getting corrupted over time
- Windows NTFS timestamp precision issues
- Cross-drive path handling issues
- Memory/state leak in file tracking
### What Should Happen?
Edit tool should succeed when the file hasn't been modified between Read and Edit calls.
### Error Messages/Logs
```shell
Error: File has been unexpectedly modified. Read it again before attempting to write it.
Steps to Reproduce
- Use Claude Code for an extended session (30+ minutes)
- Read a file using the Read tool
- Immediately attempt to Edit the same file
- Error occurs even with no external modifications
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
No response
Claude Code Version
2.1.5 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
IntelliJ IDEA terminal
Additional Information
tried it also on powershell terminal same thing
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
duplicateThis issue or pull request already existsThis issue or pull request already exists
Activity
github-actions commentedon Jan 12, 2026
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
github-actions commentedon Jan 16, 2026
This issue has been automatically closed as a duplicate of #12695.
If this is incorrect, please re-open this issue or create a new one.
🤖 Generated with Claude Code
github-actions commentedon Jan 24, 2026
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.