/mirrord:mirrord-chaosfrom mirrord
Injects artificial latency and connection errors into mirrord session outgoing traffic for chaos testing. Manages per-session chaos rules via the `mirrord chaos` CLI in interactive or CI mode.
Ships in mirrord. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Help users inject artificial failures and disruptions into a mirrord session's outgoing traffic, to test how their app behaves under unexpected conditions. A chaos rule pairs a selector (which traffic to match) with an effect (what to do to it). Rules are created and managed with the mirrord chaos CLI command, and each rule is attached to a single mirrord session: it never affects other sessions or the cluster.
This skill covers two modes:
mirrord exec and manages rules with mirrord chaos.mirrord chaos add, and runs tests under chaos.Trigger on questions like:
mirrord chaos?"_experimental_.latency configThe mirrord config schema contains an _experimental_.latency option for outgoing latency. It is marked deprecated with "Please use the mirrord chaos feature instead", and it will be removed. Never generate or recommend _experimental_.latency for latency injection. Chaos is not a mirrord.json config key: it is a runtime feature, and rules are created against a live session with mirrord chaos as described below.
selector + effect, plus an optional name and priority.mirrord chaos command takes a --session-id.priority value. If not set, priority defaults to 0, the lowest.id (UUID) on creation. name is a free-form label with no uniqueness guarantee: always use the id to modify or delete.hit_count of how many times it was applied. Editing a rule keeps its id but resets hit_count to zero.| Requirement | Detail |
|---|---|
| CLI | mirrord CLI 3.241.0+ for the mirrord chaos command. Older CLIs (3.232.0+) can manage rules over the raw REST API instead, see the chaos testing docs. |
| UI server | Not a manual step: mirrord chaos silently starts the local UI server if it isn't already running. |
| Feature stage | Chaos testing is an alpha feature. |
{
"name": "latency for database interactions",
"priority": 10,
"selector": {
"upstream": "sonic.database.svc.cluster.local",
"percentage": 35
},
"effect": {
"latency": {
"read_ms": 750
}
}
}
| Field | Meaning |
|---|---|
upstream | The destination to match: a host, or host:port to match a specific port. Uses the same syntax as mirrord's outgoing traffic filter. |
percentage | Roughly how often a matched connection gets the effect. Integer 0–100; values above 100 are rounded down to 100. |
Two effects are supported. A rule has exactly one.
latency: delays the connection's read and/or write operations:
"effect": {
"latency": {
"read_ms": 100,
"write_ms": 200,
"jitter_ms": 25
}
}
At least one of read_ms or write_ms must be non-zero, or the rule is rejected with: either 'effect.latency.read_ms' or 'effect.latency.write_ms' must be non-zero.
connection_error: fails the connection:
"effect": {
"connection_error": {
"type": "reset",
"after_ms": 0
}
}
type is one of reset (can be applied to ongoing connections), timed_out, refused.
mirrord chaos prints the full rule, pretty-printed by default or as JSON with --format json. Note two differences from the request shape: the effect is nested inside the selector, and upstream comes back with an explicit port, where 0 means any port:
{
"id": "6b8f1c4e-2a73-4d9b-8e56-c3f0a7d1b924",
"name": "latency for database interactions",
"priority": 10,
"selector": {
"type": "tcp",
"upstream": "sonic.database.svc.cluster.local:0",
"percentage": 35,
"effect": {
"latency": {
"read_ms": 750
}
}
},
"hit_count": 0
}
mirrord chaos commandEvery subcommand takes --session-id (-s). add and edit read the rule JSON from stdin, or from a file with --file-path (-f). Output format is controlled with --format (pretty (default), json for scripting, silent).
| Command | Action |
|---|---|
mirrord chaos add -s <session> -f <file> | Create a rule, or several at once from a JSON array. Aliases: post. |
mirrord chaos list -s <session> | List the session's active rules. Add -r <rule-id> to get one rule. Aliases: get, ls. |
mirrord chaos edit -s <session> -r <rule-id> -f <file> | Replace a rule (same id, hit_count resets). Accepts a single rule only. Aliases: put. |
mirrord chaos delete -s <session> | Delete all of the session's rules. Add -r <rule-id> to delete one. Aliases: remove, rm. |
Start a mirrord session and grab its session ID: it's printed by mirrord exec, or listed by mirrord session list.
mirrord exec -f .mirrord/mirrord.json -- node app.js
export SESSION_ID='c425f391-e9cc-4199-8de9-7bdbb3e7dfcc' # printed by mirrord exec
Write the rule to a JSON file (e.g. latency-rule.json, see Rule anatomy) and manage it:
# Create
mirrord chaos add -s "$SESSION_ID" -f latency-rule.json
# List
mirrord chaos list -s "$SESSION_ID"
# Modify (edit the file, resend with the rule id)
export RULE_ID='6b8f1c4e-2a73-4d9b-8e56-c3f0a7d1b924'
mirrord chaos edit -s "$SESSION_ID" -r "$RULE_ID" -f latency-rule.json
# Delete one rule / all rules
mirrord chaos delete -s "$SESSION_ID" -r "$RULE_ID"
mirrord chaos delete -s "$SESSION_ID"
Rules can also be piped on stdin instead of -f:
cat latency-rule.json | mirrord chaos add -s "$SESSION_ID"
Deleting a rule stops it from affecting the session immediately.
Rule files are declarative JSON: check them into the repo (e.g. .mirrord/chaos/) so chaos scenarios are versioned and PR-reviewed alongside the tests that use them. No HTTP client, token, or port handling is needed: mirrord chaos talks to the session directly and starts the local UI server itself if needed.
Tag the session with a known key (mirrord exec --key) so the pipeline can find its session ID in the mirrord session list output:
# GitHub Actions excerpt: assumes mirrord is installed and kubeconfig is set up
- name: Run integration tests under chaos
run: |
# Start the app under mirrord in the background, tagged with a session key
mirrord exec --key chaos-ci -f .mirrord/mirrord.json -- node app.js &
# Wait for the session to register, then pull its ID from the session table
for i in $(seq 1 10); do
SESSION_ID="$(mirrord session list 2>/dev/null \
| awk -F'|' '/chaos-ci/ {gsub(/ /,"",$2); print $2; exit}')"
[ -n "$SESSION_ID" ] && break
sleep 2
done
if [ -z "$SESSION_ID" ]; then
echo "ERROR: session 'chaos-ci' not found after retries" >&2
exit 1
fi
# Apply every chaos rule checked into the repo
for rule in .mirrord/chaos/*.json; do
mirrord chaos add -s "$SESSION_ID" -f "$rule" --format json
done
npm test
# Teardown: clear the rules and stop the UI server that mirrord chaos auto-started
mirrord chaos delete -s "$SESSION_ID"
mirrord ui stop
Polling note: session registration is asynchronous, so mirrord session list may not show the session right after mirrord exec starts. The retry loop above covers it. mirrord session list prints a table with |-separated columns and the Session ID first; the awk pulls field $2 (the ID) from the row whose key matches. If the table layout changes in a future release, update the snippet; the empty-ID guard turns that breakage into a clear error instead of a silent one.
| Issue | Solution |
|---|---|
| Rule creation rejected for a latency effect | At least one of read_ms / write_ms must be non-zero. |
| Rule created but never fires | Only outgoing TCP selectors are implemented today; file operation and HTTP selectors are planned and won't match. Also check percentage and that the session actually makes outgoing connections to the upstream. |
| Two rules match, only one applies | By design: highest priority wins. Raise the priority of the rule you want. |
percentage above 100 | Rounded down to 100. |
| Can't find a rule by name | name is not unique: mirrord chaos list the rules and use the id. |
hit_count dropped to zero after an edit | edit resets hit_count; the id stays the same. |
upstream in output shows host:0 | 0 means any port; it's the serialized form of a filter with no port. |
| Session not found | Wrong --session-id, the session ended, or it hasn't registered yet. List sessions with mirrord session list and retry after a short wait. |
chaos edit rejects the input | edit accepts a single rule, not an array. To replace several rules, edit them one by one, or delete and re-add. |
mirrord chaos commands.mirrord exec, or from mirrord session list.read_ms or write_ms non-zero, type is one of reset / timed_out / refused, TCP upstream selectors only.mirrord chaos delete -s <session> to clear the rules, and mirrord ui stop to stop the UI server that mirrord chaos auto-started.User: "Make 30% of my service's calls to the payments API time out, so I can test our retry logic."
Response:
payments-timeout.json: connection_error effect with "type": "timed_out", selector with upstream set to the payments host and "percentage": 30.mirrord chaos add -s <session> -f payments-timeout.json command, and the matching mirrord chaos delete for cleanup once testing is done.id needed to edit or delete it later.upstream filter syntaxWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
chaos-engineering, network-testing, failure-injection, mirrord
npx claudepluginhub metalbear-co/skills --plugin mirrord13 skills in this plugin
/mirrord-beyondHelp users set up and use mirrord Beyond, which runs a local process against workloads outside Kubernetes (docs section "Beyond Kubernetes"; the CLI, dashboard and config call them serverless workloads and `serverless/` targets). Two tracks. ECS setup, for platform teams - wire an existing Amazon ECS service (Fargate or EC2) to the MetalBear Cloud sessions-manager - store the serverless agent API key in AWS Secrets Manager, merge the mirrord remote bootstrap into the task definition, deploy and verify. Developer session - sign in with `mirrord login`, write a `mirrord-up.yaml` with a `serverless/` target, and run `mirrord up` (or the IDE) against the ECS service. Use when users mention mirrord Beyond, Beyond Kubernetes, ECS or Fargate with mirrord, serverless targets, sessions-manager, MetalBear Cloud, the serverless agent API key, MIRRORD_REMOTE_SERVICE, or errors from either side. Also covers the Operator-hosted mode briefly./mirrord-ciHelp users set up mirrord in CI pipelines for testing against real Kubernetes environments. Use when users want to run end-to-end tests, integration tests, or automated tests in CI using mirrord to connect to staging/shared clusters./mirrord-configHelps users generate, edit, and validate mirrord.json configuration files for mirrord (MetalBear). Use when the user runs mirrord from the VS Code or IntelliJ extension or with `mirrord exec`, needs feedback on or changes to an existing mirrord.json, or needs mirrord.json options (env/fs/network) for a mirrord-up.yaml `config_patch`. For a new config to run a local process against a Kubernetes cluster from the CLI, use the mirrord-up skill instead. Always ensures output JSON is valid and schema-conformant.Other plugins' skills for the same job