Runs from the CLI
Use `@@CLI@@ runs` to start a test run from a terminal or CI job, wait for it to finish, cancel it, or list recent runs.
Use heybug runs to start a test run from a terminal or CI job, wait for it to finish, cancel it, or list recent runs. The same runs appear in the dashboard, with the same verdicts and results.
start and list need a project id. Find it in the project's URL, or list your projects with heybug project list. wait and cancel take run ids instead.
Start a run
heybug runs start --project <projectId>With no test ids, this runs the whole suite. Pass test ids after the command to run only those cases:
heybug runs start TC-12 TC-15 --project <projectId>Useful flags:
| Flag | What it does |
|---|---|
--filter text | Runs only the tests whose titles match the text. |
--env name | Runs against the project environment with this name. The name is matched without regard to case. |
--target-url url | Sets the target URL for this run. |
--max-concurrency n | Caps how many cases run at the same time. |
--timeout s | Stops following the run after this many seconds. 0 means no limit. |
--dry-run | Shows which cases would run, and starts nothing. |
--allow-empty | Starts nothing and does not fail when no test matches. Without it, an empty match is an error. |
--wait | Follows the runs to their verdict. This is the default. Exits 0 when every run passes and 1 otherwise. Cannot be used with --no-wait. |
--no-wait | Starts the runs and exits at once. |
--detach | Pressing Ctrl-C stops following but leaves the runs going. |
--idempotency-key k | Makes a retry safe. A repeated key returns the first run instead of starting another. |
--output json | Prints one JSON receipt on stdout instead of text. |
While it follows a run, the command prints one line each time a case changes state, with its key, its status and the failing step if there is one. Progress goes to stderr, so stdout stays clean for --output json.
Wait for runs
heybug runs wait <runId...> --timeout 30mwait starts nothing. It follows one or more runs that are already going, and all of them share one deadline. The default timeout is 30 minutes.
Cancel runs
heybug runs cancel <runId...>Cancel stops runs that are still going. A run that has already finished keeps its verdict. The receipt marks each run as alreadyFinished or alreadyCancelled, so repeating the command is safe.
Pressing Ctrl-C while start is following a run cancels the runs that command started. Add --detach to keep them running. The command then prints how to follow them again with heybug runs wait.
List recent runs
heybug runs list --project <projectId> --limit 20This prints the latest runs of a project, newest first, with their number and status. --limit sets how many to show.
Example: a CI job
RUN=$(heybug runs start --project "$HEYBUG_PROJECT" --env staging \
--filter checkout --idempotency-key "$CI_PIPELINE_ID" \
--output json --no-wait)
RUN_ID=$(echo "$RUN" | jq -r '.runs[0].runId')
heybug runs wait "$RUN_ID" --timeout 20m --output json > receipt.jsonIn CI, sign in with heybug auth login --token-stdin and a token from a secret store, and keep the project id in a variable. Read the receipt file afterwards to show per-case results in your CI log.
Receipt shape
With --output json, every command prints one receipt:
{"runs":[{"runId","number","status","dashboardUrl","alreadyCancelled","alreadyFinished"}],
"results":[{"resultId","caseKey","status","failedStep"}]}failedStep appears only when a case failed. A dry run also sets "dryRun": true.
Exit codes
| Code | Meaning |
|---|---|
| 0 | Every run passed. |
| 1 | A run failed, was blocked or was cancelled. |
| 2 | Bad command or flags. |
| 3 | Not signed in. Run heybug auth login again. |
| 4 | Project or run not found. |
| 5 | Invalid input, such as an unknown --env name. |
| 6 | The server could not be reached, or wait timed out. Runs that already started keep going. |
| 7 | Rate limited. Wait and try again. |
| 12 | Out of credits. |
| 13 | Blocked by a gate. |
| 130 | Interrupted. |
When something fails
- "No environment named ... in this project." (exit 5) The
--envname does not match an environment in the project. Check the environment names in the project, or drop the flag. - Exit 3. Your token is missing or expired. Run
heybug doctorto see what is wrong, thenheybug auth login. - Exit 6 from
wait. The timeout passed, or the server could not be reached. The runs are still going. Runheybug runs wait <runId>again, or open the dashboard link from the receipt. - Exit 1 from
start. At least one case failed. Read thefailedStepfor each case in the receipt, or opendashboardUrl. - "Nothing matched" error. No test matched the filter or the ids. Check the spelling of
--filter, or add--allow-emptyif an empty run is fine. - A retry started a second run. Add the same
--idempotency-keyto every attempt of the same job. A repeated key returns the earlier run.
From an AI coding agent, the same work runs through the MCP tools heybug_list_runs and heybug_rerun. See the MCP guide for setup.