---
name: "etcd-raft-distributed-consensus"
description: "Manage strongly consistent distributed configuration and leader leases using etcd v3."
metadata:
  author: "etcd Team"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "backup etcd snapshot"
  - "etcdctl put and watch"
  - "defragment etcd database"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# etcd Raft Consensus & Key-Value Operations

Deploys etcd key-value clusters: executing atomic transactions (Txn), managing leases and keep-alive heartbeats, configuring watch streams, handling compaction and defragmentation, and disaster recovery snapshots.

## When to Invoke
Invoke this skill whenever you need to:
- backup etcd snapshot
- etcdctl put and watch
- defragment etcd database

## Execution SOP & Rules
1. Save snapshot: ETCDCTL_API=3 etcdctl snapshot save /var/backups/etcd-snapshot.db.
2. Create lease: LEASE_ID=$(etcdctl lease grant 60 | awk '{print $2}'); etcdctl put mykey myval --lease=$LEASE_ID.
3. Defragment member storage: ETCDCTL_API=3 etcdctl defrag --endpoints=127.0.0.1:2379.
4. Verify cluster health and endpoint status using etcdctl endpoint health and endpoint status -w table.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
