Output Formats & Exit Codes
Every recon command takes a global --format flag that decides whether it prints text for a person or JSON for a program. Exit codes follow one contract across commands, so scripts, CI jobs and AI agents can branch on them. Read this page before you parse recon output.
The --format flag
Section titled “The --format flag”recon --format json history --limit 5recon history --limit 5 --format json--format is global, so it works before or after the subcommand. The values are:
| Value | Output |
|---|---|
auto (default) |
human if stdout is a terminal, otherwise agent. |
human |
Text for people, with ANSI colour codes. |
agent |
JSON for programs and AI agents. |
json |
JSON for programs. |
How auto resolves
Section titled “How auto resolves”auto checks only whether stdout is a terminal. Run recon in a terminal and you get human. Pipe or redirect stdout (recon send x | jq, recon test > out.json, a CI step, an agent’s subprocess) and you get agent. Where stderr goes does not matter.
Human output is meant to be read. It uses colours (green check marks, red crosses, coloured methods and status codes) and short tables.
agent and json
Section titled “agent and json”For almost every command, agent and json print the same pretty-printed JSON document to stdout. The differences:
| Command | agent |
json |
|---|---|---|
recon send |
body is the PII Airlock-masked body. |
body is the raw response body. |
recon diff-branch |
Plain-text summary, or Markdown with --markdown. |
JSON report. |
recon doctor |
Plain-text check list. | JSON object with healthy, workspace_root and checks. |
recon setup-mcp |
Plain-text snippets. | JSON array of snippets. |
Because auto becomes agent when piped, recon send piped to another program prints the masked body. Pass --format json when you need the raw body.
Commands that ignore --format
Section titled “Commands that ignore --format”| Command | Output |
|---|---|
recon ui |
URL on stdout; status lines on stderr. |
recon mcp |
JSON-RPC 2.0 messages on stdio. See MCP Server. |
recon skill |
The bundled SKILL.md text, or an Installed Recon skill to ... line. |
recon export code |
The generated snippet. |
recon export types |
The generated types. |
recon capsule export |
Capsule JSON, or Markdown with --markdown. |
recon test --markdown-summary - and recon drift --sarif - print the Markdown or SARIF document to stdout in place of the normal output, whatever the format.
stdout and stderr
Section titled “stdout and stderr”- Results go to stdout.
- Errors go to stderr, in every format.
- Long-running servers print their URL to stdout and status lines to stderr:
recon ui,recon mock,recon proxyandrecon shadow. This lets a script capture the URL with$(...). recon proxyandrecon shadowprint their shutdown summary to stderr in human mode and to stdout as JSON inagent/jsonmode.recon watchprints its “watching” banner to stderr, andrecon auth oauth2-loginprints the authorization URL to stderr.
The error envelope
Section titled “The error envelope”When a command fails in a way recon handles, it prints an error envelope to stderr. In agent and json mode the envelope is pretty-printed JSON:
recon send nope{ "code": "E_NOT_FOUND", "message": "request `nope` not found in collections", "fix_hint": "Pass a valid URL (`https://...`) or saved request ID/name.", "retryable": false}In human mode the same envelope is two coloured lines:
error E_NOT_FOUND: request `nope` not found in collections hint: Pass a valid URL (`https://...`) or saved request ID/name.| Field | Type | Meaning |
|---|---|---|
code |
string | Stable machine-readable code. See Error Codes. |
message |
string | What went wrong. For E_CLI_RUNTIME this is the full error chain. |
fix_hint |
string | What to try next. |
retryable |
boolean | Whether retrying without changes may succeed. Every envelope the CLI emits sets it to false. |
Any error that a command does not handle itself is wrapped as E_CLI_RUNTIME with the hint “Check workspace .recon.toml, arguments, or network connectivity.” and exit code 2:
{ "code": "E_CLI_RUNTIME", "message": "TCP connection failed to `127.0.0.1:5099`: Connection refused (os error 111)", "fix_hint": "Check workspace `.recon.toml`, arguments, or network connectivity.", "retryable": false}Errors in the command line itself (a missing argument, an unknown flag, an invalid --format value) are reported by the argument parser as plain text, not as an envelope, and exit with code 2:
error: invalid value 'xml' for '--format <FORMAT>' [possible values: auto, human, agent, json]
For more information, try '--help'.Exit codes
Section titled “Exit codes”All commands share three codes:
| Code | Meaning |
|---|---|
0 |
Success. |
1 |
The command ran, and its check failed: an assertion, a diff, a validation, an SLA, or a firewall block. |
2 |
The command could not run: bad arguments, an unknown target, or a runtime error (E_CLI_RUNTIME). |
--help and --version exit 0. A command-line parse error exits 2. Any unhandled error exits 2 with E_CLI_RUNTIME. The table lists the other cases each command can return.
| Command | 0 |
1 |
2 (besides parse errors and E_CLI_RUNTIME) |
|---|---|---|---|
init |
Workspace written. | ||
ui |
Server stopped with Ctrl-C. | ||
send |
Sent, all assertions passed (or none defined). | An assertion failed; E_FIREWALL_BLOCKED. |
E_NOT_FOUND |
twin |
Both requests completed, whatever the diff. | ||
diff |
Runs identical. | Runs differ. | |
test |
No case failed (including zero cases). | At least one case failed. | |
history, search |
Always. | ||
import |
Imported. | ||
export code, export types, export openapi |
Exported. | ||
airlock verify |
Ledger valid. | Ledger tampered. | |
airlock audit |
Bundle written. | ||
scan |
Scan finished. | ||
drift |
No breaking drift, or --fail-on-breaking not set. |
--fail-on-breaking and breaking drift found. |
|
contract infer |
Contract written. | ||
contract check, contract check-openapi |
Valid. | Invalid. | |
capsule export |
Exported. | ||
capsule verify |
Valid. | Invalid. | |
capsule reproduce |
Live status below 400. | Live status 400 or above. | |
watch --once |
All impacted requests passed (and no breaking drift with --drift). |
Any failed. | |
watch |
Watch loop ended. | ||
mock |
Pack exported, or server stopped with Ctrl-C. | ||
proxy, shadow |
Stopped with Ctrl-C. | ||
flow list |
Always. | ||
flow run |
Flow passed. | Flow failed. | |
load |
SLA passed. | SLA failed; E_FIREWALL_BLOCKED. |
E_NOT_FOUND |
paginate |
Finished. | E_FIREWALL_BLOCKED |
E_NOT_FOUND |
sse, ws |
Finished. | E_FIREWALL_BLOCKED |
E_NOT_FOUND |
graphql |
No GraphQL errors. | Response has GraphQL errors; E_FIREWALL_BLOCKED. |
E_INVALID_ARGS |
grpc |
gRPC status 0, or --inspect. |
Non-zero gRPC status; E_FIREWALL_BLOCKED. |
E_INVALID_ARGS |
vault ..., auth ... |
Success. | ||
mcp |
The stdio session ended. | ||
skill, setup-mcp |
Success. | ||
doctor |
No check failed (warnings allowed). | A check failed. | |
diff-branch |
No breaking change, or --fail-on-breaking not set. |
--fail-on-breaking and a breaking change found. |
Some failures use exit code 2 where you might expect 1. A firewall block in recon twin is reported as E_CLI_RUNTIME with exit code 2, and a transport error during recon test stops the run with exit code 2 instead of counting as a failed case.
Recipes
Section titled “Recipes”Branch on the result of a request in a shell script:
if recon send "List Students" > run.json; then echo "passed: $(jq -r .run_id run.json)"else case $? in 1) echo "assertion failed or firewall blocked" ;; 2) echo "could not run" ;; esacfiCapture the URL of a server started in the background:
recon ui --port 0 > ui-url.txt &For the codes that appear in envelopes and HTTP responses, see Error Codes.