Reproduce a Bug
Purpose
Establish a reproduction that fails every time (or at a known rate) with the fewest steps and variables. Without it, fixes are guesses and verification is impossible; with it, the fix can be proven and protected by a regression test.
When to use
- A bug report lacks steps, or the developer cannot trigger the defect.
- The defect is intermittent or appears only in some environments, tenants or devices.
- Before fixing, to capture the defect as a failing test.
When not to use
- The reproduction is known and you need to find the cause. Use
debugging-hypothesesorstack-trace-analysis. - Writing the defect ticket for tracking. Use
bug-report. - The failure is in a test that passes and fails without code changes. Use
flaky-test-analysis.
Inputs
Required:
- The bug description: what was observed and where.
Optional, improves quality:
- Environment and version, time of occurrence, affected users or tenants, device/browser.
- Logs, error IDs, correlation/trace IDs, screenshots.
- Recent changes (deployments, config, data migrations, feature flags).
If you do not know which system or feature is affected, ask. Mask personal data in any logs or sample records shared.
Process
- Restate the defect as expected vs actual behavior in one sentence each; separate observations from the reporter's interpretation.
- Inventory the variables that could matter: version/build, environment, config and feature flags, data shape and volume, user role/permissions, locale/time zone/clock, concurrency and timing, network conditions, client device/browser.
- Compare a failing case with a working case and list the differences, including recent changes (commits, config, data, dependencies) between the last known good and first bad occurrence; each difference is a candidate variable.
- Draft the first reproduction as close to the reported conditions as possible (same version, similar data, same role). Record whether it fails and how often (e.g., 3/20 runs).
- Minimize: remove or fix one variable at a time and re-run; keep a variable only if removing it makes the failure disappear. Use bisection over data sets, commits or config when the space is large.
- For intermittent defects, force the suspected condition: fixed seed, frozen clock, injected latency, reduced pool sizes, parallel execution, larger data volume. Report the reproduction rate before and after.
- When the reproduction is stable, express it at the lowest level possible: unit or integration test first, then API call sequence, then UI steps.
- Document preconditions and test data explicitly, using synthetic or masked data.
- If you cannot reproduce, document what was tried, the variables ruled out, and the exact additional evidence needed (log fields, trace, dump, customer data sample).
- Hand over: with a stable reproduction, suggest
debugging-hypothesesto find the root cause (no fix before it is confirmed) andunit-test-writingto keep the failing test; if the report itself is incomplete, suggestbug-report.
Output format
# Reproduction: <defect title>
**Status:** Reproduced (<n>/<m> runs) | Not reproduced yet
**Expected:** ...
**Actual:** ...
## Environment
| Item | Value |
|---|---|
| Version / build | ... |
| Environment | ... |
| Config / flags | ... |
| Client | ... |
## Preconditions and Test Data
- ...
## Minimal Steps
1. ...
## Variables Ruled Out
- <variable> — <how tested>
## Automated Reproduction
<failing test name and outline, or TBD>
## If Not Reproduced: Evidence Needed
- ...
Quality checklist
- Expected and actual results are stated separately and precisely.
- Every step and precondition is needed; removing any makes the failure disappear.
- Reproduction rate is stated for non-deterministic failures.
- Test data is synthetic or masked.
- A failing automated test is proposed or its absence explained.
- Unverified environment details are marked
[UNKNOWN]. - All checks pass; if any fails, revise the output and re-run this checklist before answering.
Common pitfalls
- Reproducing on the latest code instead of the reported version, then declaring "cannot reproduce". Pin the version first.
- Changing several variables at once during minimization. You lose the ability to say which one matters.
- Starting a fix before the reproduction is reliable ("quick fix for now"). Without a stable reproduction you cannot prove the fix works.
- Ignoring time: time zones, DST transitions, month ends and cache expiry produce "random" bugs that are fully deterministic.
Example
Input: "Export sometimes produces an empty CSV file."
Excerpt of output:
- Variables: file size, concurrent exports by the same user, storage latency, time of day.
- Minimization: fails 0/20 with a single export; 6/20 when two exports run for the same user within 1 s.
- Minimal steps: 1) Log in as a user with >1,000 orders. 2) Start two exports in parallel. 3) Download the first file: 0 bytes.
- Next: hypothesis that both jobs share a temp file name keyed by user ID — hand over to
debugging-hypotheses.