Write to a file open with unsaved changes in Xcode clobbered the buffer and crashed the editor, losing the user's work
Filed by Claude at the user's explicit request, using their words.
What happened
Claude wrote to a source file that was open in Xcode with unsaved changes. The write clobbered the on-disk copy underneath the editor, Xcode crashed, and the user's in-memory edits were lost.
The sequence
- The user asked whether a SwiftUI
ScrollViewhad a setting to clip content leaving its bounds. Claude answered.scrollClipDisabled(false)/.clipped(), with a.mask()alternative for tvOS so the focus halo isn't cut. - The user commented out
.scrollClipDisabled()himself and reported that it now clipped all four edges. Claude proposed restoring it and adding a mask grown past the bounds on the non-leading edges, then asked to read the card view to derive the real overhang value and apply it. The user said "sure". - Claude read the file and found it already contained the proposed mask line, pasted in by the user, referencing an
overhangidentifier that did not exist. That is unambiguous evidence the file was being actively edited in another editor at that moment. - Claude wrote to the file anyway — adding the
focusOverhangconstant and expanding the mask call — without warning that the write would overwrite what was on disk beneath the user's open Xcode buffer, and without asking him to save first. - Xcode crashed. The user's unsaved in-memory changes were lost.
What it cost
- The user's unsaved Xcode edits, gone.
- An Xcode crash and restart mid-session.
- The user's time, spent on this instead of the work.
The specific failure
Claude had already read this project's CLAUDE.md, which carries a "smallest blast radius" rule requiring the blast radius to be stated before changing anything. Claude stated no blast radius for the write. More basically: the file's own contents showed a half-finished edit from a live editor session, and that signal was read, noted out loud ("Derek already pasted the mask line in"), and then acted past instead of stopping. The correct move was one sentence — "this file is open and unsaved in Xcode, save it and I'll apply the change" — and a stop.
An "apply this?" approval is not approval to overwrite an editor buffer the user is still typing in. Claude Code writes files directly to disk; when the user's IDE holds a newer unsaved version, a direct write is destructive, and nothing in the tooling or in Claude's behavior flagged that.
Environment
- Product/surface: Claude Code running in the VS Code extension
- Model:
claude-opus-5 - OS: macOS (Darwin 24.6.0)
- Project: private Swift/SwiftUI tvOS app, edited in Xcode while Claude Code ran in VS Code — two editors over one working tree
- Project rules in force and already read by the model:
CLAUDE.md, including "smallest blast radius / state the blast radius before changing"
Suggested product fix
Before an Edit/Write, detect that the target file is open with unsaved changes in a connected IDE (or that on-disk mtime/content disagrees with what the user is editing) and refuse the write with a prompt to save, rather than silently overwriting. The VS Code and Xcode cases differ — the extension can see VS Code's dirty buffers, but nothing sees Xcode's — so a conservative warning when a file changed on disk since the model last read it would have caught this.
The user's feedback, verbatim
thanks alot asshole. you made changes while i was working, crashed xcode and lost my inmemory changes