Test Design Advisor
Overview
An advisory skill: it recommends how to test code and how to make untestable code testable. It does not write tests or refactor code — it produces a design the human (or /build) then implements. Use it before writing a test suite for an untested or hard-to-test module, or when a test is hard to write and you suspect the design is the cause.
Grounded in these knowledge references: knowledge/test-smells.md, knowledge/test-doubles.md, knowledge/test-pyramid.md (layers + shapes), knowledge/test-layer-gates.md for behavior pre-gates, knowledge/microservice-testing.md, knowledge/testability-patterns.md for production-code seams, and knowledge/test-strategy.md for fixture and SUT-interaction strategy. For the xUnit pattern families it grounds in knowledge/fixture-construction.md (how the fixture is built/disposed), knowledge/value-patterns.md (Literal/Derived/Generated Value + Dummy Object for test data), knowledge/result-verification.md (assertion patterns), knowledge/test-organization.md (Four-Phase + suite structure), knowledge/test-refactoring.md (goals/principles + the test-side refactoring catalog), and knowledge/test-automation-principles.md (the goals/principles a recommendation must honor — the rubric behind every "why"). When the target is untested legacy code, it grounds the get-under-test-first sequence in knowledge/dependency-breaking-techniques.md (behavior-preserving seams) and knowledge/legacy-test-strategy.md (effect/pinch reasoning for where to place the tests). On match it overlays knowledge/testing-techniques/ (specialized techniques), resolves tools from knowledge/test-stack-profiles/<stack>.md, and may adapt a worked template from knowledge/test-matrix-examples/.
Constraints
- Advisory only. Do not edit production code or write test files — output a recommendation.
- A hard-to-test design is a production-code problem. Recommend the seam (constructor injection, interface extraction), never a test workaround (reflection,
InternalsVisibleTo, mocking concrete classes). - Prefer the lowest test-pyramid layer that can verify the behavior; prefer state verification and the simplest double.
- Refactor sequences must be behavior-preserving and start with characterization tests when the code is currently untested.
- Be concise: tables and ordered steps, not prose. No restating the source material — cite the knowledge file.
- Altitude boundary. When a gate mandates application-level E2E/browser architecture, flag the seam (
→ cd-test-architecture) and defer the harness/pipeline design to thecd-test-architectureskill — do not design the E2E harness here. - Vocabulary (MinimumCD). Use the six MinimumCD test types defined in
knowledge/cd-test-architecture.md§ The Six Test Types: static analysis / unit / component / contract / integration / E2E. "Contract test" is the primary term — use it. When the codebase or external context calls it a "narrow integration test", gloss it once in the same sentence:contract test (also called narrow integration test). Never use "narrow integration" alone. When the codebase uses different names for layers (e.g. "service test", "API test", "scenario test"), emit a Terminology mapping table at the top of the report and then use the MinimumCD term consistently from that point. - Test type definitions. When the report mentions any of {unit, component, contract, integration, E2E, static analysis, sociable unit, solitary unit, resilience}, define each term on first use — either inline as a one-line gloss or in a small Test type definitions used in this report block at the top. Definitions come verbatim from
knowledge/cd-test-architecture.md§ The Six Test Types. - The pyramid is a cost heuristic, not a target shape — canonical rule in
knowledge/cd-test-architecture.md#the-pyramid-is-a-cost-heuristic-not-a-target-shape. No "current shape vs recommended shape" tables and no per-layer target counts; place each behavior at the lowest layer that can verify it. - E2E justification gate — canonical in
knowledge/cd-test-architecture.md#the-e2e-justification-gate. Recommend E2E only when all four conditions hold, and surface the four-condition verdict in the E2E justification table (Output).
Parse Arguments
Arguments: target file(s), module, or a description of the code to test. If no target is given, ask for one. Detect language and framework/stack (from manifests — package.json, build.gradle/pom.xml, *.csproj, go.mod, requirements.txt/pyproject.toml, and frontend deps like react/vue/htmx) so tool resolution can pick the right test-stack-profiles/<stack>.md. Detect whether the target crosses independently-deployable service boundaries (load microservice-testing.md only if so).
Steps
1. Assess testability
Read the target. For each unit, determine whether it can be constructed and driven through its public API with controlled inputs. Use the decision flow in knowledge/testability-patterns.md. Record blockers: static factories/singletons, new-ed-up dependencies, hidden global/clock/RNG access, concrete-class coupling, private logic with no public path.
Graph-assisted testability assessment. Prefer CodeGraph/Repowise over raw Grep/Read for finding the unit's collaborators, its callers, and blast radius before recommending a seam — see