[BUG] "File has been unexpectedly modified" error loop when using Edit/Write tools

Resolved 💬 3 comments Opened Nov 12, 2025 by seeper0 Closed Nov 15, 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?

When attempting to edit or write a file using the Edit/Write tools, Claude Code repeatedly throws a "File has been unexpectedly modified. Read it again before attempting to write it." error, even though:

  • The file was just read successfully
  • No external program is modifying the file
  • The file is not open in any editor

What Should Happen?

After reading a file, Edit/Write tools should work immediately without false "unexpectedly modified" errors.

Error Messages/Logs

● Update(C:/Work/B2BT/trunk/UnityProject/B2BT/Packages/com.dawinstone.shaderlib/Shaders/DS_SpriteLit.shader)
  ⎿  Error: File has been unexpectedly modified. Read it again before attempting to write it.

● Read(C:/Work/B2BT/trunk/UnityProject/B2BT/Packages/com.dawinstone.shaderlib/Shaders/DS_SpriteLit.shader)
  ⎿  Read 304 lines

● Update(C:/Work/B2BT/trunk/UnityProject/B2BT/Packages/com.dawinstone.shaderlib/Shaders/DS_SpriteLit.shader)
  ⎿  Error: File has been unexpectedly modified. Read it again before attempting to write it.

● 파일이 외부에서 수정된 것 같습니다. 다시 읽어보겠습니다.

● Read(C:/Work/B2BT/trunk/UnityProject/B2BT/Packages/com.dawinstone.shaderlib/Shaders/DS_SpriteLit.shader)
  ⎿  Read 50 lines

● 파일이 변하지 않았습니다. Write 도구로 전체를 다시 작성하겠습니다.

● Write(C:/Work/B2BT/trunk/UnityProject/B2BT/Packages/com.dawinstone.shaderlib/Shaders/DS_SpriteLit.shader)
  ⎿  Error writing file

● Read(C:/Work/B2BT/trunk/UnityProject/B2BT/Packages/com.dawinstone.shaderlib/Shaders/DS_SpriteLit.shader)
  ⎿  Read 304 lines

● 이제 Write로 전체 파일을 작성하겠습니다.

● Write(C:/Work/B2BT/trunk/UnityProject/B2BT/Packages/com.dawinstone.shaderlib/Shaders/DS_SpriteLit.shader)
  ⎿  Error writing file

● 제가 방금 읽었는데도 에러가 나네요. 다시 한번 읽어보겠습니다.

● Bash(cat "C:/Work/B2BT/trunk/UnityProject/B2BT/Packages/com.dawinstone.shaderlib/Shaders/DS_SpriteLit.shader" | head -1)
  ⎿  Shader "Dawinstone/SpriteLit"

● 파일이 존재하고 읽을 수 있습니다. Edit 도구를 사용해서 단계별로 수정하겠습니다.

● Update(C:/Work/B2BT/trunk/UnityProject/B2BT/Packages/com.dawinstone.shaderlib/Shaders/DS_SpriteLit.shader)
  ⎿  Error: File has been unexpectedly modified. Read it again before attempting to write it.

● Unity가 파일을 다시 불러오고 있는 것 같습니다. 잠시 기다렸다가 다시 읽어보겠습니다.

● Bash(sleep 2)
  ⎿  (No content)

● 혹시 Unity 에디터에서 파일을 열어두셨나요? 파일을 닫아주시면 제가 수정할 수 있습니다.

  또는 제가 새로운 파일로 작성한 후 복사하는 방법도 있습니다. 어떻게 진행할까요?

Steps to Reproduce

  1. Read a file using the Read tool
  2. Immediately attempt to edit it using Edit or Write tool
  3. Error occurs: "File has been unexpectedly modified"
  4. Read the file again
  5. Try to edit again → same error repeats in a loop

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.37

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

WSL (Windows Subsystem for Linux)

Additional Information

Workaround:
Restarting Claude Code resolves the issue temporarily.

Environment:

  • OS: Windows (WSL paths)
  • File type: .shader files (but may affect other file types)
  • Claude Code version: 2.0.37
  • Session ID: 4e03030c-75ef-4db0-8cc6-546e706962a6

Actual behavior:
Gets stuck in an error loop, making file editing impossible until restart.

View original on GitHub ↗

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