kane-cli generate follows a simple loop: generate → refine → save → run. Each command is one turn that exits when it finishes, and the request id links the turns together. This page walks through the whole loop. For an overview of the feature and the option reference, see Generating test cases with AI.
1. Generate
Start with a plain-language description of what you want covered:--memory to reuse relevant existing cases and avoid duplicating coverage you already have.
To give the generator more context, attach local files such as a spec, a screenshot, a PDF, or a CSV with --files. This works on a new generation or a refine:
2. Refine
You refine a set by describing changes in plain language. Each refine is a separate command with--refine --req <id>:
When generation asks a question
Sometimes a turn ends with a question instead of a result, for example “Which environment should these target, staging or production?” This is a normal outcome, not a failure, and the command exits0. To answer, run a refine with your answer:
--agent, which also turns on automatically when stdin is not a TTY. Read the signal that an answer is needed from the NDJSON output, then answer with a refine in the same way.
3. Save
When the set looks right, save it.--save writes the functional cases as _test.md files:
<cwd>/.testmuai/tests:
--out, and name the suite with --name:
4. Run
The saved files are ordinary_test.md tests. Run any of them with testmd:
@import, and commit the output to git.
Automating it (agents / CI)
Pass--agent to get structured NDJSON on stdout instead of the human-readable display, so a script or coding agent can drive the loop. The flag turns on automatically when stdin is not a TTY:
Exit codes
An invalid flag combination exits
2 with a message that explains the fix. Examples: --refine without --req, a description with --save, --out without --save, or --req without --refine or --save.
Next steps
- Generating test cases with AI: overview, modes, and the full option reference.
- Running tests with testmd: run and replay the files
--saveproduces.