Pricing
Claude Code "File Has Been Unexpectedly Modified" Error: Fixes
Claude Code says 'File has been unexpectedly modified'? Why the Edit tool fails (formatters, line endings, tabs, Windows) and the fixes users report, sourced.
9 min read
Error strings, causes and fixes checked Nov 2, 2026 in Claude Code GitHub issues #12462, #10437, #7918 and #3513, the Claude Code changelog and Anthropic’s tools reference. Workarounds marked “user report” come from GitHub comments, not from Anthropic. Every source is listed at the bottom. No affiliate links on this page (how we work).
The exact error: File has been unexpectedly modified. Read it again before attempting to write it.
Here’s how it shows up in the terminal, copied from the log in GitHub issue #12462 (verified Nov 2, 2026):
Update(qt_slideshow_util2.py)
⎿ Error: File has been unexpectedly modified. Read it again before attempting to write it.
Sometimes you only see the short version:
Update(application/views/user/layout/service-note-modal.php)
⎿ Error editing file
That second one is from issue #11447 (verified Nov 2, 2026). Anthropic’s error reference notes, for one blocked-edit case, that “the conversation view shows only a short Error editing file line; the full message appears in the transcript view, which you open with Ctrl+O” (verified Nov 2, 2026). So if all you have is “Error editing file”, press Ctrl+O and read the real message before you start guessing.
The short answer (as of Nov 2, 2026): Claude Code’s Edit tool checks that the file on disk still matches what Claude last read. When it thinks the file changed, it refuses to write and asks for a fresh read. Sometimes the file really did change (a formatter, a watcher, you). Sometimes it didn’t, and the check is wrong. That second case is a known bug, much of it reported on Windows.
A GitHub search finds 102 issues in the Claude Code repo containing that sentence, and only 2 were still open on Nov 2, 2026. Many, including #12462 and #10437, were closed as duplicates of #3513, which was still open on that date. #3513 dates to July 2025 and uses the older wording: “File has been modified since read, either by the user or by a linter.”
Why it happens
Anthropic hasn’t published a root cause for the false alarms. What we have is the documented check, the changelog, and a lot of user reports. I’ll keep them apart.
What the docs say the Edit tool checks. Per the tools reference (verified Nov 2, 2026), an edit only applies when three checks pass:
- Read-before-edit. Claude must have read the file in this conversation. A read cut short with a
PARTIAL viewnotice doesn’t count. Claude Opus 4.6, Claude Haiku 4.5 and older models always need the read. - Match.
old_string“must appear in the file exactly as written. A single character of whitespace or indentation difference is enough to miss.” - Uniqueness.
old_stringmust appear exactly once, unless Claude setsreplace_all.
The docs also say a file that changed on disk after the read can still be edited if old_string matches the current content exactly and once. Otherwise, Claude reads it again first. In a working setup, then, a changed file should trigger a re-read, not a loop.
Causes in the changelog (official).
- File watchers touching files. v2.1.6 “Fixed false “File has been unexpectedly modified” errors when file watchers touch files without changing content.”
- Files changed after reading. v2.1.208 “Fixed the Edit tool failing on files modified after reading when the target text still matches uniquely.”
- Partial reads plus resume. v2.1.212 fixed “a spurious “File has not been read yet” error when editing a file that had been read with offset/limit before resuming a session.”
- Line endings. v2.1.77 fixed the Write tool “silently converting line endings when overwriting CRLF files”, and v2.1.89 fixed “Edit/Write tools doubling CRLF on Windows”.
Causes in user reports (not confirmed by Anthropic).
- Windows path spelling. In #10437 a user tested path combinations and reported that forward-slash absolute paths (
C:/path/file.txt) failed, while relative paths or backslash absolute paths worked. Several commenters on #7918 report the same. - CRLF and git’s autocrlf. One #12462 commenter suspects line-ending conversion. It’s a hypothesis, not a confirmed cause.
- Shell prompt noise. A #10437 commenter traced their case to the Starship prompt in Git Bash on Windows.
- After compaction. One #12462 commenter says the error started once the conversation was compacted.
The reporter in #12462 checked the file’s MD5 hash and found it identical between reads, with no editor, no cloud sync and a local SSD. Claude Code looked at an unchanged file and saw a modified one. It’s Westworld in reverse: instead of “doesn’t look like anything to me”, the tool insists something changed when nothing did.
Related errors that aren’t the same bug. Tabs (#11447) and mixed literal/escaped Unicode in a multi-line old_string (#64479) show up as “Error editing file”, because the match check fails. A project on an SSHFS/FUSE mount (#91783) fails with “Write failed” and EPERM, which is a different error. Both were open as of Nov 2, 2026.
Fixes, in order
- Read the full message. Press
Ctrl+Ofor the transcript view if you only see “Error editing file”. “Unexpectedly modified” and a failed match need different fixes. - Let Claude re-read, once. The error itself says “Read it again”. If the file really changed, one fresh read fixes it. If Claude reads, fails, reads and fails again, stop the loop. You’re in bug territory, and retrying burns usage. Watching it loop is like watching Monk check the stove for the ninth time: thorough, and getting nowhere.
- Update Claude Code. Run
claude update. Anthropic’s setup doc says it reportsSuccessfully updated from <old version> to version <new version>, orClaude Code is up to date (<version>)(verified Nov 2, 2026). On an old build, this is the cheapest fix there is. - Pause whatever touches the file. Format-on-save, file watchers, sync clients. The v2.1.6 entry confirms watchers caused false alarms. Pausing them for the session tells you fast whether they’re involved.
- On Windows, use one path style (user report). Commenters on #7918 and #10437 say asking Claude to use relative paths, or absolute paths with backslashes, stopped the loop. Some put that rule in
CLAUDE.md. It’s a community workaround, not an Anthropic fix, but it’s harmless to try. - Reinstall (user report). One #12462 commenter said uninstalling and reinstalling Claude Code made the errors stop.
- For tabs or Unicode match failures, the #64479 reporter’s workaround is to make that edit through a shell command (sed, node or bun via Bash). Use it for that one edit, not as a habit. You lose the Edit tool’s safety checks.
What I’d skip: commenters have posted patches to Claude Code’s bundled cli.js that bypass the modification check. Patching the safety check out of a tool that writes to your code is a bad trade, and the next update overwrites it anyway.
“Error editing file” vs “Error writing file”
| Message | Likely cause | Fix |
|---|---|---|
| Unexpectedly modified | Stale read, watcher, Windows bug | Re-read once, update, pause watchers |
| Error editing file | Match failed (tabs, Unicode) | Ctrl+O, then fix old_string |
| Not read yet | Partial read or resume | Full read; v2.1.212+ |
| Write failed EPERM | SSHFS/FUSE mount | Local path or Remote SSH |
Causes from the changelog, the tools reference and GitHub issues #11447, #12462, #64479, #91783 and #10437, verified Nov 2, 2026. “Not read yet” is the File has not been read yet message quoted in #10437. No official doc defines “error writing file”, so I’m not printing a cause for it.
When it’s not you
If you’re on the latest build, nothing is touching the file, and the loop continues, you’ve probably hit the open bug. Two things are worth doing:
- Add your case to the canonical issue. Anthropic closed the duplicates in favour of #3513 and asked people to follow and upvote it there. Your OS, Claude Code version and shell are the useful details.
- Send a report from inside Claude Code.
/bugopens a report with a consent screen where you choose how much session history to include. (commands doc, verified Nov 2, 2026)./doctorruns a setup checkup first, if you suspect your install.
Honest frustration: a bug that makes the main editing tool unreliable on one of the big three operating systems sat open long enough to collect 102 issues. That’s a product decision about priorities, and Windows users paid for it in retries. The changelog shows fixes landing, but #7918 was still open on Nov 2, 2026.
Does this cost you usage?
Every failed edit and re-read is a turn, and turns count against your plan. A ten-attempt loop eats session allowance that should have gone to actual work. If you’re hitting limits faster than expected, check Claude Code usage limits. For other errors: Claude Code 529 overloaded is server capacity, and prompt is too long means your context window is full. Wondering whether you need a paid plan for any of this? See Is Claude Code free?. Comparing tools? AI coding tools compared has dated prices.
Here’s what I’d do
One re-read, then claude update. If the loop survives that, pause format-on-save and any watcher, and on Windows tell Claude to stick to relative paths. Still looping? Stop retrying, file it on #3513 with your version and OS, and make that one edit yourself. Arguing with an edit check that’s wrong is a fight you lose by the token.
If the message you actually see is just “Error editing file” (a failed match, not a changed file), that is a different bug: see Claude Code “Error editing file”: what it means and how to fix it.
Different failure mode: if the panel itself won’t load, see Claude Code Error Loading Webview.
Related: Claude Code “Error editing file”.
FAQ
What does File has been unexpectedly modified. Read it again before attempting to write it. mean in Claude Code?
Claude Code’s Edit tool thinks the file changed since Claude last read it, so it refuses to write until the file is read again.
Why does Claude Code keep failing to edit files? Usually a stale read, a formatter or watcher touching the file, a failed exact-string match (tabs, Unicode) or a known Windows false-positive bug.
Does updating Claude Code fix it? Often. The changelog lists fixes for watcher false alarms (v2.1.6) and edits after changes (v2.1.208), but the canonical issue #3513 was still open on Nov 2, 2026.
What does “Error editing file” mean in Claude Code? It’s the short form of an edit failure; press Ctrl+O to see the full message in the transcript view.
Is it a Windows-only problem? The issues cited here (#7918, #10437, #12462) are on Windows, but the canonical issue #3513 was filed on Linux.
Should I patch Claude Code to skip the check? No, community patches remove a safety check and get overwritten by the next update; update, re-read or report it instead.
Sources
- Claude Code GitHub issue #12462 (verbatim error, MD5 check, reinstall and CRLF comments, closed as duplicate of #3513): https://github.com/anthropics/claude-code/issues/12462 (verified 2026-11-02)
- Claude Code GitHub issue #10437 (error after Read, Windows path tests, Starship comment, “File has not been read yet”): https://github.com/anthropics/claude-code/issues/10437 (verified 2026-11-02)
- Claude Code GitHub issue #7918 (Windows, since v1.0.111, open, path workarounds): https://github.com/anthropics/claude-code/issues/7918 (verified 2026-11-02)
- Claude Code GitHub issue #3513 (canonical issue, older “modified since read” wording, open): https://github.com/anthropics/claude-code/issues/3513 (verified 2026-11-02)
- Claude Code GitHub issues #11447 (tabs, “Error editing file”), #64479 (Unicode old_string), #91783 (SSHFS/FUSE EPERM): https://github.com/anthropics/claude-code/issues/11447, https://github.com/anthropics/claude-code/issues/64479, https://github.com/anthropics/claude-code/issues/91783 (verified 2026-11-02)
- Claude Code changelog (v2.1.6, v2.1.77, v2.1.89, v2.1.208, v2.1.212): https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md (verified 2026-11-02)
- Claude Code tools reference (Edit tool checks, read-before-edit, Write tool rules): https://code.claude.com/docs/en/tools-reference (verified 2026-11-02)
- Claude Code error reference (“Error editing file” short line, Ctrl+O transcript view): https://code.claude.com/docs/en/errors (verified 2026-11-02)
- Claude Code setup (claude update): https://code.claude.com/docs/en/setup (verified 2026-11-02)
- Claude Code commands (/bug, /feedback, /doctor): https://code.claude.com/docs/en/commands (verified 2026-11-02)