Debug with a coding assistant using real evidence
Give the assistant reproduction steps, logs and expected versus actual behaviour, get ranked hypotheses and verify the fix with the smallest diagnostic.
By Invicly Tech, , in Prompt Engineering and Vibe Coding. About 9 minutes to read.
In short
Debugging with an assistant works when you give it facts, not feelings. Share the steps to reproduce the bug, the exact error output, and what you expected versus what happened. Ask for ranked guesses, test the top one with a tiny diagnostic, and only then change code.
Think of it like this: It is like describing a car noise to a mechanic: when it happens, how it sounds and what you already tried is far more useful than "the car is broken".
Explained simply
A bug report to an assistant should look like a bug report to a colleague. Say what you did, what you saw and what you expected. If the assistant has to guess, it will guess, and a confident wrong guess can send you down a long detour.
Start with reproduction steps: a numbered list that makes the bug appear every time. Add the exact error text and the few log lines around it. Remove secrets and personal data first. Then write one sentence for expected behaviour and one for actual behaviour.
Next, ask for ranked hypotheses, not a fix. Each hypothesis should come with a way to test it. That turns debugging into a short experiment instead of a pile of changes.
Pick the top hypothesis and add the smallest diagnostic that can prove or disprove it, such as one log line. Once you know the cause, apply the smallest fix and rerun your original steps. Add a test so the bug cannot quietly return.
Press Play on a diagram to walk through it one step at a time.
- 1Reproduce
Write numbered steps that trigger the bug every time
- 2Collect
Copy the error, logs and versions, with secrets removed
- 3Hypothesise
Ask for ranked causes and what would confirm each
- 4Diagnose
Add one log or test that separates the top two causes
- 5Fix and verify
Apply the smallest fix and rerun the reproduction
- 1Observe
Reproduce and capture the evidence
- 2Hypothesise
Ranked causes with tests
- 3Probe
One diagnostic
- 4Conclude
Keep or drop the hypothesis
- Back to step 1
In depth
Reproduction first
A fix you cannot check is only a hope. Reproduction steps give you a repeatable check before and after the change. Write them as numbered actions with the data you used, the environment, and the exact result.
If the bug is intermittent, say how often it happens and what you varied. If you cannot reproduce it, say so, and ask the assistant to help design logging that will catch it next time instead of guessing at a fix.
- Numbered steps with sample data
- Environment: OS, Node version, browser
- Result you saw, word for word
- Frequency if it is intermittent
What evidence to share and what to hide
Share the full error message, the stack trace and the code near the failing line. Share the version of the framework and the command that triggered the failure. A short log excerpt helps more than a whole file.
Strip anything private before you paste: access tokens, cookies, passwords, personal data and internal host names. Replace them with placeholders such as TOKEN_HERE or user@example.com. The assistant does not need real values to reason about the shape of the problem.
- "The page is broken"
- No error text
- No steps
- Assistant must guess
- Numbered steps
- Exact error and log lines
- Expected versus actual
- Secrets replaced by placeholders
Ranked hypotheses
Ask: "List the three most likely causes, most likely first. For each, say what evidence would confirm it and what the cheapest test is." The ranking exposes the assistant's reasoning, and you can disagree with it using facts you know.
Treat the list as a plan for experiments. Test in order of likelihood and cost. If the first test clears the top suspect, you have learned something even before you change code.
- You to Assistant: Steps, error, expected versus actual1Steps, error, expected versus actual
- Assistant to You: Three ranked causes with tests2Three ranked causes with tests
- You to App: Add one log line for cause 13Add one log line for cause 1
- App to You: Log shows the value is undefined4Log shows the value is undefined
- You to Assistant: Share the log, ask for the smallest fix5Share the log, ask for the smallest fix
Smallest diagnostic, then verify
A diagnostic is a tiny probe: one log line, one assertion or one failing test. It should separate two causes, not rewrite the code. Remove it after you have your answer, or keep it as a test.
After the fix, rerun the exact reproduction steps. Then add a regression test. For bugs that appeared between two known commits, git bisect can find the culprit by binary search. You mark a good and a bad commit and Git walks you to the first bad one.
- One probe per question
- Remove or convert it to a test
- Rerun the original steps
- Use git bisect for regressions across commits
Learn it in 5 short steps
About 35m each. Track them with a timer in your plan.
- 1Write reproduction steps~35m
- 2Share logs and the error output~35m
- 3State expected and actual behaviour~35m
- 4Ask for ranked hypotheses~35m
- 5Add one diagnostic and verify the fix~35m
Key points
- A bug you cannot reproduce cannot be verified as fixed. Write the steps first.
- Paste the real error text and the relevant log lines. Remove tokens, passwords and personal data.
- State expected and actual behaviour in one sentence each.
- Ask for hypotheses ranked by likelihood, each with a way to test it.
- Add the smallest diagnostic, then confirm the fix by rerunning the same steps.
Key terms
Tap a card to flip it. 0/5 known
Examples
A report that finds a null price
A cart page in the practice repo crashes with a TypeError. Step 1: write the steps (open /cart, add item 7, click Checkout). Step 2: paste the error and the three log lines around it. Step 3: ask for ranked hypotheses. The top one says the price is undefined for items with no discount. Step 4: add one log line printing the item. Step 5: the log confirms it, so you fix the default and add a test.
Steps: 1. Open /cart 2. Add item 7 3. Click Checkout
Expected: total shows 12.50
Actual: page crashes
Error: TypeError: Cannot read properties of undefined (reading 'toFixed')
at formatPrice (src/lib/price.ts:8:20)
Env: Node 22, Next.js 15, Chrome
Ask: give 3 ranked causes, each with the cheapest test. Do not edit code yet.Finding a regression with git bisect
The cart worked last week and fails now, with many commits between. Step 1: start bisect. Step 2: mark the current commit bad and last week's commit good. Step 3: Git checks out a middle commit; you run the reproduction and mark it good or bad. Step 4: repeat until Git names the first bad commit. Step 5: show that commit to the assistant and ask why it breaks the cart. Finish with git bisect reset.
git bisect start
git bisect bad
git bisect good <last-good-sha>
# run your reproduction, then mark the result:
git bisect good # or: git bisect bad
git bisect resetQuick reference
- Give numbered reproduction steps with sample data and the environment.
- Paste the exact error and nearby log lines. Replace secrets with placeholders.
- State expected behaviour and actual behaviour in one sentence each.
- Ask for ranked hypotheses, each with a cheap test. Do not ask for a fix yet.
- Add the smallest diagnostic that separates two causes.
- After the fix, rerun the original steps and add a regression test.
- git bisect start, bad, good SHA, then reset, finds the commit that broke it.
Common mistakes
- Pasting only "it does not work" and letting the assistant guess.
- Accepting a fix before rerunning the original reproduction steps.
- Sharing logs that contain tokens or customer data.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Rewrite "login does not work" as a report with steps, expected and actual behaviour.
- Exercise 2medium
Write the prompt that asks for ranked hypotheses, using the report above, without allowing code edits.
- Exercise 3hard
Plan a bisect session for a regression, including how you will automate the check.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Should I paste my whole log file?
- No. Paste the lines around the error and the command that triggered it. Too much text hides the useful part, and logs often hold private data.
- What if I cannot reproduce the bug?
- Say so, and ask the assistant to suggest logging that will capture the next occurrence. Do not apply a fix you cannot verify.
- Why not just ask the assistant to fix it?
- It may fix a symptom or the wrong cause. Evidence and a test confirm that the real cause is gone.
- Can the assistant run git bisect for me?
- It can suggest the commands, but you should understand and approve each one, since checkout commands change your working tree.