Architecture Crdts logo

Architecture Crdts

Community
j4flmao
architecture-crdts

Use this skill when the user says 'CRDT', 'real-time collaboration', 'collaborative editing', 'Yjs', 'Automerge', 'local-first', 'offline sync with merge', 'conflict-free merge', 'operational transformation vs CRDT'. Designs replicated data that merges without coordination: choosing CRDT types, library (Yjs, Automerge, Loro), sync and persistence architecture, and handling tombstones, schema evolution, and authorization. Do NOT use for: server-authoritative consistency/consensus (system-design distributed-consensus), mobile offline caching without concurrent edits (mobile/universal/offline-first), or event sourcing (backend/universal/event-sourcing).

Overview

Publisherj4flmao
Repositoryagent-skills
Skill namearchitecture-crdts
Stars
41
Forks
6
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by j4flmao on GitHub. Read the source before you install it.

Installation

Install the Architecture Crdts AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/j4flmao/agent-skills/tree/main/skills/architecture/crdts
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/j4flmao/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/skills/architecture/crdts .claude/skills/architecture-crdts
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Architecture Crdts in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Architecture Crdts on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Architecture Crdts is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Conflict-free Replicated Data Types (CRDTs)

Purpose

CRDTs let replicas accept writes independently (offline, peer-to-peer, multi-region) and still converge to the same state once they have seen the same updates, with no central lock or transform server. They trade some storage and semantic control for availability and simple sync. Use proven libraries; design the document model, sync transport, persistence, and access control around them.

Agent Protocol

Trigger

"CRDT", "collaborative editor", "multiplayer editing", "Yjs", "Automerge", "Loro", "local-first", "offline merge", "OT vs CRDT", "conflict resolution without server".

Input Context

  • Data shape (text, rich text, lists, maps, counters, trees/canvas).
  • Concurrency: number of simultaneous editors, offline duration.
  • Topology: client-server relay, peer-to-peer, multi-region servers.
  • Auth model and audit/history requirements.

Output Artifact

CRDT design: per-field type, library choice, sync/persistence architecture, compaction and auth plan.

Response Format

Document model: {field: CRDT type}
Library: {Yjs|Automerge|Loro}  Transport: {WebSocket relay|WebRTC|HTTP sync}
Persistence: {updates log + snapshots}  Compaction: {policy}
Auth: {room-level|server-validated updates}
Semantics caveats: {e.g. LWW on title, interleaving}

Completion Criteria

  • Each field's merge semantics stated (what happens on concurrent edits).
  • Server validates who may write which document.
  • Persistence keeps update log + periodic snapshots; growth bounded.
  • Convergence tested with randomized concurrent operations.

Two Families

FamilyReplicas exchangeRequirement on merge/delivery
State-based (CvRDT)Whole state (or deltas)Merge is commutative, associative, idempotent (a join-semilattice); any delivery order, duplicates OK
Operation-based (CmRDT)OperationsConcurrent ops commute; delivery exactly-once and causally ordered (usually provided by the library's sync protocol)

Delta-state CRDTs ship only the changed part of the state; Yjs and Automerge use compact update encodings with state vectors/heads so peers send only what the other side lacks.

Common Types

TypeMerge ruleCaveat
G-CounterPer-replica counts, merge = elementwise max, value = sumIncrement only
PN-CounterTwo G-Counters (inc, dec)Can go negative
LWW-RegisterHighest (timestamp, replica id) winsNeeds good clocks (hybrid logical clocks); silently drops one write
MV-RegisterKeep all concurrent valuesApp must resolve
OR-Set (add-wins)Adds tagged uniquely; remove deletes observed tagsMetadata grows
Sequence (RGA, YATA, Fugue)Elements get unique ids ordered relative to neighboursTombstones; concurrent inserts must not interleave badly
JSON/map CRDTNested maps/lists of the aboveConcurrent move/reparent is hard (tree CRDTs)
typescript
// G-Counter: the canonical state-based CRDT
type GCounter = Record<string, number>;

export const increment = (c: GCounter, replica: string, by = 1): GCounter => {
  if (by < 0) throw new RangeError(`G-Counter cannot decrement (replica=${replica}, by=${by})`);
  return { ...c, [replica]: (c[replica] ?? 0) + by };
};

export const merge = (a: GCounter, b: GCounter): GCounter => {
  const out: GCounter = { ...a };
  for (const [r, n] of Object.entries(b)) out[r] = Math.max(out[r] ?? 0, n);
  return out;
};

export const value = (c: GCounter): number => Object.values(c).reduce((s, n) => s + n, 0);

CRDT vs Operational Transformation

OTCRDT
CoordinationCentral server orders and transforms opsNone required
Offline / P2PPoorNative
MetadataSmallIds/tombstones per element (modern libs compress heavily)
Intent controlServer can enforceMerge rule is fixed by type
ExamplesGoogle Docs (historically), ShareDBYjs, Automerge, Loro

If you already have a single authoritative server and no offline requirement, server-ordered ops (OT or simple last-write with versioning) can be simpler.

Library Usage

Yjs (shared types + y-websocket relay):

typescript
import * as Y from "yjs";
import { WebsocketProvider } from "y-websocket";
import { IndexeddbPersistence } from "y-indexeddb";

const doc = new Y.Doc();
new IndexeddbPersistence("doc-42", doc);                       // offline cache
const provider = new WebsocketProvider("wss://sync.example.com", "doc-42", doc);

const text = doc.getText("body");
const meta = doc.getMap("meta");
doc.transact(() => {                                            // one update event
  text.insert(0, "Hello");
  meta.set("title", "Draft");                                   // map keys: last-writer-wins
});
provider.awareness.setLocalStateField("user", { name: "Ana" }); // presence, not persisted

// Server-side or tests: exchange binary updates
const update = Y.encodeStateAsUpdate(doc);
const replica = new Y.Doc();
Y.applyUpdate(replica, update);

Automerge (JSON-like documents, full history):

typescript
import * as A from "@automerge/automerge";

let a = A.from({ tasks: [] as { title: string; done: boolean }[], votes: new A.Counter(0) });
let b = A.clone(a);
a = A.change(a, d => { d.tasks.push({ title: "Write spec", done: false }); });
b = A.change(b, d => { d.votes.increment(1); });
const merged = A.merge(a, b);   // contains both changes

For networking and storage, Automerge Repo (@automerge/automerge-repo) provides sync adapters.

Architecture

  • The server is a relay plus persistence, but it is still the place for authorization: check the user may write the room before accepting updates; validate update size and rate.
  • Persist incremental updates; periodically merge them into a snapshot (Y.encodeStateAsUpdate) and truncate the log.
  • Project CRDT state into ordinary tables for search, reporting, and server-side business rules.

Pitfalls

  • Valid merge ≠ valid business state: two users each book the last seat; both merges are "correct". Invariants needing exclusivity (uniqueness, balances) need a server-side authority or reservation.
  • Tombstone growth: deleted text still has metadata; enable garbage collection (Yjs gc: true, default) unless you need full history, and snapshot.
  • Clock skew in LWW: use hybrid logical clocks, never raw wall clocks alone.
  • Schema evolution: field renames are new fields; write migrations that copy data inside a change, version the document schema.
  • Undo: must be per-user (Y.UndoManager with tracked origins), not global.
  • Large docs: split into sub-documents (one per page/board) to bound load time.

Checklist

  • Field-by-field CRDT type and concurrent-edit semantics documented.
  • Library chosen; no hand-rolled sequence CRDT.
  • Relay authorizes per document; rate and size limits.
  • Update log + snapshot compaction; GC policy.
  • Business invariants needing exclusivity handled server-side.
  • Property-based tests: random concurrent ops on N replicas converge.
  • Presence/awareness kept out of persisted state.

References

  • Shapiro et al., "Conflict-free Replicated Data Types" (SSS 2011).
  • Kleppmann et al., "Local-first software" (Onward! 2019).
  • Nicolaescu et al., YATA (GROUP 2016); Weidner & Kleppmann, "The Art of the Fugue" (2023).
  • Yjs docs (shared types, providers, awareness); Automerge docs.

Frequently asked questions

What does the Architecture Crdts AI skill do?

Use this skill when the user says 'CRDT', 'real-time collaboration', 'collaborative editing', 'Yjs', 'Automerge', 'local-first', 'offline sync with merge', 'conflict-free merge', 'operational transformation vs CRDT'. Designs replicated data that merges without coordination: choosing CRDT types, library (Yjs, Automerge, Loro), sync and persistence architecture, and handling tombstones, schema evolution, and authorization. Do NOT use for: server-authoritative consistency/consensus (system-design distributed-consensus), mobile offline caching without concurrent edits (mobile/universal/offline-...

Why use Architecture Crdts on TypingMind?

Because you install it once and use it with any model. Architecture Crdts is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Architecture Crdts in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/j4flmao/agent-skills/tree/main/skills/architecture/crdts. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Architecture Crdts?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Architecture Crdts?

As many as you like. As long as a model supports skills, you can use Architecture Crdts with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Architecture Crdts AI skill free?

Yes. It is published on GitHub by j4flmao under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇