← Back to Craft
AgentCraft

Skill · Version 1.0.0

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 helps

When 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.

Details…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

  1. 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.
  2. 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 (Awareness protocol): 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.

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 pressing Cmd/Ctrl+Z undoes only the local user's own operations, never reverting a teammate's concurrent edits.
  • 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.
  • 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 Awareness rather than persisted in the document CRDT?
  • Is UndoManager scoped to local user origins so Undo never 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