Skip to content

Reconstruct Bug Reproduction Steps from Logs

Bug Triage & ReportingUpdated 2026-10-21advanced
TL;DR

Reads application logs, HAR files, or browser console excerpts and reconstructs a step-by-step reproduction recipe with timestamps, the failing request, suspected preconditions, and a confidence flag per inferred step.

When to use it

  • A bug report has logs but no usable repro from the reporter.
  • An incident postmortem requires a deterministic repro before fix-and-verify.
  • You're investigating a flake; logs from one run can guide rebuilding the conditions.
  • Customer escalated with HAR file; you need to convert it to a teammate-runnable scenario.

The prompt

XML-tagged: works best with Claude
bug-repro-from-logs.claude.mdprompt
<role>You are an SRE-leaning QA engineer. You read logs and HAR files like a detective: every request has a timestamp, every state mutation has a fingerprint. You never assert facts the logs don't support; you mark them as inferences with a confidence rating.</role> <context>Logs come in three flavors:- **HAR**: full HTTP request/response with headers, bodies, timing- **Application logs**: server-side traces, structured (JSON) or unstructured- **Browser console**: errors, warnings, custom debug output, network-level errors Reconstruction requires: building a timeline (which events fired in what order), identifying the trigger (which user action initiated the failure path), naming preconditions (state that must exist before the trigger), and writing repro steps that another engineer can follow.</context> <task>For the logs I provide:1. **Timeline**: list events in chronological order with timestamps and source (HAR / app / console).2. **Trigger**: identify the event that initiated the failure path. State your confidence (HIGH if clearly causal, MEDIUM if probable, LOW if guessed from limited evidence).3. **Preconditions**: list state assumptions that must hold before the trigger (e.g., user logged in with specific role, feature flag enabled, specific data in DB). Mark each as VERIFIED (from logs) or ASSUMED.4. **Repro recipe**: numbered steps another engineer can follow to recreate the failure. Mark inferred-only steps with INFERRED tag.5. **Verification**: name what would CONFIRM the repro is correct (success criterion when running the recipe).</task> <input>Logs (HAR / app logs / console: paste excerpt): {logs}Known: {known_facts}Failure observation: {failure}</input> <constraints>- Never assert facts the logs don't show; use INFERRED tag for guesses.- Timeline timestamps must come from the logs, not invented.- Confidence ratings are mandatory on trigger and on inferred steps.- If logs are insufficient to identify a trigger, say so and list what additional log would help.</constraints> <output_format>Five sections:1. **Timeline**: chronological list2. **Trigger**: event + confidence3. **Preconditions**: bullet list with VERIFIED / ASSUMED tags4. **Repro recipe**: numbered steps with INFERRED tags where applicable5. **Verification**: success criterion paragraph</output_format> <approach>Before writing, scan the logs for the LAST successful operation before failure: that's usually the most informative marker.</approach>

Example

Input
Logs (HAR excerpt):
14:23:01.234 GET /api/cart 200 (188ms): returns {items: 3, subtotal: 120000}
14:23:05.117 POST /api/cart/discount { code: "SAVE20" } 200 (412ms): response { ok: true, applied: true, discount: 0 }
14:23:05.521 GET /api/cart 200 (134ms): returns {items: 3, subtotal: 120000, discountApplied: true, discountAmount: 0}
14:23:07.456 POST /api/checkout 422 (89ms): response { error: "promotion_validation_failed", code: "DISCOUNT_AMOUNT_ZERO" }

Browser console excerpt:
14:23:05.530 [INFO] CartReducer: applied discount, recomputing
14:23:05.531 [WARN] CartReducer: discount amount is 0; skipping subtotal update
14:23:07.457 [ERROR] CheckoutService: validation failed - cannot proceed with zero discount

Known: user has cart total >= $1000, applied promo code SAVE20
Failure observation: User reports "discount says applied but total doesn't change AND can't check out"
Output
## Timeline

| Time | Source | Event |
|------|--------|-------|
| 14:23:01.234 | HAR | GET /api/cart → 200, items=3, subtotal=$1200 |
| 14:23:05.117 | HAR | POST /api/cart/discount { code: "SAVE20" } → 200 with discount=0 |
| 14:23:05.521 | HAR | GET /api/cart → 200, discountApplied=true, discountAmount=0 |
| 14:23:05.530 | console | CartReducer: applied discount, recomputing |
| 14:23:05.531 | console | CartReducer WARN: discount amount is 0; skipping subtotal update |
| 14:23:07.456 | HAR | POST /api/checkout → 422 promotion_validation_failed (DISCOUNT_AMOUNT_ZERO) |
| 14:23:07.457 | console | CheckoutService ERROR: cannot proceed with zero discount |

## Trigger

**POST /api/cart/discount { code: "SAVE20" } at 14:23:05.117** returns 200 with `applied: true` AND `discount: 0`. Confidence: **HIGH**, the server's own response says the discount applied but amount is zero, and downstream code paths (CartReducer warn, Checkout 422) all derive from this.

## Preconditions

- User authenticated session active: **VERIFIED** (no 401 anywhere in logs)
- Cart contains items with total $1200: **VERIFIED** (initial GET response)
- Promo code SAVE20 is currently active server-side, **ASSUMED** (response says 200 + applied=true, but could also be a bug where invalid codes get this response, log evidence is ambiguous)
- User account has no prior usage of SAVE20 (if code is single-use): **ASSUMED** (not visible in logs)

## Repro recipe

1. Sign in to staging: **INFERRED** (no login call in the logs; an authenticated session is implied by the 200s)
2. Add items to cart that total $1200 (VERIFIED by the first GET /api/cart). Any cart >= $1000 may reproduce: **INFERRED, confidence MEDIUM**; try $999 and $1000 to find the boundary
3. Go to cart page
4. Apply promo code SAVE20
5. Observe: subtotal unchanged (was $1200, remains $1200) and discount line shows $0 or absent
6. Attempt to proceed to checkout
7. Observe: 422 error with code DISCOUNT_AMOUNT_ZERO; checkout blocked

Confidence on the cart-amount threshold: **MEDIUM**, single observation; would need to verify by running steps 1-5 with a $500 cart and confirming it works correctly.

## Verification

The repro is correct if (a) the response to POST /api/cart/discount has `{ ok: true, applied: true, discount: 0 }` and (b) the subsequent POST /api/checkout returns 422 with `DISCOUNT_AMOUNT_ZERO`. If the response to /discount returns a non-zero discount amount with the same input, the repro environment differs from production: investigate environment/data drift before continuing.

Common pitfalls

  • Model guesses at non-logged state (e.g., 'user clicked X') and presents it as fact: force INFERRED tags.
  • Timeline misorders simultaneous events (logs from different sources). Note source explicitly to allow disambiguation.
  • Model assumes the FIRST event is the trigger when actually it's a downstream consequence: train it to look for the LAST successful operation before failure.
  • Confidence ratings get omitted: they're the most useful part of the output for the next engineer to know where to dig.

Tips

  • Feed multiple log sources together (HAR + console + app logs): the model correlates across sources well.
  • Strip PII before pasting: log excerpts often have user emails, names, tokens.
  • When logs span minutes and the failure is intermittent, look for the time markers around state changes; that's where reproduction conditions hide.
  • After running the repro recipe, file any discrepancies back into the prompt as a refinement: second pass is much sharper.

FAQ

What if my logs don't have timestamps?

The reconstruction degrades to 'order of operations' instead of timeline. Use line numbers as a proxy and explicitly note timestamps were unavailable. Push your team to add structured timestamps; it makes triage dramatically easier.

How do I correlate server logs with client logs that have different clocks?

Use request IDs (X-Request-Id, trace ID) that flow through both sides. If you don't have them, switch to logs that include them: that's a higher-priority infrastructure investment than continuing to triage without them.

When are repro steps inferred vs verified?

INFERRED whenever the step is a logical bridge not directly evidenced in logs. The 'sign in' step is usually INFERRED unless the login HTTP call is in the logs. The trigger event is often VERIFIED because logs show it directly.

Should I include this in the bug report?

Yes: include the repro recipe + the verification block. Skip the timeline (too long for ticket); link to it separately. Recipe + verification is the actionable artifact.

Use with these tools