[BUG] Write tool broken - "file has not been read" error even after Read, forcing Bash workarounds

Resolved 💬 2 comments Opened Jan 14, 2026 by ghost Closed Feb 28, 2026

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?

Reopening this bug because it is real and it is being ignored, as you can see from this closed post.
https://github.com/anthropics/claude-code/issues/7443

I just found claude code a month ago and it has already changed my life, my entire life. so please fix this bug so the ideas we all have can continue to flow as freely, without bugs slowing us down. not to mention we pay well for it!

The Write tool fails with "file has not been read" errors even when the
file has been explicitly read in the same session. This forces users to
use hacky Bash workarounds (heredocs, base64 encoding, etc.) to write
files, which is error-prone and inefficient.

This was previously reported and auto-closed as "resolved" (#XXX - link
the old issue), but the bug persists.

  • Blocking for real work - Writing PHP, JS, or any code with mixed

quotes via Bash heredocs is extremely fragile

  • Productivity loss - Simple file writes that should take seconds

become multi-attempt debugging sessions

  • Workarounds introduce bugs - Escaping issues cause malformed output

What Should Happen?

## Expected Behavior

Write tool should:

  • Successfully write new files
  • Successfully overwrite files that have been Read in the session

## Actual Behavior

Write tool fails, requiring Bash workarounds like:

  • cat << 'EOF' > file.php (breaks on complex quoting)
  • Base64 encode/decode
  • Copy + sed modifications

Error Messages/Logs

error: File has been unexpectedly modified. Read it again before attempting to write it.

Steps to Reproduce

  1. Start a Claude Code session
  2. Use Read tool to read an existing file
  3. Attempt to use Write tool to modify/rewrite that file
  4. Receive error: "file has not been read" or similar

Alternatively:

  1. Attempt to Write a new file
  2. Tool fails or behaves unexpectedly

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

Claude Code 2.1.7

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

Please reopen investigation. This is a core tool that's essential for
Claude Code's primary use case (writing code). The auto-close bot marked
this resolved but the issue persists.
this happens all. the. time.
" Sed mangled it. Let me recreate the admin settings file properly."

View original on GitHub ↗

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