When a coding agent should reproduce a bug first
When a user, a ticket or an error report describes something that does not work in the browser. Reproduce it first, so you know the fix targets the real problem and you finish with a check that proves the fix works.
How to reproduce a bug and prove the fix
- 1
Rewrite the bug report as the expected behavior
State what should happen, starting from the URL and ending with a check. Store the values you compare, so every run records them. Bug report: "Coupon SAVE10 does not reduce the total." Objective:
textGo to http://localhost:3000/cart, store the total as 'before', apply coupon SAVE10, store the total as 'after', then verify the stored after value is less than the stored before value - 2
Run the bug reproduction before you change any code
Use the same flags as when you verify a change, so the failing run and the run after the fix happen under the same conditions.
bashkane-cli run "Go to http://localhost:3000/cart, store the total as 'before', apply coupon SAVE10, store the total as 'after', then verify the stored after value is less than the stored before value" --agent --headless --timeout 180 - 3
Confirm the reproduction fails for the reported reason
Expect exit code
1. The failing step'sremarkand thesummaryinrun_endshould describe the same problem as the report, andfinal_stateshows the storedbeforeandaftertotals. The failing step'sfailure.yamlin the evidence pack holds the error and the page state; treat its triage as a lead, not a verdict.- If the run passes (exit
0), the bug is not reproduced yet. Ask the user for the exact steps and the account or data they used, then adjust the objective. Kane CLI drives desktop Chrome, so a bug seen only in another browser or on mobile web needs a different tool. - If it exits
2, nothing ran. Fix sign-in, configuration, Chrome or the start URL first, then run the reproduction again. - If it exits
3, the run timed out or was cancelled. Raise--timeoutor shorten the objective, then run it again.
- If the run passes (exit
- 4
Show the user the failing run's evidence pack
Every run that starts seals an evidence pack with per-step screenshots, console logs and network logs. Kane CLI prints the pack path on stderr, and the pack sits under the
evidence/folder ofrun_end.session_dir. Start the viewer in the background:bashkane-cli evidence serve <path-to-pack.evidence>It keeps serving until you stop it, from a local server on this machine that the hosted viewer reads, so nothing is uploaded. Give the user the
viewerURL it prints, share the failing step's screenshot before you change code, and stop the server when they are done. - 5
Fix the code, then rerun the reproduction unchanged
Fix the code, not the check. After each fix, run the identical command and stop when it exits
0. Then tell the user what was wrong and share the passing run'stest_url. Edit the objective only if the run failed because of how it was worded, for example it targeted the wrong element, and never remove the expected outcome to get a pass. - 6
Keep the reproduction as a regression test
Add
--name <flow>to each rerun after the fix, starting with the first one, because a finished run cannot be named afterwards. When a run exits, Kane CLI writes.testmuai/tests/<flow>_test.mdand itsoutput-<flow>/recordings. Keep the files from the run that passed, move both into the repo, commit them and run them in CI, so the bug shows up as a failing test if it comes back. See Save a verified run as a committed test and Gate a pull request in CI.
Let Kane CLI flag other product bugs during a run
Turn on bug detection during a reproduction to have Kane CLI record any other product bug it confirms along the way. --bug-detection continue records each confirmed bug in the run result and the evidence pack and keeps going. --bug-detection stop fails the step and ends the run on the first confirmed bug.
Without the flag, Kane CLI uses the value saved with kane-cli config set-bug-detection, which is off unless you changed it. A suspected bug is investigated and then rejected or confirmed. Detection covers steps that are being authored, and a replayed step that fails is always investigated. In run_end, a confirmed bug arrives as result code 740 with a verdict object: report it as a product bug, not as a test failure.
kane-cli run "Go to http://localhost:3000/cart, store the total as 'before', apply coupon SAVE10, store the total as 'after', then verify the stored after value is less than the stored before value" --agent --headless --bug-detection continueStore page values and read them from final_state
Stored values land in run_end.final_state under the names you gave them, so the reproduction above reports final_state.before and final_state.after whenever the run reaches those steps. Compare them in the failing run and again after the fix.
Inside the objective, refer to a stored value in plain English ("the stored before value"), never as {{before}}. The {{name}} form is only for your own variables and secrets.
Kane CLI docs for reproducing bugs
- Writing objectives: checks, stored values and phrasing that reproduces reliably.
- Kane CLI evidence packs: what every run captures and how to open it.
- Error codes: result codes behind a failed or refused run.
Questions about reproducing a bug with Kane CLI
Does exit code 2 mean the bug was reproduced?
No. Exit 2 means nothing ran and no credits were used: sign-in, configuration, Chrome or the start URL stopped it. Fix that, then run the reproduction again.
What should a coding agent do if the reproduction passes?
Stop before writing a fix. The bug is not reproduced, so ask the user for the exact steps and the account or data they used, then change the objective to follow their path.
How does a coding agent read a page value from a Kane CLI run?
Write store the total as 'before' in the objective and read run_end.final_state.before. See stored values.