{"id":"6a75e376-331b-4e35-94e4-0d6a53290a92","shortId":"twMYnL","kind":"skill","title":"pilot-leader-election","tagline":"Elect a coordinator with automatic failover using heartbeat-based leader election.  Use this skill when: 1. A swarm needs a single coordinator for decision making 2. You need automatic failover when the current leader fails 3. You want to avoid split-brain with deterministic tie-","description":"# pilot-leader-election\n\nImplement leader election protocols with automatic failover detection.\n\n## Commands\n\n### Announce candidacy\n```bash\npilotctl --json publish \"registry-hostname\" \"election:$ELECTION_GROUP\" \\\n  --data \"{\\\"type\\\":\\\"election\\\",\\\"candidate\\\":\\\"$AGENT_ID\\\",\\\"priority\\\":$PRIORITY,\\\"term\\\":$TERM}\"\n```\n\n### Declare victory as leader\n```bash\npilotctl --json publish \"registry-hostname\" \"election:$ELECTION_GROUP\" \\\n  --data \"{\\\"type\\\":\\\"leader\\\",\\\"leader\\\":\\\"$AGENT_ID\\\",\\\"term\\\":$TERM,\\\"elected_at\\\":\\\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\\\"}\"\n```\n\n### Send leader heartbeat\n```bash\npilotctl --json publish \"registry-hostname\" \"election:$ELECTION_GROUP\" \\\n  --data \"{\\\"type\\\":\\\"heartbeat\\\",\\\"leader\\\":\\\"$AGENT_ID\\\",\\\"term\\\":$TERM,\\\"timestamp\\\":\\\"$(date -u +%s)\\\"}\"\n```\n\n### Detect leader failure\n```bash\nLAST_HEARTBEAT=$(pilotctl --json inbox \\\n  | jq -r '[.messages[] | select(.topic == \"election:'$ELECTION_GROUP'\" and .payload.type == \"heartbeat\")] | sort_by(.payload.timestamp) | last | .payload.timestamp')\n\nELAPSED=$(( $(date -u +%s) - LAST_HEARTBEAT ))\n\nif [ \"$ELAPSED\" -gt 10 ]; then\n  echo \"Leader timeout, starting election\"\nfi\n```\n\n## Workflow Example\n\nBully algorithm with priority-based election:\n\n```bash\n#!/bin/bash\nELECTION_GROUP=\"task-coordinator\"\nAGENT_ID=$(pilotctl --json info | jq -r '.node_id')\nPRIORITY=$(echo -n \"$AGENT_ID\" | cksum | cut -d' ' -f1)\nREGISTRY_HOST=\"registry.example.com\"\n\n# Announce candidacy\npilotctl --json publish \"$REGISTRY_HOST\" \"election:$ELECTION_GROUP\" \\\n  --data \"{\\\"type\\\":\\\"election\\\",\\\"candidate\\\":\\\"$AGENT_ID\\\",\\\"priority\\\":$PRIORITY,\\\"term\\\":$TERM}\"\n\n# Wait and check if highest priority\nsleep 10\n\nHIGHEST=$(pilotctl --json inbox \\\n  | jq -r '[.messages[] | select(.topic == \"election:'$ELECTION_GROUP'\" and .payload.type == \"election\")] | sort_by(.payload.priority) | last | .payload.candidate')\n\nif [ \"$HIGHEST\" = \"$AGENT_ID\" ]; then\n  pilotctl --json publish \"$REGISTRY_HOST\" \"election:$ELECTION_GROUP\" \\\n    --data \"{\\\"type\\\":\\\"leader\\\",\\\"leader\\\":\\\"$AGENT_ID\\\",\\\"term\\\":$TERM}\"\nfi\n```\n\n## Dependencies\n\nRequires pilot-protocol skill, jq, and cksum.","tags":["pilot","leader","election","skills","teoslayer","agent-skills","ai-agents","clawhub","networking","openclaw","overlay-network","p2p"],"capabilities":["skill","source-teoslayer","skill-pilot-leader-election","topic-agent-skills","topic-ai-agents","topic-clawhub","topic-networking","topic-openclaw","topic-overlay-network","topic-p2p","topic-pilot-protocol"],"categories":["pilot-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/TeoSlayer/pilot-skills/pilot-leader-election","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add TeoSlayer/pilot-skills","source_repo":"https://github.com/TeoSlayer/pilot-skills","install_from":"skills.sh"}},"qualityScore":"0.453","qualityRationale":"deterministic score 0.45 from registry signals: · indexed on github topic:agent-skills · 6 github stars · SKILL.md body (2,116 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T19:14:57.400Z","embedding":null,"createdAt":"2026-05-18T13:22:42.820Z","updatedAt":"2026-05-18T19:14:57.400Z","lastSeenAt":"2026-05-18T19:14:57.400Z","tsv":"'/bin/bash':196 '1':21 '10':178,250 '2':31 '3':41 'agent':81,105,136,202,214,237,273,288 'algorithm':189 'announc':65,223 'automat':9,34,61 'avoid':45 'base':14,193 'bash':67,91,122,147,195 'brain':48 'bulli':188 'candid':80,236 'candidaci':66,224 'check':245 'cksum':216,301 'command':64 'coordin':7,27,201 'current':38 'cut':217 'd':218 'data':77,101,132,233,284 'date':111,141,170 'decis':29 'declar':87 'depend':293 'detect':63,144 'determinist':50 'dt':115 'echo':180,212 'elaps':169,176 'elect':4,5,16,55,58,74,75,79,98,99,109,129,130,158,159,184,194,197,230,231,235,260,261,265,281,282 'exampl':187 'f1':219 'fail':40 'failov':10,35,62 'failur':146 'fi':185,292 'group':76,100,131,160,198,232,262,283 'gt':177 'h':116 'heartbeat':13,121,134,149,163,174 'heartbeat-bas':12 'highest':247,251,272 'host':221,229,280 'hostnam':73,97,128 'id':82,106,137,203,210,215,238,274,289 'implement':56 'inbox':152,254 'info':206 'jq':153,207,255,299 'json':69,93,124,151,205,226,253,277 'last':148,167,173,269 'leader':3,15,39,54,57,90,103,104,120,135,145,181,286,287 'm':114,117 'make':30 'messag':155,257 'n':213 'need':24,33 'node':209 'payload.candidate':270 'payload.priority':268 'payload.timestamp':166,168 'payload.type':162,264 'pilot':2,53,296 'pilot-leader-elect':1,52 'pilot-protocol':295 'pilotctl':68,92,123,150,204,225,252,276 'prioriti':83,84,192,211,239,240,248 'priority-bas':191 'protocol':59,297 'publish':70,94,125,227,278 'r':154,208,256 'registri':72,96,127,220,228,279 'registry-hostnam':71,95,126 'registry.example.com':222 'requir':294 'select':156,258 'send':119 'singl':26 'skill':19,298 'skill-pilot-leader-election' 'sleep':249 'sort':164,266 'source-teoslayer' 'split':47 'split-brain':46 'start':183 'swarm':23 'sz':118 'task':200 'task-coordin':199 'term':85,86,107,108,138,139,241,242,290,291 'tie':51 'timeout':182 'timestamp':140 'topic':157,259 'topic-agent-skills' 'topic-ai-agents' 'topic-clawhub' 'topic-networking' 'topic-openclaw' 'topic-overlay-network' 'topic-p2p' 'topic-pilot-protocol' 'type':78,102,133,234,285 'u':112,142,171 'use':11,17 'victori':88 'wait':243 'want':43 'workflow':186 'y':113","prices":[{"id":"ca65a89d-062a-44a0-a735-aa8b236f9679","listingId":"6a75e376-331b-4e35-94e4-0d6a53290a92","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"TeoSlayer","category":"pilot-skills","install_from":"skills.sh"},"createdAt":"2026-05-18T13:22:42.820Z"}],"sources":[{"listingId":"6a75e376-331b-4e35-94e4-0d6a53290a92","source":"github","sourceId":"TeoSlayer/pilot-skills/pilot-leader-election","sourceUrl":"https://github.com/TeoSlayer/pilot-skills/tree/main/skills/pilot-leader-election","isPrimary":false,"firstSeenAt":"2026-05-18T13:22:42.820Z","lastSeenAt":"2026-05-18T19:14:57.400Z"}],"details":{"listingId":"6a75e376-331b-4e35-94e4-0d6a53290a92","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"TeoSlayer","slug":"pilot-leader-election","github":{"repo":"TeoSlayer/pilot-skills","stars":6,"topics":["agent-skills","ai-agents","clawhub","networking","openclaw","overlay-network","p2p","pilot-protocol"],"license":"agpl-3.0","html_url":"https://github.com/TeoSlayer/pilot-skills","pushed_at":"2026-05-13T06:08:49Z","description":"80+ agent skills for Pilot Protocol — communication, file transfer, trust, task routing, swarm coordination, and more","skill_md_sha":"8e57d50d71cae295a0a5376213c350720e29c22e","skill_md_path":"skills/pilot-leader-election/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/TeoSlayer/pilot-skills/tree/main/skills/pilot-leader-election"},"layout":"multi","source":"github","category":"pilot-skills","frontmatter":{"name":"pilot-leader-election","license":"AGPL-3.0","description":"Elect a coordinator with automatic failover using heartbeat-based leader election.  Use this skill when: 1. A swarm needs a single coordinator for decision making 2. You need automatic failover when the current leader fails 3. You want to avoid split-brain with deterministic tie-breaking  Do NOT use this skill when: - All agents need equal voting power (use pilot-consensus) - You need decentralized decision making (use pilot-gossip)","compatibility":"Requires pilot-protocol skill and pilotctl binary on PATH. The daemon must be running (pilotctl daemon start)."},"skills_sh_url":"https://skills.sh/TeoSlayer/pilot-skills/pilot-leader-election"},"updatedAt":"2026-05-18T19:14:57.400Z"}}