[BUG] Edit tool fails with "File has been unexpectedly modified" when file hasn't changed (Windows)

Resolved 💬 3 comments Opened Jan 12, 2026 by GeniuSKilleR95 Closed Jan 16, 2026

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?

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

Error: File has been unexpectedly modified. Read it again before attempting to write it.

Steps to Reproduce

  1. Use Claude Code for an extended session (30+ minutes)
  2. Read a file using the Read tool
  3. Immediately attempt to Edit the same file
  4. 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

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗