test-validation
Skill0 starsChanged 11 days agoMITView on GitHub
Choose, write and run the smallest tests that prove a change - regression test first for bugs, repo run commands, flaky-test diagnosis and quarantine, mocking boundaries, coverage and mutation signals. Use after implementing a change, when fixing a bug, or when tests are missing, failing or flaky. Not for release test planning (use `plan-test-strategy`) or load tests (use `test-performance`).
In this repository33 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- global/CLAUDE.mdCLAUDE.md
- build-backendSkill
- build-commitsSkill
- build-containersSkill
- build-databaseSkill
- build-design-systemSkill
- build-frontendSkill
- build-iacSkill
- build-project-setupSkill
- core-documentationSkill
- core-prompt-engineeringSkill
- core-token-efficiencySkill
- create-marketing-copySkill
- create-seo-contentSkill
- operate-incidentSkill
- operate-observabilitySkill
- plan-architectureSkill
- plan-campaignSkill
- plan-codebase-analysisSkill
- plan-test-strategySkill
- plan-threat-modelSkill
- review-pull-requestSkill
- review-seoSkill
- review-ui-uxSkill
- secure-code-reviewSkill
- secure-repo-governanceSkill
- secure-supply-chainSkill
- ship-ci-cdSkill
- ship-github-actionsSkill
- ship-readinessSkill
- ship-releaseSkill
- test-performanceSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 7 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
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
- Distinctive: line 17
On failure: read the first failure in full (message, diff, stack), not the summary.
- Distinctive: line 37
Do not mock what you own: use real collaborators, in-memory fakes or a containerised real dependency.
- Distinctive: line 39
Prefer fakes and stubs (state) over interaction verification, except for "it must send exactly one email/charge" type outcomes.
- Distinctive: line 51
Do not lower coverage thresholds or add exclusions to pass CI.
- Distinctive: line 62
Before running suites that migrate, truncate or seed databases, check the connection env vars point to a local or disposable test resource, …
- Distinctive: line 63
Never run tests with production credentials or against live payment, email or SMS providers.
- Distinctive: line 64
Ask before deleting, skipping or quarantining tests, bulk-updating snapshots or baselines, changing CI test configuration or coverage …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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.
Files
Testing and Validation
Prove the requested behaviour works, with the fewest, most reliable tests, and report exactly what ran.
Procedure
- State the change. One sentence for the behaviour changed, one per acceptance criterion, and what result would prove it wrong.
- Find how this repo tests. The CI workflow is the source of truth for commands, flags, env vars and services; then
package.jsonscripts,Makefile,pyproject.toml/tox.ini/noxfile.py,go.mod,pom.xml/build.gradle,*.csproj,Cargo.toml,Gemfile. Read the nearest existing tests for naming, fixtures, factories and helpers and follow them. Readreferences/run-commands.mdfor single-test, repeat and coverage commands per stack. - Pick the level with the Rules table: the smallest test that can fail for the right reason.
- Bugs: test first. Write the regression test, run it, and confirm it fails for the expected reason (assertion on the buggy behaviour, not an import, setup or typo error). Then fix, then see it pass. Name it after the behaviour, link the issue in a comment if the repo does that.
- Features: one test per acceptance criterion, plus boundaries, invalid input, permission denied and the error path of each external call.
- Run narrow to wide: single test -> file -> package/module -> full suite, then lint, type-check and build exactly as CI does. Do not claim done on a narrow run.
- On failure: read the first failure in full (message, diff, stack), not the summary. Reproduce it alone. Classify: product bug, test bug, or environment. Fix the root cause; never paper over it.
- Prove the test bites. Temporarily revert the fix or invert the key condition; the new test must fail. Restore and re-run. This is a one-off manual mutation test.
- Check stability of new or touched tests: repeat 20-50 times and once in random order (commands in
references/run-commands.md). Readreferences/flaky-tests.mdwhen any test passes and fails without code changes. - Report with the Output template.
Rules
Level selection:
| Change | Smallest proving test |
| Pure logic, parsing, calculation | Unit |
| Query, migration, ORM mapping, serialisation | Integration against a real DB/broker in a container |
| HTTP handler, authz, validation | API/integration test through the router |
| Contract with another service | Consumer-driven contract test |
| UI component behaviour | Component test querying by role/label, not CSS selectors |
| Critical cross-system journey | One E2E test, only if lower levels cannot prove it |
| Config, build, infra | The build/validate/plan command CI runs |
Mocking:
- Mock at boundaries you do not own: third-party HTTP, payment, email/SMS, clock, randomness, OS. Wrap them in your own adapter; mock the adapter in callers and test the adapter separately against a sandbox or recorded responses.
- Do not mock what you own: use real collaborators, in-memory fakes or a containerised real dependency. Mocking your ORM or repository hides SQL and mapping bugs.
- Over-mocking smells: asserting call order of internals, tests that break on a pure refactor, more mock setup than assertions, mocks returning mocks.
- Prefer fakes and stubs (state) over interaction verification, except for "it must send exactly one email/charge" type outcomes.
Test quality:
- Arrange-Act-Assert; one behaviour per test; name says behaviour and condition (
rejects_transfer_above_daily_limit). - Deterministic: injected/frozen clock, seeded randomness, no
sleep(wait for a condition with a timeout), no real network. - Independent: each test creates its own data and cleans up; no order dependence; no shared mutable globals.
- Assert outcomes, specifically: exact values and error types, not
toBeTruthy, "no exception", or a broad snapshot of a whole object. - Snapshots only for stable rendered output; review every snapshot diff line by line.
Coverage and mutation:
- Coverage is a signal, not a goal. Look at changed-lines coverage: every uncovered changed branch is a question to answer ("is it tested elsewhere or dead?"), not a number to raise.
- 100% line coverage with weak assertions proves nothing. For critical logic run mutation testing (Stryker for JS/TS/C#, PIT for JVM, mutmut for Python, cargo-mutants for Rust, Gremlins for Go) on the changed files only; each surviving mutant is a missing assertion.
- Do not lower coverage thresholds or add exclusions to pass CI.
Never, to get green: delete, skip, xfail/@Ignore/.only a test; loosen assertions; change expected values to match actual without proving actual is correct; raise timeouts or add retries blindly; bulk-update snapshots or golden files; catch and swallow errors in tests. If a test is obsolete because the requirement changed, say so and get confirmation before changing it.
Gotchas:
- A test that passes before the fix is not a regression test.
- Watch modes and caches lie: use the CI-style one-shot run (
CI=true,-count=1,--no-cachewhere relevant). - Tests that pass locally but fail in CI usually differ in timezone, locale, parallelism, file-system case sensitivity, env vars or service versions; compare them.
- Async tests that never
awaitthe assertion pass vacuously; make sure the test can fail.
Safety gates
- Before running suites that migrate, truncate or seed databases, check the connection env vars point to a local or disposable test resource, never shared or production.
- Never run tests with production credentials or against live payment, email or SMS providers.
- Ask before deleting, skipping or quarantining tests, bulk-updating snapshots or baselines, changing CI test configuration or coverage thresholds, or adding test dependencies.
- Scrub secrets and personal data from fixtures, recorded HTTP cassettes and logs before committing.
Output
Change: <behaviour> Acceptance: <criteria>
Tests added/changed:
- <path>::<test name> - proves <behaviour>; failed before fix: yes (<reason>) | n/a
Commands run (exact) and results:
- <command> -> <N passed, M failed, K skipped, duration>
- lint / type-check / build -> <result>
Bite check: <what was reverted/inverted> -> test failed as expected
Stability: <test> x<N> runs, random order -> <all passed | x of N failed>
Coverage of changed lines: <%> ; uncovered: <file:line - reason>
Not tested / residual risk: <...> Pre-existing failures (unrelated): <test - evidence>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
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.

