Step 6: TDD/BDD

Turn the Gherkin scenarios of the spec into failing Vitest tests, then make them pass.

Skill: fireskill-06-tdd-bdd · Asks questions: no · Creates: Vitest test files next to the code; updates the evidence table of spec.md

When to use it

Normally you do not call it: $fireskill-05-tasks calls it in prepare mode. Call it yourself when you want one more failing test, a cycle, or an audit.

What to type

Use $fireskill-06-tdd-bdd para ler o Gherkin de referência em specs/<estado>/<NNNN>-<slug>/spec.md, criar testes TDD rastreáveis e executar RED-GREEN-REFACTOR sem executar .feature. Orquestre transições automáticas com anúncio, execução e retomada na mesma conversa.

You can name the mode in the same message: prepare, cycle or verify.

The three modes

ModeWhenWhat it does
preparebefore implementation (spec Defined, Plan Gate: Pending)writes the next test and proves RED, without production code; marks only that [TEST] task done; returns to $fireskill-05-tasks
cycleduring implementation (spec Planned or Implementing)RED → GREEN → REFACTOR for one chosen slice
verifyany timeruns the suites and audits traceability, creating no new behavior

If you do not say, it uses prepare when the task list is not being executed yet and cycle when a task is active.

How a test is written

  • The Gherkin block of the AC in spec.md is the reference. No .feature file is created or run.
  • Tests are Vitest, next to the code in its layer (shared/**/*.test.ts or server/**/*.test.ts), at the lowest level that proves the behavior. Real examples: layers/teams/shared/utils/abilities.test.ts, layers/teams/server/utils/team-seats.test.ts.
  • Each executable case carries its own marker, right beside its definition:
    // SPECSFY: US-001 FR-001 AC-001
    it("rejeita convite de quem não é administrador", async () => {
      // …
    });
    
  • At least three distinct cases for the whole feature and for each US, FR and NFR: happy path, critical rule or variation, failure or material limit. One marker shared by a whole file counts as one case.
  • Every AC is covered by at least one case.

RED, GREEN, REFACTOR

  1. RED: write the smallest test that proves the AC, run it (bun run test, or bunx vitest run <file>) and confirm it fails because the behavior is missing. A failure from syntax, import, fixture or environment does not count. A test that passes before the change proves nothing and must be refined.
  2. GREEN (in cycle): the minimum production code, focal test first, then the related suite.
  3. REFACTOR: clean up with the tests green.

Each step is recorded in the Evidência RED-GREEN-REFACTOR table of the spec.

Database protection

Before any test runs, check_database_safety.mjs classifies the command. If it is not SAFE, no test runs and the step stays pending. Tests that reach PostgreSQL need a dedicated test database; use a rolled-back transaction or fixtures limited to the case.

Check traceability yourself

node fireskills/skills/fireskill-06-tdd-bdd/scripts/check_traceability.mjs specs/planned/<NNNN>-<slug>/spec.md .
bun run test

Next

prepare returns to Step 5, which promotes the spec to planned. Then Step 7: Implement.

Nuxfire Production Kit

Ready to build and launch your SaaS?

Get 100% full source code ownership, zero proprietary wrappers, and architecture engineered for millions of requests on Cloudflare.

© 2026 Nuxfire