/system-design-skills:messaging-streamingfrom system-design-skills
Guides message queue and event-driven architecture design: delivery guarantees, ordering, dedup, DLQs, backpressure, and when async decoupling is or isn't warranted.
Ships in system-design-skills. 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.
Read when SKILL.md points to them.
Move work off the synchronous request path and decouple producers from consumers, so a slow, spiky, or failure-prone operation doesn't block the caller. Getting this wrong is subtle: a queue silently changes the delivery and ordering guarantees, and under load it can absorb a spike gracefully or become the thing that hides a meltdown until the backlog is unrecoverable.
A step is too slow to do inline (image transcode, fan-out, third-party call); the
write path is spiky and needs a buffer to smooth bursts (→ back-of-the-envelope
for the spike factor); two services must be decoupled so one can fail or deploy
independently; or many consumers need the same event stream. The async hand-off
buys responsiveness, isolation, and elasticity (scale producers and consumers
separately).
The caller needs the result now to proceed (a synchronous read, a balance check before confirming) — a queue only adds latency and a place for work to get lost. Strong read-after-write within one request. Trivial in-process work that a function call handles. Don't add a broker before a number or a coupling problem justifies it (YAGNI): it's a new stateful system to operate, monitor, and reason about under failure. "We'll need Kafka eventually" is name-dropping, not a requirement.
back-of-the-envelope.) One-shot work vs. a replayable log.Sync vs. async — settle this before picking a tool. Stay synchronous when the caller needs the result to continue and the call is fast and reliable; a direct request is simpler to build, trace, and reason about. Go async when the work is slow, spiky, fan-out-heavy, or the caller can react to the result later — this trades immediate consistency and an easy stack trace for responsiveness and isolation. Only after choosing async do the options below apply. Building request/reply over a queue to fake a synchronous answer is a smell — a direct call is the better design.
Queue (work/task queue) — one logical consumer group competes to drain messages; a message is delivered to one worker and removed when acked. Use when there are background jobs or commands to process exactly once-ish, and workers should scale to drain a backlog.
Pub/sub (fan-out) — each subscriber gets its own copy of every message; producers don't know subscribers. Use when multiple independent consumers react to the same event (notify, index, audit) and loose coupling matters.
Stream (durable, replayable log) — an append-only, partitioned, retained log;
consumers track their own offset and can replay history. Use when the design
needs ordering per partition, multiple consumers at different positions, event
sourcing, or reprocessing (→ data-storage for event sourcing/outbox).
Durable workflow (orchestration engine) — code that survives process crashes; the engine persists each step and resumes where it left off, with built-in retries, timers, and compensation. Use when a multi-step process with retries, human delays, and rollback (a saga) would otherwise become a fragile hand-rolled mesh of queues, state flags, and cron jobs.
Delivery semantics cut across all of these: at-most-once (fire and forget,
may drop), at-least-once (retries until acked, may duplicate — the practical
default), exactly-once (no loss, no dup). True end-to-end exactly-once is
impractical: a broker's "EOS" (e.g. Kafka) is intra-cluster only, so across
systems you always implement it as at-least-once + idempotent/deduped
consumers (→ api-design idempotency keys). See
references/deep-dive.md for the mechanics.
| Option | What it solves | What it worsens | Change it when |
|---|---|---|---|
| Queue (work queue) | Decouples + buffers; scale workers to drain backlog | At-least-once means duplicates; ordering not guaranteed across workers | Replay or many independent consumers are needed → stream/pub-sub |
| Pub/sub (fan-out) | One event, N decoupled reactions; add consumers freely | No replay (transient); slow subscriber can lag or drop; fan-out amplifies load | History/replay or per-key ordering is needed → stream |
| Stream (log) | Ordering per partition, replay, multi-consumer, event sourcing | Operationally heavier; partition key is a hot-shard risk; consumers must manage offsets | Simple one-shot jobs don't need a log → queue |
| Durable workflow | Crash-safe long-running sagas; retries/compensation built in | New runtime + programming model; latency overhead; lock-in to engine semantics | A single async step with no orchestration → plain queue |
| At-least-once delivery | No message loss under retry/crash | Duplicates — consumers must be idempotent (→ api-design idempotency keys) | Loss is acceptable and dedup cost isn't worth it → at-most-once |
| Exactly-once (effective) | No loss and no duplicate side effects | Cost/complexity; often narrow (within one broker, not across systems) | Idempotent at-least-once is good enough (it usually is) |
A broker's whole job is to absorb a spike — but it can also hide a meltdown.
resilience-failure.)data-storage sharding. Mitigate: better key, sub-partitioning, or batching.Monitor: queue depth, oldest-message age / consumer lag (the single best signal), redelivery/DLQ rate, consumer throughput vs. producer rate, and end-to-end latency.
consume_rate − produce_rate drain, partition count vs. consumer parallelism,
and storage = rate × message size × retention (→ back-of-the-envelope).Decision | Solves | Worsens | Change it when… table with one row per choice you made here (e.g. the
option, its store, its failure policy); the last column is a concrete trigger
(a number or observable signal). Then name what breaks first.Do
api-design keys).message_id, schema version, key, trace_id) up front.Don't
Quantify before choosing: peak produce rate vs. sustained consume rate (if
producers can outrun consumers for long, backpressure and a depth alarm are
required), retention window (drives storage = rate × message size × retention), and
partition count (caps consumer parallelism — one consumer per partition per
group). A backlog drains at (consume_rate − produce_rate); if that's negative,
it never drains. Use back-of-the-envelope for the spike factor, message sizes,
and storage; don't restate its tables here.
A message is a contract. Define it explicitly, not as "an event":
message_id (for dedup), type/schema_version, a
partition_key/ordering key, timestamp, and a trace_id for correlation.OrderPlaced{order_id, total}) over commands when fanning out; keep it small and forward-compatible.Default to the generic recipe above. If the user names a cloud, read
references/providers/<provider>.md for the managed-service mapping,
quotas/limits, and provider-specific trade-offs. If no file exists for that
provider, the generic recipe is the answer.
To visualize the producer → broker → consumer path, fan-out to multiple
subscribers, or the retry → DLQ flow, use the in-plugin architecture-diagram
skill. Quick inline sketch: producer → [queue] → workers ─fail→ [DLQ]; the main
path solid, the DLQ branch dashed.
resilience-failure — owned-concept lives in: retries/backoff/jitter,
dead-letter queues, and backpressure as outage containment. This skill names
them; that one tunes them.api-design — depends on its idempotency keys, the mechanism that makes
at-least-once delivery safe.data-storage — pairs with this for event sourcing and the transactional
outbox; owned-concept lives in: the hot-shard/partition-key problem streams inherit.consistency-coordination — owned-concept lives in: ordering guarantees,
exactly-once vs. idempotency, and saga/distributed-transaction theory behind
durable workflows.back-of-the-envelope — feeds into sizing: the produce/consume rates,
retention, and storage that size the broker.system-design — the orchestrator that routes here when work goes async.references/deep-dive.md — delivery-guarantee mechanics (acks, visibility
timeouts, offsets, idempotent/dedup consumers, transactional outbox), ordering
internals, partitioning, DLQ design, and when durable-workflow engines beat
hand-rolled queue+retry+saga. Read when designing the messaging layer in detail.references/providers/{generic,aws,azure,gcp,temporal}.md — service
mappings, decision-changing limits, and pitfalls per environment.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub proyecto26/system-design-skills --plugin system-design-skills22 skills in this plugin
/api-designThis skill should be used when the user needs to "design the API", do "endpoint design", pin down a "request/response shape", choose a "pagination" strategy (cursor vs offset), add an "idempotency key" to a write, plan "API versioning", an "error contract", or pick between "REST vs gRPC vs GraphQL" or "WebSocket vs polling". Use it whenever a design has reached the interface — the concrete request, response, primary access path, and how clients page, retry, and version — even if the user only said "the boxes talk to each other"./architecture-diagramThis skill should be used when a system design needs a diagram — "draw the architecture", "diagram this system", "show the components", "make an architecture/infrastructure/topology diagram", or visualizing boxes-and-arrows, data flow, regions, or failure paths for a design. It generates a self-contained dark-theme HTML + SVG diagram (with PNG/PDF export). Use it whenever the `system-design` orchestrator or a building block reaches the "draw it" step, even if the user doesn't say "diagram"./back-of-the-envelopeThis skill should be used when the user needs to "estimate QPS", "back-of-the-envelope" (BOTEC) numbers, "how much storage / bandwidth", "how many servers", "peak load", "capacity planning", or wants the standard latency / throughput / availability numbers to ground a design (latency table, QPS rates, powers of two, nines). Use it whenever a design decision hinges on scale — convert any "high traffic" / "huge data" phrase into concrete numbers before choosing components, even if the user doesn't say "estimate". Prefer it even for a quick "rough numbers" question (DAU × actions/day → QPS, storage per day/year, replication): it carries a calculator and the reference numbers, so the arithmetic and unit conversions are checked instead of done from memory./blob-storeThis skill should be used when the user wants a "blob store" or "object storage", names "S3" or an S3-compatible store, needs to "store images / video / files", asks about "multipart upload" or "resumable upload", "signed / presigned URLs", "media storage", "unstructured data at scale", object "versioning", storage "tiering" (hot/cold/archive), or "erasure coding" vs replication for durability. Use it whenever a design must hold large unstructured objects (photos, video, backups, logs, ML datasets) and serve them cheaply and durably, even if the user just says "where do we put the files"./cachingThis skill should be used when the user asks about a "caching strategy", "cache invalidation", "what to cache", "read-through vs write-through vs write-back", "cache eviction" (LRU/LFU/TTL), "Redis vs Memcached", "stale reads", or hits "thundering herd", "cache stampede", "cache penetration", or "hot key" problems, or is choosing a Redis `maxmemory` eviction policy (allkeys-lru, volatile-lru, noeviction) vs TTL expiry for sessions or other cached state. Use it whenever a design is read-heavy or a datastore is overloaded by reads, even if the user doesn't say "cache"./consistency-coordinationThis skill should be used when the user asks about the "CAP theorem", "PACELC", a "consistency model", "eventual vs strong consistency", "read-your-writes", "causal consistency", "quorum" or "R+W>N", "consensus", "Raft / Paxos", "leader election", "consistent hashing", a "distributed transaction", "2PC", or "saga". Use it whenever a design has multiple copies of data or coordinating nodes and a decision hinges on what a reader is guaranteed to see during replication lag, a network partition, or a node failure — even if the user doesn't say "consistency".Other plugins' skills for the same job