# CLI reference

Every command, flag and exit code of `supposing`. `supposing rank` runs on your machine; every other command talks to the cloud API.

- **`--json` on every command.** Results, lists and errors go to stdout as JSON. Progress and notes go to stderr, so stdout stays clean for pipes.
- **The estimate comes first.** `rank` and `run` print the calls and the cost before they spend anything. For a run billed to your credit, the estimate also shows the price per call and your balance after. A run that costs money needs a yes: typed at the prompt, or `--yes`. Without a terminal and without `--yes`, the command stops with exit code 7.
- **Errors say what to do next.** Each error has a stable `code`, a `message` and a `hint`.

## Commands

| Command | What it does |
|---|---|
| `supposing rank <folder\|file>` | Rank a folder of documents, or the rows of a JSONL, JSON or CSV file, on this machine |
| `supposing run <folder\|file\|dataset-id>` | Rank in the cloud: upload the folder if needed, show the estimate, start, wait, print the results. A folder already uploaded with the same files is reused, so retrying adds no copy |
| `supposing login` | Check an API key and save it for this machine (mode 600) |
| `supposing logout` | Forget the saved key |
| `supposing whoami` | The workspace the key belongs to, and where the key came from |
| `supposing datasets push <folder\|file>` | Upload a folder (one item per file, including `.pdf` and `.docx`) or a JSONL, JSON, CSV or XLSX file (one item per row) as a new dataset; prints the dataset id |
| `supposing datasets list` | Datasets, newest first |
| `supposing datasets get <id>` | A dataset and its items |
| `supposing datasets delete <id>` | Delete a dataset and its runs |
| `supposing runs list` | Runs, newest first (`--dataset <id>` to filter) |
| `supposing runs get <id>` | A run's status, progress, judge and rubric |
| `supposing runs watch <id>` | Follow a run until it finishes, then print its results |
| `supposing runs cancel <id>` | Stop a run. Calls already made are kept |
| `supposing results <run-id>` | The verdict, then the leaderboard |
| `supposing billing` | The credit balance and what running runs hold |
| `supposing billing ledger` | Every credit movement, newest first: grant, top-ups, holds, what came back |
| `supposing billing topup <dollars>` | Print a payment page for adding credit. Nothing is charged until you pay there |
| `supposing billing portal` | Print a link to receipts and payment details |
| `supposing samples` | The built-in sample datasets. `supposing rank --sample <id>` ranks one with its own rubric, no files needed |
| `supposing pricing` | The price of a judge call by model tier. Needs no login |
| `supposing usage` | This month's runs, judge calls and spend, and the balance |
| `supposing comparisons <run-id>` | Each judge call and its reasoning (`--item <id>`, `--status`, `--limit`) |
| `supposing mcp` | Serve the MCP tools over stdio for a coding agent: the cloud when a key is saved, the local engine otherwise (`--local` forces local). Needs `pip install 'supposing[mcp]'` |

## Flags shared by `rank` and `run`

The two commands take the same flags and print the same result.

| Flag | Meaning |
|---|---|
| `--rubric TEXT` or `--rubric @file` | Required. What the judge should prefer, in plain words. A file can be any text, or Markdown with a `## Criteria` list (`- Impact (weight 2): ...`) and `## Judge instructions`, or JSON with the same fields |
| `--provider` | `openrouter` (default), `mock` (free and fake, for trying things), `claude_cli`. Locally also `anthropic` and `openai_compat` |
| `--model` | Judge model, for example `anthropic/claude-haiku-5.5` |
| `--rounds N` | Opponents per item (default 8). More rounds give tighter intervals and cost more |
| `--top-n N` | Only settle the top N. Calls stop going to items that can no longer reach it |
| `--one-order` | Judge each pair once instead of twice in swapped order. Half the calls, but position bias is no longer cancelled out |
| `--pairing swiss\|random` | `swiss` (default) pairs items of similar rating |
| `--max-chars N` | Cut items longer than this before judging |
| `--max-cost USD` | A hard cap: a call starts only if, priced at the dearest call so far, it still fits under this amount. The run stops there and keeps the ranking so far |
| `--seed N` | Seed for pairing and the bootstrap |
| `-y`, `--yes` | Start without asking, even if the run costs money |
| `--dry-run` | Show the estimate and stop |
| `--json` | Print JSON |

## Reading a file: JSONL, JSON, CSV or XLSX

`rank`, `run` and `datasets push` take a file as well as a folder: one item per row. These flags say which fields make each item; the names match the API's import.

| Flag | Meaning |
|---|---|
| `--text-field FIELD` | The field with the text to judge. Repeat it to join several fields, each under a `## FIELD` heading |
| `--id-field FIELD` | Each row's id. It becomes the item's id in `rank` results and its `source_id` in the cloud, so every result keeps it |
| `--title-field FIELD` | The title to show. Default: the id |
| `--metadata-field FIELD` | Keep this field on the item but never show it to the judge (an applicant's name or email). Repeatable |
| `--sheet NAME` | For an `.xlsx` workbook, the sheet to read. Default: the first with data |

How each file is read:

- **JSONL and JSON** are read on your machine. Without flags, a field named `text`, `output`, `response`, `answer` or `content` is the text and a field named `id` is the id.
- **CSV and TSV** are read on your machine by `rank`. `run` and `datasets push` send them to the API's import, which guesses the columns when you name none: personal and date columns go to metadata.
- **XLSX** works with `run` and `datasets push` only: the API reads it. To rank one locally, save it as CSV.

Other fields are dropped. A row with no text is skipped and listed in `skipped`. Ids must be unique. In the cloud, the API also lists likely duplicate items.

In the cloud, a folder is uploaded as files, as in the web app: `.md`, `.txt`, `.html`, `.pdf` and `.docx`. Each item is titled by the document's first heading, and its file name is its `source_id`. `--redact` on `run` and `datasets push` removes names, emails and phone numbers from what the judge reads; for a spreadsheet, put those columns in `--metadata-field` instead. Locally, `rank` titles items by their path.

```sh
printf 'id,model,answer\nr1,a,The Moon pulls the sea into a bulge.\nr2,b,Gravity.\nr3,c,Water follows the Moon around the Earth.\n' > answers.csv
supposing rank answers.csv --text-field answer --id-field id --metadata-field model --rubric "Which answer is clearest?" --provider mock --json | jq -r '.results.ranking.leaderboard[].item_id'
```

`rank` only: `--sample ID` ranks a built-in sample instead of a source (`supposing samples` lists them), with the sample's rubric unless you pass `--rubric`. `--state FILE` saves progress to SQLite, and rerunning with the same file resumes the run. `--concurrency N` sets how many calls run at once, and `--base-url` sets the endpoint for `openai_compat`.

`run` only: `--name` names the run, and `--detach` starts it and prints its id without waiting.

## Configuration

| Setting | Where it comes from |
|---|---|
| API key | `--api-key` on `login`, then `SUPPOSING_API_KEY`, then the key saved by `supposing login` |
| API URL | `--api-url`, then `SUPPOSING_API_URL`, then the URL saved by `login`, then `https://api.supposing.app` |
| Saved login | `~/.config/supposing/config.json` (mode 600). `XDG_CONFIG_HOME` or `SUPPOSING_CONFIG` move it |
| Judge keys for `rank` | `OPENROUTER_API_KEY` for `openrouter`, `ANTHROPIC_API_KEY` for `anthropic` |

## The result

`rank --json`, `run --json` and `runs watch --json` all print one document:

```text
{
  "run":      the run: id, type, status, judge, ranking (the settings), progress (calls, cost_usd), note
  "estimate": n_items, min_calls, max_calls, est_cost_usd (null when the price is unknown), est_seconds
  "results":  run_id, type, final, summary (the verdict in one sentence),
              ranking: {leaderboard, diagnostics, interval, n_bootstrap}
  "skipped":  files in the folder that were left out, as [{path, reason}]
}
```

The `results` part is exactly what `supposing results <id> --json` and `GET /v1/runs/{id}/results` return. Each leaderboard row has `rank`, `rank_lo` and `rank_hi` (the 90% range of ranks), `rating` with `rating_lo` and `rating_hi`, `wins`, `losses`, `title` and `item_id`. For a local run, `run.id` and `results.run_id` are `null`, and `item_id` is the file's path.

```sh
echo "Which proposal makes the strongest case for funding?" > rubric.md
supposing rank ./proposals --rubric @rubric.md --provider mock --json > local.json
jq -r '.results.summary' local.json
jq -r '.results.ranking.leaderboard[] | "\(.rank) \(.rank_lo)-\(.rank_hi) \(.title)"' local.json
```

## Errors and exit codes

With `--json`, an error prints `{"error": {"code": "...", "message": "...", "hint": "..."}}` on stdout. Without it, the message and the hint go to stderr. [Errors](errors.md) lists every code.

| Exit | Meaning |
|---|---|
| 0 | Success |
| 1 | The run finished but failed or was canceled |
| 2 | Usage error: bad arguments, or nothing to rank |
| 3 | No API key, or the key was refused. Run `supposing login` |
| 4 | Not found |
| 5 | The API refused the request. The error's `code` and `hint` say why |
| 6 | Could not reach the API, or it failed. Safe to retry |
| 7 | The run would spend money. Rerun with `--yes` to confirm |
| 8 | Not enough credit for the run's estimate. `supposing billing topup <dollars>`, lower the cost, or use your own OpenRouter key |
| 130 | Interrupted. A cloud run keeps going: `supposing runs watch <id>` |

```sh
supposing run ./proposals --rubric @rubric.md --provider mock --dry-run --json | jq .estimate.max_calls
supposing results 00000000-0000-0000-0000-000000000000 --json || echo "exit $?"
```
