Skip to main content

Documentation Index

Fetch the complete documentation index at: https://gump.build/docs/llms.txt

Use this file to discover all available pages before exploring further.

TDD

Test-first, implement, verify.

When to use

When the spec is clear and you want tests written before code. The red/green pattern forces the agent not to cheat — tests and implementation are in separate steps with gates that verify the right files were touched.
gump run tdd --spec spec.md

The workflow

name: tdd
max_budget: 5.00

steps:
  - name: decompose
    type: split
    get:
      prompt: |
        Analyze this spec and the codebase. Decompose into independent tasks.
        For each task, list the files that will be affected.
    run:
      agent: claude-opus
    gate: [schema]
    each:
      - name: tests
        type: code
        get:
          prompt: |
            Write comprehensive tests for: {task.description}
            Cover edge cases and error conditions.
            Only create/modify test files in: {task.files}
        run:
          agent: claude-haiku
          guard:
            max_turns: 40
        gate:
          - compile
          - "touched: *_test.*"
          - tests_found
        retry:
          - attempt: 2
            agent: claude-sonnet
          - exit: 3

      - name: impl
        type: code
        get:
          session: from: tests
          prompt: |
            Implement code to pass all tests.
            Do not modify the tests.
            Only modify implementation files in: {task.files}
        run:
          agent: claude-haiku
          guard:
            max_turns: 60
        gate:
          - compile
          - test
          - "untouched: *_test.*"
        retry:
          - attempt: 3
            agent: claude-sonnet
          - exit: 5

  - name: quality
    gate: [compile, lint, test]

How it works

For each task, Gump first runs a “tests” step that writes the tests. The gate checks: code compiles, test files were touched (touched: *_test.*), and the test runner finds tests (tests_found). Then the “impl” step implements code to make the tests pass. It resumes the agent’s session (session: from: tests) for continuity. The gate checks that code compiles, tests pass, and — crucially — that test files were not modified (untouched: *_test.*). This is the anti-cheat guard.

Typical metrics

Average cost: 11–3 for a 3-task spec. Duration: 2–4 minutes.

Customize

Replace claude-haiku with qwen.
Add coverage: 80 to the quality gate.
Add context: [file: ".gump/skills/testing-guidelines.md"] to the tests step.
Call TDD from another workflow via composition:
- name: setup
  workflow: tdd
    spec: "{task.description}"