How to Prepare a Bug Report That an AI Coding Assistant Can Act On
Summary
- A good AI-ready bug report is a reproducible script: environment + exact steps + expected vs actual + evidence.
- Write for deterministic replay: concrete inputs, stable test data, and clear “start state” assumptions.
- Include minimal artifacts an assistant can use immediately: logs, stack traces, screenshots, and small code snippets.
- Provide a “suspected area” and constraints (what you already tried, what must not change) to avoid wasted iterations.
- Use a fixed template and a short review checklist so every report is actionable, not just descriptive.
AI coding assistants can help diagnose and fix bugs faster, but only when the bug report contains enough precise, replayable information. If your report reads like a story (“it sometimes breaks”), the assistant has to guess. If it reads like a script (“run this, click that, see this error”), the assistant can propose a targeted fix, write a test, or suggest instrumentation.
This guide shows how to prepare a bug report an AI coding assistant can act on: what to capture, how to structure it, example inputs (clearly labeled as invented), a ready-to-copy output template, and review checks before you send it.
What “actionable” means for an AI coding assistant
An AI assistant can act on a bug report when it can do at least one of these without guessing:
- Reproduce the issue from steps and inputs (or understand why reproduction is blocked).
- Localize the likely component, function, endpoint, or commit range involved.
- Validate a fix by proposing a test, assertion, or verification steps.
- Constrain the solution to your requirements (no breaking changes, performance limits, compatibility).
That means your report needs: a defined start state, deterministic steps, concrete inputs, and evidence (errors/logs) tied to time and context.
The core deliverable: a bug report the assistant can replay
Think of your bug report as a “replay packet” with five layers. Each layer answers a question the assistant will otherwise ask you later.
Layer 1: One-sentence problem statement
Goal: Make the bug identifiable in one line.
- Good: “Saving a draft returns 200 but the UI shows ‘Failed to save’ and the draft is missing after refresh.”
- Weak: “Saving is broken.”
Layer 2: Environment and scope
Goal: Pin down where the bug happens and where it does not.
- App version / commit SHA / build number
- Runtime: OS, browser, Node/Python version, device model
- Deployment: local/dev/staging/prod
- Feature flags, config toggles, tenant/account type
- Frequency: always / intermittent (with rough conditions)
If you cannot share some details (for privacy or policy), say what you can share and what is redacted. The assistant can still propose next steps if it knows the constraints.
Layer 3: Reproduction steps with a defined start state
Goal: Provide a deterministic script.
Include:
- Start state (logged in as X, database seeded with Y, cache cleared, feature flag on/off)
- Exact steps numbered, one action per step
- Concrete inputs (the exact text you typed, the exact API payload, the exact file used)
- Observed result at the end (and any intermediate unexpected behavior)
If the bug is intermittent, add a “reproduction hints” subsection: timing, load, specific accounts, or sequences that increase the chance of triggering it.
Layer 4: Expected vs actual behavior
Goal: Define correctness so the assistant can propose a fix and a test.
- Expected: What should happen, including UI state, API response, persisted data, and side effects.
- Actual: What happened instead, including error messages and mismatched state.
Layer 5: Evidence artifacts (minimal but sufficient)
Goal: Give the assistant raw material to reason from.
- Error output: stack trace, exception type, message, error code
- Logs: relevant lines with timestamps and correlation/request IDs
- Network traces: request URL, method, status, response body (redact secrets)
- Screenshots/screen recordings: when UI state matters
- Small code snippets: the function, component, or config involved (avoid dumping the whole repo)
When you paste logs or traces, include a short note: “These lines correspond to step 6 at 14:32:10 UTC.” That mapping is what makes the evidence usable.
Show how source material becomes the deliverable (with invented examples)
In practice, you start with messy “source material” (what you saw, what you clicked, what the console printed) and convert it into a structured report. Below is a concrete transformation with invented examples.
Example source material (invented)
- “Sometimes the Save button spins forever.”
- Browser console:
TypeError: Cannot read properties of undefined (reading 'id') - Network tab:
POST /api/draftsreturns200with JSON body{"ok":true} - After refresh, the draft is not in the list.
- Only happens for one user account that has many drafts.
Converted into an AI-actionable bug report (invented output)
Title: Draft save returns 200 but draft is not persisted; UI shows failure after spinner
Problem statement: In the web app, saving a draft returns HTTP 200, but the UI shows “Failed to save” and the draft is missing after refresh.
Environment:
- App build: (invented) web-1.18.3, commit
7c1a9f2 - Browser/OS: Chrome 126 on Windows 11
- Deployment: staging
- Account: user
u_48392(high draft count)
Start state:
- Logged in as
u_48392 - Navigate to Drafts page
- Open DevTools (Console + Network)
Steps to reproduce:
- Click “New draft”.
- In the editor, paste: (invented) “Bug repro draft 2026-10-17 14:32”.
- Click “Save”.
- Observe spinner for ~8–12 seconds.
- Observe toast: “Failed to save”.
- Hard refresh the page.
- Search drafts list for “Bug repro draft 2026-10-17 14:32”.
Expected:
- Save completes within a few seconds.
- Toast indicates success.
- Draft appears in list after refresh.
- API returns 200 and draft ID is persisted.
Actual:
- Toast indicates failure after spinner.
- Draft is missing after refresh.
- Network shows
POST /api/draftsreturns 200 with{"ok":true}. - Console error appears at the time of the toast.
Evidence:
- Console (timestamp invented 14:32:10):
TypeError: Cannot read properties of undefined (reading 'id') at saveDraftSuccessHandler (DraftEditor.tsx:214) - Network:
POST /api/draftsstatus 200, response{"ok":true}, no draft ID returned. - Observation: issue reproduces on account
u_48392; not reproduced onu_10211after 5 attempts.
Suspected area: Frontend success handler expects response.draft.id, but API returns only {"ok":true}. Alternatively, backend is returning success without persisting for high draft counts.
Constraints:
- Do not change the editor autosave behavior in this fix.
- Any API change must remain backward compatible for mobile client.
What I tried:
- Cleared cache and cookies; still reproduces.
- Reproduced in Incognito; still reproduces.
Suggested next checks (for the assistant):
- Confirm API contract for
POST /api/drafts: should it return a draft object or at least an ID? - Add a test for frontend handler when response lacks
draft. - Check backend logs for request ID from the failing save attempt.
A copy-paste template you can use (AI-ready structure)
Use this template as your standard output structure. Keep it short, but complete.
Bug Report Template
- Title: [Component] [Action] [Wrong outcome] (include error code/message if known)
- One-sentence summary: What breaks, where, and under what condition?
- Environment: app version/commit, OS, runtime, browser/device, deployment, flags/config
- Start state: logged in as…, dataset seeded…, cache state…, feature flags…
- Steps to reproduce:
- …
- …
- Expected result: (include UI + API + persisted state if relevant)
- Actual result: (include exact message, status codes, wrong state)
- Evidence: stack trace, logs (timestamps), request/response (redacted), screenshots
- Scope notes: frequency, does it happen for all users or specific accounts?
- Suspected area (optional): file/module, endpoint, recent change, hypothesis
- Constraints (optional): must not change…, must support…, performance limits…
- What I tried (optional): steps already taken to debug
What to include for different bug types (so the assistant can propose a fix)
Backend/API bugs
- Endpoint, method, headers (redact secrets), payload, status code, response body
- Correlation/request ID and timestamps
- Expected contract (what fields should exist)
- Whether the bug is data-dependent (specific IDs, edge-case payload)
Frontend/UI bugs
- Browser + device + viewport size (if layout-related)
- Console errors and stack traces
- Exact UI path (page, modal, tab), and whether it requires a specific account state
- Screen recording when timing matters (spinners, race conditions)
Performance bugs
- What is slow (API latency, render time, startup), and what “slow” means (e.g., “takes ~12s”)
- Conditions: dataset size, network conditions, cold vs warm cache
- One measurement artifact: timing logs, profiler screenshot, or request waterfall
Intermittent or race-condition bugs
- Reproduction rate (e.g., “~1 in 5 attempts”) and any patterns you noticed
- Timing details: “click Save twice quickly”, “switch tabs during upload”
- Whether retries change the outcome
- Any background jobs, websockets, or polling involved (if known)
Redaction and safety: share enough without leaking secrets
AI assistants work best with real artifacts, but you should remove sensitive data:
- Replace tokens, passwords, API keys with placeholders like
REDACTED_TOKEN. - Mask personal data (emails, phone numbers, addresses) unless you have permission to share it.
- If logs contain secrets, paste only the relevant lines and redact values.
- When redacting, keep structure intact (field names, shapes, and error codes still matter).
Review checks before you send the report (fast, deterministic)
- Replay check: Could someone follow your steps without asking “which page?” or “what did you type?”
- Start-state check: Did you specify login/account state, flags, seed data, cache state?
- Evidence check: Did you include at least one raw artifact (trace/log/stack) tied to the moment it failed?
- Expected/actual check: Are you defining correctness in a way that can be tested?
- Constraint check: Did you note what must not change (compatibility, behavior, performance)?
- Minimality check: Did you avoid dumping unrelated logs or huge code blocks?
Frequently Asked Questions
FAQ 1: What is the minimum information an AI coding assistant needs to fix a bug?
Answer: Provide (1) environment/version, (2) a defined start state, (3) numbered reproduction steps with exact inputs, (4) expected vs actual results, and (5) at least one artifact (stack trace, log lines with timestamps, or a request/response). Without those, the assistant has to guess what to reproduce and what “fixed” means.
Takeaway: Minimum viable bug report = replayable steps + correctness definition + evidence.
FAQ 2: How do I write reproduction steps that are deterministic instead of “it sometimes happens”?
Answer: Add a start state (account, flags, cache), use one action per numbered step, and include the exact inputs (text pasted, payload JSON, file used). If it is intermittent, include conditions that increase the hit rate (timing, dataset size, specific account state) and the approximate reproduction rate.
Takeaway: Determinism comes from start state + exact inputs + precise sequencing.
FAQ 3: What evidence should I paste: logs, stack traces, network requests, or screenshots?
Answer: Choose the artifact that directly captures the failure mode: stack traces for exceptions, network request/response for API mismatches, logs for backend processing and correlation IDs, and screenshots/recordings for UI state or timing issues. If you can include two, pair “what the user saw” (UI) with “what the system did” (trace/log).
Takeaway: Include the evidence that proves the failure, not just describes it.
FAQ 4: How should I report an intermittent bug so the assistant can still help?
Answer: Report the reproduction rate, the conditions that correlate with failures (specific accounts, large datasets, slow network, rapid clicks), and what changes the outcome (retry works/does not work). Include timestamps and any request IDs from a failing attempt so the assistant can propose targeted instrumentation or a hypothesis-driven fix.
Takeaway: For intermittent bugs, patterns and identifiers matter as much as steps.
FAQ 5: How do I describe expected behavior when the spec is unclear?
Answer: State the expectation as a decision question and list acceptable outcomes. For example: “Should Save return a draft ID and update the list immediately, or is eventual consistency acceptable?” Then describe what users need (data not lost, clear status) and what would be considered correct for this release. This gives the assistant a target for tests and implementation choices.
Takeaway: When the spec is unclear, define the decision and acceptable behaviors.
FAQ 6: How much code should I include in the bug report?
Answer: Include the smallest snippet that shows the failing call site, the relevant data shape, or the suspicious logic (plus file name and line numbers if available). Avoid pasting entire files unless the assistant cannot understand the context otherwise. If the bug is contract-related, include the interface/type definition and one real example payload (redacted).
Takeaway: Small, relevant snippets beat large dumps.
FAQ 7: How do I redact sensitive data without making the report useless?
Answer: Replace secret values with placeholders while keeping field names and structure intact (for example, keep JSON keys and data types). Preserve lengths or formats when relevant (e.g., “JWT_REDACTED”, “EMAIL_REDACTED”). If a specific record triggers the bug, describe its characteristics (size, flags, relationships) rather than the raw personal data.
Takeaway: Redact values, preserve structure.
FAQ 8: Should I include a suspected cause, or will that bias the assistant?
Answer: Include a suspected cause as an optional hypothesis, clearly labeled, and keep it separate from the facts (steps, expected/actual, evidence). A good pattern is: “Suspected area: X. Reason: Y.” This can speed up localization, while the assistant can still validate against the artifacts you provided.
Takeaway: Share hypotheses, but keep them distinct from verified observations.
