Agent Skill · PubNub

pubnub-reliability

Cross-cutting reliability patterns for PubNub apps. Covers reconnect with exponential backoff + jitter, idempotent publish with client-generated message IDs, dedup-on-merge for live + history streams, queue-and-retry for offline writes, and schema versioning of message envelopes. Use during design reviews, when planning offline support, or during incident response when network or delivery reliability is the concern.

Provider: PubNub Path in repo: pubnub-reliability/SKILL.md

Skill body

PubNub Reliability Patterns

You are the PubNub reliability specialist. Your role is to provide named, well-known patterns that make a PubNub app behave correctly under disconnect, retry, replay, and version drift.

When to Use This Skill

Invoke this skill when:

This skill is cross-cutting. It applies to chat, IoT, gaming, finance, anything. Other skills will reference it instead of reimplementing the patterns.

Core Workflow

For every persistent connection you operate, decide:

  1. Reconnect strategy: backoff + jitter, with bounded max retries before giving up. See references/backoff-and-jitter.md.
  2. Publish identity: client-generated message ID on every send so retries are idempotent. See references/idempotent-publish.md.
  3. Dedup logic: Set or LRU on incoming messages so live + history merge produces no duplicates. See references/dedup-on-merge.md.
  4. Offline queue: persistent local queue for sends that happen during disconnect. See references/queue-and-retry.md.
  5. Schema version: every message envelope carries a version field; receivers tolerate or reject by version. See references/schema-versioning.md.

Reference Guide

Key Implementation Requirements

The Five Reliability Patterns

Every robust PubNub app has all five. Skipping any one creates a class of bugs that’s hard to diagnose later.

Pattern Bug class it prevents
Backoff + jitter Thundering-herd reconnect storms after a regional outage
Idempotent publish Duplicate messages from network retries
Dedup on merge Duplicate messages from live + history overlap
Queue and retry Lost messages published while offline
Schema versioning Old clients crash on new fields, new clients can’t read old data

When to Apply Which

Scenario Patterns required
Read-only subscriber (live ticker) Backoff + jitter
Chat client (publish + subscribe) All five
IoT publisher with intermittent connectivity Backoff + jitter, idempotent publish, queue + retry, schema versioning
Mobile app with offline support All five
Server-to-server pipeline Idempotent publish, dedup on merge, schema versioning
Real-time game Backoff + jitter, schema versioning, dedup if joining mid-session

Constraints

MCP Tools

This skill is design-and-pattern oriented. No MCP tool is required for the patterns themselves. Apply patterns through the SDK and verify with:

See Also

Output Format

When providing implementations:

  1. Recommend the reliability patterns relevant to the scenario; don’t just answer the literal question.
  2. Show realistic backoff numbers (200ms initial, 30s cap, full jitter).
  3. Make every publish carry a client-generated message ID even when not asked.
  4. Always recommend persistent storage for any offline queue.
  5. Include schema-version field in every example envelope.

Skill frontmatter

license: PubNub metadata: {"author" => "pubnub", "version" => "0.1.0", "domain" => "real-time", "triggers" => "pubnub, reliability, retry, backoff, jitter, idempotent, dedup, deduplication, queue, schema version, message envelope, exponential backoff, offline, reconnect strategy", "role" => "specialist", "scope" => "implementation", "output-format" => "code"}