Skip to main content
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:
Kane CLI generates scenarios and cases and prints them. The output ends with a request id and the exact commands to refine or save the result:
Keep the request id. Every later command uses it. To get a smaller or larger set, set limits on its size:
Add --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:
You can attach up to 10 files, each 50 MB or smaller: documents, images, audio, or video. Kane CLI validates all paths before it sends anything. See Attaching files for context.

2. Refine

You refine a set by describing changes in plain language. Each refine is a separate command with --refine --req <id>:
Each refine returns the updated result. Repeat until the set looks right.

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 exits 0. To answer, run a refine with your answer:
If a script or agent drives the loop, add --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:
By default this writes under <cwd>/.testmuai/tests:
Choose a different location with --out, and name the suite with --name:
Only functional cases are written. Non-functional cases (Security, Performance, and so on) appear in the generated result but are not saved as runnable tests. See Saving is functional-only.

4. Run

The saved files are ordinary _test.md tests. Run any of them with testmd:
Everything in the testmd docs applies from here: replay from cache, edit steps, compose tests with @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:
Each command prints one JSON object per line. The last line is the final event, with the request id, the status, and the refine and save commands to run next.

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