You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Edit tool fails with "File has been unexpectedly modified" even after (Quite critical bug as it cannot code)Â #7443
I have searched existing issues and this hasn't been reported yet
This is a single bug report (please file separate reports for different bugs)
I am using the latest version of Claude Code
What's Wrong?
The Edit and MultiEdit tools consistently fail with "File has been unexpectedly
modified. Read it again before attempting to write it." error, even immediately after
reading the file with the Read tool.
Steps to Reproduce
Use Read tool to read a file
Immediately use Edit tool to modify the same file
Get error: "File has been unexpectedly modified. Read it again before attempting
to write it." ## Actual Behavior
Edit tool consistently fails, requiring workarounds with Bash/sed commands
What Should Happen?
Expected Behavior
Edit tool should work after reading the file, as it did previously.
Error Messages/Logs
Error: File has been unexpectedly modified. Read it again before attempting to write
it.
Steps to Reproduce
No steps cannot Edit/modify any file requested to modify Write code or repair bugs.
Found a workaround for those with this issue , you need to open another claude instance. And instruct other claude what to do where he s left. At least is something....
I am having the same issue with CC and after testing it provided a breakdown:
"
Environment
Claude Code Version: v1.0.111
Platform: Windows 10, Git Bash/MINGW64
Project: Next.js TypeScript application
Issue
Edit and MultiEdit tools consistently fail with "File has been unexpectedly modified" error when attempting to modify
files that existed before the current Claude Code session started.
Reproduction Steps
Start a new Claude Code session
Read any pre-existing file using Read tool
Attempt to Edit the file with exact string from Read output
Error: "File has been unexpectedly modified"
Test Results
â WORKS: Files created with Write tool in current session
â FAILS: Any file that existed before session started
â WORKS: Multiple edits on newly created files
â FAILS: Both Edit and MultiEdit tools affected
Same file content can be edited if file is recreated in current session
Session-based state issue: Files become "un-editable" after Claude Code restarts
Not file-specific: Same file, same content, different session = different behavior
Consistent pattern: All pre-existing files fail with "unexpectedly modified" error
Root Cause Hypothesis
Claude Code's internal file state tracking appears to be session-based. Files created during the session have proper state
initialization, while pre-existing files lack this state, causing all edit operations to fail.
Impact
Cannot edit any existing project files
Forced to use workarounds (bash/sed, manual editing)
Ok I noticed I could edit files fine in another project, so I tested more. Does this correct the problem for anyone else experiencing it? I'm back to editing...
"
Root Cause Discovery:
Issue: Path format used by Claude Code
Solution:
Use relative paths: projectfolder/... instead of E:/Projects/projectfolder/...
Use forward slashes: / not \
Start from workspace root: cd /e/projectfolder then use relative paths
Why was this closed? It's still not fixed and more and more people are duplicating this bug report. I've started to have to use claude to find a problem and cursor or codex to solve it.
I saw elsewhere that someone said using this prompt will fix it, I haven't gotten a chance to test it yet though. "There's a file modification bug in Claude Code. The workaround is: always use complete absolute Windows paths
with drive letters and backslashes for ALL file operations. Apply this rule going forward, not just for this
file."
I place this workaround in CLAUDE.md and it has worked so far:
## CRITICAL: File Editing on Windows### â ïļ MANDATORY: Always Use Backslashes on Windows for File Paths**When using Edit or MultiEdit tools on Windows, you MUST use backslashes (`\`) in file paths, NOT forward slashes (`/`).**#### â WRONG - Will cause errors:```Edit(file_path: "D:/repos/project/file.tsx", ...)MultiEdit(file_path: "D:/repos/project/file.tsx", ...)```#### â CORRECT - Always works:```Edit(file_path: "D:\repos\project\file.tsx", ...)MultiEdit(file_path: "D:\repos\project\file.tsx", ...)```
Reacted by trueshot, bOOOOc, killajunk-code, Rene Kok, SLGerr, Wira Pratama Putra, niyato2001, Leo Kim, Jambdy and Chouchou
My experience is strange. Sometimes it doesn't seem to have problems, sometimes it can't seem to do anything with files. Generally, it seems to be getting better, but sometimes it just doesn't work well at all.
I never experienced this before today, but often it would use update (edit/multi edit) and then insta fail before trying a new approach. Today it really seems to want to keep using update and then getting stuck in a loop. The first edit will succeed. The second edit will fail forever typically. Added this to test and yes the workaround works a treat, but honestly wish it didn't need to be there.
Did you try updating to claude Code 2 "claude update" I haven't had problems since.
spoke too soon.
Update(c:\buffalo\d\clients\gological\js\components\universalnavbar.js)
âŋ Â Error: File has been unexpectedly modified. Read it again before attempting to write it.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.
Activity
github-actions commentedon Sep 11, 2025
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
ðĪ Generated with Claude Code
ksoftkorea-creator commentedon Sep 11, 2025
This is NOT duplicate.
I am getting same issue after recent patch.
THIS IS CRITICAL IN MY WORKFLOW
Gtm-dev-market commentedon Sep 11, 2025
We really need this fixed is using BAsh SED , to edit. Terrible
Gtm-dev-market commentedon Sep 11, 2025
Found a workaround for those with this issue , you need to open another claude instance. And instruct other claude what to do where he s left. At least is something....
Norsninja commentedon Sep 11, 2025
I am having the same issue with CC and after testing it provided a breakdown:
"
Environment
Issue
Edit and MultiEdit tools consistently fail with "File has been unexpectedly modified" error when attempting to modify
files that existed before the current Claude Code session started.
Reproduction Steps
Test Results
â WORKS: Files created with Write tool in current session
â FAILS: Any file that existed before session started
â WORKS: Multiple edits on newly created files
â FAILS: Both Edit and MultiEdit tools affected
Evidence
Root Cause Hypothesis
Claude Code's internal file state tracking appears to be session-based. Files created during the session have proper state
initialization, while pre-existing files lack this state, causing all edit operations to fail.
Impact
trueshot commentedon Sep 11, 2025
Norsninja commentedon Sep 11, 2025
Ok I noticed I could edit files fine in another project, so I tested more. Does this correct the problem for anyone else experiencing it? I'm back to editing...
"
Root Cause Discovery:
Solution:
Test Results:
trueshot commentedon Sep 11, 2025
This is the conclusion from the tests I made it do, but It has been whacked out today, so take it with a grain of salt.
CRITICAL DISCOVERY: Sequencing Bug Identified
CORRECTED TEST RESULTS:
ROOT CAUSE IDENTIFIED:
File Caching/State Bug: The Edit tool has a caching or file state tracking issue where:
BUG PATTERN:
WORKAROUND: Before editing with absolute paths, always perform a successful relative path edit first to "warm up" the file state cache.
kohowski commentedon Sep 11, 2025
oooof first time ever I actually have to downgrade. just cannot edit anything.
trueshot commentedon Sep 12, 2025
Version 1.0.112 seems to have fixed the issue for me. Thanks!
Adamcf123 commentedon Sep 12, 2025
No. it is not over. it happens randomly.
33 remaining items
pkp24 commentedon Sep 26, 2025
Why was this closed? It's still not fixed and more and more people are duplicating this bug report. I've started to have to use claude to find a problem and cursor or codex to solve it.
I saw elsewhere that someone said using this prompt will fix it, I haven't gotten a chance to test it yet though. "There's a file modification bug in Claude Code. The workaround is: always use complete absolute Windows paths
with drive letters and backslashes for ALL file operations. Apply this rule going forward, not just for this
file."
JosiahSiegel commentedon Sep 26, 2025
I place this workaround in
CLAUDE.mdand it has worked so far:trueshot commentedon Sep 26, 2025
My experience is strange. Sometimes it doesn't seem to have problems, sometimes it can't seem to do anything with files. Generally, it seems to be getting better, but sometimes it just doesn't work well at all.
YiHuangDB commentedon Sep 28, 2025
do not use claude code, then you dont have this issue anymore. Yes I am joking, cause this bug annoys me so much
EllieTellie commentedon Sep 29, 2025
I never experienced this before today, but often it would use update (edit/multi edit) and then insta fail before trying a new approach. Today it really seems to want to keep using update and then getting stuck in a loop. The first edit will succeed. The second edit will fail forever typically. Added this to test and yes the workaround works a treat, but honestly wish it didn't need to be there.
1uv0cean commentedon Sep 30, 2025
Why we should enter that prompt manually on
CLAUDE.md?I can't understand why this issue was closed.
kohowski commentedon Oct 1, 2025
@anthropics @dicksontsai hey, sure thing there's a lot on your plate. But look at this one non-esoteric thing people struggle with please..
#7935 #7920 #7918 #7883
trueshot commentedon Oct 1, 2025
Did you try updating to claude Code 2 "claude update" I haven't had problems since.
spoke too soon.
Update(c:\buffalo\d\clients\gological\js\components\universalnavbar.js)
âŋ Â Error: File has been unexpectedly modified. Read it again before attempting to write it.
Dragod commentedon Oct 3, 2025
this thing is still plauging me. It is not acceptable on a 200$ per month.
hi-fox commentedon Oct 5, 2025
why has this been closed when it is still occurring?
thenickb commentedon Oct 5, 2025
I get this constantly on a Max plan.
dancingmadkefka commentedon Oct 6, 2025
Getting this issue as well. Don't usually use CC but did today and ya it just fails every edit first time. Windows/Bash
Christilut commentedon Oct 6, 2025
Had the same issue since it upgraded to 2.0.8, editing almost impossible. Downgraded to 2.0.5 and disabled auto update for now.
Windows terminal / git bash
github-actions commentedon Oct 14, 2025
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.