/major-ai-skills:natsfrom major-ai-skills
Design NATS subjects and JetStream streams; use pull consumers, AckWait, and Nats-Msg-Id dedupe; configure TLS/auth; debunk exactly-once—at-least-once with publish dedupe and idempotent handlers.
Ships in major-ai-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.
Core NATS is fire-and-forget pub/sub (at-most-once on lossy paths). JetStream adds persistence, replay, consumer acks, KV/Object stores, and Raft-replicated metadata. Publish deduplication (Nats-Msg-Id + stream duplicate_window) prevents duplicate records in the stream; consumer delivery remains at-least-once unless handlers are idempotent and ack timing is correct.
Publishers (TLS, creds/JWT)
-> NATS cluster (4222 client / 6222 route)
-> JetStream streams (limits/workqueue/interest retention)
-> consumers (pull preferred in prod)
Subscribers ack/nak/in-progress
Use when
Do not use when
app.region.entity.action; scope stream subjects narrowly—avoid catch-all > on high-throughput streams without filters.Nats-Msg-Id to stable business IDs; size duplicate_window to retry horizon—not a substitute for consumer idempotency (streams docs).max_bytes; keep MaxAckPending ≥ batch size; avoid huge batches if processing is sequential (pull consumers).AckWait must exceed p99 processing or send in-progress heartbeats; short AckWait causes double delivery while work still runs (ack docs). duplicate_window ≠ AckWait (nats-server #6628).import { connect, JSONCodec, headers } from "nats";
const nc = await connect({ servers: ["nats://127.0.0.1:4222"], tls: { /* caFile */ } });
const jsm = await nc.jetstreamManager();
await jsm.streams.add({
name: "ORDERS",
subjects: ["orders.*"],
retention: "limits",
max_bytes: 1024 ** 3,
duplicate_window: 120 * 1e9, // 2m publish dedupe window
});
const hdrs = headers();
hdrs.set("Nats-Msg-Id", `order-${order.orderId}`);
await nc.jetstream().publish("orders.created", codec.encode(order), { headers: hdrs });
const consumer = await js.consumers.get("ORDERS", "order-worker");
const iter = await consumer.fetch({ max_messages: 10, expires: 30_000 });
for await (const msg of iter) {
try {
await processIdempotent(msg);
msg.ack();
} catch (e) {
msg.nak(millis(2000));
}
}
| Failure signature | Root cause | Diagnostic & fix |
|---|---|---|
| Slow consumer (core) | Push faster than handler | JetStream pull; scale workers |
| Duplicate deliveries | AckWait too short / no ack | Raise AckWait; in-progress; idempotent handler |
| Duplicate publishes retried | Missing Nats-Msg-Id | Stable msg id + duplicate_window |
| Stalled pull | MaxAckPending too low | Raise pending ≥ batch; ack faster |
No storage / disk full | Stream limits / volume | nats stream info; expand PVC |
| Raft leader issues | Even-sized cluster / partition | Odd node count; check route mesh |
| Lost ack redelivery | Network drop after process | Double ack mode for critical ops (delivery doc) |
term()) after N deliveries with alert.@kafka — heavier log-oriented streaming@rabbitmq — classic broker queues@temporal — durable orchestration over activitiesMANDATORY: Do not equate
duplicate_windowwith exactly-once processing. Use pull consumers with explicit ack after side effects. Set AckWait above processing p99 or use in-progress. Financial flows require idempotent handlers and consider double ack.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub alivirgo/major-ai-skills --plugin major-ai-skills412 skills in this plugin
/3d-slicerAutomate 3D Slicer research workflows with MRML, VTK/ITK, DICOM data, and Segment Editor. Use for software workflows, not clinical interpretation./abbreviated-git-statusInspect Git branch, staging, and working-tree changes with short or porcelain status output when a compact repository check is needed./ableton-liveAutomate Ableton Live sessions with Python MIDI Remote Scripts, Max for Live, AbletonOSC, and Link synchronization./act-as-a-personal-tutorExplain a subject step by step, assess prior knowledge, and use short exercises to check understanding before advancing.Other plugins' skills for the same job