Get the FREE Ultimate OpenClaw Setup Guide →

run-tdd

Scanned
npx machina-cli add skill hardness1020/VibeFlow/run-tdd --openclaw
Files (1)
SKILL.md
5.2 KB

run-tdd

TDD implementation cycle for Stages F-H of the VibeFlow docs-first workflow.

Purpose

This skill guides the TDD cycle:

  • Stage F (RED): Create stubs + write failing unit tests
  • Stage G (GREEN): Implement minimal code to pass tests
  • Stage H (REFACTOR): Write integration tests + refactor + quality validation

Workflow

Stage F: RED
    │
    ├── Create stubs from Feature Spec API Design
    ├── Write failing unit tests
    ├── Tests fail with NotImplementedError
    └── Checkpoint #3: Tests Complete
    │
    ▼
Stage G: GREEN
    │
    ├── Implement minimal code to pass tests
    ├── If contracts change → Stage G.1
    └── All unit tests pass
    │
    ▼
Stage H: REFACTOR
    │
    ├── Write integration tests for I/O
    ├── Pass integration tests
    ├── Refactor with tests green
    ├── Complete H.4 quality validation
    └── Checkpoint #4: Implementation Complete

Usage

Start TDD Cycle

/run-tdd start

Guides through the full TDD cycle starting with Stage F.

Stage F: RED Phase

/run-tdd red
  1. Create implementation stubs from Feature Spec API Design
  2. Write failing unit tests
  3. Verify tests fail with "not implemented" errors

Stage G: GREEN Phase

/run-tdd green
  1. Implement minimal code to pass unit tests
  2. Check for contract changes (trigger G.1 if needed)
  3. Verify all unit tests pass

Stage H: REFACTOR Phase

/run-tdd refactor
  1. Write integration tests for I/O boundaries
  2. Refactor code while keeping tests green
  3. Complete H.4 quality validation

Validate Tests

/run-tdd validate

Runs test quality validation (Stage H.4 checklist).

Handle Design Changes

/run-tdd g1

Guides through Stage G.1 protocol when implementation reveals contract changes.

Stage G.1: Design Changes Protocol

If implementation reveals contract changes, STOP IMMEDIATELY and follow these steps:

  1. Document the discovered issue
  2. Update SPEC first (increment version)
  3. Create/update ADR if non-trivial
  4. Update Feature Spec API Design
  5. Update tests to new contract
  6. Resume implementation

Contract changes that trigger G.1:

  • API/Interface signature changes
  • Database schema changes
  • Event format changes
  • New external dependencies
  • SLO changes

Changes that DON'T trigger G.1:

  • Internal algorithms
  • Private function names
  • Error handling improvements (within taxonomy)
  • Performance optimizations (within SLO)

Test Categorization

All tests must have categorization tags:

Speed/Scope (required):

  • unit / fast — All dependencies mocked, runs in ms
  • integration / medium — Uses test DB, mocked external APIs
  • e2e / slow — Full workflow, multiple components
  • real_api — Makes real external API calls

Module (required):

  • Tag with module name (e.g., accounts, generation, api)

Stage H.4 Quality Validation

Before completing Stage H, validate:

Organization:

  • File structure follows conventions
  • Test names use test_<what>_<condition>_<expected>
  • Related tests grouped

Usefulness:

  • Tests based on acceptance criteria
  • Happy path, edge cases, error cases tested
  • Tests validate behavior, not implementation

Code Quality:

  • External dependencies mocked in unit tests
  • AAA pattern clear
  • No skipped tests without justification

Categorization:

  • All tests have speed/scope tags
  • No real API calls in "unit" tests

Reliability:

  • Unit tests < 1s each
  • Integration tests < 5s each
  • Tests pass consistently (no flaky tests)

Quality Gate:

  • 0-2 violations: PASS
  • 3-5 violations: CONDITIONAL
  • 6+ violations OR 2+ major: FAIL

Validation

  • scripts/validate_red.py — Validate Stage F (tests failing correctly)
  • scripts/validate_green.py — Validate Stage G (tests passing)
  • scripts/validate_refactor.py — Validate Stage H (integration + quality)
  • scripts/check_coverage.py — Report test coverage

References

See references/:

  • tdd-policy.md — TDD policy and requirements
  • tdd-guide.md — TDD workflow guidance
  • stage-g1-protocol.md — Design change handling protocol

Manifest Update

After completing each stage, update docs/workflow-state.yaml:

Stage F (RED):

  • Set stage: F

Checkpoint #3 (after Stage F):

  • Set checkpoint: 3 after passing validation
  • Criteria: Stubs exist matching Feature Spec API Design, unit tests exist and fail with NotImplementedError

Stage G (GREEN):

  • Set stage: G

Stage H (REFACTOR):

  • Set stage: H

Checkpoint #4 (after Stage H):

  • Set checkpoint: 4 after passing validation
  • Criteria: All unit tests pass, integration tests pass, H.4 quality validation passes

To advance to the next stage: /manage-work advance <ID> To check readiness: /validate-checkpoint 3 (after RED) or /validate-checkpoint 4 (after REFACTOR)

Source

git clone https://github.com/hardness1020/VibeFlow/blob/main/.claude/skills/run-tdd/SKILL.mdView on GitHub

Overview

Guides the TDD cycle for Stages F (RED), G (GREEN), and H (REFACTOR) in VibeFlow's docs-first workflow. It starts with writing failing tests, then implementing minimal code, and finishes with integration tests and a quality validation pass.

How This Skill Works

It orchestrates the RED-GREEN-REFACTOR loop across F, G, and H, including creating stubs, writing tests, and validating changes. Stage F produces NotImplementedError failures, Stage G adds minimal code to satisfy tests, and Stage H runs integration tests and quality validation.

When to Use It

  • When starting a new feature and initiating the TDD cycle (Stage F: RED).
  • When implementing minimal code to satisfy unit tests (Stage G: GREEN).
  • When performing integration tests and refactoring with quality checks (Stage H: REFACTOR).
  • When tests reveal contract changes requiring G.1 protocol.
  • When performing Stage H.4 quality validation to complete the cycle.

Quick Start

  1. Step 1: Start the cycle with /run-tdd start.
  2. Step 2: Move to RED with /run-tdd red to create stubs and failing tests.
  3. Step 3: Move to GREEN with /run-tdd green to implement minimal code and pass tests.

Best Practices

  • Create stubs from the Feature Spec API Design and wire frames.
  • Write failing unit tests first in RED and verify they fail with NotImplementedError.
  • Implement minimal, contract-compliant code to pass unit tests.
  • Add integration tests for I/O in Stage H and refactor while keeping tests green.
  • Run the Stage H.4 quality validation checklist before completion.

Example Use Cases

  • /run-tdd start to begin the cycle.
  • /run-tdd red to create stubs and failing tests.
  • /run-tdd green to implement minimal code and pass tests.
  • /run-tdd refactor to add integration tests and perform quality validation.
  • /run-tdd g1 when a design change is detected.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers