/oss-skills:testing-strategyfrom oss-skills
Designs a test suite for open-source projects that contributors can run and trust. Covers test pyramid, fixtures, property-based/snapshot testing, flake elimination, and one-command runnability.
Ships in oss-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.
None: SKILL.md is the whole skill.
For an open-source project, the test suite has a second job beyond correctness: it is the contract that lets strangers change your code safely. Without it, every external PR is a risk you must personally verify, and you become the bottleneck.
A new contributor must be able to run the full suite in one command, from a fresh clone, with no tribal knowledge:
make test # or: npm test / pytest / cargo test / go test ./...
Requirements, all of them non-negotiable:
If setup takes more than git clone && make test, contributions drop measurably. This
is the highest-leverage testing investment an OSS project can make.
| Level | Share | Runtime | Tests |
|---|---|---|---|
| Unit | ~70% | ms | Pure logic, edge cases, error paths |
| Integration | ~20% | ~s | Component boundaries, real DB/filesystem |
| End-to-end | ~10% | ~10s+ | The two or three flows that must never break |
Two common failure shapes:
Test the public API, not internals. Tests bound to private functions turn every refactor into a test rewrite, which teaches contributors that tests are an obstacle.
Prioritize by consequence-of-failure, not by ease:
api-design).Do not test: framework behavior, third-party libraries, getters and setters, or anything whose test is a restatement of the implementation.
Table-driven tests — the highest density of coverage per line of test code, and the easiest for contributors to extend when they find a new case.
tests := []struct{ name, in, want string }{
{"empty", "", ""},
{"unicode", "café", "cafe"},
{"emoji", "a👍b", "ab"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { /* ... */ })
}
Property-based testing (Hypothesis, fast-check, proptest, QuickCheck) — for parsers, serializers, encoders, and anything with an inverse. One property replaces a hundred examples and finds the case you would never have written:
@given(st.text())
def test_roundtrip(s):
assert decode(encode(s)) == s
Snapshot tests — good for CLI output, generated code, and rendered markup. Two
rules or they rot: review every snapshot diff as if it were source code, and never run
--update-snapshots without reading the diff. An auto-approved snapshot suite tests
nothing.
Golden files for compilers, formatters, and codegen: input file → expected output file, both in the repo, regenerable with one flag.
Mutation testing (mutmut, Stryker, cargo-mutants) — the honest answer to "is
our coverage real". Expensive; run it quarterly or in a nightly job, not per-PR.
Coverage is a diagnostic, not a target. Enforcing 100% produces tests written to satisfy the instrument.
A policy that works in practice:
__main__ blocks, and platform-specific branches in
config, so the number means something.Open-source code runs where you do not. Decide the support matrix explicitly, publish it, and test it — an untested claim of Windows support is worse than no claim.
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
version: ['3.10', '3.13'] # oldest supported + newest
include:
- { os: ubuntu-latest, version: '3.11' } # fill the middle on one OS only
fail-fast: false is important: you want to see all failing cells, not the first.
Full cartesian matrices waste CI minutes — test the corners exhaustively and the middle
on one platform. See ci-pipelines.
Windows deserves specific attention because it is where cross-platform bugs live: path
separators, CRLF vs LF, case-insensitive filesystems, PATH length limits, and
no fork().
A flaky test is worse than no test: it trains everyone, including you, to ignore red CI. Treat a flake as a P1 bug.
Root causes, in the order you should suspect them:
sleep() as synchronization, tests that fail near midnight or DST
boundaries, timeouts tuned to a fast laptop. Fix: inject a clock; poll for a
condition with a generous timeout instead of sleeping a fixed duration.--shuffle/-p random ordering in CI so
order dependence fails immediately rather than mysteriously.Process: quarantine the flake into a separate job immediately so it stops blocking contributors, open an issue with the failing logs, and fix or delete it within a sprint. A permanently quarantined test is a deleted test with extra steps — be honest and delete it.
In CONTRIBUTING.md, concretely:
## Tests
make test # full suite (~40s)
make test-unit # fast, no containers
make test-e2e # requires Docker
pytest tests/test_parser.py::test_unicode -x # single test
Also state: what a new feature needs (tests + docs), what a bug fix needs (a regression test), and what happens when CI is red for unrelated reasons — because a contributor who cannot tell "my fault" from "not my fault" usually just leaves.
sleep(2) as synchronization. Slow and flaky.if (CI) skip(). The test is a lie in exactly the environment that matters.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub the-open-agent/oss-skills --plugin oss-skills18 skills in this plugin
/api-designDesign public interfaces for libraries and tools that other people depend on. Use when designing or reviewing a public API surface, deciding what to export, naming functions and CLI flags, adding configuration options, planning deprecations, or when the user asks "is this a good API" or "how do I change this without breaking users". Covers minimal surface area, error design, async and extension patterns, CLI ergonomics, config precedence, and stability guarantees. Also use before a 1.0 release to freeze the interface./ci-pipelinesDesign continuous integration for an open-source repository. Use when setting up GitHub Actions from scratch, when CI is slow or flaky, when adding a build matrix across OS and language versions, when configuring caching, or when handling PRs from forks that need secrets. Covers workflow structure, concurrency and cancellation, caching strategy, required checks and branch protection, self-hosted runner risks, and keeping CI cheap. Also use for "our CI takes 40 minutes" or "why is CI failing on forks"./code-reviewReview a pull request the way a good open-source maintainer does. Use when reviewing an incoming PR, when the user asks "review this PR" or "is this ready to merge", when triaging a stale PR queue, or when writing review feedback to an external contributor. Covers what to check and in what order, severity levels, phrasing feedback so people come back, handling large or unwanted PRs, first-time contributors, AI-generated submissions, and closing PRs kindly. Complements the built-in /code-review command by adding the maintainer and community dimension./contributor-experienceTurn users into contributors and make their first PR succeed. Use when a project gets stars but no contributions, when first-time PRs stall or get abandoned, when writing or improving CONTRIBUTING.md, when setting up a dev environment that works on the first try, or when the user asks "how do I get contributors" or "why does nobody contribute". Covers the contribution funnel, good first issues, local setup, mentorship, recognition, and onboarding a contributor into a maintainer./dependency-hygieneManage a project's dependencies so they stay small, current, and safe. Use when deciding whether to add a dependency, auditing an existing dependency tree, configuring Dependabot or Renovate, dealing with upgrade churn or a flood of bot PRs, resolving version conflicts, choosing between dependency ranges and pinning, or removing an unmaintained dependency. Also use for "our install is huge", "too many Dependabot PRs", or before publishing a library that others will depend on./docs-architectureStructure and write project documentation beyond the README. Use when docs have sprawled into an unnavigable pile, when users keep asking questions the docs already answer, when choosing a docs site generator (Docusaurus, MkDocs, VitePress, mdBook, Sphinx), or when planning a docs information architecture. Covers the Diataxis framework (tutorial/how-to/reference/explanation), versioning docs across releases, API reference generation, doc testing, and migration guides. Also use for "write docs for this project" or "our docs are bad".