agentleFS
rollinsiorollinsio/beyond-test-coverage/.claude/skills/test-quality/SKILL.md

test-quality

Skill52 starsChanged 5 months agoMITView on GitHub

Audit, harden, or generate unit tests with a focus on mutation-resistance and durable quality — not just coverage %. Use when the user asks to improve or harden test quality, make tests less fragile/brittle, review tests for anti-patterns (error-message-substring asserts, private-symbol access, tautological constructor readbacks, recomputed-crypto expectations, over-mocking, missing boundary tests, unrolled cases that should be parametrized), generate a high-quality suite for an untested module, or generally "make my tests better". Measures a suite against a validated quality scorecard and iterates until it plateaus, holding coverage as a non-regression floor and REPL-verifying library assumptions. Works across stacks — Python/pytest (validated), JavaScript/TypeScript (Jest, Vitest, Mocha/Chai, node:test), Go, Kotlin (kotlin.test/JUnit5/Kotest), and Swift (XCTest/Swift Testing/Quick) — with a per-language scorer; the rubric is the same everywhere.

10 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use clean-code and security-audit.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • xfstudioSkill

    clean-code

    Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments

    Also in 3 projects that use this

  • CloudflareSkill

    security-audit

    Security guidance and vulnerability review for codebases, APIs, services, CLI tools, libraries, and daemons. Use for security questions, focused reviews, vulnerability research, security audits, or pen tests. Run the complete workflow only for explicit codebase audit or pen-test requests, full/comprehensive/end-to-end reviews, or requested report artifacts.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 5 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 10 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read pyproject.toml/pytest.ini, package.json(scripts.test, jest/vitest config), go.mod, build.gradle(.kts)/settings.gradle, Package.swift, …

    line 62
  2. Distinctive:

    Run the suite with branch coverage.

    line 78
  3. Distinctive:

    Read the tests (or, for generate mode, the source) and inventory:

    line 89
  4. Very specific:

    REPL-verify first: Before asserting on any stdlib/library runtime behavior, run it and assert what actually happens — python -c "...", node …

    line 106
  5. Distinctive:

    Run the suite: after each move. All tests must pass before you keep a move.

    line 112
  6. Distinctive:

    Stop: when 3 consecutive rounds can't produce a gated improvement, OR there are no contract violations left and every source boundary has a …

    line 119
  7. Distinctive:

    Never chase coverage through private internals: If you can't name the user-observable contract a test protects, don't write it.

    line 134

“Common” is measured: kept by at least 6 in 10 of the 10 edited versions of this file we could read. “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

test-quality

Bring a target's tests up to a durable-quality bar. "Quality" means tests that fail when behavior breaks and survive when it's only refactored — the opposite of coverage-chasing suites that hit 100% yet catch nothing.

This skill encodes the result of a controlled experiment: pointing test generation at a multi-axis quality scorecard (rather than a coverage number) produced suites that beat human-written baselines on the auto-countable axes in 9 of 9 Python suites (8 of 9 with the model held fixed — the rubric, not the model, drove the gain). The two reference docs are that experiment's distilled output:

  • references/quality-contract.md — 10 anti-fragility rules, each with the repair.
  • references/scorecard.md — the scoring axes, the improvement gate, the stop condition.
  • scripts/score.py — measures the auto-countable axes for a suite in any supported language (Python/pytest, JS/TS, Go, Kotlin, Swift).

Read both reference docs before starting. They are the substance; this file is the procedure.

Core principle

Coverage is a floor, not a goal. Once the suite is at or above its starting coverage, more coverage doesn't count as improvement. What counts is moving the quality axes: fewer fragility patterns, more rigor signals, less real mocking, better LOC efficiency — with every test traceable to a user-observable contract.

Inputs

  • Target (required): a module/package to test, an existing test file/dir to improve, or both. If the user didn't specify, ask what to target.
  • Test command (auto-detect, confirm if unsure): how to run the suite with coverage. Detect from the project's config/manifest, then by stack:
    • pytest: python -m pytest <tests> --cov=<src> --cov-branch
    • Jest: npx jest --coverage · Vitest: npx vitest run --coverage
    • Mocha: npx c8 --check-coverage mocha (c8/nyc for coverage)
    • Go: go test -cover -coverprofile=cover.out ./... && go tool cover -func=cover.out
    • Kotlin: ./gradlew test (coverage via the JaCoCo/Kover plugin if configured)
    • Swift: swift test --enable-code-coverage (SwiftPM) or xcodebuild test (Xcode) Read pyproject.toml/pytest.ini, package.json(scripts.test, jest/vitest config), go.mod, build.gradle(.kts)/settings.gradle, Package.swift, Makefile to find the project's real command — prefer it over the defaults above.

Procedure

1. Scope & detect

Identify the source package and its tests dir. Detect the language/framework (this sets the score.py --lang profile: python, js, go, kotlin, or swift) and the coverage-enabled test command. Determine the mode:

  • tests exist for the target → audit + improve (refactor in place).
  • target is untested → generate a fresh suite. (A target can be mixed: improve what exists, generate for the gaps.)

2. Capture the baseline (do this BEFORE changing anything)

  • Run the suite with branch coverage; record line % and branch % — this is the coverage floor.
  • python <skill>/scripts/score.py --tests <tests_dir> [--lang python|js|go|kotlin|swift] for the auto axes (--lang auto-detects if omitted).
  • Preserve the starting state so you can score against it: copy the tests dir aside, or note the git ref. Later runs use --baseline <that copy>.
  • For generate mode with no existing tests, the floor is the source's current coverage (often 0) and the baseline scorecard is empty — the bar is then the contract itself (zero violations), not "beat the old suite".

3. Audit against the contract

Read the tests (or, for generate mode, the source) and inventory:

  • The auto axes from score.py.
  • The judgement axes by reading: A.3 tautological readbacks, A.6 hand-coded char-sets, B.2 boundary coverage (enumerate every <,<=,>,>=,==,!= in the source and check each has a boundary test), B.3 real-I/O fixture use, E.3 contract-naming. Produce a concrete findings list: file:line → which rule → the repair.

4. Improve — iterate to plateau

Loop. Each round, make ONE focused, justified move:

  • Refactor an existing fragile test (apply the contract repair in place — do not leave the old version; rewrite it), or
  • Add a missing rigor test (a boundary case, a fixed-vector pin, a real-I/O/integration test, a parametrized consolidation), or
  • Generate a cohesive new test file for an untested unit.

Rules for the loop:

  • REPL-verify first. Before asserting on any stdlib/library runtime behavior, run it and assert what actually happens — python -c "...", node -e "..." (or a scratch test you delete), go run a snippet. Don't assert from memory. Keep a short log of what you checked.
  • Public API only; pin fixed expected literals; cover the boundary; prefer real-I/O fixtures over unittest.mock; parametrize instead of unrolling.
  • Run the suite after each move. All tests must pass before you keep a move.
  • Apply the gate (references/scorecard.md): keep the move only if the coverage floor holds, an A-axis dropped or a B-axis rose, nothing regressed, and every new test maps to a stated contract. If a move fails the gate, revert it — a no-op round is not progress.
  • Re-score after each round (score.py --tests <tests> --baseline <start>).

Stop when 3 consecutive rounds can't produce a gated improvement, OR there are no contract violations left and every source boundary has a test.

5. Verify & report

  • Final full run: suite passes, coverage ≥ floor on both line and branch.
  • Print the before/after scorecard (auto axes as a W/L/T tally vs. the captured baseline) plus the judgement-axis assessment.
  • List residual risks honestly: boundaries still uncovered, mutations likely to survive, anything you couldn't verify.

Hard rules

  • Never weaken a test to win an axis. Deleting a strict assertion to drop an A-count, or loosening == to in, is a regression even if the score "improves". The gate's rule 3 exists to catch exactly this.
  • Never chase coverage through private internals. If you can't name the user-observable contract a test protects, don't write it.
  • Don't invent library behavior. REPL-verify or read the docs (check context7 for library docs) — never assert from memory about what a call raises/returns.
  • Match the existing suite's style, fixtures, and naming when improving in place.

Notes

  • Validation tiers. Python/pytest is empirically validated (the scorer's numbers were checked against a controlled experiment). The js (Jest/Vitest/ Mocha/node:test), go, kotlin (kotlin.test/JUnit5/Kotest), and swift (XCTest/Swift Testing/Quick) profiles apply the same axes with heuristic regexes — trustworthy for trends and worst-offenders, but lean harder on reading the tests, and treat the W/L/T tally as indicative, not authoritative. The kotlin/swift regexes were calibrated against six real, well-tested suites (see tests/test_score.py for the named regressions). Two language-specific notes: Kotest spec leaves are only counted when written name(...) { … } with a body (StringSpec's "name" { … } and BehaviorSpec given/when/then are missed), and A.2 (private access) is n/a for Swift — @testable import of internal is idiomatic and private is unreachable (as same-package access is in Go).
  • The counts are plain greps. Matches inside comments and string literals count (both toward the axes and toward test_count), and the A/B count axes are absolute numbers that scale with suite size — so never optimize the numbers themselves; the gate (references/scorecard.md) and reading the tests are what keep the score honest. Known counting gaps are pinned as xfail in tests/test_score.py.
  • Other stacks (RSpec, xUnit, JUnit-for-Java, …): the rubric and contract still apply by judgment. To add a first-class profile, extend PROFILES in scripts/score.py (file globs + a test_def regex + the per-axis regexes) — it's a self-contained dict per language.
  • For a large target, scope to one module/package per invocation rather than a whole repo at once; the iterate-to-plateau loop is per-target.

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.