> ## 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.

# Bugfix

> Reproduce first, then fix. Never ship a fix without a regression test.

# Bugfix

Reproduce first, then fix.

## When to use

When you have a bug report and want to enforce the "reproduce first, fix second" discipline. The workflow ensures a regression test exists before the fix is implemented.

```bash theme={null}
gump run bugfix --spec bug-report.md
```

## The workflow

```yaml theme={null}
name: bugfix
max_budget: 3.00

steps:
  - name: analyze
    type: split
    get:
      prompt: |
        Analyze this bug report. Identify the root cause.
        Produce a single task with the reproduction strategy and affected files.
    run:
      agent: claude-sonnet
    gate: [schema]
    each:
      - name: reproduce
        type: code
        get:
          prompt: |
            Write a test that reproduces this bug: {task.description}
        run:
          agent: claude-haiku
          guard:
            max_turns: 30
        gate: [compile, tests_found]
        retry:
          - attempt: 2
            agent: claude-sonnet
          - exit: 3

      - name: patch
        type: code
        get:
          session: from: reproduce
          prompt: |
            Fix the bug. The reproduction test must pass.
            Only modify: {task.files}
        run:
          agent: claude-haiku
          guard:
            max_turns: 40
        gate: [compile, test]
        retry:
          - attempt: 3
            agent: claude-sonnet
          - exit: 4

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

## How it works

The "reproduce" step writes a test that exposes the bug — the gate checks that code compiles and tests exist, but not that tests pass (the bug is still present).

The "patch" step reuses the session (`session: from: reproduce`) and fixes the bug. The compile + test gate verifies all tests pass, including the reproduction test.

## Typical metrics

The cheapest workflow. Average cost: $0.20–$0.80. Duration: 30s–2 minutes.

## Customize

<AccordionGroup>
  <Accordion title="Ensure the fix doesn't modify tests">
    Add `untouched: "*_test.*"` to the `patch` gate.
  </Accordion>

  <Accordion title="Add recent git history as context">
    Add `context: [bash: "git log --oneline -20"]` to the `analyze` step.
  </Accordion>
</AccordionGroup>
