Claude-skill-registry crdt
Loro CRDT state management with loro-mirror. Use when working on files in src/lib/crdt/.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/crdt" ~/.claude/skills/majiayu000-claude-skill-registry-crdt && rm -rf "$T"
manifest:
skills/data/crdt/SKILL.mdsource content
CRDT Guidelines
Critical: Draft-Style Mutations Only
// CORRECT - mutate in place setState((state) => { state.transactions[id] = transaction; }); // WRONG - returning new objects breaks change tracking setState((state) => ({ ...state, transactions: { ...state.transactions, [id]: transaction }, }));
Rules
- Import types from
, don't redeclareschema.ts - Soft deletes: Set
timestamp, never remove from documentdeletedAt - Use
for IDs,crypto.randomUUID()
for timestampsDate.now()
Schema Pattern
export const entitySchema = schema.LoroMap({ id: schema.String({ required: true }), // ... fields deletedAt: schema.Number(), // 0 = not deleted, >0 = timestamp });
React Hooks
- excludes soft-deleteduseActiveTransactions()
- includes soft-deleteduseTransactions()
- for mutationsuseVaultAction()
Sync
- Updates encrypted before leaving client
- Loro handles versioning via version vectors
- Conflicts: last-write-wins per field