agentleFS
jars-demojars-demo/jars-skills/skills/chaos-engineering/SKILL.md

chaos-engineering

Skill0 starsChanged 33 days agoMITView on GitHub

Running controlled chaos experiments to find resilience weaknesses before production does: defines a steady-state hypothesis, injects realistic faults (latency, pod kill, disk fill, dependency failure) with Toxiproxy, tc/netem, Litmus, and stress-ng, limits blast radius, observes system behaviour against the hypothesis, runs a GameDay, and turns findings into hardening tasks. Use when you want to run a chaos experiment, test resilience, simulate a database outage, inject latency, do a GameDay, test circuit breakers, verify retry logic works, or find hidden failure modes.

  • Installs packages

13 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

9 rules. 0 are common, 9 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 13 edited versions we read keep these.

  • 9

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write it down before touching anything:

    line 22
  2. Distinctive:

    Never run a chaos experiment without limiting the blast radius.

    line 43
  3. Distinctive:

    If the abort metric is breached, stop the fault injection immediately and let the system recover before investigating.

    line 55
  4. Distinctive:

    Run the experiment and watch these simultaneously:

    line 196
  5. Distinctive:

    Every experiment that reveals a gap produces a ticket:

    line 251
  6. Distinctive:

    Start in staging. Graduate to production only after multiple successful staging runs.

    line 265
  7. Distinctive:

    Always have a kill switch ready — a single command that removes all fault injection immediately.

    line 268
  8. Distinctive:

    Never experiment on payment flows, PII pipelines, or data that cannot be rolled back without explicit sign-off from the team.

    line 270
  9. Distinctive:

    Document every run: hypothesis, what actually happened, recovery time, action items.

    line 272

“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

chaos-engineering

Break things on purpose, in a controlled way, to find weaknesses before they find you.

1. The experiment structure — never skip this

A chaos run without a hypothesis is just vandalism. Every experiment has five parts:

1. Steady state   — what does "healthy" look like right now? (metric + threshold)
2. Hypothesis     — "if we inject X, the system will continue to Y"
3. Blast radius   — scope the experiment so failures stay contained
4. Inject fault   — introduce the failure
5. Observe        — did the system behave as hypothesised? if not, why?

Write it down before touching anything:

## Experiment: DB primary failover

**Steady state:** order API p99 < 300 ms, error rate < 0.1 % over the last 5 min

**Hypothesis:** if the primary database node fails, the app reconnects to the
replica within 10 s and resumes serving requests with < 1 % errors

**Blast radius:** staging environment only; 10 % of synthetic traffic

**Fault:** kill the primary PostgreSQL container

**Abort condition:** error rate > 5 % for > 60 s → stop the experiment immediately

2. Blast radius control — non-negotiable

Never run a chaos experiment without limiting the blast radius. Start as small as possible and expand only when confidence is high.

DimensionHow to limit
EnvironmentStart in staging; never start in production
TrafficRoute a percentage of traffic to the experiment cohort (feature flag, header)
TimeSet a hard end time; use a kill switch to stop injection immediately
ScopeTarget one service, one region, one AZ — not the whole fleet
DataUse synthetic or shadow traffic; never experiment on live user payment flows

Abort conditions must be defined before the experiment starts, not decided in the moment. If the abort metric is breached, stop the fault injection immediately and let the system recover before investigating.


3. Tools

ToolBest for
Chaos MonkeyRandom EC2/instance termination
LitmusKubernetes-native fault injection (pod kill, node drain, network chaos)
chaos-meshKubernetes: network partition, latency, pod failure, I/O fault
ToxiproxyTCP-level latency, jitter, bandwidth, disconnect — great for local/CI
tc + netemLinux kernel network emulation — no extra install
stress-ngCPU, memory, and I/O saturation
kill / SIGSTOPProcess pause/kill — no tools needed

4. Fault recipes

Latency injection — Toxiproxy (local / CI)

# Install
brew install toxiproxy   # or download binary from releases

# Start proxy
toxiproxy-server &

# Create a proxy in front of your PostgreSQL
toxiproxy-cli create postgres_proxy --listen 0.0.0.0:5433 --upstream localhost:5432

# Add 300 ms latency with 50 ms jitter (simulates a flaky network)
toxiproxy-cli toxic add postgres_proxy --type latency --attribute latency=300 --attribute jitter=50

# Point your app at port 5433 instead of 5432
DATABASE_URL=postgresql://user:pass@localhost:5433/mydb

# Observe — does your connection pool handle it? do queries time out gracefully?

# Remove the toxic
toxiproxy-cli toxic remove postgres_proxy --toxicName latency_downstream

# Nuclear option — cut the connection entirely (timeout simulation)
toxiproxy-cli toxic add postgres_proxy --type timeout --attribute timeout=0

Network latency — Linux tc/netem (no extra install)

# Add 200 ms delay to all outbound traffic on eth0
tc qdisc add dev eth0 root netem delay 200ms

# Add 200 ms delay with 20 ms jitter and 10 % packet loss
tc qdisc add dev eth0 root netem delay 200ms 20ms loss 10%

# Remove
tc qdisc del dev eth0 root

# Scope to a specific destination IP only (e.g., your DB server)
tc qdisc add dev eth0 root handle 1: prio
tc qdisc add dev eth0 parent 1:3 handle 30: netem delay 200ms
tc filter add dev eth0 protocol ip parent 1:0 prio 3 u32 \
  match ip dst <DB_IP>/32 flowid 1:3

Pod kill — Kubernetes / Litmus

# litmus-pod-delete.yaml
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
  name: order-service-pod-delete
  namespace: staging
spec:
  appinfo:
    appns: staging
    applabel: "app=order-service"
    appkind: deployment
  chaosServiceAccount: litmus-admin
  experiments:
    - name: pod-delete
      spec:
        components:
          env:
            - name: TOTAL_CHAOS_DURATION
              value: "60"          # inject for 60 s
            - name: CHAOS_INTERVAL
              value: "10"          # kill a pod every 10 s
            - name: FORCE
              value: "false"       # graceful kill first
kubectl apply -f litmus-pod-delete.yaml
# Watch your monitoring dashboard — does the deployment recover?
# Does the load balancer stop routing to the killed pod fast enough?
kubectl delete -f litmus-pod-delete.yaml   # stop the experiment

CPU saturation — stress-ng

# Saturate 2 CPU cores for 60 seconds
stress-ng --cpu 2 --timeout 60s --metrics-brief

# Does your service degrade gracefully? Does it shed load or just get slower?
# Watch: request queue depth, p99 latency, error rate

Disk fill — simulate storage pressure

# Fill disk to 90 % capacity temporarily
fallocate -l $(df / | awk 'NR==2 {printf "%.0f", $4 * 0.8}')K /tmp/chaos_fill

# Observe: does the app handle ENOSPC errors? do logs rotate? does the DB crash?

# Clean up
rm /tmp/chaos_fill

Dependency kill — simulate a downstream service going down

# Block all traffic to an external dependency IP/port with iptables
iptables -A OUTPUT -p tcp --dport 443 -d api.stripe.com -j DROP

# Does your circuit breaker trip? Does the error surface cleanly to the user?
# Does the retry logic back off or hammer the blocked endpoint?

# Remove the rule
iptables -D OUTPUT -p tcp --dport 443 -d api.stripe.com -j DROP

5. What to observe during an experiment

Run the experiment and watch these simultaneously:

✓ Error rate          — is it within the abort threshold?
✓ p99 latency         — is it degrading or holding?
✓ Retry counters      — are retries firing? are they backing off?
✓ Circuit breaker     — did it open? did it half-open and recover?
✓ Queue depth         — is work piling up?
✓ Downstream errors   — is the fault spreading to other services?
✓ Recovery time       — how long from fault injection to steady state restored?

Record the actual numbers, not just "it worked" or "it failed."


6. GameDay — structured team exercise

A GameDay is a scheduled, team-wide chaos experiment run like a fire drill.

## GameDay runbook template

**Date:** YYYY-MM-DD  **Duration:** 2 hours  **Environment:** staging

### Scenario
Primary database AZ goes down. Replica promoted. S3 returns 503 for 5 min.

### Roles
- Experiment lead:   runs the fault injection, watches abort conditions
- Observability:     monitors dashboards, calls abort if threshold breached
- On-call engineer:  responds as if this were a real incident
- Scribe:            records timeline, findings, and action items

### Timeline
| Time  | Action |
|-------|--------|
| T+0   | Baseline captured, steady state confirmed |
| T+5   | Kill primary DB container |
| T+15  | Restore primary DB |
| T+20  | Inject S3 503 responses via Toxiproxy |
| T+30  | Remove S3 fault |
| T+35  | Debrief begins |

### Findings → action items
| Finding | Severity | Owner | Due |
|---------|----------|-------|-----|
| Replica failover took 45 s, SLA is 10 s | High | DB team | 2 weeks |
| S3 errors surfaced as 500 to users, not 503 | Medium | API team | 1 month |

7. Turn findings into hardening

Every experiment that reveals a gap produces a ticket:

FindingHardening action
Circuit breaker never openedAdd circuit breaker; tune failure threshold
Retry logic hammered the broken dependencyAdd exponential back-off + jitter
Failover took 45 sTune health check interval + DB connection timeout
Error from dependency leaked as 500Map external errors to appropriate status codes
Service crashed on disk fullAdd ENOSPC error handling; set up log rotation
Downstream failure spread to callersAdd bulkhead / timeout on the outbound call

Rules

  • Define the hypothesis and abort conditions before starting. Never improvise mid-experiment.
  • Start in staging. Graduate to production only after multiple successful staging runs.
  • One fault at a time. Injecting multiple faults simultaneously makes root cause impossible to determine.
  • Always have a kill switch ready — a single command that removes all fault injection immediately. Test the kill switch before running the experiment.
  • Never experiment on payment flows, PII pipelines, or data that cannot be rolled back without explicit sign-off from the team.
  • Document every run: hypothesis, what actually happened, recovery time, action items. An undocumented chaos run teaches the team nothing.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.