Fix Bug
Treat the user's report as a hypothesis, not a patch list. Work one defect at a time (or a small independent set) through reproduce → root cause → fix → verify. Do not edit product code for a defect until that defect is observed, or reproduction is blocked with evidence you report honestly.
Safety
- Read repository run, test, seed, and environment instructions before starting services or mutating data.
- Prefer local, sandbox, or explicitly authorized environments. Do not use production write paths, real customer data, or live payments to prove a bug unless the user authorizes it and no safer path exists.
- Never expose secrets, tokens, PII, or private logs in the final report. Redact when quoting evidence.
- Stop and ask when reproduction needs credentials, irreversible actions, or product choices you cannot discover safely. Do not invent a root cause to unblock coding.
- Prefer the smallest correct fix. No drive-by refactors, unrelated cleanups, or "while I'm here" scope expansion unless required to land the fix.
Multi-bug queue
When the user describes more than one bug (or a batch):
- Inventory each item as a short ticket: ID (bug-1…), symptoms, expected vs actual, severity/impact, known steps, and shared vs independent surface.
- Order the queue: blockers and crashes first, then user-visible wrong behavior, then polish. Prefer fixing shared root causes once when evidence shows one cause feeds many tickets.
- Run the full workflow per ticket (or per shared root-cause group). Do not claim the batch is done while any ticket is unreproduced, unfixed, or unverified.
- Keep a live scoreboard:
open | reproducing | root-caused | fixed | verified | blocked. Update it after each ticket.
- If tickets interact, re-verify earlier verified tickets after later fixes when shared code changed.
Single-bug runs are just a queue of length 1.
Workflow
For each ticket in order:
1. Capture (do not code yet)
- Restate symptoms, expected vs actual, environment hints, and any steps the user gave.
- List what would count as a successful reproduction and a successful fix for this ticket only.
- Treat "I think it's in file X" as a lead, not as the diagnosis.
2. Reproduce like a senior engineer
- Boot what the stack needs: install deps, start services, seed data, feature flags, mobile/web targets, or the minimal CLI path.
- Prefer the highest-signal path available, in order:
- failing automated test or a new minimal failing test that encodes the report;
- scripted CLI/API path with logs;
- real UI/app path with console/network/device logs when the bug is user-visible.
- Collect evidence: stack traces, log lines, status codes, screenshots, DB/query results, race timing notes. Save commands so verification can re-run them.
- Probe nearby edge cases that could change the diagnosis (empty input, auth boundary, concurrency, locale, offline, large payload, first-run vs returning).
- Gate: no product-code fix until the bug is observed or you document a blocked reproduction (missing env, flaky only in prod, insufficient access) and get direction.
3. Root cause
- Trace from observed failure to the responsible code path with evidence (not "maybe").
- Separate: trigger, underlying defect, and any secondary symptoms.
- If multiple tickets share one cause, merge them for fix/verify and note which IDs close together.
- If the report is wrong or incomplete, say so with evidence and update the ticket before coding.
4. Fix
- Implement the minimal change that addresses the root cause.
- Add or extend a regression test when the stack makes that practical; otherwise record an explicit manual repro command as the regression harness.
- Keep unrelated files out of the diff.
5. Verify
- Re-run the same reproduction path; it must pass.
- Re-check the edge cases that matter for this ticket.
- Run the repository's relevant narrow tests and the project verify gate when the change is non-trivial.
- For multi-bug: mark the ticket
verified, then proceed to the next open ticket. Re-smoke shared surfaces when a later fix touches the same code.
Verification
Report a per-ticket table (or equivalent sections) covering:
| Field |
Content |
| Ticket |
ID + one-line symptom |
| Repro |
Commands/steps, env identity, evidence observed before the fix |
| Root cause |
Evidence-backed explanation (file/function when known) |
| Fix |
What changed and why it addresses the cause |
| Proof |
Same repro after fix, tests run, edge cases checked |
| Status |
verified / blocked / deferred with reason |
| Residual risk |
What was not covered |
Do not claim a bug (or the batch) is fixed if you only read the report and edited code without observing the failure and re-running the repro path. Do not collapse multiple tickets into one green claim without per-ticket proof.
1---2name: fix-bug3description: Use when the user runs /fix-bug, says "fix this bug", "fix these bugs", "reproduce then fix", "debug this failure", or describes one or more concrete defects and wants senior-engineer proof (env, logs, edge cases, verification) before code changes — never patch from the report alone.4---56# Fix Bug78Treat the user's report as a **hypothesis**, not a patch list. Work one defect at a time (or a small independent set) through reproduce → root cause → fix → verify. Do not edit product code for a defect until that defect is observed, or reproduction is blocked with evidence you report honestly.910## Safety1112- Read repository run, test, seed, and environment instructions before starting services or mutating data.13- Prefer local, sandbox, or explicitly authorized environments. Do not use production write paths, real customer data, or live payments to prove a bug unless the user authorizes it and no safer path exists.14- Never expose secrets, tokens, PII, or private logs in the final report. Redact when quoting evidence.15- Stop and ask when reproduction needs credentials, irreversible actions, or product choices you cannot discover safely. Do not invent a root cause to unblock coding.16- Prefer the smallest correct fix. No drive-by refactors, unrelated cleanups, or "while I'm here" scope expansion unless required to land the fix.1718## Multi-bug queue1920When the user describes **more than one** bug (or a batch):21221. Inventory each item as a short ticket: ID (bug-1…), symptoms, expected vs actual, severity/impact, known steps, and shared vs independent surface.232. Order the queue: blockers and crashes first, then user-visible wrong behavior, then polish. Prefer fixing shared root causes once when evidence shows one cause feeds many tickets.243. Run the full workflow **per ticket** (or per shared root-cause group). Do not claim the batch is done while any ticket is unreproduced, unfixed, or unverified.254. Keep a live scoreboard: `open | reproducing | root-caused | fixed | verified | blocked`. Update it after each ticket.265. If tickets interact, re-verify earlier verified tickets after later fixes when shared code changed.2728Single-bug runs are just a queue of length 1.2930## Workflow3132For **each** ticket in order:3334### 1. Capture (do not code yet)3536- Restate symptoms, expected vs actual, environment hints, and any steps the user gave.37- List what would count as a successful reproduction and a successful fix for this ticket only.38- Treat "I think it's in file X" as a lead, not as the diagnosis.3940### 2. Reproduce like a senior engineer4142- Boot what the stack needs: install deps, start services, seed data, feature flags, mobile/web targets, or the minimal CLI path.43- Prefer the highest-signal path available, in order:44 1. failing automated test or a new minimal failing test that encodes the report;45 2. scripted CLI/API path with logs;46 3. real UI/app path with console/network/device logs when the bug is user-visible.47- Collect evidence: stack traces, log lines, status codes, screenshots, DB/query results, race timing notes. Save commands so verification can re-run them.48- Probe nearby edge cases that could change the diagnosis (empty input, auth boundary, concurrency, locale, offline, large payload, first-run vs returning).49- **Gate:** no product-code fix until the bug is observed **or** you document a blocked reproduction (missing env, flaky only in prod, insufficient access) and get direction.5051### 3. Root cause5253- Trace from observed failure to the responsible code path with evidence (not "maybe").54- Separate: trigger, underlying defect, and any secondary symptoms.55- If multiple tickets share one cause, merge them for fix/verify and note which IDs close together.56- If the report is wrong or incomplete, say so with evidence and update the ticket before coding.5758### 4. Fix5960- Implement the minimal change that addresses the root cause.61- Add or extend a regression test when the stack makes that practical; otherwise record an explicit manual repro command as the regression harness.62- Keep unrelated files out of the diff.6364### 5. Verify6566- Re-run the **same** reproduction path; it must pass.67- Re-check the edge cases that matter for this ticket.68- Run the repository's relevant narrow tests and the project verify gate when the change is non-trivial.69- For multi-bug: mark the ticket `verified`, then proceed to the next open ticket. Re-smoke shared surfaces when a later fix touches the same code.7071## Verification7273Report a per-ticket table (or equivalent sections) covering:7475| Field | Content |76| --- | --- |77| Ticket | ID + one-line symptom |78| Repro | Commands/steps, env identity, evidence observed before the fix |79| Root cause | Evidence-backed explanation (file/function when known) |80| Fix | What changed and why it addresses the cause |81| Proof | Same repro after fix, tests run, edge cases checked |82| Status | verified / blocked / deferred with reason |83| Residual risk | What was not covered |8485Do **not** claim a bug (or the batch) is fixed if you only read the report and edited code without observing the failure and re-running the repro path. Do not collapse multiple tickets into one green claim without per-ticket proof.