# CLI overview

> The nexus CLI does everything Nexus UI does, for people, scripts and agents.

The `nexus` CLI is one client of the Nexus API, like Nexus UI. Every command takes `--json`, exits with a meaningful
code and retries its writes safely, so scripts and AI agents can drive it as well as people.

## Install

```sh
curl -fsSL https://api.nexus.inc/install.sh | bash
```

Needs curl. The installer downloads the CLI from Nexus Gateway, checks its SHA-256 checksum, and installs it to
`~/.nexus/bin/nexus` (`NEXUS_INSTALL_DIR` changes the folder). It installs the native binary for your machine when
Gateway publishes one. Otherwise it installs the JavaScript CLI, which needs Node.js 22.6 or later. Then
[`nexus update`](/docs/cli/update) keeps it current, and `nexus update --rollback` goes back one version.

## Grammar

```sh
nexus <command> [subcommand] [arguments] [options]
nexus <product> <verb> [capability] [--input value]
```

Gateway's own commands are fixed: `auth`, `keys`, `team`, `members`, `spend`, `billing`, `chat`, `pages`, `skills`,
`routines`, `agent`, `claude`, `sessions` and the others `nexus help` lists. Product commands are
discovered from the products registered on your Gateway: `nexus help` lists them, and `nexus <product> --help` shows a
product's capabilities, verbs and inputs.

## Output

On a terminal the CLI uses color, symbols and a spinner while it waits; piped, or with `NO_COLOR` or `--no-color`, it
prints plain text. With `--json`, it prints only JSON on stdout, and `nexus help --json` lists every command, flag
and exit code for scripts and agents. The exit codes are below; `nexus claude` and `nexus codex` exit with the agent's own
code.

## Global options

| Option | Meaning |
| --- | --- |
| `--json` | Print only JSON on stdout; errors go to stderr as {"error": {"message", "hint"}} |
| `--no-color` | Plain text on a terminal too (also NO_COLOR) |
| `--help` | Help for a command (also -h) |
| `--version` | The CLI's version (also -v; with --json: {"version"}) |

## Environment

| Variable | Meaning |
| --- | --- |
| `NEXUS_URL` | The Gateway URL when none is saved (the installer's wrapper sets it; default https://api.nexus.inc) |
| `NEXUS_GATEWAY` | One command against another Gateway, with its own sign-in (nexus auth login once per Gateway); the saved one stays the default |
| `NEXUS_CONFIG` | The CLI config file (default ~/.nexus/factory/config.json) |
| `NEXUS_UI_URL` | Where the CLI's Nexus UI links point, for the Gateway NEXUS_URL names (any Gateway when NEXUS_URL is unset) |
| `NEXUS_TEAM` | The team runs and agent sessions are attributed to (--team wins) |
| `NEXUS_CLAUDE_AUTH` | Gateway or subscription: the route nexus claude takes in this shell (a flag wins; unset: your saved route, nexus agents) |
| `NEXUS_CODEX_AUTH` | Gateway or subscription: the route nexus codex takes in this shell (a flag wins; unset: your saved route) |
| `NEXUS_ANTIGRAVITY_AUTH` | Subscription, its only route: the route nexus agy takes in this shell (Antigravity runs on your Google AI plan) |
| `NEXUS_CURSOR_AUTH` | Subscription: run nexus cursor-agent on your Cursor plan |
| `NEXUS_RECORDINGS_DIR` | Where nexus recordings reads screen recordings (default: Nexus for Mac's folder) |
| `NEXUS_DESKTOP_BIN` | The binary nexus recordings frames runs (default: Nexus.app's nexus-desktop, else Nexus GPUI's nexus-desktop-gpui) |
| `NEXUS_DESKTOP_SOCKET` | The socket nexus sessions reaches Nexus for desktop through (default: the app's, in $XDG_RUNTIME_DIR or its data folder) |
| `NEXUS_NO_UPDATE_CHECK` | 1: never check for a newer CLI (also off with --json, in CI and when stdout is not a terminal) |
| `NO_COLOR` | Plain output on a terminal too |
| `NEXUS_DEBUG` | 1: print the stack trace with an error |

## Exit codes

| Code | Meaning |
| --- | --- |
| 0 | Success |
| 1 | Failure: Gateway refused or failed the request, a run failed, you are not signed in, or Gateway could not be reached |
| 2 | Usage error: an unknown command, a missing argument or an invalid flag |
