// How-to for coding agents

How a coding agent reproduces a bug report with Kane CLI

Short answer

Write what the bug report says should happen as a kane-cli run objective that ends in a check, run it with --agent before you touch the code, and confirm it fails with exit code 1 for the reported reason.

Fix the code and run the identical command again. The failing run shows the bug was real, and a passing run shows the fix works.

For Claude Code, Codex CLI, Gemini CLI, Cursor and GitHub Copilot · Checked against kane-cli 0.9.0 · Updated

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. 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:

    text
    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
  2. 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.

    bash
    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 --timeout 180
  3. 3

    Confirm the reproduction fails for the reported reason

    Expect exit code 1. The failing step's remark and the summary in run_end should describe the same problem as the report, and final_state shows the stored before and after totals. The failing step's failure.yaml in 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 --timeout or shorten the objective, then run it again.
  4. 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 of run_end.session_dir. Start the viewer in the background:

    bash
    kane-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 viewer URL it prints, share the failing step's screenshot before you change code, and stop the server when they are done.

  5. 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's test_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. 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.md and its output-<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.

bash
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 continue

Store 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

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.

Install Kane CLI to reproduce your next bug report

Sign in once, then add the Kane CLI skill to your agent or commit the AGENTS.md file to your repo. Each new bug report can then start as a failing run and end as a passing one.

Start free