The JSON contract
--output json is the stable, machine-readable contract — the shape an agent or script can depend on across releases. Changes are additive: new fields may appear, but existing fields and exit codes won’t change within a major version. --output text is human-friendly and may change freely. When in doubt, script against JSON.
--dry-run, which emits canned data whose shape matches the live response — perfect for writing and testing a script before you wire up auth.
Piping into jq
JSON output pipes straight intojq or an LLM:
Branching on exit codes
The CLI’s exit codes are stable and meaningful, so scripts can branch without parsing output at all:Timeouts still leave you something to parse
When a--wait poll hits its --timeout ceiling, the exit code is 7 — but the CLI still writes a partial result object to stdout before exiting, so a script never loses the runId on the unhappy path:
A minimal CI gate
CI/CD
A full GitHub Actions workflow — including failure-artifact upload and rate-limit handling
Debugging a script
--verbose— human-readable retry / backoff / polling messages to stderr.--debug— HTTP method, path, request id, latency, and retry decisions to stderr. The API key is never included.
jq. The same stdout-purity rule holds everywhere in the CLI: interactive prompts (the API key prompt in testsprite setup, the --target prompt in agent install) and any onboarding preamble also print to stderr, so stdout stays a single parseable payload even in an interactive terminal session.
Once every 24 hours, an interactive run also probes npm for a newer CLI version and, if one exists, prints a one-line notice to stderr. It’s automatically skipped in CI, when stderr isn’t a TTY, under --output json, and under --dry-run — disable it explicitly with TESTSPRITE_NO_UPDATE_NOTIFIER=1.
Where to Go Next
Exit Codes & Errors
The full branching contract for scripts and agents
Configuration
Profiles, environment variables, and global flags
CI/CD
A complete GitHub Actions pipeline
Command Reference
Every command, flag, and output shape