Guide TDD workflow and testing strategy. Use when implementing features with tests, writing new tests, or establishing test coverage. Triggers on "TDD", "write tests", "test coverage", "red-green-refactor".
Guide the Red-Green-Refactor cycle and pragmatic testing strategy. "Write tests. Not too many. Mostly integration."
Initial context received via slash: $ARGUMENTS
If $ARGUMENTS is filled (e.g., module name, feature description), use as starting point.
If empty, ask what will be tested.
Write artifacts and test descriptions in the user's language. When in doubt, ask. Test code itself (function names, assertions) stays in English.
/agile-protoPresent each step explicitly. Do not skip Red -- the test must fail first.
| Layer | Target | Focus |
|---|---|---|
| Unit | 60% | Pure functions, transformers, utils |
| Integration | 30% | Services, DB interactions, API routes |
| E2E | 10% | Critical user flows |
Overall coverage target: 75%+.
foo.test.ts beside foo.ts)tests/ with integration/, e2e/, helpers/, fixtures/, mocks/.test.ts (unit/integration), .e2e.test.ts (E2E).spec.tsfaker) over hardcoded databeforeEach -- no shared state between testssleep(ms) -- use proper waitsconsole.log in tests -- use proper assertions| Area | Target |
|---|---|
| Transformers / pure functions | 90%+ |
| Utils | 85%+ |
| Services | 80%+ |
| Routes / handlers | 70%+ |
bun test
bun test --watch
bun test --coverage
bun test --filter "name"
bun test src/dir/
Adjust for other runtimes (vitest, jest) as needed. Detect the project's test runner from package.json or config files before suggesting commands.
Explore the code to understand:
Use the test pyramid as guide:
For each behavior:
Run coverage and check against targets. Fill gaps in critical areas first.
/agile-story checklist/agile-refinement to review test quality/agile-status (closure mode) verificationflowchart LR
A["/agile-story"] --> B[TDD cycle]
B --> C[Red: failing test]
C --> D[Green: minimum code]
D --> E[Refactor]
E --> F{More?}
F -->|Yes| C
F -->|No| G["/agile-refinement"]
This skill operates during execution. It pairs with /agile-story (which defines what to build) and feeds into /agile-refinement (which validates the result).