Tdd

From redpanda-data/ui-harness · View interactive version

Tdd is an AI agent skill from the GitHub repository redpanda-data/ui-harness. Test-driven development with red-green-refactor loop. Use when writing tests, creating new features, or fixing bugs. Includes planning phase, tracer bullets, async leak detection, deep module design, and condition-based waiting.

How to use this skill

Skill file

Test-Driven Development

Iron Law

No prod code without failing test first. No exceptions.

Anti-Pattern: Horizontal Slices

DO NOT write all tests first, then all impl. Bulk tests test imagined behavior, not actual.

Correct: Vertical slices -- one test -> one impl -> repeat.

WRONG: RED: test1,test2,test3 -> GREEN: impl1,impl2,impl3

RIGHT: RED->GREEN: test1->impl1 -> RED->GREEN: test2->impl2

State Machine

Full state diagram: REFERENCE.md#state-machine.

Workflow

0. PLAN -- Coverage gap analysis

1. RED -- Failing test (tracer bullet)

2. GREEN -- Minimal code to pass

3. REFACTOR -- Clean up while green

Reactive TDD with Monitor

Monitor: vitest --watch -- stream pass/fail as edit. Edit->fail->fix->pass->refactor->repeat.

4. REPEAT -- Next behavior

RED->GREEN->REFACTOR per behavior. One at a time.

Per-Cycle Checklist

Test Classification

| Suffix | Purpose | DOM? |

|--------|---------|------|

| .test.ts | Unit -- pure logic | No |

| .test.tsx / .integration.tsx | Integration -- render components | Yes |

| e2e/*.spec.ts | E2E -- Playwright browser | Browser |

Visual Regression Tests (Route Files)

New TanStack Router routes need *.browser.test.tsx sibling -- only if project use vitest browser mode (existing *.browser.test.* files or @vitest/browser dep). Skip layout/redirect-only routes. See REFERENCE.md.

When Done

See REFERENCE.md for element selectors, portal testing, mock patterns, diagnostics, Vitest config.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.