agentleFS
dungnotnulldungnotnull/hybrid-harness-chaos-process-prm/skills/s14-experiment-design/SKILL.md

chaos-experiment-design

Skill19 starsChanged 6 months agoMITView on GitHub

Design end-to-end chaos engineering experiments as complete, runnable manifests. Use this skill whenever the user says "create a chaos experiment", "inject a fault", "design a chaos test", "I want to test resilience of X", "add a chaos step to my pipeline", or needs to produce ChaosExperiment / ChaosEngine YAML for LitmusChaos or Harness Chaos Engineering. Also trigger when the user wants to test failure scenarios such as pod crashes, network partitions, disk exhaustion, or CPU spikes, even if they don't use the word "chaos".

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    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:

    Before marking an experiment ready to run:

    line 243

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “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 Experiment Design

Purpose

Produce complete, safe, runnable chaos experiments following the hypothesis-driven scientific method. Every experiment has a clear hypothesis, defined steady state, bounded blast radius, and automated abort conditions.


Input Contract

InputSourceRequired
PRD / service criticality analysiss01 (workflow_context)Yes
Pipeline YAML (chaos step location)s04 outputYes
Service definitions (target services)s05 outputYes
Blast radius budget per environments01 (env tier table)Yes
Feature flag chaos gate configs08 outputNo (recommended)
Risk tolerance preferencess02 taste (risk_tolerance)Yes

Output Contract

OutputDestinationFormat
ChaosExperiment manifest.commandcode/artifacts/experiment-<name>.yamlLitmus YAML
ChaosEngine manifest.commandcode/artifacts/engine-<name>.yamlLitmus YAML
Experiment design checklists13 (hypothesis input)Markdown
Fault taxonomy maps16, s17 (fault selection)Reference
Pipeline chaos step configs04 (pipeline update)YAML
Experiment contextworkflow_context.artifactsYAML object

Prerequisites

  • LitmusChaos / Harness Chaos Engineering installed in target cluster
  • Target namespace and service identified
  • Steady state defined (see chaos/04-steady-state-definition)
  • Observability stack active (metrics flowing before experiment starts)
  • Rollback plan documented
  • Blast radius approved for target environment (see CLAUDE.md env tiers)

Experiment Design Framework (5 Steps)

1. HYPOTHESIS   → "If X fails, then Y should happen, and Z metric stays within N"
2. STEADY STATE → Baseline metrics confirmed healthy before injection
3. FAULT        → Specific fault, target scope, duration, intensity
4. OBSERVE      → Monitor during injection — did system behave as expected?
5. LEARN        → Document findings, fix gaps, update runbooks

Fault Taxonomy

CategoryFaultsSkill Reference
Applicationpod-delete, pod-cpu-hog, pod-memory-hog, container-killchaos/07-application-faults
Networknetwork-loss, network-latency, network-corruption, dns-chaoschaos/07-application-faults
Infrastructurenode-drain, node-cpu-hog, disk-fill, node-restartchaos/06-infrastructure-faults
AWSec2-stop, ebs-loss, rds-instance-stop, lambda-timeoutchaos/06-infrastructure-faults
GCPgce-vm-stop, gke-node-pool-scalechaos/06-infrastructure-faults

Experiment YAML Structure

ChaosExperiment (what fault to run + parameters)
ChaosEngine    (which targets + which experiments + probes)

Complete Experiment Example: Pod Delete

ChaosExperiment

# Generated by: hybrid-harness-chaos-process-prm
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosExperiment
metadata:
  name: pod-delete
  namespace: <TARGET_NAMESPACE>
  labels:
    app.kubernetes.io/part-of: litmus
    app.kubernetes.io/component: chaosexperiment
    managed-by: hcprm
    experiment-category: application
spec:
  definition:
    scope: Namespaced
    permissions:
      - apiGroups: [""]
        resources: ["pods"]
        verbs: ["create", "delete", "get", "list", "patch", "update", "watch"]
      - apiGroups: [""]
        resources: ["events"]
        verbs: ["create", "get", "list", "patch", "update"]
      - apiGroups: ["litmuschaos.io"]
        resources: ["chaosengines", "chaosexperiments", "chaosresults"]
        verbs: ["create", "get", "list", "patch", "update", "watch"]
    image: litmuschaos/go-runner:latest
    imagePullPolicy: Always
    args: ["-c", "ls -lt /experiments | awk 'FNR == 2 {print $9}' | xargs -I {} sh -c './{}'"]
    command: ["/bin/bash"]
    env:
      - name: TOTAL_CHAOS_DURATION
        value: "60"          # seconds of fault injection
      - name: CHAOS_INTERVAL
        value: "10"          # seconds between pod deletions
      - name: FORCE
        value: "false"       # graceful delete (respects terminationGracePeriod)
      - name: TARGET_PODS
        value: ""            # empty = random selection from appLabel pods
      - name: PODS_AFFECTED_PERC
        value: "50"          # % of matching pods to delete per interval
      - name: SEQUENCE
        value: "random"      # random | serial
      - name: RAMP_TIME
        value: "10"          # seconds to wait before and after chaos
    labels:
      experiment: pod-delete

ChaosEngine

apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
  name: <SERVICE_NAME>-pod-delete-engine
  namespace: <TARGET_NAMESPACE>
  labels:
    managed-by: hcprm
    service: <SERVICE_NAME>
    environment: <ENV>
    chaos-type: application
spec:
  appinfo:
    appns: <TARGET_NAMESPACE>       # Target namespace
    applabel: "app=<SERVICE_NAME>"  # Pod selector label
    appkind: deployment             # deployment | statefulset | daemonset
  chaosServiceAccount: litmus-admin
  monitoring: true                  # Expose Prometheus metrics
  jobCleanUpPolicy: retain          # retain | delete (keep for debugging)
  annotationCheck: "true"           # Only target pods with chaos annotation
  engineState: active
  experiments:
    - name: pod-delete
      spec:
        probe:
          # ── HTTP Probe: service must keep responding ──
          - name: application-health-check
            type: httpProbe
            mode: Continuous        # Check throughout entire experiment
            httpProbe/inputs:
              url: "http://<SERVICE_NAME>.<TARGET_NAMESPACE>.svc.cluster.local/health"
              insecureSkipVerify: false
              method:
                get:
                  criteria: "=="
                  responseCode: "200"
            runProperties:
              probeTimeout: 5s
              interval: 5s
              retry: 2
              probePollingInterval: 2s
          # ── Prometheus Probe: error rate must stay < 5% ──
          - name: error-rate-check
            type: promProbe
            mode: Edge              # Check at start and end
            promProbe/inputs:
              endpoint: "http://prometheus.monitoring.svc.cluster.local:9090"
              query: |
                sum(rate(http_requests_total{
                  namespace="<TARGET_NAMESPACE>",
                  pod=~"<SERVICE_NAME>.*",
                  status=~"5.."
                }[2m])) /
                sum(rate(http_requests_total{
                  namespace="<TARGET_NAMESPACE>",
                  pod=~"<SERVICE_NAME>.*"
                }[2m])) * 100
              comparator:
                type: float
                criteria: "<="
                value: "5.0"        # Max 5% error rate allowed
            runProperties:
              probeTimeout: 10s
              interval: 30s
              retry: 3
        components:
          env:
            - name: TOTAL_CHAOS_DURATION
              value: "60"
            - name: CHAOS_INTERVAL
              value: "10"
            - name: PODS_AFFECTED_PERC
              value: "50"
            - name: RAMP_TIME
              value: "10"

Experiment in Harness Pipeline

- step:
    name: Chaos - Pod Delete
    identifier: chaos_pod_delete
    type: Chaos
    timeout: 10m
    spec:
      experimentRef: <EXPERIMENT_UUID_FROM_HARNESS_HCE>
      expectedResilienceScore: 80    # Minimum score to pass (0-100)
    failureStrategies:
      - onFailure:
          errors: [AllErrors]
          action:
            type: StageRollback
    when:
      stageStatus: Success          # Only run chaos if deploy succeeded
      condition: <+env.type> != "Production"  # Not on prod without explicit override

Experiment Design Checklist

Before marking an experiment ready to run:

[ ] Hypothesis written in format: "If [fault] then [expected behavior] measured by [metric]"
[ ] Steady state confirmed healthy in last 10 minutes
[ ] Blast radius scoped to minimum required (namespace / label selector)
[ ] Duration appropriate: dev=30s, staging=60s, preprod=120s, prod=60s max
[ ] At least one HTTP probe OR Prometheus probe configured
[ ] Abort conditions defined (probe failure = immediate abort)
[ ] `dryRun: true` tested first
[ ] Monitoring dashboard open and visible during run
[ ] Rollback steps prepared and tested
[ ] Team notified via Slack before running in shared environments

Experiment Result Interpretation

Resilience ScoreInterpretationAction
100System fully resilient to this faultIncrease blast radius or move to production
80-99Good — minor degradation within toleranceDocument, schedule re-test after improvements
60-79Partial failure — some probes failedFile ticket, fix before next game day
40-59Significant failure — system degradedImmediate remediation required
0-39Critical — system could not handle faultP0 remediation, do not run in production

AI Agent Integration

Autonomy Level

AspectLevelDescription
CurrentL1AI recommends experiments based on system analysis
TargetL2AI generates experiment manifests from natural language

Harness AI Agent

Agent: Harness AI Reliability Agent Capabilities:

  • Chaos experiment recommendations from app events and infra changes
  • Natural language experiment generation (e.g., "Generate a pod-delete experiment for staging")
  • Service discovery and auto-creation of tailored experiments

Human Gates

  • Hypothesis approval
  • Experiment activation
  • Target service selection

MCP

  • LitmusChaos MCP (experiment CRUD, infra ops, resilience probes)
  • Gremlin MCP (experiment analysis, remediation)

Success Criteria

  • Experiment YAML passes kubectl apply --dry-run=client
  • ChaosEngine references correct appLabel for target service
  • At least one HTTP or Prometheus probe configured
  • Experiment ran successfully in dev/staging before targeting preprod
  • Resilience score ≥ 80 before considering production run
  • Results documented in experiment tracker

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.