Skill: TDD Implementation
Goal
Make the failing tests pass with clean, well-structured code. This is Dorothy's GREEN phase.
Next Step
After tests pass and all quality checks are clean, hand back to Dorothy's push routine. Do not open a PR from this phase — Dorothy handles the full push → CI → PR cycle.
Token budget
Run /caveman ultra at task start to compress implementation-phase output. Before writing commit messages or PR bodies, run /normal mode. If the caveman plugin is not installed, proceed without it.
Role
Owns source files across frontend and backend. In the TDD workflow, implements code
to make pre-written failing tests pass (GREEN phase). Does not write test files —
that is the tdd-test-writer role.
Must Never Touch
- Test files (
*.test.ts, *.test.tsx, __tests__/, tests/)
- Other repos
TDD Workflow — GREEN Phase
- Read failing tests to understand expected contracts and behavior.
- Implement the required code.
- Run the test suite.
- Run language-specific quality checks (see below).
- Report to orchestrator: "Implementation complete, all tests passing."
If test files have errors (e.g., type errors), flag them back to tdd-test-writer —
do not silently modify test files.
Regression gates — do not land the fix alone
If a failing test was written as a regression gate for a named prior bug (PR or commit
references "regression test for X", "would have caught Y", etc.), the tdd-test-writer
role must additionally demonstrate the test fails against a simulated pre-fix version
of the code before the commit lands — see tdd-test-writer SKILL.md → "Regression
gate tests — prove the gate". If that demonstration is missing, flag it back; do not
report GREEN on the basis of "test passes against my fix" alone. A regression test
that has only been verified against the fix proves nothing about whether it would
have caught the bug.
Done Criteria
- All tests pass, no regressions
- All quality checks clean (see language-specific sections)
- No test files written or modified
- Orchestrator notified with results
PR-ready boundary
- PR-ready boundary = local test suite green + lint/typecheck clean + acceptance criteria addressed.
- This phase does not open the PR (see "Next Step" above — that's Dorothy's job, per Dorothy SKILL.md → "Pre-PR discipline" → "Draft PR for Quine review"). Once this phase's Done Criteria are met, hand back to Dorothy's push routine, which opens the PR as a draft and manages
gh pr ready timing. See also Occam SKILL.md → "Ship to staging routine" Path A.
Frontend (React / Next.js)
File Ownership
- Source files: components, pages, hooks, lib (excluding lib/test/), theme
- Mocks, stories, synthetic monitoring checks
- Config: jest config, next config, tsconfig, eslint config
Quality Checks
yarn test --watchAll=false # All tests pass
yarn tsc --noEmit # No TypeScript errors
yarn lint # No ESLint errors
TypeScript errors in test files are NOT caught by lint, build, or test.
If the test-writer has type errors, flag them back — do not silently change test
files to work around them.
Accessibility Requirements
aria-label on all interactive elements without visible text (icon buttons, icon-only links, form controls without a label element)
aria-labelledby when pointing at existing visible text
data-testid on any element tests need to target: key buttons, links, form fields, sections, modals, list items
Code Style
- TypeScript strict mode; full type annotations; no
any without justification
- Functional components; React.memo where beneficial
- Styling: MUI
sx prop for one-offs; Emotion styled() for reusable styles
- PascalCase for component files/directories; camelCase for hooks and utils
Additional Done Criteria
- Run the repo's control-plane risk gate (if present) — confirm no gate violations
- All new interactive elements have
aria-label / aria-labelledby
- All test-targeted elements have
data-testid
Backend (Python / FastAPI)
File Ownership
- Source files: routers, managers, db, schemas, auth, utils, integrations, workers
- Must also never touch: Alembic migration files (autogenerate only; never hand-edit existing migrations)
Quality Checks
pytest tests # All tests pass
black . # No-op (code already formatted)
flake8 . # No lint errors
Architecture Layers
- Routers (thin): validate input → call manager → return response
- Managers (business logic): own business logic; hold DB API instances as class attributes
- db_api / DAO: all SQLAlchemy queries; return ORM models
- Schemas (Pydantic v2): separate request vs. response models
- Exceptions: raise from
utils.exceptions (e.g., NotFoundException)
Async / Session Rules
- All DB + I/O is
async/await
- Use injected session dependency; no manual commit/close in route handlers
- One session per request
ORM Safety
- Eager-load relationships with
selectinload / joinedload
- Never access relationships after session close
- Build nested trees manually in manager layer
Code Style
- Black formatter (120-char line length)
- Flake8 with import-order, quotes, naming plugins
- Full type hints on all signatures
snake_case for files, functions, variables; PascalCase for classes
Part 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.
1---2name: tdd-implementation3description: GREEN-phase role for implementing code to make failing tests pass — supports both frontend (React/Next.js) and backend (Python/FastAPI).4---56# Skill: TDD Implementation78## Goal910Make the failing tests pass with clean, well-structured code. This is Dorothy's GREEN phase.1112## Next Step1314After tests pass and all quality checks are clean, hand back to Dorothy's push routine. Do not open a PR from this phase — Dorothy handles the full push → CI → PR cycle.1516## Token budget1718Run `/caveman ultra` at task start to compress implementation-phase output. Before writing commit messages or PR bodies, run `/normal mode`. If the `caveman` plugin is not installed, proceed without it.1920## Role21Owns source files across frontend and backend. In the TDD workflow, implements code22to make pre-written failing tests pass (GREEN phase). Does not write test files —23that is the `tdd-test-writer` role.2425## Must Never Touch26- Test files (`*.test.ts`, `*.test.tsx`, `__tests__/`, `tests/`)27- Other repos2829## TDD Workflow — GREEN Phase301. Read failing tests to understand expected contracts and behavior.312. Implement the required code.323. Run the test suite.334. Run language-specific quality checks (see below).345. Report to orchestrator: "Implementation complete, all tests passing."3536> If test files have errors (e.g., type errors), flag them back to `tdd-test-writer` —37> do not silently modify test files.3839### Regression gates — do not land the fix alone4041If a failing test was written as a regression gate for a named prior bug (PR or commit42references "regression test for X", "would have caught Y", etc.), the `tdd-test-writer`43role must additionally demonstrate the test fails against a simulated pre-fix version44of the code before the commit lands — see `tdd-test-writer` SKILL.md → "Regression45gate tests — prove the gate". If that demonstration is missing, flag it back; do not46report GREEN on the basis of "test passes against my fix" alone. A regression test47that has only been verified against the fix proves nothing about whether it would48have caught the bug.4950## Done Criteria51- All tests pass, no regressions52- All quality checks clean (see language-specific sections)53- No test files written or modified54- Orchestrator notified with results5556## PR-ready boundary 5758- PR-ready boundary = local test suite green + lint/typecheck clean + acceptance criteria addressed.59- This phase does not open the PR (see "Next Step" above — that's Dorothy's job, per Dorothy SKILL.md → "Pre-PR discipline" → "Draft PR for Quine review"). Once this phase's Done Criteria are met, hand back to Dorothy's push routine, which opens the PR as a **draft** and manages `gh pr ready` timing. See also Occam SKILL.md → "Ship to staging routine" Path A.6061---6263## Frontend (React / Next.js)6465### File Ownership66- Source files: components, pages, hooks, lib (excluding lib/test/), theme67- Mocks, stories, synthetic monitoring checks68- Config: jest config, next config, tsconfig, eslint config6970### Quality Checks71```bash72yarn test --watchAll=false # All tests pass73yarn tsc --noEmit # No TypeScript errors74yarn lint # No ESLint errors75```7677> **TypeScript errors in test files are NOT caught by lint, build, or test.**78> If the test-writer has type errors, flag them back — do not silently change test79> files to work around them.8081### Accessibility Requirements82- `aria-label` on all interactive elements without visible text (icon buttons, icon-only links, form controls without a label element)83- `aria-labelledby` when pointing at existing visible text84- `data-testid` on any element tests need to target: key buttons, links, form fields, sections, modals, list items8586### Code Style87- TypeScript strict mode; full type annotations; no `any` without justification88- Functional components; React.memo where beneficial89- Styling: MUI `sx` prop for one-offs; Emotion `styled()` for reusable styles90- PascalCase for component files/directories; camelCase for hooks and utils9192### Additional Done Criteria93- Run the repo's control-plane risk gate (if present) — confirm no gate violations94- All new interactive elements have `aria-label` / `aria-labelledby`95- All test-targeted elements have `data-testid`9697---9899## Backend (Python / FastAPI)100101### File Ownership102- Source files: routers, managers, db, schemas, auth, utils, integrations, workers103- Must also never touch: Alembic migration files (autogenerate only; never hand-edit existing migrations)104105### Quality Checks106```bash107pytest tests # All tests pass108black . # No-op (code already formatted)109flake8 . # No lint errors110```111112### Architecture Layers113- **Routers** (thin): validate input → call manager → return response114- **Managers** (business logic): own business logic; hold DB API instances as class attributes115- **db_api / DAO**: all SQLAlchemy queries; return ORM models116- **Schemas** (Pydantic v2): separate request vs. response models117- **Exceptions**: raise from `utils.exceptions` (e.g., `NotFoundException`)118119### Async / Session Rules120- All DB + I/O is `async`/`await`121- Use injected session dependency; no manual commit/close in route handlers122- One session per request123124### ORM Safety125- Eager-load relationships with `selectinload` / `joinedload`126- Never access relationships after session close127- Build nested trees manually in manager layer128129### Code Style130- Black formatter (120-char line length)131- Flake8 with import-order, quotes, naming plugins132- Full type hints on all signatures133- `snake_case` for files, functions, variables; `PascalCase` for classes134135---136137*Part of [kromatic-dev-stack](https://github.com/Kromatic-Innovation/kromatic-dev-stack) by [Kromatic](https://kromatic.com). Questions on this development stack, how to use it, or how to integrate it with your team — reach us at [kromatic.com/contact-us](https://kromatic.com/contact-us).*