# CLI reference

Source: https://www.zerd.si/docs/cli

```text
zerd [OPTIONS] [PROMPT]
```

Run `zerd` alone to start an interactive session. Add a `PROMPT` and zerd does that one task, then exits:

```bash
zerd                                   # interactive
zerd "fix the failing test"            # one shot, then exit
```

## Options

| Flag | What it does |
|---|---|
| `-m`, `--model <id>` | Model id. Overrides config. Interactive sessions otherwise start on the model you used last |
| `--approval <mode>` | `on-request`, `on-failure`, `auto`, `auto-edit`, `never`, `yolo` or `plan`. Overrides config |
| `--effort <low\|medium\|high>` | Reasoning effort. Codex models only, others ignore it |
| `-c`, `--cwd <dir>` | Working directory |
| `--add-dir <dir>` | An extra directory the agent may use besides the working directory. Repeatable |
| `--trust` | Trust this project's `.zerd/config.toml` (hooks, verify commands, approval) |
| `--challenge` | Have a second model argue against risky requests first. Always on interactively |
| `--pi`, `--no-pi` | Pi mode on or off for this run. Overrides `pi_mode` in config. See [Modes](/docs/modes) |
| `--continue` | Continue the newest saved session that ran in this folder |
| `--resume <id>` | Continue a saved session by id. The id is shown when you exit, and `/sessions` lists them |
| `--parallel` | Let a planner split the request into parallel workers. Needs a prompt |
| `--graph <tasks.json>` | Run a task graph from a JSON file. Implies `--parallel` |
| `--apply [true\|false]` | After a parallel run, fast-forward the integrated result into a clean checkout. Default true |
| `--json` | Print agent events as JSON lines instead of the UI. Needs a prompt |
| `--rpc` | Read JSON commands on stdin and write events on stdout, for editors and scripts |
| `--report <file>` | Write run metrics as JSON |
| `-h`, `--help` / `-V`, `--version` | Help and version |

## What scripted runs change

A run counts as scripted when you pass a prompt, `--json` or `--rpc`. In that case:

- Nobody is there to approve things, so the default approval becomes `auto-edit`. Running commands still needs `--approval auto`.
- Checks run on their own after edits, with repair rounds.
- The challenger stays off unless you pass `--challenge`.
- Learning from corrections is off, so CI never writes into your repo.
- A missing API key stops the run with an error instead of a warning.
- The last-used model is not read or saved.

The exit code is `1` when the run ends `failed` or `verification_failed`, or could not run at all. Otherwise it is `0`, so CI can fail the build on it.

## Subcommands

### `zerd setup`

Walks you through first-run setup: pick where models come from, save and test a key, pick a model and an approval mode. It starts by itself when no model is usable. Set `ZERD_NO_SETUP=1` to stop that.

### `zerd doctor`

Checks your setup and prints one line per problem, each with its fix. Exits 1 if something blocks. See [Troubleshooting](/docs/troubleshooting).

### `zerd update`

Checks GitHub for the latest release and, if it's newer, installs it into the folder the current `zerd` lives in. zerd also checks by itself once a day when you open it in a terminal, and asks `Update now? [Y/n]` before the session starts. Yes installs and restarts on the new version. One-shot runs, `--json`, `--rpc` and builds from source never check. Inside a session, `/update` installs the new version quietly; it takes over the next time you start zerd. Set `ZERD_NO_UPDATE_CHECK=1` to turn the launch check off.

### `zerd graph <action> [name] [to|direction] [depth]`

Query the code graph yourself to see what the model would see. The actions are: `trace`, `symbol`, `find`, `callers`, `callees`, `impact`, `importers`, `imports`, `blast`, `tests`, `neighbors`, `path`, `community` and `stats`.

```bash
zerd graph callers parse_invoice
zerd graph impact charge
zerd graph stats
```

With no action, `zerd graph` indexes the repo and asks a few questions about folders to ignore. See [Code graph](/docs/code-graph).

### `zerd learn-import --repo <dir> [--deep] [--reweigh] [--apply]`

Pulls rules and edit history out of your old Claude Code sessions. Without `--apply` it is a dry run, so you can preview first.

See [Memory and undo](/docs/memory-and-undo).

### `zerd insights [--days N] [--json]`

Reads zerd's own trace files and reports, per model, failed calls, retries, speed, cache hit rate, bad tool calls and how often the loop had to step in. It covers the last 7 days by default.

### `zerd telemetry [on|off|status]`

Telemetry is off unless you turn it on, either here or by answering yes in `zerd setup`. When it is on, zerd writes one small record after each finished request so the harness can be tuned on more than one person's runs.

It never slows a request down: the record is a one-line append to a local file, and a background task posts whatever is waiting in a single batch. If you are offline, the records wait and go out later.

Sent: a random id for the install, the zerd version, OS, model name, approval mode, how the request ended, and counts (rounds, seconds, token totals, the largest prompt, files changed, calls and errors per built-in tool, how often the loop stepped in).

Never sent: what you typed, file names, commands, error text or code. MCP tools and your own tools are counted as "other" so their names stay with you.

`zerd telemetry off` stops it, deletes the id and throws away anything still waiting to be sent. `zerd telemetry status` shows the current choice. `DO_NOT_TRACK=1` or `ZERD_TELEMETRY=0` also switches it off.

### `zerd probe-models [--json <file>]`

Sends a tiny request to every model your gateway key can list and prints status and latency. It uses the gateway's `API_KEY` and `BASE_URL`.
