real-time-collab
Was er macht
Dieser Skill erklärt, wie man in einer Agent-Native-App gemeinsames Live-Bearbeiten baut, mit Yjs und TipTap, damit sich Änderungen sauber zusammenführen. Er richtet sich an Entwickler, die gemeinsame Dokumente hinzufügen oder Synchronisierungsprobleme beheben.
Wann du ihn nutzt
- ✓Wenn du einem Dokument in einer App gemeinsames Live-Bearbeiten hinzufügst.
- ✓Wenn zwei Personen oder der Agent dasselbe Dokument bearbeiten und Änderungen verloren gehen.
- ✓Wenn du Synchronisierungsprobleme zwischen Nutzern und dem Agenten debuggen musst.
Link zum Skill
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/real-time-collab/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Lass zwei Personen dasselbe Dokument gleichzeitig bearbeiten und zeig beiden die Änderungen der KI.”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Änderungen werden als gemeinsames Dokument gespeichert, das Änderungen automatisch zusammenführt. Aktualisierungen werden an die Nutzer gesendet, mit einer Rückfallebene auf reguläre Abfragen, wenn die Live-Verbindung abbricht.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von GitHub.
Real-Time Collaboration
Rule
Collaborative editing uses Yjs CRDT via TipTap. The agent and human users are
equal participants — both edit the same Y.Doc and changes merge cleanly without
conflicts. Always choose an explicit access mode on createCollabPlugin.
How It Works
Y.Docstores the document as aY.XmlFragment(ProseMirror node tree)- TipTap's Collaboration extension binds the editor to the Y.XmlFragment
via
ySyncPlugin - CollaborationCaret extension renders remote users' cursors with names and colors
- SSE fast-path —
/_agent-native/poll-eventsEventSourcedelivers collab events push-style; while SSE is healthy the collab poll interval relaxes to ~12 s - Polling fallback —
/_agent-native/pollis polled every 2 s when SSE drops mid-session. On serverless,/eventsanswers 204 up front (poll-live) and this client relaxes to ~12 s, because/pollis the only channel. - Collab poll boost — while the awareness set shows another visible human
on the doc (agent and hidden tabs do not count), the connection holds
acquireCollabPollBoost()and the shared transport polls every 2.5 s whenever no stream is connected: a no-op while SSE or the hosted gateway is live. A joiner is noticed on the existing user's next ~12 s collab poll (the joiner sees them at once), a leaver within one poll plus the 30 s awareness TTL. The boost lapses after 3 minutes with no input and no remote events. Lone tabs pay nothing extra. Events under the request source a connection posts with (any app-chosen tab id, not onlygetBrowserTabId()) are this tab's own and never count. A read-only viewer must join the doc too (Design'suseViewerPresence; it never uses theydoc), or it never sees an editor and stays on the idle cadence. A viewer on a different screen than the editor shares no doc with them; its own collab poll sees the design's resource-scoped events from other tabs and starts the boost (60 s) itself. - Update batching — local Yjs updates are debounced ~80 ms and coalesced
with
Y.mergeUpdatesbefore sending; flushed immediately onvisibilitychange/pagehide - SQL
_collab_docstable persists Yjs state as base64 in Postgres. Tombstone compaction fires automatically when the stored blob exceeds 4× the fresh encoded size.
Agent + Human Editing
- Human edits → TipTap → ySyncPlugin → Y.XmlFragment →
POST /_agent-native/collab/:docId/update - Agent edits → action edits canonical SQL content + bumps
updatedAt→ change-sync refetch → the open editor reconciles the new content into the live Y.Doc (see below) → poll update → all clients
Both produce Yjs operations that merge cleanly. Agent edits appear without destroying cursor position, selection, or undo history.
The agent does not push edits into Yjs in-process and does not call any localhost probe — those approaches silently no-op on serverless (the action runs in a different process). The peer-editor model below replaced them.
Agent Edits As A Real-Time Peer Editor
SQL is the durable source of truth for document body content. The agent
action edits the canonical content column and bumps updatedAt. No localhost
calls, no in-process Yjs mutation.
The open editor reconciles authoritative external content into the live
Y.Doc. The updatedAt bump flows through change-sync, which refetches the
record. The lead client applies the new content via setContent, producing Yjs
operations that merge with concurrent human edits. Every connected client
receives the result through normal Yjs sync.
The updatedAt gate
// In the editor's reconcile effect
if (loaded.updatedAt > lastAppliedUpdatedAt.current) {
applyAuthoritativeContent(loaded.content); // adopt
lastAppliedUpdatedAt.current = loaded.updatedAt;
}
// else: lagging poll / stale snapshot → ignore
Without the gate, a slightly-behind poll response re-applies old content and the edit "reverts on next poll". A fresh mount always adopts whatever content it loaded.
Lead-client election
Exactly ONE connected client applies the authoritative snapshot; the rest receive it through Yjs sync:
import { isReconcileLeadClient } from "@agent-native/core/client/collab";
if (
loaded.updatedAt > lastAppliedUpdatedAt.current &&
isReconcileLeadClient(awareness, ydoc.clientID)
) {
applyAuthoritativeContent(loaded.content);
}
The agent's awareness entry (`AGENT
Häufige Fragen
Können Agent und Personen gemeinsam bearbeiten?
Ja. Der Skill behandelt den Agenten und menschliche Nutzer als gleichberechtigte Teilnehmer im selben Dokument.
Wie werden die Cursor anderer Nutzer gezeigt?
Eine Cursor-Erweiterung zeigt die Cursor entfernter Nutzer mit ihren Namen und Farben.
Was passiert, wenn die Live-Verbindung abbricht?
Die App fragt den Server dann etwa alle zwei Sekunden ab.
Details
Originalbeschreibung des Autors
Multi-user collaborative editing with Yjs CRDT, SSE fast-path transport, and granular server-side merge. Use when adding real-time collaborative editing to a template, debugging sync issues, or understanding how the agent and humans edit documents simultaneously.
repo: BuilderIO/agent-native
Beliebtheit
- GitHub-Sterne
- 7.6k
- Platz im Ranking
- #13174
- Lizenz
- MIT
- Aktualisiert
- 2.11.2026
Kommentare
- …
Weitere Skills aus diesem Repository
design-exploration
7.6kHilft deinem Agenten, mehrere UI-Design-Richtungen nebeneinander zu erkunden, dich eine auswählen zu lassen und das gewählte Design danach zu verfeinern.
visual-edit
7.6kHilft deinem Agenten, eine laufende lokale App in einem visuellen Editor zu öffnen, damit du ihre echten Bildschirme gemeinsam prüfen und bearbeiten kannst.
turn-into-app
7.6kVerwandelt einen Arbeitsablauf, eine Tabelle oder ein Projekt in eine ausgearbeitete visuelle App mit gefüllten Bildschirmen und einem Agenten im Hintergrund.
visual-plan
7.6kVerwandelt einen einfachen Textplan in einen interaktiven visuellen Plan mit Diagrammen, Dateiübersichten, Code-Ausschnitten und offenen Fragen.
Ähnliche Skills
angular-developer
280kHilft deinem Agenten bei Angular-Code und gibt Tipps zur Projektstruktur. Nützlich für neue Projekte, einzelne Code-Teile sowie Performance und Barrierefreiheit.
frontend-a11y
280kHilft deinem Agenten, Weboberflächen für alle zugänglich zu machen. Sorgt dafür, dass Websites und Apps gut mit Screenreadern und Tastaturnavigation funktionieren.
frontend-patterns
280kLässt deinen Agenten moderne Muster in der Frontend-Entwicklung anwenden. Optimiert Performance, verwaltet State und folgt Best Practices für React und Next.js.