# CLI

> For the complete documentation index, see [llms.txt](https://docs-stg.ringleader.dev/llms.txt).

> Every rl command and subcommand, with flags, arguments, and examples.


The `rl` CLI is how you drive Ringleader, from signing in to booting a cloud VM. This section
has three parts. [CLI commands](https://docs-stg.ringleader.dev/reference/cli/commands/) covers every `rl` command, with
its flags and examples. [Local API](https://docs-stg.ringleader.dev/reference/cli/local-api/) covers `rl api`, which sends one
request to the API on this computer. [Docs bundle](https://docs-stg.ringleader.dev/reference/cli/docs/) covers `rl docs`,
the documentation built into the binary. This page covers what every command shares: the command
groups, the common flags, the exit codes and how a namespace is chosen.

If you installed the [macOS native application](https://docs-stg.ringleader.dev/install/), the `rl` binary
is already on your `PATH` (symlinked to `/usr/local/bin/rl`). The
[Windows installer](https://docs-stg.ringleader.dev/install/) adds it to the machine `PATH`.

<div class="callout callout-note">
  <p class="callout-title">Note</p>
  <div class="callout-body">
    The CLI is named <strong><code>rl</code></strong>. The longer <code>ringleader</code> name remains available as a
permanent alias on every platform, so existing scripts keep working unchanged.
The two are interchangeable; this documentation uses <code>rl</code> throughout.
  </div>
</div>


## Command groups

Every resource kind gets a command group of the same name, and the grammar is
`rl <kind> <verb>` (e.g. `rl workstation get`, `rl secret create`). The generic
verbs and the cross-cutting `apply` mirror `kubectl`. Commands fall into a few
families:

- [Authentication commands](https://docs-stg.ringleader.dev/reference/cli/commands/authentication/): `auth login`, `auth logout`, `auth status`, `auth token`.
- [Service accounts](https://docs-stg.ringleader.dev/reference/resources/serviceaccount/): `serviceaccount create`/`trust`, the non-human identities CI signs in as.
- [Resource verbs](https://docs-stg.ringleader.dev/reference/cli/commands/resource-verbs/): `apply`, `diff`, and the per-kind `get`, `describe`, `create`, `edit`, `label`, `annotate`, `copy`, `delete`, `wait`.
- [Imperative creation commands](https://docs-stg.ringleader.dev/reference/cli/commands/imperative-creation/): the rich generators `namespace create`, `secret create`, `workstation create`, `configmap create` and `sshkey create`.
- [Workstation access](https://docs-stg.ringleader.dev/reference/cli/commands/workstation-access/): `workstation start`/`stop`/`restart`/`cordon`/`uncordon`/`release-finalizer`/`get-resolved-configuration`/`egress`, `shell`, `code`, `tmux`, `logs`, `troubleshoot`.
- [Workstation pools](https://docs-stg.ringleader.dev/reference/cli/commands/workstation-access/#rl-workstationpool): `workstationpool create`/`lease`/`usage` and `workstationpoollease renew`/`release`, workstations built from one template and leased out one at a time.
- [File transfer](https://docs-stg.ringleader.dev/reference/cli/commands/workstation-access/#rl-file-cp--r-src-dst): `file cp`, moving files to and from a workstation.
- [Agent session commands](https://docs-stg.ringleader.dev/reference/cli/commands/agent-sessions/): `agentsession create`/`exec`/`send`/`chat`/`stop`/`resume`/`share` and the rest, which run coding agents on workstations.
- [Terminal session and worktree set commands](https://docs-stg.ringleader.dev/reference/cli/commands/terminal-sessions/): `terminalsession create`/`add-pane`/`upload`/`share`, `worktreeset create` and `workstation list-worktrees`.
- [Shares and access](https://docs-stg.ringleader.dev/reference/cli/commands/shares-access/): `workstation share`/`unshare`/`access`, `secret share`/`unshare`/`access`, `workstationpool share`/`unshare`/`access`, and `share show`/`enable`/`disable`.
- [Local bindings](https://docs-stg.ringleader.dev/reference/cli/commands/bindings/): `binding show`, `enable`, `disable` and `switch`.
- [URL open rules](https://docs-stg.ringleader.dev/reference/cli/commands/url-open-rules/): `urlopenrules default queue`/`history`/`approve`, what your computer does with the links that workstations ask to open.
- [SSH keys](https://docs-stg.ringleader.dev/reference/resources/sshkey/): `sshkey create`/`enable`/`disable`, forwarding a local key into workstations.
- [ConfigMap](https://docs-stg.ringleader.dev/reference/resources/configmap/): `configmap create`/`get`/`edit`, the text a config's `scripts`/`files` can reference.
- [Organization and OrgDomain](https://docs-stg.ringleader.dev/reference/resources/organization/): `org get`/`describe`/`create`/`edit`, the company your namespaces belong to.
- [Usage report](https://docs-stg.ringleader.dev/reference/cli/commands/usage/): `usage`, how long your workstations and Edge VMs ran and the model tokens and network bytes they used, per UTC day, as a table, JSON or CSV.
- [Daily usage summary](https://docs-stg.ringleader.dev/reference/cli/commands/usage-summary/): `telemetry on`/`off`/`status`, whether your computer sends Ringleader a small daily summary of counts while you are signed out.
- [Daemon and status](https://docs-stg.ringleader.dev/reference/cli/commands/daemon/): `daemon start`, `stop`, `restart`, `status` and `log-level`. The page also covers `rl status`, which reports the workstation providers this computer can use.
- [Local API](https://docs-stg.ringleader.dev/reference/cli/local-api/): `api`, which sends one request to the API the daemon serves on this computer.
- [Cached images](https://docs-stg.ringleader.dev/reference/cli/commands/images/): `image list` and `image delete`, the OS images cached on this computer.
- [Local runtime](https://docs-stg.ringleader.dev/reference/cli/commands/local-runtime/): `local-runtime create`/`status`/`delete`, the local container runtime your `docker` command talks to. Its `default-socket` form is in [Desktop application](https://docs-stg.ringleader.dev/reference/desktop-application/#let-tools-find-docker-at-the-default-socket).
- [Docs bundle](https://docs-stg.ringleader.dev/reference/cli/docs/): `docs`, the embedded, offline documentation bundle.
- [Terminal UI command](https://docs-stg.ringleader.dev/reference/cli/commands/terminal-ui-command/): `tui`, a full-screen dashboard over your resources (full walkthrough in the [Terminal UI](https://docs-stg.ringleader.dev/reference/tui/) section).

A few commands stand apart from the groups:

- `rl version` prints the CLI version and the version of the in-VM agent it expects on a
  workstation. `rl --version` and `rl -v` print the same.
- `rl version --check` first asks whether a newer client is available, then prints the
  version. It exits `1` if it cannot ask.
- `rl licenses` prints the license notices for the third-party software built into `rl`. The
  notices ship inside the binary, so it works offline.
- `rl completion <shell>` generates a shell completion script.

## Check for a newer version

A running daemon asks whether a newer client is available when it starts and then once
an hour, as `rl version --check` does. When the answer is yes, `rl version` and
`rl auth status` add a line such as
`a newer client is available: 0.48.0 (you have 0.47.1)`, and the desktop application's
[About page](https://docs-stg.ringleader.dev/reference/desktop-application/#about) says so too.

Each check carries this computer's device ID, its `rl` version, its operating system and its
CPU type. Where the check goes depends on whether you are signed in:

- Signed in, it goes to Ringleader, with your sign-in.
- Signed out, it goes to `https://app.ringleader.dev` with no credential. If you turned on the
  [Daily usage summary](https://docs-stg.ringleader.dev/reference/cli/commands/usage-summary/), the check
  carries that too. When the answer names a download page, the line about a newer client ends
  with that address.

To stop the signed-out check, set `RINGLEADER_CLIENT_UPDATE_URL=off` in the environment
the daemon and `rl` run in. `rl version --check` then reports that there is nothing to
check. A check while you are signed in ignores the setting.

## Install a newer version

While you are signed in on a Mac or a Windows PC, the line about a newer client ends
by telling you to run `rl upgrade`:

```bash
rl upgrade            # runs the installer with its window and waits until it ends
rl upgrade --silent   # asks for administrator rights once, then installs with no window
```

`rl upgrade` downloads this computer's installer from Ringleader and checks it
against the SHA-256 Ringleader lists. It refuses a download that does not match,
and deletes it. When this computer already runs the newest release, it says so and
downloads nothing.

- On a Mac, `rl upgrade` opens the installer, which asks for an administrator password,
  and waits until the installer closes. If the installer is already open, `rl upgrade`
  asks you to quit it first and downloads nothing. With `--silent`, it asks for the password first,
  through `sudo` in a terminal or the macOS password dialog otherwise, and then installs.
  Either way it ends by saying whether the new version is installed.
- On Windows, `rl upgrade` asks for administrator rights through the Windows prompt
  before it downloads anything. It then runs the installer with its window, or with none
  for `--silent`, and waits until the installer ends. The installer stops the `rl` you
  started while it replaces it, so `rl upgrade` waits from a copy of itself outside the
  install folder, and that copy prints the result. Your prompt may come back before that
  line.
- On Linux, `rl upgrade` names the Downloads page of the Ringleader console, where you can
  download the new `rl`.

Signed out, `rl upgrade` names a download page when it knows one, and installs nothing.

## Common flags

Most commands accept these flags:

| Flag | Description |
|------|-------------|
| `--home <dir>` | Data directory (default `$RINGLEADER_HOME`, else `~/.ringleader`). |
| `-n, --namespace <ns>` | Target namespace. Defaults to the namespace pinned on this device, else your primary origin's default namespace, else `local`. |
| `-A, --all-namespaces` | Operate across every namespace you can see. |
| `-o, --output <format>` | Output format: `table` (default for `get`), `yaml`, `json`, or `jsonpath='{.path}'`. |
| `--as <subject>` | Impersonate a subject (e.g. `user:alice`, `sa:builder`). Requires the right to do so. |

## Exit codes

| Code | Meaning |
|------|---------|
| `0` | Success. |
| `1` | Command error (the operation failed). |
| `2` | Usage or flag error. |
| `3` | `daemon status` only: no daemon is running (scriptable, like `systemctl`). |

## Namespaces and resolution

Your namespace is created the first time you sign in, not before, and the control
plane decides which one you land in. Working locally without signing in, you get
the reserved `local` namespace, which also holds the local container runtime.

When you omit `-n`, the CLI resolves the namespace in this order, highest first:

1. an explicit `-n` / `--namespace` on the command;
2. the namespace **pinned on this device** with `rl namespace use`;
3. your primary origin's `spec.defaultNamespace`, assigned at login;
4. the reserved built-in `local`.

### `rl namespace use [namespace]`

Pin the namespace that bare commands target on this device, so you stop typing
`-n` on every command. With no name, it reports the answer **and which rung of the
ladder produced it**.

```bash
rl namespace use team-a       # pin it
rl namespace use              # what do bare commands target, and why?
rl namespace use --unset      # drop the pin, follow the origin's default again
```

```text
$ rl namespace use team-a
namespace pinned to "team-a"

$ rl namespace use
team-a (pinned on this device)

$ rl namespace use --unset
namespace pin cleared; commands now target "platform" (from origin "cp1")
```

The part in parentheses matters. `local (the built-in default)` and
`local (pinned on this device)` are the same namespace for different reasons, and
only the first tells you that no login ever assigned you one.

| Flag | Description |
|------|-------------|
| `--unset` | Clear the pin and follow the origin's default again. |
| `--home <dir>` | Data directory. |

Notes:

- The pin is **device-local**. It never federates, and it survives `rl auth login`
  and `rl auth logout`, so a login cannot re-target a user who has chosen otherwise.
- It sits **below `-n`**, so a per-invocation override still wins.
- It works in standalone mode, where there is no origin at all.
- Only the *shape* of the name is checked. You can pin a namespace you cannot yet
  read; the next command reports an ordinary not-found that names it.
- Set and show are one verb, like `git config`. `rl ns use` is the same command.


## Pages in this section

- [CLI commands](https://docs-stg.ringleader.dev/reference/cli/commands/index.md): Every rl command, grouped by what it works on.
- [Local API](https://docs-stg.ringleader.dev/reference/cli/local-api/index.md): Send one request to the Ringleader API on this computer from a terminal or a script, with the same access every rl command has.
- [Docs bundle](https://docs-stg.ringleader.dev/reference/cli/docs/index.md): Print Ringleader's documentation to stdout, offline, ready to pipe into an AI assistant.

