Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Nats Messaging?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/adityaaatiwari-nats-messaging-anvil)
---
name: nats-messaging
description: "Build NATS Core and JetStream systems: subject design, stream retention, Pull consumers, ack waits and KV"
---
<!-- Generated by `anvil plugin build` from catalog/. Edit the catalog, not this file. -->
# NATS messaging
Use when designing NATS subjects, request-reply RPCs, or durable JetStream streams and consumers.
## Subject hierarchy and NATS Core
- Structure hierarchical dot-separated subjects cleanly (`orders.us.created.v1`), keeping high-cardinality IDs in safe positions so wildcard subscriptions (`orders.*.created.*`) stay flexible.
- Remember NATS Core is at-most-once fire-and-forget with zero offline persistence; use queue groups (`subscribe(subj, { queue: "workers" })`) for horizontal load balancing across workers.
## JetStream durability
- Use **JetStream Streams** whenever at-least-once delivery or replay is required. Set explicit `MaxMsgs`, `MaxBytes`, or `MaxAge` retention bounds (`LimitsPolicy`, `WorkQueuePolicy`, or `InterestPolicy`) so storage never grows silently without limit.
- Prefer **Pull consumers** with bounded batch sizes over Push consumers for worker fleets so each worker controls concurrency and memory backpressure.
- Match consumer `AckWait` to worst-case processing time and call `msg.working()` for slow tasks before `AckWait` expires and triggers redelivery.
## Reliability and safety
Send `Nats-Msg-Id` deduplication headers on publishes inside JetStream duplicate windows, use `term()` on unrecoverable poison messages, and separate credentials by subject publish/subscribe permissions (`NKey`/JWT).
## Verify
Tests checking queue-group single delivery in Core, JetStream redelivery after `nak()`, deduplication via `Nats-Msg-Id`, and stream retention eviction behavior.