[BUG] Edit/Write/Read tools use mtime for change detection — false positives from IDE autosave
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?
Claude Code tracks file changes by comparing modification timestamps (mtime). Any IDE with autosave — PyCharm, VS Code with afterDelay, Neovim auto-write — will update mtime constantly without changing file content. This breaks two things:
Edit/Write tools reject operations with "file has been modified since read." The file wasn't modified — it was autosaved with identical content. Claude re-reads the file, retries, sometimes fails again. Each cycle wastes tokens and context window.
Read tool injects <system-reminder> blocks claiming a file "was modified, either by the user or by a linter" and dumps the file content (potentially hundreds of lines) into the conversation. On large files this is a lot of wasted tokens for nothing — the content hasn't changed.
With PyCharm's default autosave (every 15 seconds of inactivity), this happens on nearly every edit in a session. The workaround is re-reading before every operation, which Claude already does on failure — but the failed attempt still costs tokens and time.
What Should Happen?
Compare a content hash (SHA-256 or similar) stored at read time against current file content. If the hash matches, the file hasn't changed — ignore the mtime difference.
- mtime changed, content identical → proceed normally, no error, no system reminder
- content actually changed → current behavior (error on Edit/Write, reminder on Read)
Error Messages/Logs
Edit/Write failure:
File has been modified since read, either by the user or by a linter.
Read it again before attempting to write it.
Read false positive (injected into context between turns):
<system-reminder>
Note: /path/to/file.py was modified, either by the user or by a linter.
This change was intentional, so make sure to take it into account...
Here are the relevant changes (shown with line numbers):
[... hundreds of lines of unchanged content ...]
</system-reminder>
Steps to Reproduce
Edit/Write:
- Use any IDE with autosave (PyCharm default settings work)
- Have a file open in the IDE
- Ask Claude to read then edit that file
- If autosave fires between read and edit (likely within seconds), the edit fails
Read:
- Have a large file (400+ lines) open in IDE with autosave
- Read it with Claude
- Send another message
- System reminder appears claiming the file was modified
Verify with git status (clean) and sha256sum (identical before/after). Only stat mtime differs.
Prior issues (auto-closed without a fix)
- #10498 — Write tool false positives from IDE saves (auto-closed after 60 days)
- #9614 — Read tool false "modified" reminders on large files (auto-closed despite active discussion — see #16497 about the bot closing issues with recent comments)
- #7918 — Edit fails on Windows (open)
- #12315 — Unexpected modification error (open)
Same root cause across all of them. The first two were closed by the inactivity bot, not by anyone actually looking at the problem.
Claude Model
All models — this is tool-level, not model-level
Is this a regression?
No — the mtime approach has been there from the start. #9614 notes a brief period (v2.0.10) where the Read side didn't waste tokens, but it regressed by v2.0.13.
Last Working Version
_No response_
Claude Code Version
2.1.39
Platform
Anthropic API
Operating System
macOS (also reported on Linux and Windows/WSL in prior issues)
Terminal/Shell
VS Code integrated terminal, standalone iTerm2
Additional Information
A content hash stored alongside the mtime at read time would fix this without changing the tool API or behavior for actual modifications.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗