/test-skills:test-constitutionfrom Test Skills
Set up (or amend) a project's test constitution - governance rules agreed up front that keep an agent-driven test suite adequate but lean - test budgets, risk-tiered adequacy by mutation score instead of 100% coverage, marginal-value admission of new tests, the Red-Green-Refactor-Prune TDD cycle, flake quarantine, certified deletion - as TEST-CONSTITUTION.md plus a machine-enforced test-policy.toml, an agent-instructions block in CLAUDE.md/AGENTS.md, and a CI gate. Use this skill whenever the user wants testing rules, standards, a testing policy, guardrails, or governance for humans or agents; says agents write too many or low-value tests and wants that to stop going forward; wants a coverage policy or test budget; or is starting a new project and wants to set testing up right. For measuring an existing suite use test-audit; for planning tests for one feature use test-plan.
Ships in Test Skills. 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; scripts run unread.
Incremental TDD with agents is locally rational and globally ruinous. Each test is reasonable on its own, but nothing ever asks whether the suite as a whole still pays for itself. The fix is the one spec-kit applied to design: agree the rules before the work, write them down, and let machines enforce whatever machines can check.
spec-kit's constitution has test-first and integration-first articles, but none about test economy. This constitution adds them: budgets, marginal-value admission, pruning, and certified deletion.
The deliverable is four files and one CI step:
| File | Role |
|---|---|
TEST-CONSTITUTION.md | 13 articles: the rules, why, and which are gated. Humans read this. |
test-policy.toml | Every number: budgets, risk tiers, admission rules, quarantine, probation. tmx gate reads this. |
managed block in CLAUDE.md / AGENTS.md | The six rules an agent needs while writing a test. |
.test-baseline.json | The ratchet: the accepted suite state. The gate measures the base commit's own collection and refuses a baseline whose count no longer matches it, in either direction (DEC-209). |
CI: tmx gate | Fails the change, and names the article, when a rule is broken. |
Discover. Read the project:
Decide the numbers with the user. Propose defaults, then ask only what you cannot
infer (references/tuning.md):
references/rigor-profiles.md). The project default is usually
R3 Standard, and the critical tier R4 Strict. Offer R5 High-Assurance only for
safety- or mission-critical components, and say plainly that R5 is not
certification. Offer R1/R2 for prototypes or internal tooling. The user can name a
level directly ("set this repo up at Strict").max_tests. If a test-audit exists, use its certified minimum plus 30–50%
headroom. Otherwise use today's count plus one change's worth of new tests (the
adopt.py default), so a good test for a real gap is not blocked on day one. Then plan an
audit to ratchet it down.max_suite_seconds. Aim for a PR tier under 5–10 minutes end to end.Adopt. First run the suite once with JUnit output. The day-one budget must count parametrized rows, which a static count cannot. Then:
python3 ${CLAUDE_SKILL_DIR}/scripts/adopt.py --root . --src <src-root> \
--critical '<glob>' [--critical '<glob>'] --rigor R3 --critical-rigor R4 \
--junit report.xml [--max-tests N] [--max-seconds S] \
--agents CLAUDE.md[,AGENTS.md] [--codeowners @org/test-owners]
--codeowners routes every governance file to a human owner: the constitution, the policy,
the baseline, the probation and quarantine lists, and the protected and survivor files.
Pair it with branch protection that requires code-owner review. The gate already judges
PRs by the base branch's policy, and CODEOWNERS closes the other door, which is merging
an amendment without a human.
The script writes the constitution and policy from assets/, upserts the managed
agent block, and git-ignores .tmx/. It refuses to overwrite an existing
constitution without --force.
Then edit the constitution for this project:
Do not dilute the articles to fit current practice. The point is to change practice. Record any genuine exception in the amendment log with its reason.
Baseline and gate.
python3 ${CLAUDE_SKILL_DIR}/../test-audit/scripts/tmx.py baseline --junit <xml>.
Use --matrix too if a kill matrix exists.--base and a JUnit
report, the gate measures the base commit's own collection (a pytest --collect-only over a
throwaway copy of that tree) and fails by name when the recorded count differs in either
direction, so a baseline left behind reads as phantom growth on every later PR. A partial
collection is not a measurement and fails too. Moving the baseline is an Article XIII
amendment, because it moves the per-change limit's reference point.tmx gate --policy test-policy.toml --junit <xml> once locally. On adoption day
it must pass, since budgets start at today's state. Fix the policy, not the gate, if
it does not.testing/survivors.json
as equivalent with a reason a reviewer can check. Do not leave the nightly or PR gate red
"for later". A gate that is red on day one gets disabled on day two.test-ci, or use the minimal job in references/ci-snippet.md.Optional: an edit-time guard for agents. Offer to install the project-level Claude
Code hook from references/hooks.md. It runs the smell check on every test file an agent
writes and feeds violations back immediately. Gates catch at PR time; the hook catches
at edit time. Ask before writing .claude/settings.json.
Amendments.
test-policy.toml and/or the article text.max_tests, lowering a mutation threshold, or removing a gated rule always
needs a reason that names a real cost.With --base, the gate judges a PR by the base branch's policy and baseline, so a
change cannot loosen its own gate. An amendment therefore takes effect once it merges.
Land it as its own PR before the work that needs the new room. "Too many tests fail the gate" is not a reason:
that is the gate working.
Report. Say what was adopted, and the numbers chosen and why. Say what is gated and
what is advisory only. Point out the next step: test-audit for an existing suite,
test-plan for new work.
The full article-by-article rationale, with sources, is in references/articles.md. In
short:
max_tests below today's count on adoption day. CI would go red for reasons
unrelated to the change being made. Ratchet down through test-reduce.test-skills:constitution markers.
Re-run adopt.py, which updates it idempotently.references/rigor-profiles.md: R1–R5, what each level adds, and what the gate enforces
at each.references/articles.md: each article's rationale, the sources and standards behind it,
and how it is enforced.references/tuning.md: how to choose each number, and when to amend.references/hooks.md: the edit-time Claude Code hook for test files.references/ci-snippet.md: the minimal gate job for GitHub Actions and GitLab.assets/TEST-CONSTITUTION.md, assets/test-policy.toml, assets/agent-block.md: the
templates.assets/TEST-CONSTITUTION.md (opens in a new tab)assets/agent-block.md (opens in a new tab)assets/test-policy.toml (opens in a new tab)references/articles.md (opens in a new tab)references/ci-snippet.md (opens in a new tab)references/hooks.md (opens in a new tab)references/rigor-profiles.md (opens in a new tab)references/tuning.md (opens in a new tab)scripts/adopt.py (opens in a new tab)scripts/hook_test_edit.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
6 skills in this plugin
/coverage-proofTurn "are these tests enough?" and "can these tests go?" into stated, machine-checked claims - mutation kill-set certificates, partition and t-way covering-array completeness under an explicit uniformity hypothesis, property subsumption (one property replacing a table of examples), bounded-exhaustive checks under the small-scope hypothesis, differential tests against a reference model, confidence bounds for random testing, and TLA+/Lean proofs via proof-skills - then retire the example tests each claim subsumes, keeping one conformance test. Use this skill whenever the user asks to prove test adequacy, justify deleting tests mathematically, know how many tests a function really needs, replace many example tests with a property or model, get "provable coverage", or produce R4/R5 (Strict / High-Assurance) verification evidence - even if they just ask "is this enough?". It works on a named unit or cluster of tests; for auditing a whole suite use test-audit, and to cut or demote tests use test-reduce./test-auditUse this skill to diagnose the health of a whole existing test suite and its CI, and to report how lean it could be without losing fault detection. It builds a per-test mutation kill matrix, certifies a minimal subset, and flags duplicate, subsumed and zero-signal tests, clone clusters, test smells, flakiness and CI tiering problems. Use it when the concern is the suite as a whole: it's bloated, slow, brittle, untrusted or agent-grown; the user wants to know how many tests they really need; they doubt their coverage or mutation score; or they want it checked against a test constitution. Vague complaints like "CI takes forever" count. Do not use it for narrow questions about specific named tests, such as whether one test is flaky or whether a given property test subsumes certain example tests. Also skip it for writing new tests, explaining concepts, or carrying out deletions and consolidation, which belong to test-reduce. This skill only measures and recommends.Other plugins' skills for the same job
test-skills@opum is listed by opum-ai/opum-marketplace — review the source before installing
npx claudepluginhub opum-ai/opum-marketplace --plugin test-skills