Architecture Crdtsのロゴ

Architecture Crdts

コミュニティ
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).

概要

公開者j4flmao
リポジトリagent-skills
スキル名architecture-crdts
スター
41
フォーク
6
同梱ファイル
指示のみ
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    j4flmaoがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Architecture Crdts」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/j4flmao/agent-skills/tree/main/skills/architecture/crdts
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

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
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでArchitecture Crdtsを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にArchitecture Crdtsを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Architecture Crdtsは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

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.

よくある質問

AIスキル「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-...

TypingMindでArchitecture Crdtsを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Architecture Crdtsはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにArchitecture Crdtsをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/j4flmao/agent-skills/tree/main/skills/architecture/crdtsを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Architecture Crdtsを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Architecture Crdtsで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもArchitecture Crdtsを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Architecture Crdts」は無料ですか?

はい。j4flmaoがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇