Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Distributed systems design patterns and analysis for CS research
.claude/skills/brycewang-stanford-distributed-systems-guide/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 19% | 0% |
| case-25 | ✗→✓ | ▲ Improved | 139% | 0% |
| case-18 | ✗→✓ | ▲ Improved | 80% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 148% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 73% | 0% |
A skill for researching and designing distributed systems, covering consensus algorithms, replication strategies, consistency models, fault tolerance, and performance analysis. Provides theoretical foundations and practical implementations relevant to systems research.
Strongest
| Linearizability (atomic, real-time ordering)
| Sequential consistency (program order respected)
| Causal consistency (causally related ops ordered)
| PRAM / FIFO consistency (per-process order)
| Eventual consistency (converges if updates stop)
WeakestThe CAP theorem states that during a network partition, a distributed system must choose between consistency and availability:
| System | Partition Behavior | Normal Behavior | Classification | |--------|-------------------|----------------|----------------| | ZooKeeper | Consistent (sacrifice A) | Low latency, consistent | CP / PC/EC | | Cassandra | Available (sacrifice C) | Low latency, eventual | AP / PA/EL | | Spanner | Consistent (sacrifice A) | Higher latency, consistent | CP / PC/EC | | DynamoDB | Configurable per-read | Tunable consistency | AP or CP | | CockroachDB | Consistent (sacrifice A) | Serializable | CP / PC/EC |
pythonfrom enum import Enum from dataclasses import dataclass, field import random class NodeState(Enum): FOLLOWER = "follower" CANDIDATE = "candidate" LEADER = "leader" @dataclass class LogEntry: term: int index: int command: str @dataclass class RaftNode: """ Simplified Raft consensus node for educational purposes. Implements leader election and log replication state machine. """ node_id: str state: NodeState = NodeState.FOLLOWER current_term: int = 0 voted_for: str = None log: list = field(default_factory=list) commit_index: int = 0 last_applied: int = 0 # Leader state next_index: dict = field(default_factory=dict) match_index: dict = field(default_factory=dict) def start_election(self, peers: list[str]) -> dict: """Transition to candidate and request votes.""" self.state = NodeState.CANDIDATE self.current_term += 1 self.voted_for = self.node_id last_log_index = len(self.log) - 1 if self.log else -1 last_log_term = self.log[-1].term if self.log else 0 return { "type": "RequestVote", "term": self.current_term, "candidate_id": self.node_id, "last_log_index": last_log_index, "last_log_term": last_log_term, } def handle_vote_request(self, term: int, candidate_id: str, last_log_index: int, last_log_term: int) -> dict: """Process a RequestVote RPC.""" if term < self.current_term: return {"term": self.current_term, "vote_granted": False} if term > self.current_term: self.current_term = term self.state = NodeState.FOLLOWER self.voted_for = None # Check if candidate's log is at least as up-to-date my_last_term = self.log[-1].term if self.log else 0 my_last_index = len(self.log) - 1 if self.log else -1 log_ok = (last_log_term > my_last_term or (last_log_term == my_last_term and last_log_index >= my_last_index)) vote_granted = ( (self.voted_for is None or self.voted_for == candidate_id) and log_ok ) if vote_granted: self.voted_for = candidate_id return {"term": self.current_term, "vote_granted": vote_granted} def append_entry(self, command: str) -> LogEntry: """Leader appends a new entry to its log.""" entry = LogEntry( term=self.current_term, index=len(self.log), command=command, ) self.log.append(entry) return entry
| Algorithm | Fault Model | Tolerance | Rounds | Complexity | |-----------|-------------|-----------|--------|------------| | Paxos | Crash faults | f < n/2 | 2 (normal) | Difficult to implement correctly | | Raft | Crash faults | f < n/2 | 2 (normal) | Designed for understandability | | PBFT | Byzantine faults | f < n/3 | 3 | O(n^2) message complexity | | HotStuff | Byzantine faults | f < n/3 | 3 | O(n) with pipelining |
pythonclass ReplicatedStateMachine: """ State machine replication with configurable consistency. Demonstrates read/write quorum intersection for correctness. """ def __init__(self, n_replicas: int, read_quorum: int = None, write_quorum: int = None): self.n = n_replicas self.R = read_quorum or (n_replicas // 2 + 1) self.W = write_quorum or (n_replicas // 2 + 1) # Quorum intersection guarantees: R + W > N assert self.R + self.W > self.n, ( f"Quorum intersection violated: R({self.R}) + W({self.W}) " f"must be > N({self.n})" ) self.replicas = [{} for _ in range(n_replicas)] self.version_clock = 0 def write(self, key: str, value: str) -> dict: """Write to W replicas.""" self.version_clock += 1 # Select W replicas (in practice, based on availability) targets = random.sample(range(self.n), self.W) for i in targets: self.replicas[i][key] = (value, self.version_clock) return { "key": key, "version": self.version_clock, "acked_by": len(targets), "quorum_met": True, } def read(self, key: str) -> dict: """Read from R replicas, return latest version.""" targets = random.sample(range(self.n), self.R) responses = [] for i in targets: if key in self.replicas[i]: responses.append(self.replicas[i][key]) if not responses: return {"key": key, "value": None, "found": False} # Return the value with the highest version latest = max(responses, key=lambda x: x[1]) return { "key": key, "value": latest[0], "version": latest[1], "found": True, }
pythonclass VectorClock: """Vector clock for tracking causality in distributed systems.""" def __init__(self, process_id: str, processes: list[str]): self.pid = process_id self.clock = {p: 0 for p in processes} def increment(self): """Local event: increment own counter.""" self.clock[self.pid] += 1 def send(self) -> dict: """Prepare clock for sending with a message.""" self.increment() return dict(self.clock) def receive(self, other_clock: dict): """Merge received clock: element-wise max, then increment.""" for p in self.clock: self.clock[p] = max(self.clock[p], other_clock.get(p, 0)) self.increment() def happened_before(self, other: dict) -> bool: """Check if this clock happened-before other (causal ordering).""" return (all(self.clock[p] <= other.get(p, 0) for p in self.clock) and any(self.clock[p] < other.get(p, 0) for p in self.clock))
Key metrics for evaluating distributed systems:
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-02 | pass→pass | 11,749 | 14,840 | +26% | 1 | 1 | 0% | 2,078 | 5,158 | +148% | 0 | 0 | — |
case-01 | fail→pass | 28,433 | 29,561 | +4% | 1 | 1 | 0% | 5,356 | 6,375 | +19% | 0 | 0 | — |
case-03 | pass→pass | 17,128 | 15,561 | -9% | 1 | 1 | 0% | 3,261 | 5,644 | +73% | 0 | 0 | — |
case-04 | pass→pass | 14,547 | 13,966 | -4% | 1 | 1 | 0% | 2,665 | 4,881 | +83% | 0 | 0 | — |
case-05 | pass→pass | 13,942 | 11,992 | -14% | 1 | 1 | 0% | 2,563 | 4,733 | +85% | 0 | 0 | — |
case-06 | pass→pass | 24,667 | 18,580 | -25% | 1 | 1 | 0% | 4,153 | 5,323 | +28% | 0 | 0 | — |
case-07 | pass→pass | 19,765 | 16,549 | -16% | 1 | 1 | 0% | 3,363 | 5,256 | +56% | 0 | 0 | — |
case-08 | pass→pass | 16,487 | 15,869 | -4% | 1 | 1 | 0% | 2,404 | 4,707 | +96% | 0 | 0 | — |
case-09 | pass→pass | 13,200 | 18,238 | +38% | 1 | 1 | 0% | 2,062 | 4,997 | +142% | 0 | 0 | — |
case-10 | pass→pass | 10,065 | 14,973 | +49% | 1 | 1 | 0% | 1,702 | 4,652 | +173% | 0 | 0 | — |
case-11 | pass→pass | 4,657 | 4,979 | +7% | 1 | 1 | 0% | 788 | 3,119 | +296% | 0 | 0 | — |
case-12 | pass→pass | 6,423 | 6,333 | -1% | 1 | 1 | 0% | 1,145 | 3,675 | +221% | 0 | 0 | — |
case-13 | pass→pass | 19,662 | 37,318 | +90% | 1 | 1 | 0% | 3,152 | 7,950 | +152% | 0 | 0 | — |
case-14 | pass→pass | 7,852 | 10,232 | +30% | 1 | 1 | 0% | 1,339 | 3,922 | +193% | 0 | 0 | — |
case-15 | pass→pass | 10,267 | 12,383 | +21% | 1 | 1 | 0% | 1,849 | 4,676 | +153% | 0 | 0 | — |
case-25 | fail→pass | 10,087 | 10,558 | +5% | 1 | 1 | 0% | 1,766 | 4,226 | +139% | 0 | 0 | — |
case-16 | pass→pass | 8,398 | 9,236 | +10% | 1 | 1 | 0% | 1,635 | 4,083 | +150% | 0 | 0 | — |
case-17 | fail→fail | 23,407 | 20,999 | -10% | 1 | 1 | 0% | 3,731 | 5,520 | +48% | 0 | 0 | — |
case-18 | fail→pass | 12,708 | 8,399 | -34% | 1 | 1 | 0% | 2,139 | 3,851 | +80% | 0 | 0 | — |
case-19 | pass→pass | 11,601 | 12,673 | +9% | 1 | 1 | 0% | 1,541 | 4,251 | +176% | 0 | 0 | — |
case-24 | pass→pass | 7,722 | 9,632 | +25% | 1 | 1 | 0% | 1,458 | 4,098 | +181% | 0 | 0 | — |
case-20 | pass→pass | 12,420 | 16,134 | +30% | 1 | 1 | 0% | 1,766 | 4,652 | +163% | 0 | 0 | — |
case-21 | pass→pass | 17,813 | 19,511 | +10% | 1 | 1 | 0% | 2,689 | 5,372 | +100% | 0 | 0 | — |
case-22 | pass→pass | 15,962 | 17,522 | +10% | 1 | 1 | 0% | 2,567 | 5,084 | +98% | 0 | 0 | — |
case-23 | pass→pass | 14,947 | 13,010 | -13% | 1 | 1 | 0% | 2,399 | 5,052 | +111% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 25 cases were attempted. The headline lift of +12 percentage points is the difference between those two pass rates over the 25 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.