# CLI

> The bareci command line: sign-in, init, runs, the Gate, findings, previews, spend, flows, the local MCP server and docs, with flags and exit codes.

Source: https://bareci.com/docs/cli

`bareci` is the command line for BareCI, for agents first and people second.

## For agents

Every command takes `--json` and then prints one JSON object on standard output whose `next` field names the next action. Progress and streamed output go to standard error.

Exit codes: the command's own for `run`; 0 or 1 for the rest (`ready` exits 0 when the pull request is ready); 2 for a usage error; 8 when `wait` times out. `mcp` speaks MCP on standard input and output instead, and exits 0 when its input ends.

## Commands

| Command                                                                 | What it does                                                                                                                                               |
| ----------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bareci login [--scope "read run operate"]`                             | Sign in with a one-time code in the browser. The token goes to the OS keychain, else a file only you can read                                              |
| `bareci logout`                                                         | Revoke this machine's token and forget it                                                                                                                  |
| `bareci whoami`                                                         | Who the token belongs to, its organisations and scopes                                                                                                     |
| `bareci init [--dry-run] [--no-pr]`                                     | Set the repository up and open a pull request. See [Getting started](https://bareci.com/docs/getting-started)                                                                |
| `bareci doctor`                                                         | Check every step of `init` and print the one fix for each failure                                                                                          |
| `bareci run [flags] [-- <command…>]`                                    | Run a command on a fresh machine from this worktree. See [Runs](https://bareci.com/docs/modules/runs)                                                                        |
| `bareci runs <get\|logs\|cancel\|artifacts> <id>`                       | Look at or stop a run                                                                                                                                      |
| `bareci ready [--pr N] [--wait]`                                        | The Gate's verdict with every reason and its fix. See [Gate](https://bareci.com/docs/modules/gate)                                                                           |
| `bareci wait --until <condition> [--pr N] [--timeout S] [--since V]`    | Wait, without polling GitHub, until the checks finish, it is ready, queued, merged, closed or changed. See [Wait](https://bareci.com/docs/agents/wait)                       |
| `bareci findings [list\|fix <id>\|rebut <id> --reason …\|dismiss <id>]` | Every reviewer's findings, and the loop. See [Reviews](https://bareci.com/docs/modules/reviews)                                                                              |
| `bareci resolve <id> [--sha <commit>\|--reason …]`                      | Answer a finding: fixed in a commit (default `HEAD`), or disputed with a reason. The same as `findings fix` and `findings rebut`                           |
| `bareci review [--reviewer codepanel]`                                  | Ask the reviewers to review the head now                                                                                                                   |
| `bareci previews [list\|get <id>\|stop <id>\|close\|usage]`             | The repository's previews. See [Previews](https://bareci.com/docs/modules/previews)                                                                                          |
| `bareci spend [--org <login>] [--month YYYY-MM]`                        | The organisation's spend this month: by meter, machines by size and market, Flows by model, savings. See [Spend](https://bareci.com/docs/modules/spend)                      |
| `bareci preview --port <n> [--ttl 2h] [-- <command…>]`                  | In a job on a BareCI machine: start the app and keep the machine serving it. See [Previews](https://bareci.com/docs/modules/previews)                                        |
| `bareci flows run [files…] [--strict\|--record]`                        | Run Flows. See [Flows](https://bareci.com/docs/modules/flows)                                                                                                                |
| `bareci mcp [--project-flows]`                                          | A local MCP server on standard input and output: the hosted tools with this machine's token, and the live browser tools. See [MCP setup](https://bareci.com/docs/agents/mcp) |
| `bareci docs [topic]`                                                   | These docs, offline                                                                                                                                        |

## Flags most commands take

| Flag                | What it does                                    |
| ------------------- | ----------------------------------------------- |
| `--json`            | One JSON object on standard output, with `next` |
| `--repo owner/name` | The repository (default: the `origin` remote)   |
| `--pr N`            | The pull request (default: this branch's)       |
| `--api <url>`       | The API (default `https://api.bareci.com`)      |
| `--help`            | Help for the command                            |

## Environment

| Variable              | What it does                                        |
| --------------------- | --------------------------------------------------- |
| `BARECI_TOKEN`        | Use this token instead of the stored one            |
| `BARECI_URL`          | The API, like `--api`                               |
| `BARECI_KEYRING=file` | Store the token in a file instead of the keychain   |
| `BARECI_CONFIG_DIR`   | Where the CLI keeps its configuration               |
| `BARECI_NO_BROWSER`   | Print the sign-in link instead of opening a browser |
| `BARECI_FLOWS_MCP`    | The live browser host `bareci mcp` starts           |
