CD Test Architecture
Role: worker. This command assesses and reports — it does not write tests or refactor code; it hands the migration steps to /plan or /build; Step 4b's build-vs-document ask is this skill's one interactive branch point, and even there it proposes a Story rather than invoking /build itself.
Overview
An advisory, application-level skill: it assesses how an existing application is tested, classifies that against a CD-aligned test taxonomy, finds the tests that can't run in a clean CI gate, and recommends a target architecture plus a migration path. It does not write tests or refactor code. test-design-advisor works at the unit/module level and test-smell-review finds smells in test files; this skill works at the whole-application level: test types, pipeline stages, per-component patterns.
Grounded in these knowledge references — read cd-test-architecture.md and component-test-patterns.md before assessing. The shared core names the same files as system-test-design; repo_invariants.py fails when the two lists diverge.
<!-- shared-core:start -->
knowledge/cd-test-architecture.md— six test types, the pre-merge gate rule, the adapter rule, double validation, pipeline stages, MinimumCD-vs-Fowler terminology.knowledge/microservice-testing.md— Contract test checks: consumer and provider coverage, replay of consumer contracts, deploy gates (e.g.can-i-deploy). Step 3 runs them.knowledge/test-layer-ownership.md— in/out of band, the ownership decision, duplication checks, removal rule, antipatterns.knowledge/test-doubles.md— Stub/Fake/Mock/Spy taxonomy; load when Step 4b's database or downstream-service branch proposes a hand-rolled Fake double, so it's named correctly (a Fake, never a "mock").knowledge/component-test-patterns.md— per-component patterns (UI / Services / Batch): isolation strategy and pipeline placement.
<!-- shared-core:end -->
Loaded only here:
knowledge/database-test-patterns.md— Database Sandbox, rollback/truncation teardown, in-memory Fakes for database-backed components.knowledge/virtual-service-libraries.md— record-and-replay library catalog and Resolution order; load for Step 4b's Downstream-service branch.
Constraints
- Advisory only. Assess and recommend; do not edit production or test code. Hand the migration steps to
/planor/build— including Step 4b's build-vs-document ask: it proposes a downstream Story, it never invokes/buildor edits code directly. - Use MinimumCD vocabulary (unit / component / contract / integration / E2E / static analysis) consistently; when the codebase uses other names, map them explicitly.
- The pre-merge gate may contain only deterministic tests (static, unit, component, contract). Placement follows
cd-test-architecture.md, Component-test dependency exception and The Pre-Merge Gate Rule. Flag any test that fails those rules as not pre-merge. - Recommend isolation via in-memory doubles (or, for downstream-service adapters, a record-and-replay virtual-service library per
virtual-service-libraries.md) + owned adapters, validated by the double-validation loop. Do not recommend standing up the whole system (docker-compose of dependencies) for the gate — that is the configured-dependency problem this architecture removes. - Do not assume provider cooperation. For dependencies the team doesn't control, the defense against contract breakage is consumer-owned, scheduled verification against the provider's test environment (out-of-band) plus consumer resilience — not provider-side CDC verification. Recommend accordingly.
- Baseline before refactor (don't lead with refactoring). For under-tested or legacy components, first recommend the best outside-in test achievable at existing seams without changing the code — a characterization baseline — then the refactor that improves testability under that green baseline. Never change behavior and structure in the same step. Defer the procedure to the
legacy-codeskill and use the DDD skills (domain-driven-design,domain-analysis) to suggest the target structure for the refactor. - Minimal tooling: prefer a record-and-replay virtual-service library (
virtual-service-libraries.md) or in-memory doubles for the pre-merge gate, one real browser for UI, testcontainers for off-gate adapter integration or, under the component-test dependency exception, a per-test isolated instance. Don't recommend a sprawl of frameworks. - Be concise: tables and ordered steps, not prose. Cite the knowledge file instead of restating it.
Parse Arguments
Arguments: a target application/repo path or description. Optional --component <name> to scope to one component, --ci <path> to point at the existing pipeline config, --external-tests <path-or-repo-or-description> to point at tests that live outside this repo (another repo's suite, a third-party runner, Postman/Insomnia collections, manual test scripts, recorded UI flows, spreadsheets of test cases), and --stack <id> to override stack detection (default: detect from manifests; resolved profile key like dotnet, node, spring-boot, go, django, react, vue, ssr-htmx). --yes runs unattended: Step 4b's build-vs-document prompt is skipped and every flagged component defaults to Document-only, per human-oversight-protocol's non-interactive convention. If little or no in-repo testing is found and no external location is given, ask where the application is actually tested before concluding it is untested. If no target is given, ask for one.
Steps
0. Detect stack
Resolve the project's stack so the assessment can resolve concrete tools from knowledge/test-stack-profiles/<stack>.md. Mirrors skills/test-design-advisor/SKILL.md:31, 62: when --stack <id> is provided, it takes precedence and detection is skipped. Otherwise, read manifests at the target — package.json (refined to react/vue via dependency, or to ssr-htmx when an htmx dep is present alongside templates/*.html), *.csproj / *.sln, pom.xml / build.gradle*, go.mod, pyproject.toml / requirements.txt — and resolve the matching profile key. Load knowledge/test-stack-profiles/<stack>.md (and any references it points at) so the Target architecture table can name concrete tools per layer. When no profile matches, proceed with stack-agnostic guidance and name the missing profile in the report — never block on it.
1. Inventory the application's components
Map the deployable/testable surfaces and assign each its pattern from component-test-patterns.md (User Interface; API Provider / API Consumer / Event Consumer / Event Producer / Stateful Service / CLI-Library; Scheduled Job). A real system is usually several — list each surface.
Exhaustive surface-type discovery is the mandatory default — always on, never operator-gated (issue #1464). Actively search for every pattern type in component-test-patterns.md's table (all eight above), not just the first one found. Stopping after the first obvious surface type is a spec violation of this step: a real system often has surfaces in several pattern groups at once (Services and Batch and UI). Record the search itself, not only what it found: the Output's ### Components & patterns table (Step 6) has a row for every pattern type searched — None found rather than an omitted row — mirroring /gherkin-derive Step 2's ## Analysis Coverage section (issue #1450), so a thin run is detectable from the report.
Existing-tool detection (feeds Step 4b's Downstream-service branch). Also check the dependency manifest and test files for an existing virtual-service/record-replay library (e.g. Nock, WireMock, WireMock.Net, VCR.py, go-vcr). When found, per knowledge/virtual-service-libraries.md's Resolution order it becomes the default recommended tool for that component's Build (Fake) row in Step 4b instead of the catalog's per-stack default, with no switch suggested. This is inventory-phase data gathering, not a Step 4 recommendation.
Graph-assisted inventory. Prefer CodeGraph/Repowise over raw Grep for locating components, surfaces, and test suites — see