/shipwright:test-migration runs instead · from shipwright
Phase 3 of the test-readiness pipeline. Reconciles existing tests against inventory and blueprint, bucketing each into reuse/promote/rebuild/trim/net-new. Enforces canonical-layer rule and writes migration doc.
This skill never runs in Claude Code
It ships in shipwright at skills/, but /shipwright:test-migration (a command, or a skill Claude Code finds first) has the same name: typing it, or Claude choosing it, runs that one instead.
Reconcile reality against the blueprint. Bucket every existing test and every inventory item.
By the /test-migration command. Requires both prior artifacts:
docs/test-readiness/test-inventory.md (Phase 1)docs/test-readiness/test-system.md (Phase 2)ALL of:
Right shape, fixable gap:
TEST_TARGET_URL env var plumbing)Wrong fundamentals:
A test contains assertions that re-assert functionality already covered at a lower (canonical) layer. Layer hierarchy: unit > integration > smoke > E2E. Higher-layer tests are kept — they prove wiring and user-visible outcomes that lower layers cannot — but redundant assertions inside them are trimmed.
The no-duplicate-coverage principle (t5_no_duplicate_coverage in references/principles.md) is the authoritative source for this rule: each layer tests only what that layer can verify; don't re-assert business rules already covered by lower-layer unit tests. Treat references/principles.md as canonical.
Do not delete E2E tests. E2E tests prove what unit and integration tests cannot: that pieces connect, that state persists correctly across requests, that the system delivers the user-visible outcome end-to-end. A unit test for a business rule does not make the E2E redundant — the E2E still validates the wire.
Check git history before any trim. E2E tests added after production outages often document seam failures that unit tests missed — a DB constraint that wasn't tested, a middleware that dropped a header, a race condition across services. If a test has an outage-linked commit, its assertions are intentional. Mark it reuse and leave it.
Examples of assertions to trim (within an otherwise valid test):
This is the most contentious bucket. Every trim entry MUST include:
Inventory items with zero existing coverage. Sorted by inventory criticality (critical first).
Read inventory + system design. Abort if either missing.
Glob patterns from the Phase 2 framework matrix:
**/*.{test,spec}.{ts,tsx,js,jsx}**/test_*.py, **/*_test.py**/*_test.go**/*_spec.rb**/e2e/**/*.{spec,test}.{ts,js}Exclude node_modules/, dist/, build/, vendored deps.
For each existing test, read enough to determine:
.test.ts next to a route handler that spins up a DB connection is doing integration work even if filed as unitSpeed measurement is aggregate-first, split into an always-on aggregate pull and a
conditional per-layer breakdown. This mirrors speed-budgets/SKILL.md's two-tier model —
treat that skill's escalation formula as canonical.
Pull the aggregate wall-clock and pass/fail/skip counts from the most recent green CI run of
the lint / typecheck / test job, via gh run list / gh run view --log. No local Postgres
or per-layer infra is needed for this step — it's always obtainable from CI history alone.
Compare the aggregate wall-clock against speed-budgets' <15 min Full PR pipeline budget. This
step is mandatory and runs on every /test-migration invocation.
Only run this step if Step 4a's aggregate wall-clock trips the Tier 2 escalation trigger
defined in speed-budgets/SKILL.md (aggregate exceeds 50% of the <15 min budget, sustained
across 2 consecutive measurements). When triggered, actually run the suite and capture
per-test timings via the runner's reporter; a unit test taking 3 seconds is doing integration
work — speed is a strong layer-mismatch signal, flag for rebuild.
A suite that's comfortably in budget after Step 4a alone is a valid, complete outcome for this step — do not treat the absence of local per-layer infra (e.g. no Postgres in the sandbox) as a gap requiring escalation. The infra gap is not a speed problem unless Step 4a's aggregate actually breaches the Tier 2 trigger.
Read coverage from the reader, never from CI logs. From the target repo's worktree run:
bun run "${CLAUDE_PLUGIN_ROOT}/scripts/coverage-summary.ts" --repo {org}/{repo}
The reader consumes the coverage artifact the repo's CI publishes (contract in
references/coverage-output.md) and prints JSON: one result per commit, each with raw
lines counts and, when the report carries them, functions and branches counts, plus
commitSha and runUrl. Compute line_coverage_pct (nullable) as lines.covered / lines.total, and
function_coverage_pct / branch_coverage_pct the same way when functions / branches
are present; use the most recent result. No local coverage run is needed — like Step 4a,
this is always obtainable from CI history alone. This step is mandatory and runs on every
/test-migration invocation.
Carry feature_coverage_pct forward rather than recomputing it: read it from
docs/test-readiness/test-inventory.md, the Step 1 prerequisite artifact already loaded for
this run (Phase 1's test-inventory skill computes and writes it).
Cite sources explicitly, every time:
line_coverage_pct / function_coverage_pct / branch_coverage_pct — cite the CI run URL
(runUrl) and the commit SHA (commitSha) from the reader's result.feature_coverage_pct — cite that the value was carried forward from
docs/test-readiness/test-inventory.md.Never guess. If the reader returns not_reporting (or exits nonzero), the line,
function and branch percentages are null; a result without functions or branches counts
leaves that percentage null too. If docs/test-readiness/test-inventory.md is missing or
lacks the field, feature_coverage_pct is null — never a guessed or estimated value. This
mirrors Step 4a's verify-before-cite rule: a percentage without a citable CI run URL + commit (or, for
feature_coverage_pct, a citable test-inventory.md reference) does not get reported as a
number.
Walk the matrix:
For each existing test:
has-assertions-already-owned-by-lower-layer? → if so, → TRIM (remove those assertions; keep the test)
right-layer? → if not, → REBUILD
right-framework? → if not, → REBUILD
within-speed-budget? → if not, hard-cap? → REBUILD; if soft, → PROMOTE
local-runnable? → if not, → REBUILD
canary-required-and-missing? → PROMOTE
shallow-or-missing-edge-cases? → PROMOTE
else → REUSE
For each inventory item with no existing test → NET-NEW
Same five buckets, applied to:
For each entry, assign small / medium / large effort. These feed Phase 4's milestone sequencing.
Mandatory: any test that currently passes but gets a delete or rebuild verdict must have an explicit risk callout. Deleting a green test is the highest-stakes call in this audit — false-confidence coverage is exactly what kills autonomous programming, but a wrongly-deleted test is also a regression vector. Every such call needs reasoning.
Load ${CLAUDE_PLUGIN_ROOT}/assets/templates/test-migration.md.tmpl. Write to docs/test-readiness/test-migration.md.
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). /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:
{ "reuse": 0, "promote": 0, "rebuild": 0, "trim": 0, "net_new": 0, "tests_scanned": 0 }
That covers the per-bucket counts and the number of tests scanned. The artifact keeps only detail (migration buckets).
docs/test-readiness/ artifact. Git history holds
the prior versions, and the run record holds the counts./test-migration 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).unit/foo.test.ts that spins up a DB is integration, not unit. The file-naming convention principle (t8_file_naming_convention in references/principles.md) is about correctly encoding the layer in the filename, not inferring the layer from it; the code is the truth.delete verdicts. A test currently flagged green being recommended for deletion is the single most reviewable judgment call in the report./test-migration runs while a real, load-bearing measurement-only item (not a test file — e.g. a per-layer speed measurement gated behind Step 4b) stays carried forward unactioned, typically because Step 4a's aggregate has never actually breached speed-budgets' escalation formula and so Step 4b's per-layer infra (live DB/service access) was never exercised. That is not, by itself, a gap requiring escalation — Tier 2 infra being unavailable on a suite that's otherwise in budget is an expected, valid state, not a finding. Track any measurement-only item across cycles, but gate the mandatory-M1 trigger on an actual Tier 1 budget breach: only when Step 4a's aggregate has tripped speed-budgets' escalation formula (aggregate exceeds 50% of the <15 min budget, sustained across 2 consecutive measurements) AND the resulting Tier 2 item remains carried forward unactioned does it need to be surfaced explicitly in this artifact so /test-roadmap can act on it. Do not rely on the roadmap author noticing the streak in prose — when the Tier 1 budget breach gate is hit, /test-roadmap must place the item as the first Milestone 1 (M1) task by construction, the same way the naming-convention task is guaranteed a Milestone 1 slot.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub app-vitals/shipwright --plugin shipwright27 skills in this plugin
/agent-readinessScore one repo against the agent-readiness catalogue (docs/readiness.md) with the deterministic scorer, post one ReadinessSnapshot and record one run. Requires --repo org/repo. No model judgment, no task creation, no repo files./canary-executionCross-cutting contract for the test-readiness pipeline. Defines how canary-eligible test code runs in two modes — `local` (boot dependencies inline, hit localhost) and `canary` (skip the boot, hit a deployed `TEST_TARGET_URL`) — via a dedicated entry point separate from the local smoke runner. Specifies eligibility rules (read-only or self-cleaning, smoke/E2E only, critical/high tier only, zero DB-dependent tests) and the deploy-gate budget (<60s wall time). Referenced by the inventory, system-design, migration, and roadmap skills.
/duplication-fixRead a repo's ready_to_propose duplication patterns from the task store (PatrolFinding) and queue them as routed task-store tasks (auto, review or plan), one task per pattern, each carrying a strangler-fig (build -> coexist -> eliminate) execution plan. Requires --repo org/repo and duplication-scan to have run first./duplication-scanDiscover emerging duplicate/similar code patterns in one repo via judgment-driven comparison, track them across runs in the task store's PatrolFinding ledger, and list only stabilized open patterns in docs/patrols/duplication.md. Requires --repo org/repo. Report only — no code changes./entropy-fixRead the entropy-scan handoff for one repo and route PR-worthy violations as task-store tasks (auto / review / plan), one task per rule. Requires --repo org/repo and /entropy-scan to have run first./entropy-scanScan one repo for principle deviations and write docs/patrols/entropy.md. Requires --repo org/repo. Report only — no code changes.Other plugins' skills for the same job