tdd-test-writer
RED-phase role for writing failing tests before implementation — supports both frontend (React/Next.js) and backend (Python/pytest).
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
RED-phase role for writing failing tests before implementation — supports both frontend (React/Next.js) and backend (Python/pytest).
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
Assess and install the kromatic-dev-stack personas against this user's actual setup. Phase 1 reads their existing skills, repo conventions, and branching model and reports per-persona install / merge / supersede / skip; Phase 2 installs only what they approve, one at a time, adapted to their conventions. Use when adopting, installing, renaming, or re-evaluating the bundle.
Aristotle the Analyst persona — Answer GA4 to BigQuery conversion and prioritization questions for your web properties, with visitor-based definitions, Bayesian impact-first ranking, route ownership attribution, and strict JSON-first outputs.
Lean default development workflow for branch choice, incremental commits, merge/promotion boundaries, and concise reporting.
UX director for all experience design — human and agent. Defines JTBD, identifies user types, and runs the human-facing and agent-facing design-intent passes for detailed specification and verification.
Top-level orchestrator for multi-repo planning and execution with complexity gating, issue-graph enforcement, fanout orchestration, repo-local lane safety, and retrospective governance.
Occam sub-skill — comprehensive single-repo audit producing (a) a decision sheet for a human and (b) an issue graph for implementers with no session memory. Diagnosis only, never fixes. Use when asked to audit, review, or assess the health of a repository.
| name | tdd-test-writer |
| description | RED-phase role for writing failing tests before implementation — supports both frontend (React/Next.js) and backend (Python/pytest). |
| user-invocable | false |
| metadata | {"skill_type":"role","short-description":"TDD test author role (frontend + Python)"} |
Write tests that fail for the right reason — they describe the expected behavior before any implementation exists.
RED-phase ownership boundary (per your specialist-dispatch policy → "RED-phase test authorship"): Dorothy's own outside-in contract/E2E RED (written inline, per Dorothy SKILL.md → "Pre-PR discipline") is a separate phase from this role's — this role's primary, most-used mode is Mode B, the post-implementation information-asymmetric unit-test lane. "This is Dorothy's RED phase" (prior wording here) was only ever true of Mode A; it does not describe Mode B.
After confirming RED state (tests fail as expected), hand to tdd-implementation to make them pass (GREEN phase).
Run /caveman ultra at task start to compress test-writing output. Before writing commit messages or PR bodies, run /normal mode. If the caveman plugin is not installed, proceed without it.
This skill supports two invocation modes. The orchestrator (Occam) selects which one when dispatching.
Mode A — RED (pre-implementation; default). Standard outside-in TDD. The agent receives the acceptance criteria + the system surface to be tested (existing functions, types, source interfaces). Writes failing acceptance / e2e / contract tests that define the GREEN target. Confirms RED before handing off to tdd-implementation.
Mode B — Post-implementation unit-test pass (information-asymmetric). Occam dispatches this in a separate lane after outside-in TDD has gone GREEN, to write the unit tests that pin internal contracts without ossifying the implementation. The agent receives:
In Mode B, write unit tests against the contract. If the contract is ambiguous, raise a clarification request to the orchestrator rather than guessing from observed behavior — the ambiguity is a positive externality, not a problem to paper over.
Caveat for Mode B: signatures-only view works cleanly for pure functions and well-shaped modules. For stateful subsystems whose behavior depends on internal state machines, ask the orchestrator to expand the context envelope to include a behavioral spec (state diagram, invariants) before writing tests. Signatures alone are too thin for stateful targets.
Owns all test files across frontend and backend. In TDD workflow, writes failing tests before implementation (RED phase). Knows component contracts, router signatures, schemas, and source interfaces. Runs the test suite to verify red/green state, then reports to the orchestrator.
When a test exists specifically to catch a known past bug (i.e. the PR description or commit message includes "regression test for X", "would have caught Y", or the test was added in response to a shipped incident), the test's failure mode must be demonstrated against a simulated pre-fix version of the code before the commit lands. It is not enough to show the test passes against the fix; the test must also be shown to fail against the bug.
How to demonstrate:
Why this rule exists: a regression test that passes against the fix proves nothing about whether it would have caught the original bug. Without the failure demonstration, a tautological test (one that accidentally depends only on code paths that exist in the fix) will silently provide zero protection.
Exempt: tests for brand-new features (no past bug to regress against), property-based tests, and smoke tests. This rule targets regression gates specifically — tests whose raison d'être is a named prior failure.
Track overall thresholds and per-module coverage; report delta to orchestrator.
yarn test --watchAll=false # Run full suite
yarn test --watchAll=false --coverage # With coverage
yarn tsc --noEmit # TypeScript check — ALWAYS run after writing tests
Critical:
yarn lint,yarn build, andyarn testdo NOT catch type errors in test files. Onlyyarn tsc --noEmitdoes. Always run it before reporting green.
getByRole (preferred — semantic)getByLabelTextgetByTestIdUnit/integration tests prefer role-based queries because they test semantic intent. Testid is a fallback for elements without stable accessible names.
| What | Where |
|---|---|
| Component test | Next to source: components/Foo/Foo.test.tsx |
| Page test | __tests__/pages/page-name.test.tsx — never in pages/ |
| Hook test | hooks/__tests__/useMyHook.test.ts |
Assert elements are reachable by role and accessible name before using testid.
yarn tsc --noEmit — no TypeScript errors in test files| Directory | Purpose |
|---|---|
tests/unit/ | Mocked; no DB required |
tests/integration/ | Real DB via testcontainers |
tests/api/ | HTTP endpoint tests |
@pytest.mark.unit — mocked, no DB@pytest.mark.integration — real DB@pytest.mark.api — HTTP endpoint@pytest.mark.e2e — end-to-end@pytest.mark.database — requires DB@pytest.mark.slow — long-running@pytest.mark.serial — cannot parallelize; must justify in comment@pytest.mark.parallel_safe — explicitly safe to parallelize@pytest.mark.asyncio
@pytest.mark.unit
async def test_example(mocker):
mock_db = mocker.patch.object(MyManager, "_db_api", new_callable=AsyncMock)
...
Use shared factory fixtures for test entities; never hand-build DB state in individual tests.
black tests/ and flake8 tests/ — formatting and lint on test filesPart of kromatic-dev-stack by Kromatic. Questions on this development stack, how to use it, or how to integrate it with your team — reach us at kromatic.com/contact-us.