Command line
This page lists every mainworthy command, with its flags and exit codes. The tables describe the version of Mainworthy that serves this guide.
mainworthy is one executable. With no arguments, it starts the server. Most other commands use HTTP to reach a server on this machine or another one. mainworthy fmt, mainworthy audit verify <file>, and
mainworthy help need no server.
Sign in from the command line #
When the server runs in local mode on the same machine, with no proxy named, the CLI needs no token. Otherwise, it signs in with a token. If you sign in through the identity provider, you can create a personal token in Settings under Your sign-in, then Your command-line tokens. See make your own command-line token.
The admin capability on a project lets you accept its policy changes. A project admin
holds it on one project. An instance admin holds it on every project. A person who is an instance admin can also invite people, issue
tokens, and change grants. If you are a person who holds admin across the organisation's projects, use mainworthy token new --human <name>
to issue a token for a new person. To give the CLI a token, use
MAINWORTHY_TOKEN or a private token file.
Reach a server #
A command uses the flag first, then the environment variable, then the default from this table.
| What | Flag | Variable | Default |
|---|---|---|---|
| Server address | --url | MAINWORTHY_URL | http://127.0.0.1:7357 |
| Token | --token, or --token-file | MAINWORTHY_TOKEN, or MAINWORTHY_TOKEN_FILE | None. Local mode on the same machine needs no token, unless a proxy is named. |
| Project | --project | MAINWORTHY_PROJECT | the only project the caller can access, when there is one |
When the CLI displays a server address from --url or MAINWORTHY_URL, it leaves out the URL's username and password. This applies to diagnostics, links, and JSON
output. Requests still use the configured address.
Give the token in the environment or in a file #
MAINWORTHY_TOKEN avoids exposing the token as an argument. An argument appears
in the machine's process list while the command runs and in the shell's history
afterwards.
--token-file <path> or MAINWORTHY_TOKEN_FILE reads the token from a file, such as
a secret file mounted by a pipeline. The CLI removes surrounding whitespace,
including a final newline. The token may have at most 512 characters, the server's
limit. The whole file, including whitespace, may have at most 4096 bytes.
If the token file is empty, unreadable, too large, or contains more than one token, the command stops locally with exit code 4. The error names the file without quoting its
contents. The command refuses --token together with --token-file. If neither
flag is present, it refuses both token variables being set. A flag takes precedence over a variable.
health, version, fmt, help and a command's --help need no token. They ignore token flags and variables, including unreadable token files and conflicting token options. serve uses the server configuration, not the client token options.
Before sending a token to a plain http:// address on another machine, a command
warns once on standard error. The command then continues and sends the token
unencrypted. An https:// address encrypts the token in transit. The warning
does not appear for loopback addresses, https:// addresses, or commands that
send no token. Loopback addresses include localhost, 127.0.0.0/8, and [::1].
The warning does not affect standard output, so --json remains valid JSON.
Configuration explains local and server mode. People, agents and pipelines explains tokens.
CLI and server versions #
mainworthy version prints the CLI's software version and required API version without contacting a server.
mainworthy version --json prints {"version":"0.1.0","apiVersion":4}.
mainworthy health --json reports the server's apiVersion and whether it is compatible with this CLI.
The health check reports availability. It exits 0 even when a healthy server reports an incompatible or unknown API version.
While the database is upgrading, health also exits 0 and prints upgrading. Its JSON includes state: "upgrading". The process is alive but cannot accept application requests yet. Other commands report that the server is upgrading. A deployment must require /health to report ok: true and the expected commit before declaring it ready.
Before its first authenticated request, the CLI reads /health without sending a token.
If that probe redirects, the error gives the destination's origin for --url, without the /health path.
The server must advertise the same API version as the CLI. Software versions and build commits may differ.
An absent, malformed or different API version stops the command with incompatible and exit code 4, before it sends an operation.
A retry requires a CLI and server with the same API version. Servers from before
this contract need an upgrade.
After the probe, each request carries X-Mainworthy-API-Version. A server with a
different API version refuses the request with HTTP 409 and code conflict
before reading or writing project data.
The header check also catches a server upgrade after the first probe.
Before 1.0, adding or removing an operation, or an incompatible change to its inputs, replies, capabilities, or meaning, increments the API version. There is no promise to support the previous API version. Clients from before this check cannot detect a version mismatch. The API reference describes the operations themselves.
Ask a command what it takes #
$ mainworthy help
$ mainworthy gate --help
mainworthy help lists every command. --help after a command prints its flags.
Human-readable output escapes terminal controls, including embedded line breaks,
as visible \uNNNN text. This covers import previews, warnings, receipts and
lists. Non-ASCII text such as é and 雪 stays readable. Output also escapes
GitHub Actions command prefixes so imported text cannot create annotations.
get --md and fmt retain Markdown structure and encode controls and command
prefixes with reversible canonical Markdown escapes. Parsing that output recovers
the original values. Ordinary syntax in the middle of a line stays literal, including std::vector, a::before, and [::1]. The CLI escapes :: only where it could start a workflow command. Their JSON forms preserve the canonical document text.
Pretty and compact JSON preserve their values
and remain valid JSON; saved archives and audit exports retain their original bytes.
Commands #
Commands for people #
Each prints text made to be read, and --json where it is listed prints the same as JSON.
| Command | What it does |
|---|---|
mainworthy serve | Start the server and web UI. Also the default with no arguments. |
mainworthy announce --deploy <build> --env <env> [--digest sha256:<hash> --repo <repo> --commit <sha>] | Record that a build was deployed to an environment. The first time a build label is announced, give its digest; for a digest not seen before, also its repository and full commit. |
mainworthy report <files...> [--format <format>] [--session <name>] [--run R-4] | report --nothing-required [--commit <sha>] [--json] | Upload test reports, or say a commit needs no tests. Reads the CI build from the environment and prints what was recorded. Run gate for the verdict. |
mainworthy gate [--commit <sha> | --run R-4 | --change pr:482] [--wait <seconds>] [--json] | Check a commit, change or run. Exit 0 passed, 1 failed, 2 blocked, 3 pending. |
mainworthy token new --agent <name> | --ci <name> | --human <name> [--can read,produce] [--project <key>] [--expires 90d] | token list | token revoke <id> | Make, list and revoke tokens for people, agents and pipelines. A token may do what its owner is granted now, on every project. A new token is shown once. token list prints each token's id first, which token revoke takes. |
mainworthy invite new <name> [--can read,answer] [--project <key>] [--expires 3d] | invite list | invite revoke <id> | Invite a person with a link that is shown once, list invitations, and revoke one. |
mainworthy actor list | actor grant <name> --can read,record [--roles approver,lead] [--project <key>] | actor ungrant <name> [--project <key>] | actor forget <name> --confirm <name> | List each person, agent and pipeline and what they may do, change what they may do, or forget who someone was while keeping what they did. |
mainworthy audit export --out <file> [--from <time>] [--to <time>] [--receipt <id> --cursor <cursor> --limit <n>] | audit verify <file> | Export a project's audit history, or verify a saved audit file offline. |
mainworthy policy show | policy use <loose|standard|strict|ci> | policy tests <ask|track|create> | policy empty <pending|nothing-required> [--json] | Show the project's policy line by line: who answers each kind of question. An admin can also choose its preset, what happens to tests with no case, and whether CI may pass a commit by saying it needs no tests. |
mainworthy new [file|-] [--json] | Create a case from a Markdown file in Mainworthy's case layout, or from an outline on standard input. |
mainworthy seed <project> [--cases 2000] [--seed 1] [--days 14] [--unlinked-files 60] [--json] | Fill a new or empty project with demo data: a shop's cases, two weeks of results and runs, and questions to answer. |
mainworthy get <ref> [--md] [--json] | Read anything by its ref, such as C-12 or Q-7, or print a case as Markdown with --md. |
mainworthy fmt <file> [--json] | Print a case file in Mainworthy's case layout. An error names its line in your file. |
mainworthy check [--limit <number>] [--json] | Print suite problems grouped by rule. Exit 0 with none, 1 with problems. |
mainworthy export --out <file> [--project <key> | --instance] [--omit-unavailable-attachments] [--json] | Export your organisation, a project, or the whole instance with --instance. A .gz suffix enables gzip. |
mainworthy import <file> [--format csv|testrail|qase] [--case-prefix QASE] [--cmd id] [--json] | Import an archive into a fresh instance, or propose cases from CSV, TestRail or Qase. |
mainworthy import-csv <file> [--mapping '<column mapping JSON>'] [--preset testrail] [--confirm hash] [--cmd id] [--json] | Preview a mapped CSV file, then import it with the preview's confirmation. |
mainworthy mcp | Let an agent connect over MCP (Model Context Protocol) on standard input and output; its calls go to the running server. |
mainworthy open [--json] | Print the web UI URL of the running instance. |
mainworthy health [--url <url>] [--json] | Check that the server answers, including while upgrading. Exit 0 when it does, 1 when it does not. |
mainworthy version [--json] | Print the CLI version and the API version it requires. No server is contacted. |
mainworthy help | List every operation and adapter. |
Flags of mainworthy announce:
--deploy <string>: The build's label, such as a version number.--env <string>: The environment the build was deployed to, such as production.--digest <string>: The SHA-256 digest of the built artifact, such as a container image.--repo <string>: Source repository.--commit <string>: Full source commit hash.--cmd <string>: A key you choose for this announcement: sent again with the same key, it is recorded once.
Flags of mainworthy report:
--commit <string>: Commit tested. Overrides CI/Git detection.--branch <string>: Branch tested.--pr <number>: Pull request number.--base <string>: Base commit of the change.--head <string>: The change's latest commit, as the code host shows it now. Never guessed from CI.--env <string>: Test environment.--format <string>: Report format: auto (default), junit, playwright, jest, vitest, pytest (pytest-json-report), trx.--attachments <string>: Read JUnit attachment files inside this directory. Unavailable or disallowed files are skipped with a warning.--build <string>: The label of a build recorded with announce. Overrides what CI or Git says.--session <string>: A name for results that belong to no build, such as a manual test session.--run <string>: Planned run these results are for.--job <string>: CI job name. Overrides detection.--attempt <number>: Build attempt. Overrides detection.--shard <string>: This report is one shard of its job, as index/count, for example 2/6. The commit's gate waits for every shard.--nothing-required: Say this commit needs no tests, so its gate can pass with no reports. Only a pipeline may, and only when the policy allows it. Give no files.
Flags of mainworthy gate:
--commit <string>: Commit to check. Defaults to CI/Git detection.--run <string>: Run to check.--change <string>: Change to check, for example pr:482.--repo <string>: Repository, when the commit was reported for more than one.--wait <number>: While the verdict is pending, keep asking for at most this many seconds.
Flags of mainworthy token:
--agent <string>: Issue a token for this agent.--ci <string>: Issue a token for this pipeline: it records results and reads the gate.--human <string>: Issue a token for this person.--can <a,b,...>: What a new name may do, as capabilities such as read,produce, comma-separated or repeated. For a name that exists, use actor grant.--expires <string>: How long the new token works: 90d, 12h, 2w. Without it the token has no end.
Flags of mainworthy invite:
--can <a,b,...>: What the new person may do, as capabilities such as read,answer, comma-separated or repeated. For a person who exists, use actor grant.--expires <string>: How long the link works: 12h, 3d, 2w. At most 30d.
Flags of mainworthy actor:
--roles <a,b,...>: Roles a policy line can ask for by name, such as approver, comma-separated or repeated. Omit to keep the current ones; an empty value clears them.--can <a,b,...>: What they may do: any of read, record, produce, answer, plan and admin (a pipeline: read and record only), comma-separated or repeated. The guide's glossary says what each allows.--confirm <string>: Type the name again to confirm forgetting them. A pseudonym replaces their name wherever Mainworthy says who did something, including question evidence and saved replies. Their tokens lose their labels and the network addresses they were used from. They leave their teams and this organisation: their tokens and invitations stop working and their sessions here end. Their account stays theirs, with the identities they sign in with and any other organisations. An account no organisation has is deleted once it has gone 30 days out of every organisation and unused, with no session open. History, attachments and the text they typed in cases and notes stay. Some records of their sign-ins and requests stay. This cannot be undone.
Flags of mainworthy audit:
--receipt <string>: Export one page of the results a merge receipt saved: what counted when the merge was reported.--cursor <string>: Continue a receipt evidence export.--limit <string>: Receipt evidence items per page (1–50).--out <string>: The file to write, as NDJSON: one JSON record per line.--from <string>: Inclusive start: Unix milliseconds or ISO timestamp with a timezone.--to <string>: Exclusive end: Unix milliseconds or ISO timestamp with a timezone.
Flags of mainworthy seed:
--cases <number>: How many cases to write. Defaults to 2000.--seed <number>: The number the demo is made from: the same seed gives the same demo. Defaults to 1.--days <number>: How many days of history to write before today, 0 for none. Defaults to 14.--unlinked-files <number>: How many files of unit tests with no case the pipeline reports: one open question each. Defaults to 60; 0 for none.
Flags of mainworthy get:
--md: Print the case as Markdown in Mainworthy's case layout.
Flags of mainworthy check:
--limit <number>: Maximum problems to print.
Flags of mainworthy export:
--out <string>: Archive destination. Use .gz for gzip.--instance: Export the whole instance. Requires the instance operator.--omit-unavailable-attachments: Export even when some attachments' files are missing or damaged. The archive lists them as omitted and is an incomplete backup. Without it, such an export fails.
Flags of mainworthy import:
--cmd <string>: A key you choose: run again with the same key to resume a case import without proposing cases twice.--format <string>: Case CSV format: csv, testrail or qase. Omit for a Mainworthy archive.--case-prefix <string>: The Qase project key, kept with each case as part of its ID in Qase. Defaults to QASE.
Flags of mainworthy import-csv:
--mapping <string>: Column mapping JSON. Required unless --preset testrail is given.--preset <string>: testrail uses the documented TestRail column names.--confirm <string>: The confirmation the preview printed. Omit it to preview.--cmd <string>: A key you choose: retried with the same key, the import happens once.
One command per operation #
Every operation of the API is also a command with the same name. Give its input as flags, or whole as --json '<input JSON>'. Where a command for people has the same name, the operation form is the one that runs when you pass --json input.
| Command | What it does |
|---|---|
mainworthy job | Run the server's queued background work. Only the server itself may call it. |
mainworthy attach | Append a screenshot or small file to a result you recorded. Supply the file as base64. |
mainworthy attachment | List a result's attachments, or read one: its file name, its content type and its bytes as base64. |
mainworthy propose | Save edits: create or change cases and folders, set which requirements a case covers, pin a fragment's version, quarantine a test, or change the policy. Every save is a proposal; the policy decides whether it takes effect at once or waits for someone to accept it. Linking a test to a case is not an edit: answer its question with decide. |
mainworthy import-csv | Preview the cases a CSV file makes once its columns are mapped to case fields, then confirm to propose them, at most 200 cases to a proposal. A row whose ID in the other tool was imported before is refused. |
mainworthy report | Record test results: those parsed from a CI report, one result a person tested by hand, or an agent's batch. Each result is recorded as reported by the caller: a person, agent or pipeline. |
mainworthy claim | Record a review and what it found, or why failed results failed. A review with no findings is still recorded. |
mainworthy change | Mark a change, such as a pull request, as merged, closed or open again. Reporting a merge saves its head commit's gate as it stands then. Ending a change closes the questions about its failures, except those an open planned run still waits on. |
mainworthy announce | Record a deployment: which build went to which environment, tied for good to the built artifact's digest and source commits. The caller needs the record capability and must be a pipeline or a person with admin on the project. |
mainworthy tracker | Preview a defect for a failed result, ask your issue tracker to create it, or check that an existing tracker issue can be linked to it. Needs both the read and the produce capability. |
mainworthy plan | Start a planned run: choose its cases, which results count, and what finishes it. Results already recorded that count fill their slots at once. |
mainworthy work | Take a case's slot in a planned run for a limited time (a lease), either a named slot or the next free one; renew the lease, or give the slot back. |
mainworthy decide | Answer a question, or withdraw a decision. Policy says whether your answer settles it, is advice, or is refused. |
mainworthy handoff | Hand a failure question to the coding agent this instance is configured to start, with its evidence. |
mainworthy inbox | List the questions waiting for an answer; with no filter, the ones that block most come first. With state=decided, list past decisions instead. |
mainworthy get | Read cases, questions, runs, tests, results or proposals by their refs, such as C-12 or Q-7. |
mainworthy find | Search and list: cases (by text, folder, tag, or compact outline), tests, runs, slots, folders, requirements, changes. |
mainworthy impact | List the cases a change affects and why, with what was already reviewed or decided, so you check those instead of the whole suite. |
mainworthy since | List what changed since a cursor from an earlier read: each case that changed and how, and the questions that were settled. |
mainworthy gate | Say whether a commit, change or run is tested: passed, failed (needs a fix), blocked (a question needs an answer) or pending (still waiting for evidence). |
mainworthy history | List a case's versions, or compare two of them step by step. |
mainworthy timeline | Show what happened to a case, newest first: versions, moves, results from everyone who reported, findings, reviews and questions. |
mainworthy check | Check the suite for structural problems: cases with no steps or no expected result, duplicate titles, dangling links. |
mainworthy stats | Reports over the last days: pass rate per day, flaky tests, time lost to reruns, automation and its backlog, manual effort, coverage by requirement. |
mainworthy command | Look up a write you sent with a cmd key, a retry key you choose: not recorded, begun, or done with its reply. |
mainworthy tracker-status | Read whether a request to your issue tracker, a new defect or a check of an existing issue, went through, and the issue it names. |
mainworthy handoff-status | Read whether a failure question's latest hand-off to an agent was sent, or why it failed. |
mainworthy audit | Export a project's retained decisions, answers, policy changes and case versions as a verifiable audit file. |
mainworthy admin | Manage your organisation: its projects, its actors (people, agents and pipelines), teams, grants (what each actor may do) and tokens, and hand it to another owner. There are no seats: an actor costs nothing, and a token may do what its actor's grants allow. From a browser, making a token or granting admin needs a recent sign-in. |
mainworthy org | For the operator who runs this instance: list its organisations, approve one made by signup, suspend one or let it in again, read and raise one's limits, and delete an account on the operator's own decision, never on a request by email. An organisation made by signup only reads until it is approved. A suspended organisation's tokens and sessions are refused and its data is kept. |
mainworthy session | List your browser sign-ins, or end one. A person with admin on every project of the organisation can do the same for anyone in the organisation except the instance's operator. |
mainworthy credential | List, make or revoke your own command-line tokens in this organisation. Only a person may call it. From a browser, making one needs a recent sign-in through the identity provider in that session. A personal token is shown once and expires after 30 days by default. The identities you sign in with belong to your account: see account. |
mainworthy invitation | Invite a person with a link: make one, list them, revoke one. The person accepts by signing in at the identity provider, so an instance without one makes no invitations. The link is shown once. From a browser, making one needs a recent sign-in; a token or the instance's own command line needs none. |
mainworthy account | What you do as your account, from a browser signed in through the identity provider: the organisations you are in, making one with its first project where this instance takes new ones, the identities you sign in with (removing one needs a recent sign-in), your sessions in every organisation, and deleting the account once no organisation has you (also after a recent sign-in). A token, or a browser signed in with one, is refused: it speaks for one organisation. Switching organisation is POST /api/login/switch. |
mainworthy billing | What this organisation pays for: its subscription and that subscription's status, or the offer when there is none. |
mainworthy subscribe | Start a checkout for this organisation, at the instance's configured price, and get the checkout's address. An organisation that already has a subscription is refused; an open checkout is offered again. |
mainworthy billing-event | Where Paddle sends its notifications. Only a body signed with the destination's secret in Paddle-Signature is taken; each event is applied once. |
Flags every command takes #
--url <string>: Server URL. Defaults to MAINWORTHY_URL or http://127.0.0.1:7357.--token <string>: Bearer token. Defaults to MAINWORTHY_TOKEN, which is safer: an argument is in the process list and the shell's history.--token-file <string>: Read the bearer token from this file, so no argument holds it. Defaults to MAINWORTHY_TOKEN_FILE. Not with --token.--project <string>: Project key. Defaults to MAINWORTHY_PROJECT or the only project.--compact: Print JSON on one line.--help: Show command help.
Exit codes #
| Code | Meaning |
|---|---|
| 0 | mainworthy gate: the verdict is passed |
| 1 | mainworthy gate: the verdict is failed |
| 2 | mainworthy gate: the verdict is blocked |
| 3 | mainworthy gate: the verdict is pending |
| 1 | mainworthy check found problems in the suite; mainworthy health got no answer |
| 4 | The command could not run: the server refused it, could not be reached, or the input was wrong |
A command that could not run exits with code 4 and prints one line to standard
error. The line contains the error code followed by the message, for example
forbidden: .... Troubleshooting lists the codes. A command that runs prints its result and uses the exit code in the table above. For example, it can return a blocked gate or report problems with the suite.
For archive exports, exit 0 means the CLI wrote the file successfully. This includes an export you explicitly requested with omissions. With --json, the omittedAttachments field reports how many attachments have missing content. Zero means no omissions. A positive number means the backup is incomplete. The out field names the file. See Your data for the HTTP header
and archive footer that carry the same count.
See also #
- Report results for
mainworthy reportin a pipeline. - Changes and the gate for
mainworthy gateand what each verdict needs. - API and agent tools for the input of each operation.