# Sonjoo CLI exit codes

> Interpret Sonjoo exit codes 0, 1, 2, and 130 and distinguish a valid report that failed a CI gate from an execution error.

Canonical documentation: <https://sajaddehshiri.ir/sonjoo-seo-audit/cli/exit-codes/>

Check the exit code and the report together. An audit can finish, write a valid report, and exit 1 because a gate failed.

| Exit code | Meaning                                                                                                                                                                                |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `0`       | Command succeeded. For an audit, the configured gates passed. Findings can still appear in the report.                                                                                 |
| `1`       | An audit or analysis failed a gate, `compare --fail-on-regression` found a comparable regression, `config <key>` could not find the requested key, or `serve` returned a server error. |
| `2`       | Command usage, configuration, or execution error. Audit examples in JSON mode can return an error object. Parser errors print diagnostics to standard error.                           |
| `130`     | An audit, analysis, or crawl was interrupted. Use the saved crawl ID to resume a journaled crawl.                                                                                      |

## What does exit code 1 mean?

For `sonjoo audit`, exit 1 means a configured score, coverage, required-rule, or custom-search gate failed. Read the report before deciding what to fix. Check `gate.reason`, `gate.failedCiRules`, `gate.unevaluated`, and the optional `gate.coverage` and `gate.failedCustomSearches` fields.

When running in a shell pipeline, capture the status of Sonjoo itself. To keep an export on failure, pass `--format json --output audit.json` and persist that file in your CI job. [Reproduce both gate outcomes](https://sajaddehshiri.ir/sonjoo-seo-audit/guides/ci-gates/#require-a-specific-rule)

## What does exit code 2 mean?

Look for the message and hint in the diagnostic. With an explicit `--format json` or `--json`, runtime failures can produce a JSON error object on stdout even if you requested a report file. A JSON output setting in TOML alone does not select JSON diagnostics. Start with a fresh output path so a file left by an earlier run cannot be mistaken for a new report.

This example rejects an unsupported URL scheme before making a request.


```sh
sonjoo audit 'file:///example' --no-save --format json --output unexpected.json
```

Expect exit 2 and a JSON object with `error: true`. The command creates no report at `unexpected.json`. If a valid HTTP(S) target fails instead, check reachability, then use `sonjoo self doctor` to check the local setup.
