← Back to Craft
AgentCraft
Collaborative editing
Integrates concurrent document editing with shared-state models, local undo and authorized reconnection instead of full-document overwrites.
collaborative-editing-integration
See how it helpsWhen is it useful?
Use when concurrent document edits must merge without replacing other users' work.
What does it help you do?
- Connects a proven collaboration model to the editor's supported bindings.
- Keeps persistent content separate from temporary cursors and presence.
- Scopes undo to local edits and checks authorization during reconnection.
Try asking this
Design simultaneous paragraph editing with offline reconnection and undo that affects only the initiating user's changes. Have two users edit adjacent text while one disconnects. After reconnection, both edits should survive and one user's undo must not erase the other's work.
Detailed documentation
Read the skill’s original instructions, examples and checks in their authored language.
Show less
Collaborative Editing Integration
Use this skill when real-time multi-user editing, live cursors/presence, or concurrent conflict-free document synchronization is explicitly required.
Core Collaborative Architecture Principles
- Do Not Bolt Real-Time Sync Onto an Ad-Hoc State Model:
- Never attempt multi-user real-time editing by broadcasting full JSON snapshots over WebSockets—concurrent edits will overwrite each other and reset peers' cursors.
- Use a proven collaborative model matched to the editor engine:
- CRDTs (
Yjs,Automerge) with official editor bindings (y-prosemirror,@tiptap/extension-collaboration,@lexical/yjs). - Operational Transformation / Authority Step Stream (
prosemirror-collab) where a central authority orders steps and clients rebase unconfirmed local steps.
- CRDTs (
- Strictly Separate Shared Document CRDT from Ephemeral Awareness:
- Shared Document (
Y.Doc/Y.XmlFragment/Y.Map): Stores persistent blocks, text, marks, and canvas shapes. - Ephemeral Presence (
Awarenessprotocol): Stores live cursor coordinates, text selection ranges, active user name/color, and viewport focus. Never write cursor movements or hover states into the persistent CRDT document, which would bloat history and storage permanently.
- Shared Document (
Local-Scoped Undo/Redo & Relative Cursors
- User-Scoped Collaborative UndoManager:
- In collaborative sessions, disable the single-user history plugin and use the CRDT's local-origin
UndoManager(trackedOrigins) so pressingCmd/Ctrl+Zundoes only the local user's own operations, never reverting a teammate's concurrent edits.
- In collaborative sessions, disable the single-user history plugin and use the CRDT's local-origin
- Relative Positions for Selections and Anchors:
- Represent comments, annotations, and remote cursors using CRDT Relative Positions (
Y.RelativePosition) rather than raw integer indices so anchors stay attached to the intended text/block when remote peers insert or delete content above them.
- Represent comments, annotations, and remote cursors using CRDT Relative Positions (
- Reconnection, Initial Sync & Authorization:
- Gate document room access and write vs. read/comment-only permissions on the server before accepting CRDT updates, and handle offline buffering and reconnection merge cleanly without duplicating initial template content.
Checklist
- Is real-time sync backed by a proper CRDT/OT binding rather than whole-document WebSocket overwrites?
- Are live cursors and selections broadcast via ephemeral
Awarenessrather than persisted in the document CRDT? - Is
UndoManagerscoped to local user origins soUndonever reverts another collaborator's edits? - Are initial template seeding and reconnect merges idempotent so two users opening a new doc do not duplicate initial blocks?
Included files 1
SKILL.md
