Bug FixMedium risk
Bug Fixing Loop
Reproduce a bug, fix the smallest cause, and verify with a regression test.
What this Loop Engineering template does
Reproduce the reported bug, fix the smallest root cause, and prove it with a regression test.
Start by reproducing the bug. Write a failing regression test first, then fix until it passes.
When to use it
Reproducible bugs
Regression-testable fixes
Localized defects
When not to use it
Vague “it feels slow” reports
Bugs needing product decisions
Large refactors
Validation checks
validation
✓Bug is reproduced before fix
✓Regression test fails before fix and passes after fix
✓Full relevant test suite passes
Boundaries & stop rule
!Do not rewrite unrelated modules
!Do not hide errors
!Do not change expected behavior without documenting why
Stop rule — Stop when the regression test passes and the suite is green, or after 5 failed attempts. If the root cause is unclear, summarize the reproduction, hypotheses tried, and recommended next step.
Copy the loop prompt
claude-goal.txt
/goal Reproduce the reported bug, fix the smallest root cause, and prove it with a regression test.Work toward this goal until all validation checks pass or the stop rule is reached.Loop cycle:1. Discovery — Read the latest signal for this template before acting: CI output, issue detail, review comment, dataset report, or content brief.2. Handoff — Hand the work to one agent in an isolated branch, worktree, or clearly scoped session. Keep final approval with a human.3. Verification — Use an independent review pass to confirm the result, inspect the diff or artifact, and reject shortcut work.4. Persistence — Save a short run note with the signal reviewed, actions taken, validation result, and next recommended step.5. Scheduling — Run manually until the loop is reliable; only then consider a scheduled or event-triggered run.Context:Start by reproducing the bug. Write a failing regression test first, then fix until it passes.Validation:Bug is reproduced before fixRegression test fails before fix and passes after fixFull relevant test suite passesIndependent checker:Use an independent review pass to confirm the result, inspect the diff or artifact, and reject shortcut work.Boundaries:Do not rewrite unrelated modulesDo not hide errorsDo not change expected behavior without documenting whyStop rule:Stop when the regression test passes and the suite is green, or after 5 failed attempts.Maximum iterations: 6Budget:Stop before exceeding the agreed per-run token budget.Human approval:Required before merge, deploy, delete, purchase, or external communication.Fallback:If the root cause is unclear, summarize the reproduction, hypotheses tried, and recommended next step.Do not delete tests, bypass checks, or modify unrelated files just to satisfy the validation condition. If blocked, stop and summarize the blocker, attempted fixes, and recommended next action.
Failure modes to watch
Agent fixes a symptom, not the cause
Agent skips the regression test
Agent broadens scope unnecessarily
Agent suppresses the error
Loop Engineering FAQ
A test that fails before the fix and passes after proves the bug was real and the fix addresses it — not just that the code changed.