distributed-consensus
Use when the user asks about consensus, Raft leader election, Paxos, quorums, split brain, etcd, ZooKeeper, KRaft, replicated logs, linearizability, fencing…
от j4flmao★ 47 звёзд на GitHub
Установить distributed-consensus в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Distributed Consensus
Purpose
Consensus lets a group of machines agree on a sequence of values (a replicated log) despite crashes and network partitions, which is how etcd, ZooKeeper, Consul and Kafka's KRaft keep a single source of truth. This skill explains the guarantees and failure model, the Raft algorithm in enough detail to reason about edge cases, and the rules for using these systems safely.
Agent Protocol
Trigger
"consensus", "Raft", "Paxos", "leader election", "split brain", "quorum", "etcd", "ZooKeeper", "KRaft", "replicated log", "linearizable", "fencing token".
Input Context
- What must be agreed (configuration, leadership, metadata, every write)
- Cluster size, zones/regions, latency between them
- Failure model (crash-stop vs Byzantine) and consistency requirement
Output Artifact
Cluster sizing, protocol explanation, failure-scenario walkthrough, usage pattern. No file unless requested.
Response Format
Need: {leader election | config store | replicated state machine}
Cluster: {N nodes over Z zones} tolerates {f} failures
Protocol/system: {Raft via etcd | ZooKeeper (ZAB) | ...}
Scenario: {failure} -> {behaviour}
Client rules: {timeouts, fencing, linearizable reads}
1. Fundamentals
- Crash-fault-tolerant consensus needs a majority quorum: N = 2f + 1 nodes tolerate f failures (3 → 1, 5 → 2). Even sizes add cost without tolerance (4 still tolerates 1).
- Two majorities always intersect, which is why only the side with a majority can make progress during a partition — this prevents split brain.
- FLP impossibility: no deterministic protocol guarantees termination in a fully asynchronous network with one faulty process; practical protocols guarantee safety always and liveness when timing is reasonable (timeouts, randomisation).
- Byzantine (malicious) faults need 3f + 1 nodes and different protocols (PBFT, HotStuff) — not covered by Raft/Paxos.
2. Raft
Raft decomposes consensus into leader election, log replication and safety (Ongaro & Ousterhout, 2014).
Terms and roles
Time is divided into terms with at most one leader each. Nodes are follower, candidate or leader. Every message carries the sender's term; a node seeing a higher term steps down to follower and updates its term.
Leader election
- Followers that hear no heartbeat (
AppendEntries) within a randomised election timeout (the paper's example: 150–300 ms) become candidates, increment the term and sendRequestVote. - A node grants at most one vote per term, and only to a candidate whose log is at least as up to date (higher last term, or same term and longer log).
- Randomised timeouts make split votes rare. PreVote (implemented in etcd) stops a partitioned node from disrupting the cluster with ever-increasing terms when it rejoins.
Log replication
- The leader appends client commands to its log and replicates via
AppendEntries(with the previous index/term for the consistency check). - An entry is committed once stored on a majority; the leader applies it to its state machine and replies to the client. Followers apply entries up to the leader's commit index.
- Log Matching: if two logs contain an entry with the same index and term, all preceding entries are identical. On a mismatch the leader backs up and overwrites the follower's conflicting, uncommitted suffix.
Safety details
- A leader only counts replicas for entries from its current term when advancing the commit index (older-term entries become committed indirectly) — this closes the classic Figure 8 scenario.
- A deposed leader in a minority partition can still accept requests but can never commit them; when it sees the higher term it steps down and its uncommitted entries are replaced.
Membership changes
Change one server at a time (single-server changes) or use joint consensus; add new members as non-voting learners first so they catch up before affecting quorum.
Snapshots
Compact the log with state-machine snapshots; lagging followers receive InstallSnapshot.
3. Paxos Family and ZAB
- Paxos (Lamport): proposers, acceptors, learners; two phases (prepare/promise, accept/accepted) agree on one value; Multi-Paxos elects a stable leader to skip phase 1 for consecutive slots. Equivalent power to Raft; harder to implement fully (Raft specifies more of the system).
- ZAB (ZooKeeper Atomic Broadcast): leader-based, primary-backup ordering with epochs; ZooKeeper offers ordered writes and sequential/ephemeral znodes.
- Kafka 4.0 removed ZooKeeper; clusters use KRaft (a Raft-based metadata quorum).
4. Reads
- Reads served by any node can be stale. Linearizable reads need the leader to confirm it is still leader: a quorum round (ReadIndex) or a time-based leader lease (requires bounded clock drift).
- etcd: linearizable reads by default;
serializablereads are faster but may be stale. ZooKeeper reads are local (sequentially consistent); callsync()first when you need the latest value.
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл distributed-consensus?
Use when the user asks about consensus, Raft leader election, Paxos, quorums, split brain, etcd, ZooKeeper, KRaft, replicated logs, linearizability, fencing tokens or how many nodes tolerate failures. Explains consensus and how to use consensus systems safely. Not for application lock APIs (use backend-distributed-locking) or blockchain consensus (use blockchain-core).
Как установить скилл distributed-consensus?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл distributed-consensus запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
AnthropicGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
webapp-testing
AnthropicToolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
brand-guidelines
AnthropicApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
web-artifacts-builder
AnthropicSuite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…