# CLI commands

> Every warmbuild command: what it does and the flags you will reach for.

Source: https://warmbuild.dev/docs/cli/

Every command of the `warmbuild` CLI, in the order you meet them. `warmbuild <command> --help` lists all of a command's flags.

- Commands that read CI data take `--repo owner/name` (default: this checkout's GitHub repository) and need a sign-in: `warmbuild login` on a Mac, the job's OIDC token on CI.
- Most commands take `--json`.
- Exit codes are the same for every command: `0` done, `1` failed, `2` wrong command line, `124` gave up waiting ([details](https://warmbuild.dev/docs/agents/#scripting)).

## On a Mac

| Command | What it does |
| --- | --- |
| `login` | Signs in with GitHub: open the link, enter the code. The read-only token stays in the macOS Keychain. `--tenant <account>` picks the account when you belong to several; `--write` asks for a token that may upload (account admins only). |
| `start` | Starts the cache for local builds. Run it in the repository: it maps every worktree, gives the Xcode app `XCODE_XCCONFIG_FILE`, and keeps running after a reboot. `--add-to-profile` adds the `XCODE_XCCONFIG_FILE` line to your shell profile without asking; `--no-modify-profile` only prints it. `--quiet` prints one line. |
| `status` | Is the cache on, who is signed in, and the last build's hits and misses, per worktree. Exits `1` when the cache is off. |
| `doctor` | Checks why builds miss: the server, the sign-in, the xcconfig, DerivedData under `/tmp`, the Xcode version, CI's last fill and the latest release. Prints the fix for each check that fails. `--offline` skips the checks that need the network. |
| `wait` | Waits until the cache serves builds, for scripts: `warmbuild wait && xcodebuild …`. `--timeout` in seconds (default 900). |
| `run -- <command>` | Runs one command, such as `xcodebuild`, with the cache, and ends with what the cache saved. Exits with the command's own code. |
| `stop` | Turns the cache off. Builds then run without it. |
| `update` | Installs the latest release now. The cache also does this daily, unless `~/.warmbuild/config.json` has `"autoUpdate": false`. |
| `gc` | Shrinks the local store in `~/.warmbuild/store` to its cap now (10 GiB by default, or `--max-size 20G`). Never touches Xcode's DerivedData. |
| `link` | Points `/tmp/warmbuild/src` at this checkout, for `#filePath` and the debugger, and maps its worktrees. `start` does this for you. |

## For the team

| Command | What it does |
| --- | --- |
| `init` | Once per repository, by its owner. Writes an optional xcconfig include and a build step that, on Macs without Warmbuild, prints one warning with the install line. Then prints the `git commit` command to run. |
| `invite` | Prints a message for the team chat: the install line and what it does. |

## Reading CI

The same data as the dashboard's CI report, in the terminal. Agents use these most.

| Command | What it does |
| --- | --- |
| `builds` | Recent CI jobs: duration, cache hits and misses, test results. `--branch main`, `--limit`. |
| `report` | One job: where its time went, targets by compile time with hits and misses, the slowest tasks and tests. `--job <id>` from `builds` (default: the newest). |
| `findings` | The dashboard's findings for the repository, each with the time it would save per job. |
| `why-miss [target]` | A target's hits and misses across recent jobs, and what changed since the last job without misses: Xcode, runner, ref, event or commit. Without a target, it explains the newest job's costliest miss. |
| `insights` | Which module recompiles most and pulls others with it, and which of its parts could move into a package. `--local` reads this checkout's git history. |
| `tests` | The tests your change can reach, as `-only-testing` arguments for `xcodebuild test`. `--changed` includes uncommitted files; `--format swift` prints a `swift test --filter` pattern. With `--slow`, `--flaky` or `--failing`: those tests from recent CI jobs. |

``` title="Terminal"
xcodebuild test -scheme App $(warmbuild tests --changed)
warmbuild why-miss
```

## Run by the Action

The GitHub Action and the Mac's LaunchAgent run these. You rarely need them yourself.

| Command | What it does |
| --- | --- |
| `ci-report` | Reads the job's build logs and result bundles and writes the CI report and the job summary. |
| `test-cache` | `plan` leaves out test targets that passed before with the same products; `step` skips a step whose inputs passed before; `keys` prints the keys. |
| `packages` | `restore` puts saved Swift packages back before `xcodebuild` resolves; `save` stores them once per set of pins. |
| `typecheck` | `plan`: which targets a pull request times type-checking in. |
| `flags` | Prints the `xcodebuild` settings the cache needs, one per line. |
| `daemon`, `supervise`, `serve` | The cache server: under the LaunchAgent, restarted when it crashes, or in the foreground. |
| `selftest` | Asks the server on a socket for one lookup and prints `ok` when it answers. |
