Concurrent editing: agent file edits race user's editor autosave (need collision detection / merge)
Status Open
Maintainer reply None cached
Workaround ✓ Mentioned in description ↑
Activity 0 comments · opened Aug 16, 2026
Summary
When the user actively edits a file in their editor while Claude Code edits the same file, editor autosaves silently overwrite the agent's applied edits (and vice versa). There is no collision detection between the agent's Edit tool and an external editor buffer, and no merge path akin to collaborative editing.
Concrete failure (real session, 2026-08-15)
Working on a Quarto slide deck the user had open in their editor:
- Agent inserted a new slide via Edit; user's editor autosaved a stale buffer -> slide silently gone.
- Agent re-applied and committed; autosave landed in the seconds BETWEEN Edit and git add -> the commit captured only part of the change, and the working-tree content was again stale.
- Agent's workaround: build the intended content out-of-band, git hash-object + update-index to stage it as a blob (autosave cannot race the object database), commit, then sync the working tree and ask the user to reload their editor buffer.
The Edit tool's file-modified-since-read guard helped once, but most overwrites happened AFTER a successful Edit, which the guard cannot see.
Ask
Some path toward safe co-editing, e.g.:
- watch edited files and warn/re-verify when mtime changes between an Edit and subsequent dependent operations (staging, render);
- an opt-in advisory lock or 'user is editing this file' signal surfaced to the agent;
- longer term, OT/CRDT-style merge with external editors -- Google-Docs-like co-editing is the user's stated expectation.
Environment: Claude Code (agent SDK session) on Windows 11; editor: user's own (autosave enabled).