leader-election
Implement leader election to ensure only one instance executes scheduled tasks.
Install
mkdir -p .claude/skills/leader-election && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/6980" && unzip -o skill.zip -d .claude/skills/leader-election && rm skill.zipInstalls to .claude/skills/leader-election
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Elect a single leader among multiple instances. Only one instance runs cron jobs or processes queues. Automatic failover when leader dies.Key capabilities
- →Elect a single leader among multiple service instances
- →Coordinate distributed workers or queue consumers
- →Execute automatic failover when a leader stops sending heartbeats
- →Manage leadership state via database heartbeats
How it works
Instances compete to become the leader by updating a shared database table; the leader maintains its status by sending periodic heartbeats, and followers take over if the heartbeat times out.
Inputs & outputs
When to use leader-election
- →Ensure exclusive cron job execution
- →Manage distributed task queues
- →Failover for background processing
About leader-election
Manages a distributed lock or election mechanism to assign a single leader among multiple service instances. Supports automatic failover.
Elect a single leader among multiple instances. Only one instance runs cron jobs or processes queues. Automatic failover when leader dies.
When not to use it
- →When instances share the same candidate ID
- →When the heartbeat interval is not significantly shorter than the timeout
Prerequisites
Limitations
- →Requires a database to store election state
- →Requires explicit handling of SIGTERM for graceful shutdown
How it compares
This approach uses atomic database operations to manage distributed state rather than relying on manual coordination or external locking services.
Compared to similar skills
leader-election side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| leader-election (this skill) | 1 | 6mo | Review | Intermediate |
| applescript | 28 | 8mo | Review | Advanced |
| bazel-build-optimization | 14 | 2mo | No flags | Advanced |
| home-assistant-manager | 9 | 8mo | Review | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by dadbodgeoff
View all by dadbodgeoff →You might also like
applescript
martinholovsky
Expert in AppleScript and JavaScript for Automation (JXA) for macOS system scripting. Specializes in secure script execution, application automation, and system integration. HIGH-RISK skill due to shell command execution and system-wide control capabilities.
bazel-build-optimization
wshobson
Optimize Bazel builds for large-scale monorepos. Use when configuring Bazel, implementing remote execution, or optimizing build performance for enterprise codebases.
home-assistant-manager
komal-SkyNET
Expert-level Home Assistant configuration management with efficient deployment workflows (git and rapid scp iteration), remote CLI access via SSH and hass-cli, automation verification protocols, log analysis, reload vs restart optimization, and comprehensive Lovelace dashboard management for tablet-optimized UIs. Includes template patterns, card types, debugging strategies, and real-world examples.
swarm-advanced
ruvnet
Advanced swarm orchestration patterns for research, development, testing, and complex distributed workflows
windows-expert
jackspace
Expert guidance for Windows, PowerShell, WSL interop, and cross-platform development
bash-linux
davila7
Bash/Linux terminal patterns. Critical commands, piping, error handling, scripting. Use when working on macOS or Linux systems.