anthropics / anthropics/claude-code
[BUG] external file changes are not notified to the agent before an Edit tool call when the file was only Read (not previously Edited) — no “modified since read” guard, no change notification
- Dominant language
- Python
- Stars
- 145k
- Forks
- 23.1k
- PR merge metrics
- PR metrics pending
Description
### Preflight Checklist
- [x] I have searched [existing issues](https://github.com/anthropics/claude-code/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) 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?
Claude Code’s file-freshness tracking appears to be armed only by write operations (`Edit`/`Write`), never by `Read`.
Proactive change notification only fires once, and only after a write. The “this file was modified since you last read it” system note only appears for the first external change that happens after the agent has Edited the file. It fires once and then disarms. A subsequent `Read` does not re-arm it, so later manual edits go completely unannounced — even though the notification text literally says “since you last read it.”
### What Should Happen?
A `Read` should establish (and refresh) the freshness baseline for a file, exactly as an `Edit`/`Write` does.
- The “file changed since you last read it” notification should fire on every turn where the on-disk file differs from what the agent last saw — not only once, and not only after a prior `Edit`.
### Steps to Reproduce
1. Ask the agent to `Read` a file.
2. Manually edit the file (outside the agent) and save.
3. Ask the agent to `Edit` the file.
- Actual: the edit succeeds silently. No change notification.
- Expected: A "File has been modified since you last read it, here are the changes...." notification should be sent along with my user prompt.
4. Manually edit the file again and save.
5. Send any prompt (e.g. “ok thanks”).
- The agent now receives a “this file was modified since you last read it” notification. (This is the only point at which the notification fires — after a prior agent `Edit`.)
6. Ask the agent to `Read` the file again.
7. Manually edit the file again and save.
8. Ask the agent to `Edit` the file.
- Actual: no notification about the step-7 manual change; the `Read` in step 6 did not re-arm tracking.
- Expected: a notification and/or an Edit-time rejection reflecting the step-7 change.
### Claude Model
Not sure / Multiple models
### Is this a regression?
I don't know
### Last Working Version
_No response_
### Claude Code Version
2.1.273
### Platform
Anthropic API
### Operating System
macOS
### Terminal/Shell
Other
### Additional Information
_No response_
Contributor guide
No contributing guide indexed for this repository
Research direction
The report names the Read, Edit, and Write tool paths but no source files or tests. Start by tracing their file-freshness tracking and reproduce the eight-step sequence on macOS. Done means Read establishes or refreshes the baseline and each later external change produces the stated notification or Edit-time rejection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100