Official TestSprite CLI — AI-powered automated testing from your terminal
Official TestSprite CLI — AI-powered automated testing from your terminal
▶ Watch the launch video — the three hard limits every coding agent hits, and the loop that breaks them (4 min).
TestSprite is the AI testing platform 100,000+ teams use to test their software, frontend and backend — in the cloud, against the live product, not mocks. This repo is its official CLI.
It puts that platform in your coding agent's hands: the agent verifies every behavior it ships, and what broke comes back as one self-consistent bundle it can act on — no dashboard scraping. Humans drive the same surface from a terminal or CI.
If you find testsprite useful, a GitHub Star ⭐️ would be greatly appreciated — it helps other builders (and their agents) find the project, and stars notify you about new releases.
Requires Node.js 20.19+, 22.13+, or 24+. (No global install? npx @testsprite/testsprite-cli works too.)
npm install -g @testsprite/testsprite-cli
testsprite setuptestsprite setup prompts for your API key, verifies it, and installs the verification-loop skill for the coding agents this project uses — one command, so your agent is wired to verify its own work.
Which agent it installs for. Each of the eight supported targets — claude, cursor, cline, windsurf, antigravity, kiro, copilot, codex — lands its skill in a different place, so setup works out which you use: the agent calling it, if it identifies itself, together with every agent whose config is already in the project. It installs for all of them and prints what it found — in a terminal it shows you that list first, so you can accept it or narrow it before anything is written. If nothing identifies an agent, it installs for claude and says so — that is the one case where you want --agent <target> to name one yourself. Check the result any time with testsprite agent status.
Non-interactive (CI / onboarding scripts):
TESTSPRITE_API_KEY=sk-... testsprite setup --from-env --yesPointing a coding agent (Claude Code, Cursor, Codex, Cline, …) at TestSprite? Have it run
testsprite setupfirst — that installs the verification skill, so the agent knows how to create, run, and triage tests on its own (instead of guessing from this README).setupreports which agents it installed for; add--agent <target>if that list is not the one you wanted. New here? Start with the getting-started overview.
Privacy note: interactive runs check the npm registry at most once per 24 h to offer a "new version available" notice — package name only, never your key or data;
TESTSPRITE_NO_UPDATE_NOTIFIER=1disables it. The backend also advertises its minimum supported CLI version — a below-floor CLI prints a one-line upgrade advisory on stderr, and a too-old client may be rejected with exit 14 (CLIENT_TOO_OLD). Details in DOCUMENTATION.md → Update notice.
From there, the loop runs on its own — an example session, typed by the coding agent:
# 1 — describe the behavior you want to guarantee, run it, wait
testsprite test create --project proj_8f0f6 --type frontend \
--plan-from ./checkout-flow.plan.json --run --wait --output json
# → exits 1: the run failed
# 2 — pull ONE self-consistent failure bundle
testsprite test failure get test_3a9f21c7 --out ./.testsprite/failure
# 3 — the agent reads the bundle, fixes the code, then replays
testsprite test rerun test_3a9f21c7 --wait --output json
# → exits 0: passed. The test now lives in your durable suite../checkout-flow.plan.json (the --plan-from argument above) is a JSON file describing the test in plain language — no browser code required. This is the exact, byte-identical output of testsprite test create --plan-template (also embedded verbatim in test create --help):
{
"$schema": "https://raw.githubusercontent.com/TestSprite/testsprite-cli/v0.4.0/schemas/plan.schema.json",
"projectId": "prj_abc123",
"type": "frontend",
"name": "Login rejects an empty password",
"planSteps": [
{
"type": "action",
"description": "Navigate to /login and submit the form with an empty password"
},
{
"type": "assertion",
"description": "Verify an inline error says the password is required"
}
]
}Get this exact skeleton without hand-copying it (and without the risk of it drifting from your installed version — see below): testsprite test create --plan-template. Full field reference (including the {{...}}-placeholder caveat, size caps, and the $schema hook for live editor validation): Plan file format.
The
$schemaURL above is pinned to the CLI version that generated this doc (v0.4.0) —--plan-template's live output always pins to your installed version instead, which is what actually resolves. If you're reading this on a later release, run the command yourself rather than trusting this snippet verbatim.
Don't want to write the first tests yourself? For a deployed target, ask TestSprite to propose them. Local projects use the authored-plan flow below. testsprite test plan generate --project <id> explores your app (or reads the API spec you uploaded with project docs upload), drafts test cases, and stages them for review — nothing is written to your disk. You read the printed table and keep what you want:
testsprite test plan generate --project proj_8f0f6 # stages proposals for review
testsprite test plan accept --project proj_8f0f6 # → real tests
testsprite test plan accept --project proj_8f0f6 --only prop_2 prop_5 # or just theseIt only runs what the project is still missing, so a second call picks up where the first left off. Generation spends workspace credits per stage that actually runs (the result line reports the spend), and a PRD uploaded with project docs upload --role prd bills 0.5 credits for its embedding — an API spec is free. Full walkthrough, including what happens on Ctrl-C and every precondition error: Generate commands.
Prefer to configure each step by hand (or learn the surface offline with --dry-run first)? See Manual setup and Install & verify.
Frontend tests can reach your running app through a TestSprite tunnel, including on the Free plan (ordinary run credits apply).
Use an API key with run:tunnel: keys minted before that scope existed need to be replaced; the CLI names the missing scope.
testsprite project create --type frontend --name "My local app" --local 3000
testsprite test create --plan-from ./checkout.plan.json --project <project-id>
testsprite test run <test-id> --local 3000 # per-run tunnel; waits up to 1200 seconds
# Or keep one tunnel open in terminal A (no port argument)
testsprite tunnel start --ttl 3600
# Terminal B: borrow the clientId printed above; keep terminal A running
testsprite test run <test-id> --local 3000 --tunnel-client <client-uuid>Run one test per invocation; parallel invocations are fine (5 live tunnel bindings per user); --all --local is refused.
A second tunnel start or process using the same credential takes over, and the first exits 10.
The examples use 127.0.0.1. For another loopback listener, pass the same --local-host localhost or --local-host ::1 to project creation and every follow-up run. The selected host is stored in the project URL (::1 becomes http://[::1]:<port>); project get/list exposes originMode: 'local' in JSON and shows (Local) in text output.
The control plane is WebSocket over TLS (wss://control.tun.testsprite.com/ws). The data plane, which carries the tunnel secret and proxied traffic, uses TLS at data.tun.testsprite.com:443 and verifies the certificate with Node's default trust store: its bundled Mozilla roots, plus certificates supplied through NODE_EXTRA_CA_CERTS and the system CAs when Node is started with --use-system-ca. Node 20 is supported without losing NODE_EXTRA_CA_CERTS. Verification cannot be disabled, and the CLI never falls back from TLS to plaintext. On a network that re-signs TLS, export your organisation's root CA to a PEM file and set NODE_EXTRA_CA_CERTS=/path/to/ca.pem before running testsprite. Plaintext connects and TLS handshakes each time out after 10 seconds. The first failed attempt starts a 60-second retry episode; writing TunnelHello is not enough to reset it. The episode ends only after the first inbound tunnel stream or after the socket remains open for 5 seconds following the hello. A real deadline timer stays armed across retries and destroys an in-flight socket when it expires. After that, an owned test run --local run is cancelled and refunded and the command exits 10; tunnel start exits 10. If a self-hosted or older TestSprite server does not advertise a TLS endpoint, the CLI prints a one-time warning and uses legacy plaintext port 7400 under the same timeout and retry rules. tunnel start prints transport: tls or transport: plaintext.
An owned tunnel's timeout or Ctrl-C cancels the run by default. A borrowed run still detaches without cancellation on Ctrl-C/SIGTERM because its owner keeps the tunnel alive; if that owner disappears while the run is active, the borrower cancels its own run and reports cancelled, already finished, or skipped. A run cancelled before it finishes is refunded. --no-cancel-on-interrupt also skips this owner-gone cancellation. Keep the early Run <runId> receipt on stderr and read the reported run before re-running.
Local projects skip exploration/plan generation; author plans with test create --plan-from. Portal runs are blocked for free until you set a public project URL.
See the full local-testing reference for flags, login, billing/refunds, timeouts, and retargeting.
| Group | Command | What it does |
|---|---|---|
| Setup | setup |
Start here — one command: configure your API key, verify it, and install the agent verification skill |
doctor |
Environment diagnostic — CLI/Node versions, profile, endpoint, credentials, connectivity, agent skill; exits non-zero on failure | |
| Auth | auth status |
Resolve the active profile to its user, key, env, and scopes |
No open issues yet, or sync has not completed.