# CLI reference

Every command and flag of rungent, the developer's command. The authoring commands that check a catalog and generate documents, keys and a branded CLI, rungent serve, and its exit codes.

`rungent`, from the package `rungent`, is the developer's command: it checks a catalog, generates
a host's documents, keys and branded CLI, and serves rungent for hosts in other languages. It needs
Node 22 or later (24 for `serve`). Your users' command, `rungent-cli` from `@rungent/cli`, and
every branded CLI built on it, are on [Use the CLI](use-the-cli.md).

```text
Usage: rungent <command> [args]
```

## Authoring commands

These are the `rungent` command's (`npx rungent …`). They work on an OpenAPI document and never contact a host. `--openapi` takes a JSON file or an
`http(s)` URL; `-o` (`--out`) writes to a file instead of stdout.

### `check`

```bash
rungent check --openapi <file|url> [--routes routes.txt]
```

Prints every catalog issue as `<where>: <message>` and exits 1 when there is any; otherwise prints
`ok: N operations` on stderr. The rules are in [x-rungent](x-rungent.md#validation-rules). `--routes`
lists the requests your UI makes, `METHOD /path` per line, and fails each one no operation serves;
mark a route only the browser needs with `# browser-only: <reason>`.

### `skill`, `llms`, `reference`, `docs`

```bash
rungent skill --openapi <file|url> --product <name> --url <url> [--guide guide.md] [--cli-command acme] [-o SKILL.md]
rungent llms --openapi <file|url> --product <name> --url <url> --summary <text> [-o llms.txt]
rungent reference --openapi <file|url> [-o reference.md]
rungent docs --openapi <file|url> --product <name> --url <url> --summary <text> [--guide f] [--cli-command c] -o <dir>
```

`skill` writes the agent skill rungent serves at `/skill.md`: frontmatter, your guide, how to connect,
the safety rules and the operation index. `llms` writes `llms.txt`; `reference` a Markdown
reference of every operation; `docs` all three into a directory.

### `keys generate`

```bash
rungent keys generate --kid rungent-2026-11 [-o rungent-2026-11.private.jwk]
```

Prints the public JWK, which your API pins, on stdout, and writes the private JWK, rungent's signing
key, to a new file with mode 0600 (default `<kid>.private.jwk`). It never overwrites a file and
never prints the private key. Both are portable Ed25519 JWKs that Node, Bun, Deno and workerd
import alike.

### `brand`

```bash
rungent brand --name acme [--host https://console.example.com] [--env-host VAR] [--env-token VAR] -o acme-cli [--npm-name @acme/cli]
```

Writes an npm package (`package.json`, `bin/acme.js`, `README.md`), depending on `@rungent/cli`,
whose bin `acme` runs `rungent-cli` under that name. Its users read [Use the CLI](use-the-cli.md); the variables it reads are named there for `acme`.

| Flag | Meaning |
|---|---|
| `--name` | Required: the command, lowercase letters, digits and `-`. |
| `-o`, `--out` | Required: the package's directory. |
| `--host <url>` | A preset host. Leave it out for a product customers host themselves. |
| `--env-host`, `--env-token` | The variables it reads. Default `<NAME>_HOST` and `<NAME>_TOKEN`, the name uppercased with `-` as `_`. |
| `--npm-name` | The package name. Default `<name>-cli`. |

To build the CLI into a program of your own, call `run(argv, {program?, host?, env?})` from
`@rungent/cli`; it answers the exit code. This is what `brand` writes.

## `serve`

```bash
rungent serve
```

Runs rungent as an HTTP server beside a host, configured from `RUNGENT_*` environment variables, until
`SIGTERM` or `SIGINT`. A missing or invalid variable exits 2 with its name. Every variable is in
[Configure](configure.md#where-each-setting-lives).

## Exit codes

| Code | Meaning |
|---|---|
| `0` | OK. |
| `1` | `check` found issues, or a command failed. |
| `2` | Usage: an unknown command or flag, a missing or invalid value, or, for `serve`, a missing or invalid variable. |
| `4` | Network: an `--openapi` URL cannot be fetched, or answered an HTTP error. |
