Skip to main content
Variables keep credentials and test data out of your objectives. You reference a reusable value or secret by name, so you can run the same test with different inputs without editing the objective text. Context files give the agent standing background information: guidance, conventions, and notes that apply to every run. This page covers how kane-cli finds and merges variables, how to mark a value as secret, and where to put context files for the agent to read.

Variables

Format

Variables are defined in JSON, as an object keyed by variable name. Each entry describes one variable:

Usage in Objectives

Reference a variable in the objective with its syntax. With the default syntax, that is {{<name>}}. Variables resolve anywhere Kane CLI types or sets a value: form fields, cookie and localStorage values, and clipboard writes.
Before the objective reaches the agent, Kane CLI rewrites {{email}} to {{global.email}} and the secret {{password}} to a secrets reference. The agent works with the resolved values when the run executes. Saved _test.md files keep the bare {{name}} form.

Loading Order

Kane CLI merges variables from four sources in this order. When two sources define the same key, the later source wins:
  1. Global directory: ~/.testmuai/kaneai/variables/*.json
  2. Local project directory: {cwd}/.testmuai/variables/*.json (relative to where you invoke kane-cli)
  3. File flag: --variables-file <path>
  4. Inline flag: --variables '<json>' (highest priority)
Within a directory, files are read in alphabetical order, and a later file wins for a duplicate key. A file that is not valid JSON is skipped with a warning.

Inline Variables

Pass a JSON object directly on the command line. Inline variables have the highest precedence.

Variables from a File

Point at a single JSON file to load all of its variables at once.
The file must be a JSON object whose values are variable entries (see Format).

Project-Local Variables

Drop one or more *.json files into .testmuai/variables/ inside your project’s working directory. They load automatically whenever you run kane-cli from that directory.
Project-local variables override global variables but are overridden by file and inline flags.

Global Variables

For values you want available across every project on your machine, place *.json files in ~/.testmuai/kaneai/variables/. These files are not the same as {{global.<name>}}, which reads a Test Manager global variable. See Runtime Namespaces.
Global variables have the lowest precedence: anything else with the same key wins.

Example Variable File

Secrets

Mark a variable as secret by setting "secret": true:
Secret values are masked in displayed output and logs, and are routed to the secrets store instead of being synced to Test Manager as plain variables. Use this for credentials, tokens, and anything else that should not appear in shareable artifacts.

Runtime Namespaces: global, environment, smart

Requires Kane CLI 0.9.0 or later.
Besides your own variables, an objective can use values that Kane CLI fills in at run time. A namespace is the prefix before the dot, such as global. or smart.. It tells Kane CLI where the value comes from: How they behave:
  • Resolved when each objective starts. The agent sees the real value, so it can type it, reason about it, and assert on it. The saved test keeps the reference, not the value, so every replay resolves it fresh. A {{smart.random_email}} is a different address on every run, and in an interactive session on every objective.
  • {{…}} only. ${global.x} is not a namespace reference. ${…} is reserved for dataset columns.
  • Two references can sit side by side. {{smart.random_int}}.{{smart.random_int}} is two values joined by a dot.
  • A value the test stored wins. If an earlier step stored a value under the same name, Kane CLI uses that value.
  • An unresolved global or environment reference stops the run before step 1, and Kane CLI shows the reason. A smart reference never stops a run. An unknown name resolves to an empty string, so check the spelling.

Smart Variables

  • Smart variables take no arguments. For a date format or offset the table does not have, describe it in the objective instead (“pick the date one week from today”).
  • Dates and times in a browser run are in UTC, not your machine’s time zone. Keep that in mind around midnight.
Examples:

Variables declared by kane-cli design tests

When a design session needs a value nobody has provided yet, such as a start URL or a test account, it references the value as {{name}} and declares it as a variable. Before it picks a name, design reads every *.json file in both variable directories and reuses a name you already have instead of inventing a new one. The agent sees only which names exist and whether each one has a value. It never sees the values themselves. For each name it declares, Kane CLI writes an empty stub (the name with a blank value) into .testmuai/variables/assurance.json. It never writes a value. Kane CLI tells you about new stubs during the round (⚒ declared 2 new variables — login_email · login_password (values needed)) and again at the end (2 variable(s) need values — see .testmuai/variables/assurance.json):
Fill in value. Kane CLI never overwrites a key that already exists in any of your variable files, so a stub cannot replace a value you set. A value you type in chat stays in the step as literal text. Design creates a variable only when the value is unknown.

Before a run: unresolved variables

kane-cli run, kane-cli testmd run, and kane-cli testrun run check every {{name}} that an authored step references before the run starts. A name with no value produces a warning, not an error. The run goes ahead and types the name as written, unless an earlier step sets it:
How to read the warning:
  • Grouping. The warning groups names by the variables file they belong in (the pool file, such as .testmuai/variables/assurance.json) and names that file once per group.
  • Test filenames. A test filename appears only when it differs from the file you ran. An @imported unit and a testrun member both show their own filename. A kane-cli run objective shows no location.
  • Names in no file. If the pool file exists, the warning says Add it to <file>. If there is no pool file yet, it shows the JSON to create.
The check skips these references:
  • An explicit {{global.*}}. It resolves from Test Manager when the run executes. Only a bare {{name}} is looked up in your variables files.
  • {{smart.*}}, {{environment.*}}, {{secrets.*}}, and {{totp.*}}, which resolve when the run executes.
  • A name that an earlier step stores (store the price as 'price').
  • A name that the test’s own frontmatter variables: declares, even with an empty value.
  • Replayed steps, which resolve from their recording (tape) and from Test Manager. A testrun run preflight still lists a replayed step’s names, because it checks the file before it knows which steps replay.
${x} is a dataset column reference, not a variables-file reference. If ${x} is not a column of the dataset row the run received, it gets its own warning. In agent mode, the same content arrives as one warning event with code: "unresolved_variables". See Modes of Operation.
Do not commit credential files to version control. Add .testmuai/variables/ to your .gitignore, or use environment variable substitution in CI/CD.

Context Files

Context files are plain Markdown files whose contents are passed to the agent alongside your objective. Use them for standing instructions: coding conventions, accounts to use, sites to avoid, or domain knowledge the agent should always have.

Two Levels

Global context (default path ~/.testmuai/kaneai/global-memory.md): put guidance that applies to every project and your whole account here. Kane CLI loads it for every run unless you override it. Local context (default path .testmuai/context.md in the current working directory): put guidance here that only makes sense for the project you are testing. Kane CLI loads it automatically when you run kane-cli from a directory that contains it.

Example Local Context File

Override Per Run

Use the run flags to point at a different file for a single invocation:
If a context file is missing or empty, Kane CLI ignores it without raising an error.

What to Put in Context

Global context:
  • Company terminology and naming conventions
  • Standard test account references (no hardcoded values)
  • Performance expectations (e.g., “page loads in under 3 seconds”)
  • Universal navigation patterns
Local context:
  • App overview and purpose
  • Test environment URL and known limitations
  • Navigation patterns specific to this app
  • Known UI quirks and workarounds
  • Common test flows
  • Test data references (IDs, emails: no passwords)
Keep out of context:
  • Hardcoded secrets (use variables)
  • Large code blocks or logs
  • Information that changes frequently