/private-chat-engines:chat-builder-and-operator-playbooksfrom private-chat-engines
Provides checklists and design guidance for building and operating private-chat products: protocol shape, crypto stack, server components, key custody, pre-launch audits, metadata budgets, abuse under E2EE, WebRTC, library selection, ops, and incident response.
Ships in private-chat-engines. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Part 6 of 6 of the Private Chat Engines dossier (plugin
private-chat-engines), covering §1–§12 — plus §2.5 (the server you have to write anyway) and §5.5 (the WebRTC layer behind voice and video). Sibling skills:chat-orientation-threat-models-and-landscape(§0–§5 — the three architectural families, threat-model taxonomy, the comparison matrix, the timeline, the five forces),chat-signal(§1–§6 — the protocol stack, the organisation and its costs, legal posture, operator and developer perspectives, honest weaknesses),chat-telegram(§1–§7 — MTProto and the cloud-chat compromise, the Durov prosecution, scale and economics, the bot and Mini-App economy),chat-matrix-and-element(§1–§6 — federation, Matrix 2.0, the ecosystem and its funding, the homeserver operator handbook, the developer surface),chat-the-wider-field(§1–§13 — MLS and Wire, WhatsApp, iMessage PQ3, Threema, Olvid, SimpleX, Session, Nostr, XMPP, Briar, Delta Chat, the dead ones, the policy annex). Section numbers are per skill, not shared across the set: each file is a self-contained dossier entry. A reference written as §N →skillpoints at that skill's own §N.Currency: state of research 16 September 2026. The checklists and the metadata budget are stable fundamentals; §6's library list and §11's budget anchors are dated specifics. Assumes the vocabulary of the five sibling skills.
⚠️ What you would write in the design doc of a private-chat product, and what you would tape inside the rack of a private-chat deployment.
⚠️ GOTCHA boxes mark where the common mental model is wrong in ways that get people hurt or products mis-designed.
The three ideas that organize this document:
- ⚠️ CHOOSE THE PROTOCOL SHAPE BEFORE TOUCHING CRYPTO §1 is first for a reason. The family decision (centralised E2EE, server-encrypted cloud, federated) constrains every cryptographic choice after it, and reversing it later is a rewrite.
- ⚠️ EVERY SERVICE MUST FILL IN THE METADATA BUDGET §3 is a table, not an essay. If you cannot say what your service learns about who talks to whom and when, you have not designed the privacy — you have only encrypted the content.
- ⚠️ ABUSE UNDER E2EE IS THE PART EVERYONE FORGETS TO DESIGN §4 exists because trust-and-safety cannot be bolted on after the crypto. If the server cannot read content, moderation has to be designed into the product from the start.
This file assumes the five sibling skills. It's organised as what you would write in the design doc of a private-chat product, and what you would tape inside the rack of a private-chat deployment.
| Decision | Options | When each is right |
|---|---|---|
| Group crypto | Double Ratchet + sender keys (Signal/WhatsApp/OMEMO) | groups ≤ few thousand; strongest per-message FS/PCS |
| MLS (RFC 9420, TreeKEM) | large or dynamic groups; standards interop (MIMI, DMA); O(log n) membership ops | |
| MegOlm-style outbound ratchets (Matrix) | cheap fan-out where weak PCS is acceptable and rotation is configured | |
| Pairwise queues, no group crypto (SimpleX) | metadata minimalism above all | |
| Delivery | Server-mediated queues | async UX, offline delivery, multi-device |
| Onion-routed swarms (Session) | network-level unlinkability; latency/storage complexity tax | |
| P2P/direct (Briar, calls) | no server trust; battery/NAT/nat-relay pain | |
| Identity | Phone number (Signal/WhatsApp) | viral adoption, abuse control; leaks a government-traceable root |
| Keypair-only (Session, Nostr, SimpleX) | maximal deniability; discovery UX becomes your problem | |
| Random short ID (Threema) / email (Wire/Delta) | middle paths with existing account rails |
⚠️ IF YOU HAVE NO STRONG REASON TO FEDERATE, START CENTRALISED. The engineering effort is roughly 5–10× lower, the security model is coherent, and one team can ship a protocol upgrade to the whole fleet — Signal shipped the Triple Ratchet in weeks; Matrix's E2EE changes take years (→
chat-signal§4,chat-matrix-and-element§2). Federation can be added later; it cannot be removed later. It is the right answer for an open communications commons, not for a private system where you control the trust model and carry the consequences — and the real bill is state replication, cross-server key distribution and split-brain, not the protocol itself (→chat-matrix-and-element§4 for what you are signing up to).
Session establishment
Ongoing ratchet
MAX_SKIP) as a
storage-DoS defence — enforced in the OMEMO 2 library
for exactly this reason.Multi-device
The boring baseline (get these wrong and the ratchet does not save you)
rand().⚠️ DO NOT IMPLEMENT CRYPTOGRAPHY YOURSELF Use vetted libraries at the highest level of abstraction that solves the problem. If your code contains a mode of operation, an IV, or a padding decision, you are already lower-level than you probably need to be. The primitives are rarely broken; the systems built from them fail constantly — implementation bugs, key-management errors, protocol-composition mistakes.
Key custody — the algorithm choice is easy; where the keys live is where systems fail
Client message pipeline
Before you ship
Whatever the protocol shape, a centralised engine needs the same five pieces — and the privacy of the product is decided by what each one is allowed to remember:
| Component | Job | What it may keep |
|---|---|---|
| Account service | registration, device authentication, account management | account identifier + public identity keys |
| Pre-key directory | the X3DH bootstrap: serve one bundle per request | signed pre-key + one-time pre-keys, each one-time key deleted on use |
| Message queue | hold ciphertext for offline recipients | undelivered messages only — delete after authenticated client acknowledgement |
| Push service | wake sleeping clients via APNs/FCM | device token; never message content |
| WebSocket / long-poll | real-time delivery to connected clients | deliver, then dequeue only on an authenticated acknowledgement naming the message — a completed write is not receipt |
⚠️ IF YOU KEEP MESSAGES AFTER DELIVERY YOU ARE NOT RUNNING A MESSAGE QUEUE, YOU ARE RUNNING A MESSAGE ARCHIVE. Decide which one you are building, then write it into the metadata budget (§3).
Delivery doctrine. A socket write that returns is not a message that arrived. The client can
disconnect, crash, or be killed by the OS between your write() succeeding and the ciphertext
reaching durable storage on the device — and if you dequeued on the write, the message is now gone
from the server and gone from the recipient, permanently, with no error anywhere. Drop it only
when the client says it has it: an authenticated acknowledgement, on the authenticated session
that owns that queue, naming the server-assigned ID of the message it persisted. The same rule
governs long-poll — an HTTP 200 on the response proves less than a socket write, not more — so
long-poll delivery is acknowledged on the next request, not by the response completing. The price
is that delivery becomes at-least-once: a client that persists a message and then loses the
connection before acknowledging will be sent it again. That is the correct trade (a duplicate is a
UI problem, a loss is a broken product), and it is handled, not avoided — give every message a
stable server-assigned ID, have the client discard an ID it has already stored, and make the
acknowledgement itself idempotent so a replayed ack is a no-op rather than an error. Then bound each
queue by age and by depth, or a device that never comes back turns your queue into the archive the
warning above forbids.
The queue is per device, not per recipient. The checklist above requires per-device session fan-out (the Sesame pattern), and delivery has to match it. Hold one queue entry per device, and drop that entry only on an acknowledgement from that device. A single recipient-level entry dequeued on the first acknowledgement to arrive is a message the recipient's phone confirms and their laptop never receives — and it fails silently in the worst way, because from the server's side the message was delivered and acknowledged, so nothing anywhere reports an error. So fan a message out to every registered device of the recipient, track acknowledgement per device, and retain each copy until that device acknowledges it or its own bound expires. What a device that registers later is owed is a linked-device history policy — a decision you make deliberately in the metadata budget (§3), not an accident of which device happened to acknowledge first.
Storage doctrine. The ideal database holds account registrations, public keys, pre-keys and undelivered messages. It does not hold delivered messages, who-messaged-whom, social graphs or connection logs. Where a feature forces you to keep some metadata — group membership is the usual case — keep the minimum and delete it when it stops being needed. Postgres for the relational side, Redis for the queue; session state belongs to the client, never the server.
☑ Rate-limit pre-key fetches per account. An attacker who drains a user's one-time pre-keys degrades or blocks delivery to them: pre-key exhaustion is a denial-of-service surface, not only a capacity parameter. §2's "last-resort" pre-key is the graceful half of the answer; the rate limit is the other half.
| Datum visible to your server by default | Signal's mitigation | If you can't mitigate it, write it down |
|---|---|---|
| Sender identity on each message | Sealed Sender + delivery tokens | at least encrypt sender outside routing fields |
| Social graph | zero-knowledge groups (zkgroup KVAC credentials), enclave contact discovery (CDSI/PathORAM) | delete-on-delivery policies; retention audits |
| Registration/contact discovery | SGX enclave + ORAM (and its documented enclave-compromise residual risk) | hashing is theatre against nation states; say so |
| Group membership | zkgroup | at least avoid server-readable role metadata |
| Backups | zero-knowledge, unlinked-from-account storage (2025 backups design) | encrypted client-side or don't offer backups |
| Push timing/token | content-free pushes; community paths around FCM/APN (Molly+UnifiedPush) | document that Apple/Google see wake-up metadata |
| IPs | call relays; Tor/proxy support | log rotation discipline in writing |
chat-signal §4).If the product has calls, it has WebRTC, whether or not anyone says so.
⚠️ WEBRTC GIVES YOU ENCRYPTED MEDIA AND NOTHING ELSE. Signalling is deliberately unspecified — your chat server carries the SDP offers/answers and the ICE candidates, or two browsers never meet.
The pieces: getUserMedia (camera/mic capture), RTCPeerConnection (the encrypted peer
transport), RTCDataChannel (arbitrary data over SCTP, optionally reliable, optionally ordered).
NAT traversal is the hard part. ICE tries candidate paths; STUN tells a peer its own public
address; TURN relays when direct connection fails — and a meaningful fraction of calls need it.
Relay bandwidth is a line item, not a rounding error: Signal's own breakdown puts call relaying at
~$1.7M/yr of ~$2.8M bandwidth, ~20 PB/yr (→ chat-signal §2). Budget TURN before you promise calls.
⚠️ WEBRTC LEAKS IP ADDRESSES BY DESIGN ICE candidate gathering hands local and public addresses to the page — which is why WebRTC has been used for de-anonymisation and VPN-leak detection. Browser mitigations (mDNS for local addresses) are partial. During a call your users' IPs are visible to the other peer unless you force traffic through your own relays, which is exactly what Signal's "always relay calls" toggle buys, at latency and bandwidth cost.
SRTP with DTLS is transport encryption, not E2EE. Media is always encrypted on the wire with keys exchanged via DTLS, but the moment an SFU is in the path the SFU can see the media unless you add E2EE through insertable streams.
| Topology | Who does the work | When it is right |
|---|---|---|
| Mesh | everyone sends to everyone | ≤3–4 participants; upstream bandwidth explodes past that |
| SFU (selective forwarding unit) | server forwards streams without decoding | the standard answer — Jitsi, LiveKit, mediasoup, Signal's group calls, MatrixRTC |
| MCU (multipoint control unit) | server decodes and composites into one stream | only for very weak clients; expensive in CPU, rare in modern systems |
Simulcast and SVC — send several qualities so the SFU forwards the appropriate one per receiver. This is the only reason a gallery view of thirty people works at all.
⚠️ THE E2EE PROBLEM WITH CONFERENCING An SFU only forwards, so it can work with E2EE (insertable streams: it relays media it cannot decode). But every server-side feature that needs the content — recording, transcription, noise suppression, server-computed backgrounds — becomes impossible. That tension is why most conferencing is not E2EE by default, and why Zoom's 2020 "end-to-end encrypted" marketing described transport encryption and ended in an FTC settlement: the canonical case of the four meanings of "encrypted" being conflated (→
chat-orientation-threat-models-and-landscape§2).
Reference that transfers: WebRTC for the Curious and the W3C WebRTC API spec plus the ICE/STUN/TURN/SRTP/DTLS RFCs.
signalapp/libsignal-client (Rust, AGPL) — the canonical stack, SPQR included
(repo).matrix-rust-sdk + vodozemac (crypto incl. cross-signing, 4S backup), matrix-js-sdk,
mautrix-go (appservices/bridges), matrix-nio (Python).chat-telegram).| You want… | Run… | You'll own… |
|---|---|---|
| A zero-ops private chat for family/team | Signal (or Threema paid) | device posture & user training only |
| Sovereign org comms with admin controls | Element/Synapse or Continuwuity (Matrix 2.0; or Wire enterprise, self-hosted variants) | infra, keys, GDPR/DSA duties, moderation |
| Public square with scale + bots | Telegram communities | platform policy risk; nothing infra-side |
| Metadata-resistant small group comms | SimpleX (your own relays) | relay uptime, link distribution |
| Censored-population comms | Signal TLS proxies, Session nodes, Delta Chat chatmail, Tor pluggable transports | volunteer infra, rotation discipline |
| Offline/mesh contingencies | Briar (maintenance mode; know it) | pairing logistics |
server_name apex and delegate via .well-known; never migrate
it later — design your domain story in the first hour.m.room.server_acl changes monitored like firewall rule changes.March 2025: senior US officials coordinated strike planning in a Signal group and accidentally added a magazine editor. Nothing about Signal failed. Everything around it did: wrong channel choice for classified material, no identity verification on join, no records handling, no device policy. The operator lesson that transfers to every engine in this dossier:
E2EE secures the transport between endpoints. It cannot tell you if the endpoints are the right people, on managed devices, following retention law, or sober. Organisations answering that gap in 2026 are buying sovereign Matrix deployments and certified niche messengers (BwMessenger, Olvid, Wire) — and writing policy, which no protocol ships with.
Cross-references throughout to chat-signal, chat-telegram, chat-matrix-and-element and chat-the-wider-field carry the dated provenance; additional anchors cited
inline: libomemo.js 2.0.0 release,
Matrix FY2025 annual report,
Signal's 990 filings via ProPublica,
Signal SPQR announcement,
Signal Secure Backups,
SimpleX PQ ratchet,
[RFC 9420 (MLS)] and RFC 9941 (sntrup761x25519),
Briar maintenance-mode statement.
Stable fundamentals (ratchet mechanics, TreeKEM, federation design) are stated unsourced by design.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
private-chat, e2ee, metadata-budget, webrtc, incident-response, audit-checklist
6 skills in this plugin
/chat-matrix-and-elementUse when running or building on Matrix — the federated protocol and its room/event model, Olm and Megolm, Matrix 2.0 and where it stands, the ecosystem's organisations and funding, the homeserver operator handbook including the European sovereignty deployments, and the developer surface. Companion to the other private-chat-engine skills./chat-orientation-threat-models-and-landscapeUse when orienting in private messaging — the three architectural families and what follows from each, the threat-model questions that decide every other choice, the September 2026 comparison matrix, how the field got here, and the five forces reshaping it. Start here. Companion to the other private-chat-engine skills./chat-signalUse when working with Signal or the Signal protocol — X3DH and the double ratchet, sealed sender, private contact discovery and SGX enclaves, key transparency, PQXDH and post-quantum ratcheting, the Foundation's cost structure, the legal and political fights, what you can and cannot operate or build, and the weaknesses worth saying out loud. Companion to the other private-chat-engine skills.npx claudepluginhub the-vibey-project/vibey --plugin private-chat-engines