Designs chaos experiments, creates failure injection frameworks, and facilitates game day exercises for distributed systems — producing runbooks, experiment manifests, rollback procedures, and post-mortem templates. Use when designing chaos experiments, implementing failure injection frameworks, or conducting game day exercises. Invoke for chaos experiments, resilience testing, blast radius control, game days, antifragile systems, fault injection, Chaos Monkey, Litmus Chaos.
git clone https://github.com/Jeffallan/claude-skills.git--- name: chaos-engineer description: Designs chaos experiments, creates failure injection frameworks, and facilitates game day exercises for distributed systems — producing runbooks, experiment manifests, rollback procedures, and post-mortem templates. Use when designing chaos experiments, implementing failure injection frameworks, or conducting game day exercises. Invoke for chaos experiments, resilience testing, blast radius control, game days, antifragile systems, fault injection, Chaos Monkey, Litmus Chaos. license: MIT metadata: author: https://github.com/Jeffallan version: "1.1.0" domain: devops triggers: chaos engineering, resilience testing, failure injection, game day, blast radius, chaos experiment, fault injection, Chaos Monkey, Litmus Chaos, antifragile role: specialist scope: implementation output-format: code related-skills: sre-engineer, devops-engineer, kubernetes-specialist --- # Chaos Engineer ## When to Use This Skill - Designing and executing chaos experiments - Implementing failure injection frameworks (Chaos Monkey, Litmus, etc.) - Planning and conducting game day exercises - Building blast radius controls and safety mechanisms - Setting up continuous chaos testing in CI/CD - Improving system resilience based on experiment findings ## Core Workflow 1. **System Analysis** - Map architecture, dependencies, critical paths, and failure modes 2. **Experiment Design** - Define hypothesis, steady state, blast radius, and safety controls 3. **Execute Chaos** - Run controlled experiments with monitoring and quick rollback 4. **Learn & Improve** - Document findings, implement fixes, enhance monitoring 5. **Automate** - Integrate chaos testing into CI/CD for continuous resilience ## Reference Guide Load detailed guidance based on context: | Topic | Reference | Load When | |-------|-----------|-----------| | Experiments | `references/experiment-design.md` | Designing hypothesis, blast radius, rollback | | Infrastructure | `references/infrastructure-chaos.md` | Server, network, zone, region failures | | Kubernetes | `references/kubernetes-chaos.md` | Pod, node, Litmus, chaos mesh experiments | | Tools & Automation | `references/chaos-tools.md` | Chaos Monkey, Gremlin, Pumba, CI/CD integration | | Game Days | `references/game-days.md` | Planning, executing, learning from game days | ## Safety Checklist Non-obvious constraints that must be enforced on every experiment: - **Steady state first** — define and verify baseline metrics before injecting any failure - **Blast radius cap** — start with the smallest possible impact scope; expand only after validation - **Automated rollback ≤ 30 seconds** — abort path must be scripted and tested before the experiment begins - **Single variable** — change only one failure condition at a time until behaviour is well understood - **No production without safety nets** — customer-facing environments require circuit breakers, feature flags, or canary isolation - **Close the loop** — every experiment must produce a written learning summary and at least one tracked improvement ## Output Templates When implementing chaos engineering, provide: 1. Experiment design document (hypothesis, metrics, blast radius) 2. Implementation code (failure injection scripts/manifests) 3. Monitoring setup and alert configuration 4. Rollback procedures and safety controls 5. Learning summary and improvement recommendations ## Concrete Example: Pod Failure Experiment (Litmus Chaos) The following shows a complete experiment — from hypothesis to rollback — using Litmus Chaos on Kubernetes. ### Step 1 — Define steady state and apply the experiment ```bash # Verify baseline: p99 latency < 200ms, error rate < 0.1% kubectl get deploy my-service -n production kubectl top pods -n production -l app=my-service ``` ### Step 2 — Create and apply a Litmus ChaosEngine manifest ```yaml # chaos-pod-delete.yaml apiVersion: litmuschaos.io/v1alpha1 kind: ChaosEngine metadata: name: my-service-pod-delete namespace: production spec: appinfo: appns: production applabel: "app=my-service" appkind: deployment # Limit blast radius: only 1 replica at a time engineState: active chaosServiceAccount: litmus-admin experiments: - name: pod-delete spec: components: env: - name: TOTAL_CHAOS_DURATION value: "60" # seconds - name: CHAOS_INTERVAL value: "20" # delete one pod every 20s - name: FORCE value: "false" - name: PODS_AFFECTED_PERC value: "33" # max 33% of replicas affected ``` ```bash # Apply the experiment kubectl apply -f chaos-pod-delete.yaml # Watch experiment status kubectl describe chaosengine my-service-pod-delete -n production kubectl get chaosresult my-service-pod-delete-pod-delete -n production -w ``` ### Step 3 — Monitor during the experiment ```bash # Tail application logs for errors kubectl logs -l app=my-service -n production --since=2m -f # Check ChaosResult verdict when complete kubectl get chaosresult my-service-pod-delete-pod-delete \ -n production -o jsonpath='{.status.experimentStatus.verdict}' ``` ### Step 4 — Rollback / abort if steady state is violated ```bash # Immediately stop the experiment kubectl patch chaosengine my-service-pod-delete \ -n production --type merge -p '{"spec":{"engineState":"stop"}}' # Confirm all pods are healthy kubectl rollout status deployment/my-service -n production ``` ## Concrete Example: Network Latency with toxiproxy ```bash # Install toxiproxy CLI brew install toxiproxy # macOS; use the binary release on Linux # Start toxiproxy server (runs alongside your service) toxiproxy-server & # Create a proxy for your downstream dependency toxiproxy-cli create -l 0.0.0.0:22222 -u downstream-db:5432 db-proxy # Inject 300ms latency with 10% jitter — blast radius: this proxy only toxiproxy-cli toxic add db-proxy -t latency -a latency=300 -a jitter=30 # Run your load test / observe metrics here ... # Remove the toxic to restore normal behaviour toxiproxy-cli toxic remove db-proxy -n latency_downstream ``` ## Concrete Example: Chaos Monkey (Spinnaker / standalone) ```bash # chaos-monkey-config.yml — restrict to a single ASG deployment: enabled: true regionIndependence: false chaos: enabled: true meanTimeBetweenKillsInWorkDays: 2 minTimeBetweenKillsInWorkDays: 1 grouping: APP # kill one instance per app, not per cluster exceptions: - account: production region: us-east-1 detail: "*-canary" # never kill canary instances # Apply and trigger a manual kill for testing chaos-monkey --app my-service --account staging --dry-run false ``` [Documentation](https://jeffallan.github.io/claude-skills/skills/devops/chaos-engineer/)
[{"step":"Define the failure scenario and system boundaries. Use [FAILURE_SCENARIO] (e.g., 'node failure', 'network partition') and [SYSTEM_NAME] (e.g., 'e-commerce platform'). Tip: Start with low-impact experiments (e.g., single pod kill) before scaling to cluster-wide failures.","action":"List the critical components and their dependencies. Tools: Use `kubectl get pods -o wide` for Kubernetes or `aws ec2 describe-instances` for AWS. Document SLOs (e.g., '99.9% uptime for checkout service')."},{"step":"Generate the experiment manifest using the prompt template. Replace [PLACEHOLDERS] with your specific values (e.g., '[SYSTEM_NAME]' → 'checkout-service', '[SPECIFIC_FAILURE_SCENARIO]' → 'disk I/O throttling').","action":"Use LitmusChaos for Kubernetes or Gremlin/Chaos Mesh for multi-cloud. Validate the manifest syntax with `litmusctl validate -f experiment.yaml`."},{"step":"Execute the experiment in a staging environment first. Use the runbook to monitor metrics and capture blast radius.","action":"Tools: Prometheus/Grafana for metrics, Chaos Toolkit for execution. Set up alerts for error rates or latency spikes before starting."},{"step":"Analyze results with the post-mortem template. Compare pre-experiment, during-experiment, and post-recovery metrics.","action":"Focus on MTTR, error rates, and blast radius. Use tools like `chaos-exporter` to aggregate data. Identify gaps in observability or recovery procedures."},{"step":"Iterate and automate. Refine runbooks and rollback procedures based on findings. Automate experiment execution using CI/CD pipelines.","action":"Example: Add chaos experiments to GitHub Actions workflows or Argo Workflows. Schedule weekly game days to test new failure scenarios."}]
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/Jeffallan/claude-skills/tree/main/skills/chaos-engineerCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Design a chaos experiment to test the resilience of [SYSTEM_NAME] under [SPECIFIC_FAILURE_SCENARIO]. Include: 1) Experiment manifest with injected failures (e.g., pod kills, network latency, disk I/O throttling), 2) Runbook with step-by-step execution instructions, 3) Rollback procedure with safety checks, 4) Post-mortem template capturing metrics like MTTR, error rates, and blast radius. Target [FAILURE_SCOPE] (e.g., microservice, database, load balancer) and define success criteria as [METRICS_TO_IMPROVE].
### Chaos Experiment: Pod Kill Resilience for Order-Processing Service
**Experiment Manifest (LitmusChaos):**
```yaml
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: order-service-pod-kill
spec:
engineState: "active"
chaosServiceAccount: litmus-admin
experiments:
- name: pod-delete
spec:
components:
env:
- name: TOTAL_CHAOS_DURATION
value: '30'
- name: CHAOS_INTERVAL
value: '10'
- name: FORCE
value: 'true'
- name: TARGET_PODS
value: 'order-service-7d9f8c'
```
**Runbook:**
1. **Pre-requisites:** Ensure monitoring (Prometheus) is active and alerts are configured for `order-service` errors.
2. **Baseline:** Record pre-experiment metrics (e.g., 99th percentile latency: 450ms, error rate: 0.1%).
3. **Execute:** Apply the manifest via `kubectl apply -f order-service-pod-kill.yaml`.
4. **Monitor:** Watch for cascading failures in `payment-service` or `inventory-service` (expected blast radius).
5. **Validate:** Confirm auto-recovery of `order-service` pods within 30s (K8s liveness probes).
**Rollback Procedure:**
- If MTTR exceeds 60s or error rate spikes >5%, manually scale `order-service` to 3 replicas: `kubectl scale deployment order-service --replicas=3`.
- Verify rollback success via `kubectl get pods -w` and metric recovery.
**Post-Mortem Template:**
| Metric | Pre-Experiment | During Experiment | Post-Recovery | Notes |
|-----------------------|----------------|-------------------|---------------|--------------------------------|
| P99 Latency | 450ms | 1200ms | 480ms | Database connection pool exhausted |
| Error Rate | 0.1% | 8.2% | 0.2% | Timeout retries triggered |
| Blast Radius | 0 services | 3 services | 0 services | `payment-service` degraded |
| MTTR | N/A | N/A | 45s | Within SLA |
**Key Findings:**
- The `order-service` recovered within 30s, but downstream `payment-service` required manual intervention due to aggressive retries.
- **Action Items:** 1) Increase `payment-service` timeout from 5s to 10s, 2) Add circuit breaker to `order-service` → `payment-service` calls.
**Success Criteria Met:** MTTR < 60s, no data loss, and blast radius contained to 3 services (vs. 10+ in prior experiments).skills-collection
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan