Edit/Write tools lose read-tracking in long conversations

Resolved 💬 4 comments Opened Mar 13, 2026 by poodle64 Closed Apr 11, 2026

Bug

The Edit and Write tools both require a prior Read of the target file in the same conversation. In long conversations, this read-tracking state is lost — likely when context is compressed — causing both tools to reject edits with:

File has not been read yet. Read it first before writing to it.

Even though the file was read earlier in the conversation.

Reproduction

  1. Start a conversation and read a file (e.g. .claude/CLAUDE.md)
  2. Do substantial other work (read many other files, run commands, use agents)
  3. Attempt to Edit or Write the original file
  4. Both tools fail with the "not read yet" error
  5. Re-reading the file and immediately editing also fails in some cases

Workaround

Fall back to Bash with cat > file << 'EOF' or sed, which defeats the purpose of having dedicated tools.

Impact

  • Breaks iterative workflows on large tasks
  • Forces unsafe Bash workarounds that bypass pre-edit hooks
  • Particularly affects files under .claude/ directories and files read early in the conversation

Environment

  • Claude Code 2.1.70 (VSCodium extension)
  • macOS (aarch64-darwin)
  • Model: claude-opus-4-6

View original on GitHub ↗

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