[BUG] File-watch mechanism invalidates read state between Read and Write/Edit tool calls

Resolved 💬 3 comments Opened Oct 22, 2025 by rainyhill Closed Oct 23, 2025

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:

  1. It's blocking normal iterative development workflows
  2. The "read" state is being invalidated even when no external changes occur
  3. 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

  1. Setup: Have a file in a Git repository (e.g., test.c)
  2. Step 1 - Read the file:

Use Read tool on test.c
Result: File contents successfully read

  1. 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."

  1. 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_

View original on GitHub ↗

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