|
| 1 | +--- |
| 2 | +name: loro |
| 3 | +description: "Comprehensive guide for using Loro across document modeling, synchronization, versioning, rich text editors, app-state mirroring, performance tradeoffs, and wasm bindings. Use when Codex needs to work with `loro-crdt`, `loro`, `loro-prosemirror`, `loro-mirror`, or `crates/loro-wasm` for: (1) Choosing CRDT container types and document structure, (2) Designing sync, persistence, checkout, or history workflows, (3) Integrating rich-text editors and stable selections, (4) Mirroring app state with schemas and React, (5) Reasoning about versions, events, import status, or Inspector output, or (6) Maintaining the WASM binding layer." |
| 4 | +--- |
| 5 | + |
| 6 | +# Loro |
| 7 | + |
| 8 | +Use this skill as the single entry point for all Loro work. Load one primary chapter first. Load a second chapter only when the task clearly crosses domains. |
| 9 | + |
| 10 | +## Select A Chapter |
| 11 | + |
| 12 | +- Read [references/topic-map.md](references/topic-map.md) if the task is broad and you need to route it. |
| 13 | +- Read [references/fit-and-architecture.md](references/fit-and-architecture.md) for CRDT fit, local-first framing, setup, and high-level architecture. |
| 14 | +- Read [references/containers-and-encoding.md](references/containers-and-encoding.md) for container choice, composition, encoding, persistence, shallow snapshots, and redaction. |
| 15 | +- Read [references/sync-versioning-and-events.md](references/sync-versioning-and-events.md) for sync flows, frontiers, version vectors, checkout, import status, timestamps, event timing, and Inspector. |
| 16 | +- Read [references/richtext-and-editors.md](references/richtext-and-editors.md) for `LoroText`, cursors, `applyDelta`, `updateByLine`, `loro-prosemirror`, Tiptap, and CodeMirror. |
| 17 | +- Read [references/mirror-and-react.md](references/mirror-and-react.md) for `loro-mirror`, `$cid`, `idSelector`, validation, selectors, and React integration. |
| 18 | +- Read [references/wasm-maintenance.md](references/wasm-maintenance.md) for `crates/loro-wasm`, `#[wasm_bindgen]`, pending-event flushing, wrapper decoration, and tests. |
| 19 | +- Read [references/performance-and-research.md](references/performance-and-research.md) for benchmarks, Eg-Walker tradeoffs, movable-tree context, rich-text design context, and project history. |
| 20 | + |
| 21 | +## Route Common Tasks |
| 22 | + |
| 23 | +- “Build a collaborative document model / choose data types / persist history” |
| 24 | + - Start with `containers-and-encoding.md` |
| 25 | + - Add `sync-versioning-and-events.md` if version/history behavior matters |
| 26 | +- “Debug checkout / detached mode / missing imports / event timing” |
| 27 | + - Start with `sync-versioning-and-events.md` |
| 28 | +- “Integrate ProseMirror, Tiptap, CodeMirror, or custom rich text” |
| 29 | + - Start with `richtext-and-editors.md` |
| 30 | + - Add `sync-versioning-and-events.md` if undo/version/event behavior matters |
| 31 | +- “Model app state with loro-mirror or loro-mirror-react” |
| 32 | + - Start with `mirror-and-react.md` |
| 33 | + - Add `containers-and-encoding.md` if schema semantics depend on container choice |
| 34 | +- “Change wasm bindings or debug pending event flushing” |
| 35 | + - Start with `wasm-maintenance.md` |
| 36 | +- “Decide whether Loro is even the right tool / explain tradeoffs” |
| 37 | + - Start with `fit-and-architecture.md` |
| 38 | + - Add `performance-and-research.md` if benchmark or research context matters |
| 39 | + |
| 40 | +## Execute The Task |
| 41 | + |
| 42 | +1. Classify the task before reading everything. |
| 43 | +2. Load one primary chapter. |
| 44 | +3. Load at most one secondary chapter for cross-domain work. |
| 45 | +4. Keep solutions grounded in Loro semantics: |
| 46 | + - choose data types by merge behavior, |
| 47 | + - distinguish state version from history version, |
| 48 | + - keep ephemeral state out of persisted CRDT data, |
| 49 | + - respect the binding/runtime invariants in `crates/loro-wasm`. |
| 50 | + |
| 51 | +## Keep Guardrails |
| 52 | + |
| 53 | +- Do not assume CRDTs are the right fit for hard invariants, exclusivity, or authorization-at-write-time problems. |
| 54 | +- Do not model editable text as plain strings when user intent requires merged edits. |
| 55 | +- Do not reuse peer IDs across concurrent sessions. |
| 56 | +- Do not confuse detached documents with detached containers. |
| 57 | +- Do not change wasm-exposed mutators without checking pending-event flushing behavior. |
0 commit comments