> ## Documentation Index
> Fetch the complete documentation index at: https://www.testmuai.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Design Kane CLI Tests from Use-Cases

> Turn one use-case into acceptance criteria, scenarios, and one runnable test per scenario with kane-cli design tests: reviewed, cited, and linked.

`kane-cli design tests` takes **one committed use-case** and produces everything needed to prove it: acceptance criteria (ACs), scenarios, and exactly one runnable test per scenario. It works as a conversation, on the same chat surface that [`kane-cli context extract`](https://www.testmuai.com/docs/kane-cli-assurance-context#extract) uses. Everything the engine produces starts as **derived** knowledge for you to review. Your approval promotes it, and nothing becomes trusted without that approval.

```bash theme={null}
kane-cli design tests --use-case uc-manage-the-cart      # design one use-case (chat)
kane-cli design explain t-add-first-item                 # replay WHY — zero fresh AI
```

`<ref>` is a short logical id (`uc-manage-the-cart`, `t-login-smoke`) or a full cid (content id).

## Flags

| Flag | Meaning |
| - | - |
| `--use-case <ref>` | The use-case to design. Optional with `--resume`, because the session remembers it |
| `--max <n>` | Budget ceiling: the maximum number of scenario and test pairs to keep. **With no value there is no ceiling**: the agent estimates the right size and asks you to confirm. Every pair cut to fit the budget is recorded as a named `budget-evicted` gap |
| `--strength pairwise\|3-wise` | Sets the covering-array strength manually. When omitted, the agent judges it from risk, and uses 3-wise when money, authentication, or data loss is involved |
| `--mode <mode>` | How a headless run handles questions: `agent` \| `ci` \| `override`. A non-TTY run with no `--mode` exits `2`. See [Automation](https://www.testmuai.com/docs/kane-cli-assurance-automation.md) |
| `--force` | Redesign a use-case that already has a live design. The new scenario and test pairs supersede the old ones, and equivalent ACs are reused |
| `--phase <name>` | Start the design at a specific phase (`grounding`, `acs`, `scenarios`, `wiring`, `tests`), rebuilt from the earlier phases already committed. If an earlier phase is missing, you are asked on a terminal; in agent mode the run exits `2` and lists the commands to run in `next` |
| `--allow-unreviewed` | Design against a use-case that is still unreviewed (`derived`) without approving it first. See the gate below |
| `--resume <sid>` | Resume a paused session ([sessions](https://www.testmuai.com/docs/kane-cli-assurance-context.md#sessions)) |
| `--message "<text>"` | With `--resume`: answer the pending questions, or steer, in plain words |
| `--answer <q>=<v>` | With `--resume --mode agent`: answer a specific pending question by id, as `<question-id>=<option number or free text>`. Repeatable |
| `--plan` | Print what each phase would commit (the finalize payload) and commit nothing |

## The session: five phases

An interactive run is a chat. The engine works through the phases in order and pauses after each one for your approval. You steer it in plain words.

0. **Grounding.** The engine reads the use-case and its cited criteria, follows the citations into the actual source text, and checks what already exists that it can reuse.
1. **Invariant ACs.** These are promises that hold on every path, each with a complete oracle (an expected result a machine can check). If the source never states the expected result for a promise, the engine records a `missing-expected-result` gap with a recommended default instead of inventing an answer.
2. **Scenarios.** The engine expands the use-case into paths using test-design techniques: happy, negative, boundary, and edge paths, plus security, accessibility, performance, and i18n paths where the use-case calls for them. Existing scenarios are linked, never duplicated, and preconditions become dependencies.
3. **Path ACs and wiring.** The engine writes criteria for each scenario and records which scenario exercises which invariant. An invariant that no scenario exercises becomes an `invariant-unexercised` gap.
4. **Tests.** The engine writes exactly **one test per scenario** (strict 1:1). Pairs are scored and cut to fit the budget. Each kept test has a runnable body, a step that captures a baseline when a check needs a before and after comparison, and a written check whose expected value comes from its AC. A check that disagrees with its criterion is rejected, so a test cannot quietly assert something weaker than the requirement.

Between phases the session pauses on a **check-in panel**, the same kind of panel [extract uses](https://www.testmuai.com/docs/kane-cli-assurance-context.md#the-interactive-session). The headline reads `<phase> done — next: <next>`. A dim line under it explains in plain words what the finished phase produced. The rows are:

* `continue to <next>` (row 1). Pressing Enter at every check-in walks through the whole design.
* `view what's saved`
* `finish here`
* `✎ adjust — tell me what to change`

Typing anywhere opens the `✎` editor, and your words steer the engine (rename, drop, redirect) before the next phase.

**Questions that need a typed value.** When an answer has to be a concrete value, such as a URL or a fixture id, the question does one of two things. It either offers an option row that takes input, where selecting the row opens an inline editor so the answer carries both the pick and your value, or it tells you to type the value directly. A plain option row sends only its label, so the plain options on such a question are the real alternatives (use a placeholder, reduce scope, skip). If a needed value does not arrive, the agent asks once more and then continues with the fallback it stated. It announces this in the narrative; it never happens silently.

In headless runs, each phase reports its progress. Any question pauses an `agent`-mode run, which you can resume. A high-risk question stops a `ci`-mode run with a failure. Each phase still commits and reports on the event stream as it completes. See [Automation](https://www.testmuai.com/docs/kane-cli-assurance-automation.md).

## What you get

A design run commits to the graph **and writes files**. Each kept test is written as a normal, runnable `*_test.md` file under `<cwd>/.testmuai/tests/`:

```markdown theme={null}
---
assurance:
  id: t-add-one-in-stock-product-and-verify-minimum-valid-cart
  base: sha256:00f8…
---
# Add one in-stock product and verify minimum valid cart pricing

> Prove the customer can create the minimum valid cart and see a line total and subtotal.

## Step 1

Open {{store_url}} in a fresh browser session and navigate to the product listing…

## Step 4 — assert @verifies ac-a-valid-cart-contains-at-least-1-item, ac-the-cart-displays-an-order-subtotal

Confirm count check: 1 (equals) — the stated promise: after adding one in-stock product, the cart contains exactly 1 item.
```

Three things to notice:

* **`@verifies` tags** bind each assert step to the acceptance criteria it proves. [`kane-cli cover`](https://www.testmuai.com/docs/kane-cli-assurance-coverage) measures coverage against this link. It is captured when the test is written, and it is permanent and auditable.
* **`{{variables}}`** appear wherever the requirements did not specify a value, such as the store URL or a known in-stock product. See [Variables declared by design](#variables) below.
* **The `assurance:` frontmatter** links the file to its design entry in the graph, so coverage lookups stay exact even after you move the file.

### Variables declared by design

Before naming a variable, design reads every `*.json` file in your variable directories and reuses a name you already have. Each name it has to create is **declared**: an empty stub is added to `.testmuai/variables/assurance.json`. Design never writes a value, and never overwrites a key that already exists anywhere.

You are told about new variables twice:

* As the phase commits: `⚒ declared 2 new variables — store_url · in_stock_product (values needed)`.
* At the end of the run: `2 variable(s) need values — see .testmuai/variables/assurance.json`.

On the `--mode agent` stream, these two moments are separate events:

* `variables_declared` lists the stubs a phase commit wrote: `file`, plus `variables[]` with `name`, `description` and `secret`. It fires in the tests phase, just before that phase's `commit` event.
* `variables_summary` lists every name the run declared. It is sent after `session_complete` when a run completes cleanly; a paused run does not send it.

See [Automation](https://www.testmuai.com/docs/kane-cli-assurance-automation.md) for the stream.

Fill in the values before you author the tests. If a name has no value, the run warns you and types the name as written. An agent fills in the values it already has from your documents or your messages and asks you for the rest. A secret value goes straight into the file, never through the chat. See [Variables & context](https://www.testmuai.com/docs/kane-cli-variables-and-context.md#variables-declared-by-kane-cli-design-tests).

### What else the run records

Alongside the tests, the run records:

* the ACs and scenarios themselves, and the wiring between them;
* **gap nodes**, with full context, for everything it could not resolve;
* a rationale file per test (under `.context/design/rationale/`) that `design explain` replays.

You also see **warnings** at commit time, for example when a test's `@verifies` list claims more criteria than its written check actually asserts.

Design output starts as `derived`, like everything else. Review it with [`kane-cli context review`](https://www.testmuai.com/docs/kane-cli-assurance-context#review), or browse it with [`kane-cli context view`](https://www.testmuai.com/docs/kane-cli-assurance-context#inspect).

### From design to execution

A designed test is a normal test file, but it is still `derived` and it has never been *run*. Work through it in this order:

1. **Review the design output** like anything else the engine produces. Approve, edit, or reject the generated ACs, scenarios, and tests with [`kane-cli context review`](https://www.testmuai.com/docs/kane-cli-assurance-context#review). The commit-time warnings appear again there.
2. **Author each kept test once.** After that it runs in batches like any other test.

```bash theme={null}
kane-cli testmd run .testmuai/tests/t-add-one-…_test.md   # author it (first run, agent works it out)
kane-cli testrun run --match 't-'                          # from then on: batch replay
```

[`kane-cli testrun`](https://www.testmuai.com/docs/kane-cli-testrun) can also author fresh tests itself: they are classified as `author` at preflight and consolidated after the run. `kane-cli testmd run` is the way to author a single test. See [Coverage](https://www.testmuai.com/docs/kane-cli-assurance-coverage.md#the-authoring-bridge).

Until a test's first authored run, [`kane-cli cover`](https://www.testmuai.com/docs/kane-cli-assurance-coverage) reports its criteria as covered on paper but not yet proven. This is intentional.

## Gates, re-runs, and `--force`

**Designing against an unreviewed use-case.** If the use-case is still unreviewed (`derived`), the run stops so you can decide explicitly:

* On a terminal, you see what this means and choose.
* In agent mode, the run exits `2` with the review command to run in `next`.
* In `ci` mode, the run refuses outright.

`--allow-unreviewed` skips this gate on purpose. The recommended path is to review the use-case first with [`context review`](https://www.testmuai.com/docs/kane-cli-assurance-context#review).

**Re-runs check whether the design is stale.** If a use-case already has a live design, design does not silently redesign it. It asks you what to do:

* On a terminal, the session tells you whether the design is current or stale and what a redesign would supersede. You can view the design, redesign it, refresh a stale design first with [`maintain evolve`](https://www.testmuai.com/docs/kane-cli-assurance-maintain#evolve), or pick another use-case. A redesign asks for your **reason**, which goes on the record.
* In agent mode, the run exits `2` with the follow-up commands in `next`, including the `--force` form.
* In `ci` mode, the run fails without redesigning.

`design tests` has no `--because` flag. A headless `--force` run proceeds and records a reason automatically.

`--force` regenerates the scenario and test pairs and supersedes the old ones. ACs are deduplicated first: if the engine produces an AC equivalent to an existing one, it reuses the existing node instead of adding a copy.

* If the staleness comes from a source document you just changed, [`kane-cli maintain reconcile`](https://www.testmuai.com/docs/kane-cli-assurance-maintain) offers the same redesign as part of reviewing the changed source.
* For staleness from older changes, [`kane-cli maintain evolve`](https://www.testmuai.com/docs/kane-cli-assurance-maintain#evolve) redesigns the use-case and tells you first what the redesign will affect.

**Citations are verified before they commit.** Every citation a design run wants to record is checked against the pinned source text before anything lands. A citation that does not match is sent back to the agent to fix, so designed items never carry made-up provenance.

## `design explain`: replay the why

```bash theme={null}
kane-cli design explain <ref>
```

Replays the rationale recorded at design time, without ever calling a model:

* For a **test**: the technique that produced it, the boundary values considered, the covering-array strength and why it was chosen, the criteria it verifies, and the scenario it automates.
* For a **scenario, AC, or gap**: its content plus every recorded judgement and review verdict.

If you ask "why does this test exist?" six months later, you get the answer recorded at design time, not a reconstruction.

## Extending the technique catalog

The design engine includes a built-in catalog of test-design techniques and surface profiles. To extend it for one store, add YAML files under `.context/design/`. An entry with an existing id replaces the built-in one, and a new id adds an entry. No upgrade is needed.

## Exit codes

| Code | Meaning |
| - | - |
| `0` | Design complete (or `--plan` output complete). |
| `1` | Runtime failure. |
| `2` | Usage error or refusal: an unknown use-case; an already-designed or unreviewed target refused in a headless mode (the stream's `next` carries the follow-up commands); a `--phase` whose earlier phases are missing; or a non-TTY run with no `--mode`. |
| `3` | Session paused and resumable. See [sessions](https://www.testmuai.com/docs/kane-cli-assurance-context.md#sessions). |

## Next steps

* [Coverage](https://www.testmuai.com/docs/kane-cli-assurance-coverage.md): measure what the designed tests prove.
* [Maintaining the suite](https://www.testmuai.com/docs/kane-cli-assurance-maintain.md): reconcile the suite when requirements change.
* [Automation](https://www.testmuai.com/docs/kane-cli-assurance-automation.md): run design headless in CI or from an agent.

## Terminal First Testing With Kane CLI

Natural language browser & mobile app tests right from terminal.

Book a Demo

![Kane CLI terminal](https://assets.testmu.ai/resources/images/Terminal-KaneCLI.png)

×

Schedule Your Personal Demo

<form>
  Select Product

  Schedule Demo
</form>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.