test-driven-development
When to use
- Adding a new function, method, or behavior
- Fixing a bug (the bug needs a regression test before the fix)
- Refactoring a unit whose current behavior is unclear
- Any task where expected behavior can be expressed as an assertion
Do NOT use when:
- Writing throwaway prototype or spike code explicitly marked as exploration
- Generating boilerplate (migrations, config files, scaffolding)
- Editing pure documentation (
.md,AGENTS.md, README) - Working inside this
agent-configpackage on skill/rule markdown
Goal
- Drive implementation from a verified-failing test, not from the agent's
belief that the code "should work".
- Catch edge cases before they become production bugs.
- Leave every change with a regression test that runs in CI.
Escalate to a SPARC-style 5-phase workflow when
Plain TDD (red → green → refactor) is the right size for most work.
A small subset benefits from a gated 5-phase wrapper —
Spec → Pseudocode → Architecture → Refine → Complete —
where each gate produces a written artifact before the next phase runs.
Decision tree — escalate if any branch is true:
- The ticket has AC count > 5 (the spec itself is non-trivial — write
it down before testing it).
- The change modifies a contract consumed by ≥1 other module
(public API signature, persisted schema, event payload, queue message).
- The change cuts across ≥3 modules / bounded contexts at once.
When escalating: drop the Spec artifact in agents/roadmaps/ (or the