--- description: Enforce test-driven development. Scaffold types, write Vitest tests FIRST, then implement the minimum to pass. Ensure 80%+ coverage. --- # TDD Command This command invokes the **tdd-guide** agent. ## What This Command Does 1. **Scaffold types** — inputs/outputs first 2. **Write failing tests** (RED) with Vitest 3. **Implement the minimum** (GREEN) 4. **Refactor** while green 5. **Check coverage** (80%+) ## When to Use - New validators, transformers, stores, components - Bug fixes (reproducing test first) - Refactors of existing logic ## Cycle ``` RED → GREEN → REFACTOR → REPEAT ``` ## Example ``` User: /tdd Add validation for the full-page name field ``` ```typescript // full-page.validator.test.ts import { createFullPageSchema } from './full-page.validator'; it('rejects an empty name', () => { const schema = createFullPageSchema((k) => k); expect(schema.safeParse({ code: 'ABC', name: '' }).success).toBe(false); }); ``` ```bash pnpm --filter web test pnpm test pnpm check:all ``` Mock `@repo/core-api` / `apiClient`, not a database. UI in `packages/ui` uses Testing Library. ## Related Agent: `.cursor/agents/tdd-guide.md` Skill: `.agents/skills/tdd-workflow/`