# Output and exit codes

> Abstract: A review ends in one of six states. The command line writes a JSON report to stdout and exits 0 or 2. With `--post`, or from the poller, it also publishes one comment on the reviewed head. This page lists every state, every field, and the comment's exact shape.

## Six states

| State | Exit status | When |
|---|---|---|
| `over-budget` | 2 | The estimate is above the limit. The model was not called. |
| `estimate` | 0 | `--estimate` was given. The model was not called. |
| `model-unavailable` | 2 | The model failed, timed out, or returned an answer the reviewer rejects. |
| `partial` | 2 | A path was left out, or a check could not run. |
| `reviewed` | 0 | The model ran, and nothing is incomplete. |
| `empty` | 0 | There was no text to review, and nothing is incomplete. |

The second line of every posted comment is one of these words.

> `partial` follows the file checks alone. A history result that is partial or unavailable does not change the state. And exit 0 does not mean the change is clean: a review with findings is `reviewed`, and exits 0.

## The JSON report

`cursor-review` writes one JSON object to stdout. When it catches an error it writes nothing to stdout, and prints `cursor-review: <message>` on stderr.

| Key | Present | Holds |
|---|---|---|
| `provider` | Always | `cursor`, `claude` or `codex` |
| `source` | Always | The change's address, or the repository path |
| `head` | Always | The full commit that was reviewed |
| `model` | Always | The model named, or `<provider>-default` |
| `estimated_input_tokens` | Always | The estimate. 0 when there is no text to review. |
| `max_input_tokens` | Always | The limit in force |
| `state` | Always | One of the six states |
| `findings` | Always | The model's findings, at most three. Each has `path`, `line`, `end_line`, `title` and `message`. |
| `omitted` | Always | The sorted paths outside the review's coverage |
| `checks` | Always | ShellCheck, actionlint and any Go analysis. One entry per file, with its `state`, its `findings`, and a `reason` when it could not check. |
| `static_checks` | When any ran | Hadolint, zizmor and OSV-Scanner. One entry per file, with its `source` (`ci` or `local`), its `state`, its `findings` and a `reason`. |
| `cache_hit` | Always | Whether the model's answer came from the cache |
| `model_invocations` | Always | How many model calls the review made: 0 or 1 |
| `model_usage` | Always | The usage the provider CLI reported, or null |
| `qualgen` | With history | Its `state`, the `advisories`, the `unscreened` paths and the `history_head` |
| `error` | `model-unavailable` | What went wrong |
| `cursor_team_id` | Cursor with a team | The team billed |
| `publication` | With `--post` | `posted-or-already-present`, or `failed` |

> The report also carries `cursor_invocations` and `cursor_usage`, the original names of the invocation count and the usage. For Claude and Codex they are always 0 and null. Read `model_invocations` and `model_usage`.

[Cost and coverage](cost.md#real) quotes a complete report from a real `--estimate` run, with each field annotated.

## The posted comment

A review posts at most one comment, as an ordinary comment on the reviewed head. Its lines follow a fixed order:

1. A header: the provider's name, then `review of`, then the full commit.
2. The state.
3. Each model finding: its path and line, then the finding's title and message.
4. One line on what became of the model: `Skipped <provider>. Estimated prompt <n> tokens exceeds the limit of <m>.`, or `<provider> could not complete the review.`, or, when there are no findings, `No model findings in the reviewed scope.`
5. Each local check that could not run, and the findings of those that did.
6. A `Static checks` block: one count per tool, then up to 30 entries.
7. A history block: its title, then up to 20 entries.
8. Each path outside the review's coverage.
9. A blank line, then credit to PR-Agent.

## Where the backticks come from

Paths come from the pull request. Titles and messages come from the model. The comment sets each one as code, using a backtick run one longer than the longest run inside it.

A path chosen to look like a mention, or a message written to look like a link, is therefore posted as literal text. The reviewer's identity never posts a live mention or a link on a contributor's behalf.

> The header, the state, the status line, the tool counts and the credit line are the reviewer's own words, and are posted as plain text. Only the PR-Agent credit contains a link.

## A comment, assembled

The comment below is illustrative. Every line follows a template from the source, and the change is made up. It shows a review with one model finding, a check that could not run, a check finding, both blocks and one omitted path.

**An illustrative comment for a `partial` review.**

```text
Cursor review of 9c1f0ab2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8
partial
- ` src/app.py `:42 — ` Unhandled None `. ` parse() can return None. `
- actionlint: could not check ` tool unavailable `
- ` scripts/deploy.sh `:12 — ` SC2086 ` ` Double quote to prevent globbing and word splitting. `

Static checks
- hadolint: 1 CI, 0 local, 1 findings, 0 incomplete.
- zizmor: 0 CI, 1 local, 0 findings, 1 incomplete.
- ` hadolint (ci) Dockerfile:3 — DL3007 Latest tag used `
- ` zizmor (local) .github/workflows/ci.yml — could not check: source unavailable or scanner failed `


Qualgen history advisories (baseline 3b9e21c7d4a0)
- ` src/app.py — reference-rot: historically coupled to partner.py `
- ` docs/new.md — insufficient history or unable to screen `

- Outside review coverage: ` docs/readme.md `

Review tooling built on [PR-Agent](https://github.com/the-pr-agent/pr-agent).
```

Comments:
- Comment 1 (line 1): The header: provider, then the full commit.
- Comment 2 (line 2): The state.
- Comment 3 (line 3): A model finding. Path, line, title and message, each set as code.
- Comment 4 (line 4): A local check that could not run, with its reason.
- Comment 5 (line 5): A finding from a check that did.
- Comment 6 (line 8): Each tool's count: how many files came from CI, how many ran locally, the findings, the incomplete ones.
- Comment 7 (line 10): One Hadolint finding, from a CI report.
- Comment 8 (line 11): zizmor's one file could not be checked, so the review is partial.
- Comment 9 (line 14): The history block names the commit its history was mined from.
- Comment 10 (line 18): A file the model never saw.
- Comment 11 (line 20): The only link the reviewer posts.


## What a comment leaves out

| Limit | In the comment | In the report |
|---|---|---|
| 30 scanner entries | Then a line saying how many were omitted | The full list under `static_checks` |
| 20 history entries | Then a line saying how many were omitted | The full list under `qualgen` |
| 450 characters per scanner entry, 500 per history entry | Cut | The full text |

> Assay's forge tool, which posts the comment for the reviewer identity, adds a final line of its own naming the operator. The [real comments](index.md) end with it.

## Reading the exit status

| Exit status | Meaning |
|---|---|
| 0 | The requested review or estimate completed in full, including a review with findings |
| 2 | Partial coverage, a budget refusal, a model or tool error, or a publication failure |

Inspect `state`, `checks` and `findings` when a pipeline reads the report.

---

Source of this page: https://pr-agent.assay.guide/output
