Back to Docs

Manage Tests with the CLI

Create, edit, list, inspect, and run hosted tests using explicit project IDs.

Every test command requires --project PROJECT_ID. Prompts can be supplied inline, from a file, or through standard input using --prompt-file -. Use Markdown for headings, lists, and clear steps; plain text also works.

Create and edit

mechasm tests create --project PROJECT_ID --name "Login flow" --prompt-file prompt.md --json
mechasm tests edit --project PROJECT_ID TEST_ID --prompt "Also check password reset" --json

Create requires a name and a prompt. It creates the test and starts generation and a run. Editing the prompt of an enabled test also starts generation and a run. Name, tags, and enabled-state changes do not start generation.

Create and edit support --tags LIST, --name NAME, and --enabled true|false where applicable. Test generation and healing follow the same workflow as other Mechasm tests.

List and inspect

mechasm tests list --project PROJECT_ID --json
mechasm tests list --project PROJECT_ID --offset 50 --limit 50 --json
mechasm tests get TEST_ID --project PROJECT_ID --json

tests list returns 50 tests by default. --offset starts at 0; --limit accepts 1–100. tests get returns one test and its prompt.

Run an existing test

mechasm tests run TEST_ID --project PROJECT_ID --json

Commands that start a run return its runId and workspace runUrl while the run continues. Use that run ID to watch execution:

mechasm runs logs RUN_ID --project PROJECT_ID --follow --json

After the stream finishes, check the final result with mechasm runs status RUN_ID --project PROJECT_ID --json. Log streaming alone does not report pass/fail through its exit code; status/get commands exit with code 5 for failed or stopped runs.

For scripts that only need the final result, add the optional --wait to create/edit/run. It waits silently until completion, then returns the result without displaying live logs. With --json, it returns one final JSON result; failed or stopped runs exit with code 5. Metadata-only edits still return immediately. See Runs, Logs & Artifacts for log following, waiting and evidence.

Safe retries and parallel work

Test create, edit, and run commands include an idempotency key. If a connection fails and the result is unknown, retry the operation with the same --idempotency-key KEY; do not generate a new key for that retry. When the API says the same operation is still in progress, the CLI retries that response while its 30-second retry window remains open. The delay starts at 250 ms and doubles up to 4 seconds. This time-based API retry has no fixed request count, does not automatically retry every network failure, and does not describe retries inside a hosted run.

Concurrent runs count against your workspace’s parallel-run capacity. Runs that use the same local app share its application state and data, so isolate test data when parallel runs could interfere. Concurrent edits to one test are separate updates; the last saved change wins.