Guides wiring atomr cluster features: sharding, singleton, distributed pub/sub, CRDTs, seed-node bootstrap, and MessageExtractor design.
Ships in atomr-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.
None: SKILL.md is the whole skill.
atomr's cluster stack is split across several crates so you only pay for what you use. This skill helps you pick the right one and wire it correctly.
| Need | Feature | Direct crate |
|---|---|---|
| Cross-process messaging only | remote | atomr-remote |
| Membership, gossip, reachability | cluster | atomr-cluster |
| Singleton, distributed pub/sub, cluster client | cluster-tools | atomr-cluster-tools |
| Sharded entities (rebalance, remember-entities) | cluster-sharding | atomr-cluster-sharding |
| Adaptive load balancing | cluster-metrics | atomr-cluster-metrics |
CRDTs (Replicator) | distributed-data | atomr-distributed-data |
Cluster-grade applications usually want
features = ["cluster", "cluster-tools", "cluster-sharding", "persistence"]
or simply the cluster-app bundle.
cluster-sharding transitively requires persistence and
distributed-data because the shard coordinator persists allocations
and uses CRDTs for remember-entities.
A node needs:
ActorSystem name shared by every node in the cluster.use atomr::prelude::*;
let system = ActorSystem::create("my-cluster", Config::reference()).await?;
// `Config::reference()` loads `reference.conf` from your project; it should
// contain a `cluster { seed-nodes = [...] }` block. See docs/remoting.md.
Seed-node order matters during cold start: the first listed seed is expected to be reachable first.
ShardRegion is the entry point. You provide:
MessageExtractor that maps an incoming message to an entity
id and a shard id.ShardCoordinator that owns shard placement.Pattern (from examples/sharded-keyvalue/):
struct KvExtractor;
impl MessageExtractor for KvExtractor {
type Message = KvCmd;
fn entity_id(&self, m: &Self::Message) -> String { /* … */ }
fn shard_id(&self, m: &Self::Message) -> String { /* bucket entities */ }
}
let region = ShardRegion::new("node-1", Arc::new(KvExtractor), coord, factory);
region.deliver(my_cmd);
Design rules of thumb:
shard_id must be deterministic and well-distributed. Hash the
entity id; don't use the first character unless the keyspace is
uniform (the example does it for clarity, not for production).PassivationTracker to identify idle entities
and stop them; they'll be recreated on next message.ClusterSingleton (in atomr-cluster-tools) elects exactly one
instance of an actor across the cluster, with handoff on member loss.
Use it for cluster-wide schedulers, leaders, or external resource
owners — not for per-entity work (use sharding for that).
DistributedPubSub (from atomr-cluster-tools) gives you
topic-broadcast and group-routing semantics:
use atomr_cluster_tools::DistributedPubSub;
let bus = DistributedPubSub::new();
bus.subscribe("room1", subscriber_ref);
bus.publish_msg("room1", ChatMsg { /* … */ });
bus.subscribe_to_group("work-queue", "G1", worker_ref);
bus.send_to_group("work-queue", "G1", JobMsg { /* … */ }); // round-robin
See examples/cluster-pubsub-chat/ for the full pattern.
When you need cluster-wide state without a coordinator (counters, sets,
maps), use atomr-distributed-data::Replicator. It exposes the usual
CRDTs (G-Counter, OR-Set, LWW-Register, etc.) and replicates writes
under tunable consistency (Local, Majority, All).
For replicas that must survive a node restart, use
atomr-distributed-data-lmdb::RedbDurableStore — a redb-backed
implementation of DurableStore. Wire it into the Replicator
config when you mark a key as durable.
atomr_cluster::LeaderHandover is a watcher that compares successive
membership snapshots and emits a LeaderHandoverEvent whenever the
elected leader changes (or transitions in/out of None). Subscribe
when you need to flush, fence, or hand off cluster-singleton-style
work as leadership moves between nodes.
Always configure a split-brain resolver in production. atomr ships
several strategies (KeepMajority, StaticQuorum, KeepOldest,
DownAllWhenUnstable). See crates/atomr-cluster/src/sbr.rs and
docs/architecture.md.
The dashboard (atomr-dashboard) and telemetry exporters are the
fastest way to debug membership and rebalance issues. Expect to wire
both in any non-trivial cluster deployment.
examples/cluster-pubsub-chat/ — DistributedPubSubexamples/sharded-keyvalue/ — ShardRegion, MessageExtractor,
PassivationTrackercrates/atomr-cluster/src/lib.rs — membership APIcrates/atomr-cluster/src/sbr.rs — split-brain resolverscrates/atomr-cluster-sharding/src/lib.rs — sharding APIcrates/atomr-cluster-tools/src/lib.rs — singleton, pub/subdocs/remoting.md — transport + delivery semanticsdocs/architecture.md — cluster internalsTests cover the cluster surface in depth — when in doubt about
expected semantics, search for them by name: vector clock, member
ordering, reachability, cluster events, gossip, SBR strategy,
heartbeat, membership state, singleton, cluster client, pub/sub,
sharding allocation/handoff, failure detector, endpoint state, CRDT
laws, OrMap, LWWMap, PNCounterMap, ORMultiMap, replicator
subscribe.
cluster implies remote. Wire your transport.shard_id. Use a stable hasher; small
changes in algorithm reshuffle every entity.What SKILL.md sets; muted values are Claude Code's defaults
/atomr-ai-skills:atomr-clusterfrom atomr-ai-skills
npx claudepluginhub rustakka/atomr --plugin atomr-ai-skills6 skills in this plugin
/atomr-actor-designUse when authoring or modifying an actor in a project that depends on atomr. Covers Msg type design, the Actor trait's lifecycle hooks, ask vs tell, supervision strategies, and FSM patterns. Triggers on writing or editing an `impl Actor`, choosing a Msg enum, picking a supervision strategy, or wiring `Props`/`ActorSystem`./atomr-persistenceUse when adding event sourcing to an actor in a project that depends on atomr. Covers the Eventsourced trait, journals, snapshots, recovery, RecoveryPermitter, AsyncSnapshotter, and choosing a storage adapter (sql / redis / mongodb / cassandra / aws / azure). Triggers when implementing PersistentActor or Eventsourced, configuring a Journal/SnapshotStore, or wiring a backend./atomr-pythonUse when working with atomr's Python bindings — authoring Python actors, choosing a GIL/dispatcher strategy (python-pinned / python-subinterpreter-pool / python-nogil / python-subprocess), using ask/tell from async or sync code, or declaring C-extension subinterpreter compatibility. Triggers when `pip install atomr`, `from atomr import …`, or any Python file calling `ActorSystem`, `Props`, `Actor`, etc./atomr-testingUse when writing tests against atomr actors using atomr-testkit. Covers TestKit, TestProbe (expect_msg / receive_n / expect_no_msg / expect_msg_pf), and the virtual-time TestScheduler. Triggers when authoring `#[tokio::test]` cases that exercise actors, mailboxes, or scheduled timers./atomr-troubleshootingUse when diagnosing failures in a project that depends on atomr. Covers compile-time errors (missing feature flags, wrong prelude), runtime issues (mailbox stalls, restart loops, ask timeouts), and cluster-level problems (split-brain, unreachable members). Triggers on atomr error messages, missing-symbol errors, hangs, or repeated restarts.