Phase 2 of the test-readiness pipeline. Given the Phase 1 inventory, designs the ideal test system greenfield — framework per layer, local execution architecture, canary execution contract, test-data strategy, CI pipeline shape, coverage targets, and speed budgets. Does not look at existing tests (that's Phase 3). Writes `docs/test-readiness/test-system.md`. Invoke when the `/test-design` command runs.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Test Design?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/app-vitals-test-design)
---
name: test-design
description: >
Phase 2 of the test-readiness pipeline. Given the Phase 1 inventory, designs the ideal test system greenfield — framework per layer, local execution architecture, canary execution contract, test-data strategy, CI pipeline shape, coverage targets, and speed budgets. Does not look at existing tests (that's Phase 3). Writes `docs/test-readiness/test-system.md`. Invoke when the `/test-design` command runs.
---
# test-design skill
## Purpose
Design the **target** test system. Greenfield. The blueprint Phase 3 reconciles existing tests against.
## When invoked
By the `/test-design` command. Requires `docs/test-readiness/test-inventory.md` from Phase 1.
## Process
### Step 1 — load the inventory
Read `docs/test-readiness/test-inventory.md`. If missing, abort with a clear "run /test-inventory first" message. Extract:
- Stack profile
- Per-layer test counts (how many unit, integration, smoke, E2E)
- External dependencies named (DBs, queues, third-party APIs)
- Canary suite candidates (canary-eligible roster)
### Step 2 — recommend frameworks per layer
Based on the stack profile, select one framework per layer. Use the matrix below as the default; override only if the inventory reveals a specific reason (e.g., existing build infra makes one choice radically cheaper).
| Stack | Unit | Integration | Smoke | E2E |
|---|---|---|---|---|
| TypeScript (Bun) | `bun test` | `bun test` + testcontainers | supertest / Hono test client | Playwright |
| TypeScript (Node) | Vitest | Vitest + testcontainers | supertest | Playwright |
| Python | pytest | pytest + testcontainers / docker-compose | httpx / FastAPI TestClient | Playwright (Python) |
| Go | `go test` | `go test` + testcontainers-go | `httptest` | Playwright |
| Ruby | RSpec | RSpec + database_cleaner | Rack::Test | Capybara / Playwright |
### Step 3 — local execution architecture
For every external dependency named in the inventory, prescribe a **local substitute**. Tests that require a hosted external service with no local substitute are categorically forbidden in this system design.
| Dependency type | Preferred local substitute |
|---|---|
| Postgres / MySQL | Real DB per test run (testcontainers or a dedicated test DB). **Pattern:** wrap ORM calls in a typed service layer (interface + implementation); integration tests hit a real DB through that interface; unit tests mock the interface. Never mock the DB itself at the SQL or ORM level — that mocks the wrong thing. |
| Redis | testcontainers / in-memory shim |
| S3 / blob storage | localstack / minio |
| Internal HTTP service | Recorded fixture doubles (msw / nock / hand-authored JSON) by default — they're faster and require no service infra. If the service ships a Go/TS client interface, prefer mocking that interface over mocking the wire protocol. Inline service or docker-compose only when recorded fixture doubles are impractical (e.g., bidirectional streaming). |
| Third-party HTTP API | Recorded fixture doubles (msw / nock / hand-authored JSON) — never live. |
| SMTP / email | mailhog / capture-only |
| Webhook receiver | local HTTP listener (e.g., smee / ngrok-recorded) |
**Rule:** no recommendation may rely on the developer manually starting an external service. If `docker-compose up` is required, the system design lists the exact compose file path the implementation phase will create.
### Step 4 — canary execution contract
Reference `${CLAUDE_PLUGIN_ROOT}/skills/canary-execution/SKILL.md` and include its contract verbatim in the artifact. Specifically:
- `TEST_TARGET_URL` env var as the local/canary mode switch
- Canary tests must be read-only OR self-cleaning
- Canary suite hard budget: <60s wall time
- Auth strategy for canary mode (token-scoped, not production credentials)
- Canary suite runs zero DB-dependent local tests (eligibility rule 6)
**Prescribe a dedicated canary entry point.** The artifact must specify a separate npm script (`test:canary`) or Playwright project (e.g., `playwright.canary.config.ts`) for running the canary suite. This entry point must never reuse `test:smoke`. CI wires two distinct jobs: `smoke` (pre-merge, runs `test:smoke`, boots local deps) and `canary` (post-deploy, sets `TEST_TARGET_URL`, runs `test:canary`). Document both the script name and the CI job name in the artifact.
### Step 5 — test-data strategy
Decide and document:
- **Per-service DBs vs. shared** — prefer per-service (matches modern microservice convention).
- **Real DB per test run vs. transaction rollback** — depends on parallelism. Document the choice.
- **Factories vs. fixtures** — factories preferred for variability; fixtures for stable golden cases.
- **Seed strategy** — explicit, named seed sets, not "whatever's in the migration."
- **API-first seeding** — seed through the public API wherever the API exists, not via direct DB writes. Direct DB writes bypass business rules (validations, side effects, derived fields) that accumulate over time, causing seeds to diverge from what the application actually produces. DB writes are an explicit fallback for seeding state that the API cannot express (e.g., legacy data, corrupt-state tests).
- **Eventual consistency** — seeding via API may trigger async workers (queues, webhooks, event buses). Tests that assert on state produced by async workers must use a wait/poll pattern: retry the assertion with exponential backoff up to a hard timeout (e.g., 5 retries, 500ms base, 5s cap). Document the specific async paths in the repo and which tests need this pattern.
### Step 6 — CI pipeline shape
Document:
- **Layer order**: unit → integration → smoke. E2E and canary run post-merge / post-deploy.
- **Fail-fast**: unit failures skip integration. Integration failures skip smoke.
- **Job shape**: default to ONE test job running unit, integration and smoke together (in-process test workers are still fine). E2E and canary placement are unchanged. Gate it with the single required `CI` check and the safe-skip rules in `${CLAUDE_PLUGIN_ROOT}/skills/repo-config/SKILL.md`.
- **Parallelism**: per-layer worker count.
- **Budget**: <15min total per PR (agent-readiness checklist Condition 4).
- **Coverage toolchain**: detect and record the repo's actual coverage tool alongside the
above — one of `lcov` (Bun/Jest/Vitest native), `jacoco` (JVM), `coverage.py` (Python),
`c8`/`nyc` (Node), or `go-cover` (Go). Recorded the same way as the other CI pipeline
shape fields — per repo, not a fixed default.
- **Coverage report path and upload step**: alongside the toolchain, record the native
report path (the file the toolchain's reporter writes, e.g. `coverage/lcov.info`) and the
step that uploads it as the `shipwright-coverage` workflow artifact, on pushes to the
default branch. Take the reporter command and path from the per-language recipe table in
`${CLAUDE_PLUGIN_ROOT}/references/coverage-output.md` rather than restating it here.
**One test job by default; splitting is an explicit override.** The default CI shape is **one test job** that runs unit, integration and smoke, replacing a one-job-per-layer default. Per-job overhead (checkout, dependency install, environment setup, and container init for dependencies like Postgres) is fixed cost paid by every job regardless of how little work it does, and job-level queuing delays multiply with every extra job. Keep the speed measurement: the 15-minute budget, and per-layer measurement when a layer's aggregate is over 50% of the budget twice in a row (see `speed-budgets/SKILL.md`). That trigger prompts investigation; it does not by itself justify a split.
Split into several jobs (per layer or per workspace) only when CI takes too long against the 15-minute budget **and** measurements show the split saves meaningful time. The projected wall-clock savings must exceed roughly **2x** the added fixed per-job overhead (checkout+setup+install, plus container init where applicable), so the split pays for itself at least twice over. Flaky or slow tests are not a reason to split on their own; fix those tests first.
Split jobs follow the safe-skip rules in `repo-config/SKILL.md` (all of them join the single `CI` check via `needs`) and the all-layer coverage contract in `${CLAUDE_PLUGIN_ROOT}/references/coverage-output.md`. Repos that already have separate jobs need not merge them.
**Naming convention and runner-exclusion config (required):** The artifact must specify both a file-naming convention and the runner-exclusion config that enforces it. These two items are inseparable — a naming convention without matching exclusion config is not enforced, and exclusion config without a naming convention is unauditable. Document:
1. **File-naming convention** — one suffix rule per entry point:
- `.canary.ts` / `.canary.spec.ts` — canary entry point only
- `.smoke.ts` / `.smoke.spec.ts` — smoke layer (pre-merge)
- `.integration.ts` / `.integration.spec.ts` — integration layer (testcontainers / docker-compose)
- `.unit.ts` / `.unit.spec.ts` or default — unit layer
2. **Runner-exclusion config** — each runner explicitly excludes other layers:
- **Jest / Vitest** `testMatch` / `include` — exclude `.canary.`, `.smoke.`, `.integration.` from the unit runner
- **Playwright** `testMatch` — scope to `.canary.spec.ts` or the canary project directory; exclude `.unit.`, `.integration.` files
- **Coverage config** `exclude` — exclude test helpers, fixtures, factory files, and non-source files from line/branch coverage reports
- **bun test `--filter`** or equivalent — use path-based filters aligned with the naming convention
3. **Verification** — for each runner, a command that confirms it picks up only its layer's files (e.g., `bun test --filter integration --dry-run | grep -v .integration.` should return nothing).
### Step 7 — coverage targets
Enforce a **single coverage floor** (≥90% line, ≥80% branch) enforced by standard coverage tooling — no per-tier thresholds in CI. Criticality drives *prioritization* (write critical tests first), not enforcement: the CI gate does not need to know which files are critical.
| Layer | Minimum CI floor | Notes |
|---|---|---|
| unit | ≥90% line, ≥80% branch | Critical-path files should aim higher, but enforced via team practice, not separate CI gates |
| integration | every named boundary covered | Measured by code path, not line count |
| smoke | every public route 200/4xx covered | Route coverage, not code coverage |
| E2E | every top-5 journey covered | Journey coverage |
**The floor is measured across all layers.** The single floor applies to the coverage figure computed over every layer the repo runs (unit, integration, smoke), not to any one layer's report. The CI shape from Step 6 must therefore publish all-layer coverage: when layers are split into separate jobs, each job emits its own lcov report and the `shipwright-coverage` artifact contains every layer. Runner exclusions (Step 5) only decide which tests a job runs; they must never narrow what the artifact measures. The contract lives in `${CLAUDE_PLUGIN_ROOT}/references/coverage-output.md` ("All-layer coverage") — cite it, do not restate it.
**The line floor is a rising minimum, checked inside `CI`.** Publish coverage first, then add tests until line coverage reaches 90%. The enforced minimum starts at current line coverage, fails below it, and is raised by tasks that add coverage until it reaches 90%. Check it where all layer reports come together: in the single test job, or with split jobs in a `coverage-check` job on PRs and the default branch that `CI` needs. Default-branch runs always run every coverage layer and publish a complete report; a PR either runs every layer or skips all layers and the check together. Never compare partial coverage with the full minimum; a missing or failed report fails the check. See `repo-config/SKILL.md` ("Coverage minimum") and `coverage-output.md`.
**Why a single floor:** per-tier thresholds require a maintained criticality mapping in CI. As files are added, moved, or grow in importance, the mapping decays silently. A single floor enforced by the language's built-in coverage reporter avoids this maintenance burden while still directing attention to critical paths during planning.
### Step 8 — speed budgets
Reference `${CLAUDE_PLUGIN_ROOT}/skills/speed-budgets/SKILL.md` and include the default budget table. May tighten per repo; never loosen.
Also output the **parallelization plan**: worker count and sharding strategy per layer that makes the suite targets achievable.
### Step 9 — shared helpers / utilities inventory
List the test-support code the implementation will need:
- HTTP request builders (auth tokens, default headers)
- Test-user factory / auth fixture
- DB reset helper (truncate or migrate-rollback)
- Time freezer (for deterministic time-dependent tests)
- Recorded-fixture loader
### Step 10 — repo configuration
Reference `${CLAUDE_PLUGIN_ROOT}/skills/repo-config/SKILL.md` and include a **Repo configuration** section in the artifact covering:
- **Branch protection** rule definition for `main` — required status checks (the single `CI` check, per `repo-config/SKILL.md`), required reviews, admin enforcement decision
- **Required secrets** — `TEST_CANARY_API_KEY`, per-external service auth tokens, staging/prod deploy credentials
- **Required GitHub Environments** — `staging`, `production` with reviewer gates
- **PR template recommendation** — `.github/pull_request_template.md` with a Closing Checklist that requires the verification-command output
Without this section, the test pipeline is advisory. The Phase 4 roadmap will auto-pair workflow tasks with branch-protection tasks per the **pairing rule** in `repo-config/SKILL.md`.
### Step 11 — write the artifact
Load template at `${CLAUDE_PLUGIN_ROOT}/assets/templates/test-system.md.tmpl`. Fill in. Write to `docs/test-readiness/test-system.md`.
## Run metrics
Every run is recorded through the shared cron-run recorder, and the numbers live in the run
record, never in the artifact (see "System-cron contract" in
[docs/task-store.md](../../../../docs/task-store.md)). `/shipwright:test-readiness` owns the
single run record for the repo and merges this phase's metrics into it; this skill reports
them in its final output as a `metrics` object, for example:
```json
{ "sections_changed": 0, "layers": 0, "ci_jobs": 0 }
```
That covers how many blueprint sections changed, plus the layer and CI-job counts. The artifact keeps only detail (blueprint).
- Never write a refresh log, a "refreshed on" note, a delta or top-up paragraph, an "N rows
added, N removed, N re-verified" line (or any equivalent count line), or a "preserved for
continuity" prior-cycle section into the `docs/test-readiness/` artifact. Git history holds
the prior versions, and the run record holds the counts.
- The artifact header is a single "Generated by `/test-design` against `org/repo`" line — no dates,
commit stamps or worktree names, so an unchanged artifact stays byte-stable and opens no docs
PR (only a material change does; see `/shipwright:test-readiness`).
---
## Failure modes to avoid
- **Don't look at existing tests.** That's Phase 3's job. Anchoring here makes Phase 3 cosmetic.
- **A recommendation in this artifact is a target state, not a verified fact about current coverage.** Because this phase never reads existing tests, statements like "prefer mocking the client interface" for an internal HTTP service describe what *should* exist, not confirmation that it *does*. Downstream consumers — Phase 3 reconciliation, Phase 4 task generation, or an agent implementing a generated task — must verify actual coverage (e.g., does a recorded-client abstraction actually exist in the codebase) against the working tree before trusting this document's implied existing-coverage claims as a basis for effort estimation or task scoping.
- **Don't recommend mocks for boundaries the inventory marked as integration-canonical.** A mocked DB is not an integration test.
- **Don't skip the parallelization plan.** "Suite finishes in 8 minutes" is meaningless without "with N workers running in parallel."
- **Don't recommend a stack the team can't actually run locally.** If the inventory names a dependency you can't suggest a local substitute for, flag it as a *blocker* in the artifact rather than hand-waving.