Skip to content
Agent loop · Testing

Bug Repro Until Fixed

Turn a bug report or error event into a failing regression test, fix the code until that test passes, and confirm nothing else in the suite broke.

Up to 8 iterationsStop rules and safety limits
The prompt

Copy the Bug Repro Until Fixed loop

Stops when a regression test reproduces the bug, then passes after the fix, with the full suite green, or after 8 iterations. Edit the settings block, then paste the whole prompt into your agent.

bug-repro-until-fixed.prompt.md
You are running the "Bug Repro Until Fixed" loop.

Settings (edit before running):
- Bug source: <issue URL, tracker ID, or error event ID>
- Test command: npm test
- Max iterations: 8

Goal: a regression test that fails before your fix and passes after it, with the full suite green.

Phase 1, reproduce (up to 3 iterations):
1. Read the bug source: expected vs actual behavior, steps, inputs, stack trace, environment, and the release it first appeared in.
2. Write the smallest automated test that reproduces it. Run it and confirm it fails with the same symptom as the report.
3. If it passes, adjust the inputs or setup and try again. If you cannot reproduce it in 3 attempts, stop and report what you tried.

Phase 2, fix (remaining iterations):
4. Trace the failure to its root cause. Explain it in two or three sentences before changing code.
5. Make the smallest fix at the root cause, not at the symptom.
6. Run the new test, then the full suite. Repeat until both pass.

Stop when:
- The regression test fails without the fix, passes with it, and the full suite is green. Success.
- You reach the max iteration count.

Rules:
- Read the bug source only. Do not comment on, close, reassign, or relabel the issue.
- Do not change or delete existing tests to make the suite pass.
- Strip any personal data or tokens from the report before putting values in a test.

Final report: root cause, the fix, the test name, and a short comment ready to paste on the issue.
When to use it

When this loop fits

  • A bug report or issue has steps to reproduce, but nobody has pinned it down in code yet.
  • An error tracker shows a recurring exception with a stack trace and you want a tested fix.
  • You want every bug fix to land with a test that stops it coming back.
How it works

What happens on each pass

The agent repeats these steps until the stop condition holds or it runs out of iterations.

  1. Gather the evidence. Read the issue or error event: steps, inputs, stack trace, environment, and first-seen release.
  2. Reproduce in a test. Write the smallest test that fails the same way the report describes.
  3. Locate the cause. Trace from the failing assertion to the line that produces the wrong behavior.
  4. Fix and verify. Fix the cause, run the new test and the full suite, and repeat until both pass.
  5. Link back. Summarize the cause and fix so it can be posted on the issue.
Recommended servers

MCP servers for this loop

The 6 strongest of 848 matching servers, ranked by how closely they fit and then by trust score.

More in Monitoring
  • Trust score 76 of 100, Good

    OpenOSINT

    by openosint · Python

    AI-powered OSINT agent & MCP server. 21 tools: email, breach, IP, WHOIS, DNS, Shodan, GitHub & more.

    Registry
    LicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 16 days ago.
    1.8K stars—/wk weekly downloads— tools
  • Trust score 70 of 100, Good

    Github

    by pipeworx-io · TypeScript

    GitHub MCP — wraps the GitHub public REST API (no auth required for public endpoints)

    RegistryRemote
    LicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 13 days ago.
    0 stars797/wk weekly downloads— tools
  • Trust score 69 of 100, Good

    mcp-jira-stdio

    by freema · TypeScript

    MCP server for Jira Cloud — issues, search, comments, attachments, transitions.

    Registry
    LicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: B. Last commit or release 36 days ago.
    14 stars—/wk weekly downloads— tools
  • Trust score 69 of 100, Good

    SandboxAPIs

    by driftwork-llc · TypeScript

    Drop-in read-only replicas of GitHub, Jira, Slack and 22 more, preloaded with one fake company.

    Registry
    LicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 19 days ago.
    0 stars266/wk weekly downloads— tools
  • Trust score 68 of 100, Good

    GraphQL gateway for LLMs. Handles huge GitHub GraphQL & @neo4j/graphql schemas without crashing

    Registry
    LicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 12 days ago.
    6 stars—/wk weekly downloads— tools
  • Trust score 68 of 100, Good

    Tldr Pages

    by pipeworx-io · JavaScript

    tldr-pages MCP — fetched from the canonical github repo.

    RegistryRemote
    LicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 9 days ago.
    0 stars48/wk weekly downloads— tools
Run it

How to run this loop

  1. Connect the tools. Install a server the loop can use, for example OpenOSINT, or rely on your agent's built-in terminal and file access.
  2. Edit the settings block. Replace the example commands, targets, and limits with your project's own. Keep the iteration cap low on the first run.
  3. Paste it into an agent session. Start a fresh session in Claude Code, Cursor, or VS Code agent mode, in the repository root, and paste the prompt.
  4. Review before you merge. Read the final report and the diff. The loop leaves its work for you to review rather than shipping it.
FAQ

Bug Repro Until Fixed questions

When does the Bug Repro Until Fixed loop stop?

It stops as soon as a regression test reproduces the bug, then passes after the fix, with the full suite green. It also stops after 8 iterations by default, or earlier when the prompt's own stop rules say it is stuck, and then reports what changed and what is left. Change the cap in the settings block at the top of the prompt.

Which MCP servers help with this loop?

An issue tracker server (GitHub, Linear, Jira) or an error monitoring server such as Sentry lets the agent read the report, stack trace, and affected release directly. Without one, paste the report into the settings block instead.

What if the agent cannot reproduce the bug?

The loop gives up after three attempts and reports what it tried. That is useful on its own: it often means the report is missing an input, an environment detail, or a data condition, which is exactly what to ask the reporter for.

Keep exploring
All loops