Reference
tea-trace CLI
tea-trace CLI
Section titled “tea-trace CLI”tea-trace runs the Trace skill against existing requirements and tests.
It writes a traceability matrix, coverage summary, and gate decision when the run is gate-eligible.
Before the agent starts, the CLI freezes the target criteria and priorities from the source document.
It checks the saved oracle ledger, matrix, coverage arithmetic, decision, and live evidence before publishing reports.
Each attempt retains its prompt, agent output, and generated files.
Needs Node.js 22.20.0+. A live run also needs an agent CLI you already use: Claude Code (--agent claude), Codex (--agent codex), Antigravity (--agent agy), or any other runner through --agent custom with --agent-cmd. It uses that CLI’s existing session, so there is no separate login step. --agent none saves the prompt without calling an agent and needs neither. Prerequisites cover each agent.
The package includes the Trace skill and knowledge base.
A consuming project can provide _bmad/config.toml and workflow customizations.
npm install --save-dev bmad-method-test-architecture-enterprisenpx tea-trace \ --agent codex \ --target docs/epics/epic-4-tenant-export.md \ --test-dir tests \ --json trace-result.jsonUse --project-root to run against a project from another directory.
Relative paths resolve inside that project, and artifact links outside it fail validation.
Scope and inputs
Section titled “Scope and inputs”| Option | Meaning |
|---|---|
--target <path> | Story, epic, or requirements document. Omit it for project-level oracle discovery. |
--target-id <id> | Explicit identity for the selected scope. |
--gate-type <type> | story, epic, release, or hotfix. Inferred from the target when omitted. |
--test-dir <path> | Static tests, default tests. |
--source-dir <path> | Oracle-discovery source, default the project root. |
--live-results <path> | Runtime evidence. Defaults to live-verification-results.json in the artifact root. |
--waiver-register <path> | Waiver register. Defaults to gate-waivers.md in the artifact root. |
--coverage-levels <list> | Comma-separated levels, default e2e,api,component,unit,live. |
--collection-mode <mode> | Defaults to contract_static; accepts inventory_only, runtime_manifest, deferred_shared, waived, restricted, and inaccessible. |
--no-gate | Collect coverage without a gate. inventory_only also disables gate evaluation. |
--fail-on <status> | Defaults to fail. Use concerns to exit 1 on CONCERNS. |
Use runtime_manifest when no static test directory is available.
Missing or unreadable live evidence reports INACCESSIBLE and leaves the gate unevaluated.
The CLI rejects reports that claim collected coverage from missing evidence.
It reads the live verification contract.
Existing Test Design and NFR documents are read from the same artifact root.
Agent and execution
Section titled “Agent and execution”--agent is required.
Choose codex, claude, agy, custom, or none.
A live run uses the agent CLI’s existing session; Test Review CLI prerequisites describe agent setup.
| Option | Meaning |
|---|---|
--model <name> | Model override; not accepted with custom or none. |
--agent-cmd <path> | Override the executable; required for custom. |
--agent-arg <arg> | Pass an extra agent argument. Repeat as needed. |
--env-pass <NAME> | Pass an environment variable. Repeat as needed. |
--timeout-ms <n> | Timeout per attempt, default 1200000. |
--retries <n> | Additional attempts after a transport failure, a timeout, or rejected output, default 1, maximum 3. |
--skill-root <path> | Use an explicit Trace skill directory with sibling bmod-tea/knowledge. |
Claude and Codex default to an adapter model and Agy to its session model. A custom runner takes its model via --agent-arg (details).
--agent none prints and saves the resolved prompt without invoking an agent or replacing reports.
Each retry uses a fresh attempt directory.
Reports must be independent files inside that attempt; links to old or external reports fail validation.
Invalid or incomplete output retains diagnostic evidence.
A retry also follows rejected output: a missing matrix or summary, or one that fails validation.
The next attempt’s run instructions quote the first line of the latest rejection message, so the agent knows what to correct.
A missing gate file counts as rejected output too. A parser rejection is quoted without the agent-written text it excerpts.
A changed input file, a moved Git revision, a file-system fault such as a permission error, or an invalid invocation stops the run without a retry.
The CLI checks inputs and the revision after every agent exit, including one that crashed or timed out.
A failed result lists every attempt in attempt_results, with its status, failure class and the first line of its message; attempt.json keeps the full message.
Each failed attempt’s attempt.json keeps the last 2 KB of the agent’s standard output and error as agentTail.
When the agent leaves no matrix or summary, the failed result’s reason quotes that tail too, whatever the exit.
The console copy of the result escapes the :: and ##[ markers of GitHub Actions workflow commands as JSON Unicode escapes, so parsing it still recovers the exact text.
When the target has no criteria table or AC-, FR-, NFR- or REQ- claims, the CLI freezes no oracle ledger.
The prompt then asks the agent to build a nonempty ledger from the source documents, or from the selected tests for a synthetic oracle.
Every coverage pct is the integer floor of covered * 100 / total, and 100 for an empty bucket.
The prompt states this rule, and validation applies the same function.
A summary whose source_sha is an abbreviation of the project’s Git HEAD publishes with the full SHA.
Outputs and exit codes
Section titled “Outputs and exit codes”--output-dir overrides the artifact root resolved from the TEA test_artifacts setting in the project configuration. Without project configuration, the root is _bmad-output/test-artifacts.
The CLI publishes scope-specific files under trace/:
traceability-matrix-{run_key}.mde2e-trace-summary-{run_key}.json, schema0.3.xgate-decision-{run_key}.json, schema0.1.0, for gate-eligible runs
Epic 4 uses epic-4; stories use their document basename; release and hotfix scopes use slugs.
Runs without a narrower target use system.
The result prints artifact and evidence paths to standard output.
--json <path> also saves the result and must point outside declared inputs and trace artifacts.
--evidence-dir sets the retained attempt root, default .tea-runs.
| Exit | Meaning |
|---|---|
0 | PASS, accepted CONCERNS, coverage without a gate, or prompt inspection. |
1 | FAIL, or CONCERNS with --fail-on concerns. |
2 | Invalid configuration, input, unavailable agent, rejected output path, or report publication failure. |
3 | Agent execution failed, or the last attempt’s artifacts failed validation after every retry. |
Before the agent runs, the CLI snapshots supplied inputs and the consuming Git revision. It checks input bytes, identity, permissions, and paths again before publication. Live results are checked against the frozen manifest and revision. A current-revision failure caps a passing gate at CONCERNS, including mixed-freshness manifests.
Existing reports remain available during a rerun. The CLI replaces them after the new attempt passes validation. Failed attempts retain evidence and publish a failed command result. Publication stages the report set and restores it after a write failure. If rollback fails, the error names retained recovery backups. Reports for other scopes remain in place.
Diagnostic harness
Section titled “Diagnostic harness”The repository’s test/eval-trace.js diagnostic harness runs tea-trace-runner for skill evaluations and takes --artifacts-dir <path> to retain staged projects, prompts and output streams. Point it outside the repository to keep the evaluated Git state unchanged. Public CLI checks run tea-trace.