Skip to main content
skill CX Codex

realtime-sync — Claude Code skill: what it does, how to install

realtime-sync guides agents through designing low-latency sync using WebTransport, CRDT conflict resolution, and batched AI token streaming.

MIT 108 installs ★ 29 updated 2026-08-17

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add oakoss/agent-skills --skill realtime-sync -a claude-code
Open on GitHub

What realtime-sync does

The skill provides architecture blueprints for distributed sync targeting sub-50ms latency. It covers WebTransport multiplexed bidirectional streams on HTTP/3, message sequence tracking for reconnect recovery, and the transactional outbox pattern to keep databases aligned with real-time push channels.

It details conflict-free collaborative workflows via Yjs and Automerge, cursor presence with y-protocols/awareness, and granular undo histories. For streaming AI output, it guides token batching using requestAnimationFrame and backpressure control so rapid token arrivals do not choke UI rendering threads.

Because strict corporate networks frequently drop UDP and HTTP/3 traffic, you must provide a WebSocket fallback.

What it helps with

  • set up bidirectional WebTransport streams on HTTP/3
  • resolve concurrent text edits without locks using CRDTs
  • batch high-frequency AI token streams to eliminate UI lag
  • implement a transactional outbox with sequence tracking for reconnections

Example prompts for the agent

  • Design a collaborative document editor using Yjs with cursor presence.
  • Implement a WebTransport client connection that falls back to WebSockets if UDP is blocked.
  • Build an AI token streaming component that batches render updates with requestAnimationFrame.

How to install realtime-sync

1Skills CLI (Vercel)

npx skills add oakoss/agent-skills --skill realtime-sync -a claude-code

2Manually: put the files in place

~/.claude/skills/realtime-sync/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/realtime-sync/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about realtime-sync

How to install realtime-sync in Claude Code?

Run npx skills add oakoss/agent-skills --skill realtime-sync -a claude-code in your terminal.

What does realtime-sync do?

It instructs your coding agent on building low-latency real-time sync systems using WebTransport, CRDTs, transactional outbox patterns, and UI backpressure handling.

How should high-frequency messages be serialized?

For message frequencies around 100Hz and above, use Protocol Buffers or MessagePack instead of JSON.stringify to reduce CPU overhead.

Source text

SKILL.md · MIT
---
name: realtime-sync
description: 'Low-latency synchronization with WebTransport, pub/sub messaging, CRDTs, and AI stream orchestration. Covers bidirectional streaming, transactional outbox patterns, sequence tracking, and collaborative editing. Use when building real-time collaborative UIs, implementing pub/sub messaging, handling WebTransport or WebSocket connections, orchestrating live AI token streams, or resolving conflicts with CRDTs.'
license: MIT
metadata:
  author: oakoss
  version: '1.1'
user-invocable: false
---

# Realtime Sync

## Overview

Architects high-concurrency, sub-50ms latency synchronization between distributed clients and servers. Covers WebTransport (HTTP/3) bidirectional streaming, transactional outbox patterns for database-to-sync consistency, CRDTs for collaborative editing, and AI token stream orchestration.

Core principles: the database is the source of truth (real-time channels notify, not persist), CRDTs eliminate locking for concurrent edits, and backpressure management prevents UI jitter from high-frequency streams.

**When to use:** Real-time collaborative UIs, pub/sub messaging, WebTransport/WebSocket connections, live AI token streams, presence tracking, conflict resolution with CRDTs, multiplayer applications.

**When NOT to use:** Batch processing pipelines, static content delivery, request-response APIs without real-time requirements, offline-only applications.

## Quick Reference

| Pattern               | Approach                                     | Key Points                                               |
| --------------------- | -------------------------------------------- | -------------------------------------------------------- |
| WebTransport          | `new WebTransport(url)` + `await ready`      | HTTP/3 multiplexed; replaces WebSockets for new projects |
| Bidirectional stream  | `transport.createBidirectionalStream()`      | Returns `{ readable, writable }` for request-response    |
| Unidirectional stream | `transport.createUnidirectionalStream()`     | Returns a `WritableStream` directly for one-way pushes   |
| Datagrams             | `transport.datagrams.writable`               | UDP-like unreliable delivery for high-frequency state    |
| Connection stats      | `transport.getStats()`                       | Returns `smoothedRtt`, `bytesSent`, `packetsLost`        |
| Transactional outbox  | DB write + outbox insert in one transaction  | CDC worker pushes to channel; prevents state drift       |
| Sequence tracking     | Sequence IDs on every message                | Rewind on reconnect to fetch missed messages             |
| CRDT collaboration    | Yjs (text) or Automerge (JSON state)         | Conflict-free concurrent editing without locks           |
| CRDT awareness        | `y-protocols/awareness` module               | Tracks cursors, selections, and user presence            |
| CRDT undo/redo        | `Y.UndoManager` with `trackedOrigins`        | Tracks only local user operations for selective undo     |
| Presence              | Heartbeat-based user tracking                | Epidemic broadcast for reliable zombie cleanup           |
| AI stream batching    | `requestAnimationFrame` for token rendering  | Prevents UI jitter from high-frequency updates           |
| Buffer-and-batch      | `useTransition` for sync-triggered updates   | Defers non-urgent re-renders during sync bursts          |
| Backpressure          | Buffer size limit with forced flush          | Prevents memory buildup when tokens outpace rendering    |
| WebSocket fallback    | Detect WebTransport support first            | Enterprise firewalls may block UDP/HTTP/3                |
| Serialization         | Protocol Buffers or MessagePack              | Avoid JSON.stringify on 100Hz+ streams                   |
| Web Worker transport  | Handle WebTransport in a Web Worker          | Prevents blocking the UI thread                          |
| Channel multiplexing  | Subscribe to multiple channels on one socket | All subscriptions share a single transport connection    |

## Common Mistakes

| Mistake                                                        | Correct Pattern                                                      |
| -------------------------------------------------------------- | -------------------------------------------------------------------- |
| Using real-time messages as the primary source of truth        | State lives in the database; real-time is the notification of change |
| Using JSON.stringify on high-frequency streams (100Hz+)        | Use Protocol Buffers or MessagePack for serialization                |
| Ignoring sequence drift when a client misses messages          | Implement Sequence IDs and a rewind mechanism on the client          |
| Implementing global locks for concurrent access                | Use Optimistic UI and CRDTs for conflict-free collaboration          |
| Sticking with WebSockets for new projects needing multiplexing | Use WebTransport (HTTP/3) for bidirectional, multiplexed streams     |
| CRDT document bloat from unbounded history                     | Use snapshotting (LWW) for fields that do not need history           |
| Failing to close WebTransport streams on unmount               | Explicitly close streams to prevent transport crashes                |
| Importing Awareness from `yjs` instead of `y-protocols`        | Use `import { Awareness } from 'y-protocols/awareness'`              |
| Using `ydoc.clientID` as UndoManager tracked origin            | Use custom transaction origins passed to `doc.transact()`            |
| One React re-render per AI token received                      | Batch tokens with `requestAnimationFrame` and flush once per frame   |
| Not handling WebTransport `closed` promise                     | Monitor `transport.closed` to detect unexpected disconnections       |

## Delegation

> If the `local-first` skill is available, delegate local-first architecture decisions, sync engine comparison, and client storage selection to it.
> If the `electricsql` skill is available, delegate ElectricSQL shape-based Postgres sync patterns to it.

- **Explore transport protocol options and latency benchmarks**: Use `Explore` agent to compare WebTransport, SSE, and WebSocket tradeoffs
- **Implement transactional outbox pattern with CDC pipeline**: Use `Task` agent to set up database triggers, outbox table, and background worker
- **Design real-time architecture for collaborative editing**: Use `Plan` agent to map CRDT strategy, presence management, and conflict resolution flow
- **Build multi-stream AI orchestration component**: Use `Task` agent to implement parallel token stream rendering with backpressure
- **Audit real-time connection lifecycle management**: Use `Review` agent to check for stream leaks, missing cleanup, and reconnection handling

## References

- [WebTransport streaming and worker patterns](references/webtransport.md)
- [Pub/sub messaging and guaranteed delivery](references/pubsub-delivery.md)
- [CRDTs and collaborative editing](references/crdt-collaboration.md)
- [AI stream orchestration patterns](references/ai-stream-orchestration.md)
- [Collaborative undo and redo patterns](references/undo-redo.md)

© oakoss · MIT · oakoss/agent-skills

Similar skills

All skills for Backend and APIs →

From the same set106

The whole set →
electricsql Briefs your coding agent on ElectricSQL: streaming slices of Postgres to the client through Shapes, plus the proxy and write patterns around it. CX Codex +1 109installs trpc trpc is a Claude Code skill for building type-safe TypeScript APIs with tRPC v11. It comes into play when working on routers, procedures, React clients, or tests. CX Codex +1 109installs tauri This Claude Code skill covers Tauri v2 apps with web frontends and Rust backends. It activates for project setup, IPC, permissions, or app releases. CX Codex +1 108installs turborepo This Claude Code skill helps configure Turborepo in JavaScript and TypeScript monorepos. Use it to set up task pipelines, caching, package filters, and CI workflows. CX Codex +1 108installs plan-first-development The plan-first-development Claude Code skill structures project planning and tracks progress across sessions. It activates for new projects, major features, and work split into phases. CX Codex +1 107installs tracer-bullets The tracer-bullets Claude Code skill splits multi-layer work into end-to-end slices. Each slice is checked before work moves on. CX Codex +1 107installs expert-instruction The expert-instruction Claude Code skill helps design system instructions for AI agents. It covers agent roles, behavioral limits, response formats, and tool-use guidance. CX Codex +1 106installs codebase-packager The codebase-packager Claude Code skill prepares large repositories for AI coding tasks. It builds digests, packs source context, and traces connections across files. CX Codex +1 105installs

Project sponsors

Companies that keep this analytics open