[BUG] Write tool overwrites existing file without Read-first prompt when file not yet touched in session

Status Open
Reported on v2.1.280
Maintainer reply None cached
Activity 0 comments · opened Sep 24, 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?

I had an existing externally authored (html) file, CC wrote to the same path without reading it first, no overwrite prompt appeared, file content was replaced. The original file was not tracked by git and therefore unrecoverable except by recreating it. This seems to be based on whether the prompt has made it clear whether the file exists or should be produced.

What Should Happen?

Before writing any file, CC should check whether it exists on disk, and if it does, either read it first or prompt. The current gap is that the check apparently doesn't happen; it only catches the conflict if the file was already read in-session, which means a file sitting on disk untouched in that session has no protection at all.

Error Messages/Logs

CC's own response to the occurance:

I didn't Read that file before Writeing it (I only read files I'd traced, and this one I was creating fresh from the table content).

The Write tool's own contract is that it refuses when a file exists and hasn't been read first in-session — it didn't refuse.

git status shows it as untracked with no history either way, so there's no git-level record to settle whether your version was already on disk at that moment or landed right around when I wrote.

Steps to Reproduce

  1. Have an ongoing Claude Code session
  2. Create a file in a known project location
  3. Describe a task that references that file by name but is not specific on whether it already exists or should be produced as part of the task.

Note: There should be no fresh session between 2 and 3. A new session will often include specifically reading project changes, something which is not ordinarily done mid-session.

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

Claude Code: 2.1.280

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

This exact issue has been previously closed due to inactivity at least twice, and is apparently still ongoing as of today's date. It's very close to a behavior issue (simply "choosing" not to read/check) and possibly overlooked in a pure bug state. Feel free to move it to get more traction.

View original on GitHub ↗