Identify Prometheus alert/recording rules that have no promtool unit-test coverage, and scaffold true-positive/false-positive/hysteresis test-case skeletons for them. Use when bootstrapping unit tests for new or existing PromQL rules, or auditing test coverage of a rules file. Fully hermetic: reads only local rule/test YAML, no running Prometheus required.
Ships in promql-cody. 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.
None: SKILL.md is the whole skill.
Coverage auditor and test-skeleton generator for Prometheus rule files. It
does not know your actual metric shapes — it emits a promtool-compatible
test file full of TODO placeholders that a human (or an agent that has
read the real metrics) must fill in with realistic input series and
expected values. Hermetic — no network access.
promtool test rules coverage, and you want a starting skeleton rather
than writing input_series/exp_alerts blocks from scratch.TODO markers) and would fail promtool test rules until a human fills them in.go build -o bin/autogen-promql-tests ./cmd/autogen-promql-tests
# or: go install github.com/conallob/o11y-analysis-tools/cmd/autogen-promql-tests@latest
autogen-promql-tests [options]
| Flag | Default | Effect |
|---|---|---|
--rules | (required) | Path to the Prometheus rules YAML file to audit. |
--tests | "" | Path to an existing test file to check coverage against. If omitted, the tool auto-discovers <rules-basename>_test.yml next to the rules file. |
--fix | false | Generate a test file covering the untested alerts/rules. |
--verbose | false | Print discovery/loading detail. |
# Coverage report only (exit 1 if anything is untested)
autogen-promql-tests --rules=./alerts.yml
# Generate a test skeleton for whatever's untested
autogen-promql-tests --rules=./alerts.yml --fix
# Check against an explicit, non-default-named test file
autogen-promql-tests --rules=./rules.yml --tests=./custom_tests.yml
Without --tests, it looks for <rules>_test.yml (rules file's basename
with .yml/.yaml stripped, _test.yml appended) in the same directory.
With --fix, the same path is the default write target unless --tests
is also given, in which case that path is used both to read and write.
For every rule not already covered (alert: or record: name absent from
the tested set), it appends four test cases to the output YAML:
input_series tuned (via a TODO) to make the
alert fire; asserts exp_alerts with the rule's actual labels: and a
TODO placeholder for each annotations: template value.TODO'd to not trigger the
condition; asserts exp_alerts: [].for: duration:
evaluates at roughly half the for: duration and asserts the alert has
not fired yet, to test the hold-down timer itself.The input_series blocks always start from a single placeholder
example_metric{job="test", instance="localhost:9090"} series with a
TODO — the tool does not parse the expression's actual metric names into
realistic series, it only echoes the first line of the expression as a
comment reminder. An agent should replace these placeholders using the
real metric names and label sets from the rule's expr:.
═══════════════════════════════════════════════════════════
Test Coverage Analysis
═══════════════════════════════════════════════════════════
Total rules/alerts: 8
Tested: 5
Untested: 3
Untested alerts/rules:
• HighErrorRate
• job:http_requests:rate5m
• LowDiskSpace
Run with --fix to generate tests for untested alerts
Exit code 1 when untested rules exist and --fix wasn't passed, 0
otherwise (including after a successful --fix run).
--fix first to see the coverage gap and decide scope.--fix to generate the skeleton file._test.yml and replace every
TODO with real series data derived from the rule's actual expr: —
correct metric names, label sets that match what the alert's labels:
expects, and values that genuinely cross (or stay under) the alerting
threshold. The file will not pass promtool test rules until this is
done.promtool test rules <generated-file> once filled in.autogen-promql-tests --rules=... --tests=<generated-file> to
confirm the rule now shows as tested.What SKILL.md sets; muted values are Claude Code's defaults
7 skills in this plugin
/alert-hysteresisQuery a live Prometheus's historical ALERTS series to statistically recommend better 'for:' hold-down durations, reducing spurious short-lived alerts and alert fatigue. Use interactively when an alert is firing too often/too briefly and needs its hysteresis tuned, or when auditing a rules file's for: values against real firing behavior. Requires a live Prometheus with sufficient ALERTS retention — not hermetic, not a CI check./e2e-alertmanager-testRender end-to-end previews of what an alert notification will actually look like (plain-text email, HTML email, Slack attachment JSON, raw webhook JSON) by replaying a Prometheus unit-test file's expected alerts through a live Alertmanager. Effectively a "print preview" for alerts. Use to review notification formatting/content before merging alert changes, or in CI against an ephemeral Alertmanager to produce a diffable preview artifact. Requires a reachable Alertmanager API and a promtool-style unit-test file as input. Can be made fully hermetic in CI by pointing the ephemeral Alertmanager at a skeleton config that keeps the team's real routing/grouping/inhibition rules but overrides receiver connection details, so no real notification ever leaves the runner.Other plugins' skills for the same job
/label-checkEnforce that PromQL expressions (and, optionally, alert definitions) carry a required set of labels — e.g. job, namespace, cluster — to prevent label collisions in multi-tenant Prometheus/Thanos/Cortex/Mimir setups. Use when validating rule YAML for required labels or required alert labels, interactively or as a CI gate. Fully hermetic: no network access or running Prometheus required./promql-cody:autogen-promql-testsfrom promql-cody
npx claudepluginhub conallob/o11y-analysis-tools --plugin promql-cody