An AI-native command-line tool for operating Rancher Manager.
A greenfield rewrite of the legacy Rancher CLI, built so a coding agent in a terminal harness (Claude Code, Codex, Gemini CLI, GitHub Copilot CLI and others) can operate Rancher like any other user - and operators get the same commands with readable table output.
Note
Experimental. rancher-cli is under heavy development and is considered experimental. Commands, flags, output and stored formats can change between releases, and the notes of each release list the changes. Use it with caution and report issues through the issue forms (see CONTRIBUTING.md for what to include). We appreciate your feedback.
- Structured, versioned output - nearly every command prints one JSON
document under
-o json(YAML under-o yaml), versioned ascli.rancher.io/v1; the default is readable text for an operator at a terminal. Five commands are exceptions, because a shell or kubectl reads their output in its own format - details: REFERENCE.md. - Self-describing -
rancher schemalists every command, flag, contract, and gate; an agent learns the CLI from it without reading the docs. - Machine-readable errors - the same document as a success, under
-o json/-o yaml, with hints for the next step; a short text message otherwise. - Distinct exit codes - scripts and agents act on the exit code without parsing any output.
- Dry-run/apply safety - a preview computed by the server before every change, with explicit gates for destructive changes.
Install · Quickstart · Commands · Reference · Migration · Feedback
rancher-cli works with Rancher 2.14 and later (details). Downloads: releases. Release notes are in each release's description.
curl --proto '=https' --tlsv1.2 -fsSL https://raw.githubusercontent.com/rancher/rancher-cli/main/install.sh | sh
On Windows (PowerShell 7 or Windows PowerShell 5.1):
irm https://raw.githubusercontent.com/rancher/rancher-cli/main/install.ps1 | iex
No GitHub account or token is needed. The installer checks both binaries
against SHA256SUMS before it installs them. To check the download before it
runs, or to install without the script, see
REFERENCE.md and
manual download.
The Linux and macOS installer puts rancher and its credential helper in
~/.local/bin; the Windows installer puts them in
%LOCALAPPDATA%\rancher-cli\bin (no root or admin rights needed, no
profile or PATH edits; the installer prints the PATH line if needed).
Checksums are always verified; build provenance is verified when a gh
CLI 2.68.0 or newer that is logged in is available. Each binary also has a
software bill of materials (SBOM) in SPDX format, with a signed attestation.
The release holds each attestation as a Sigstore bundle file, which cosign
can verify without a GitHub login: see
manual download. The manual Windows steps are in
REFERENCE.md as a fallback. Install internals and
manual download: REFERENCE.md.
Options
Flags (with either piped command: … | sh -s -- --version <tag>):
--version <tag> installs a specific release
(or set the environment variable RANCHER_CLI_VERSION; the flag takes
precedence), --pre selects the newest prerelease (on Linux and macOS it
needs jq or python3 on PATH), --bin-dir <dir> sets
the bin directory (or set the environment variable
RANCHER_CLI_INSTALL_BIN_DIR), --verify-attestation makes provenance
verification mandatory, --dry-run prints the release, the files it would
download and the directories it would use, without writing anything, -q
suppresses progress notes. The installer uses a GitHub token only when
GH_TOKEN or GITHUB_TOKEN is set or gh is logged in; none is needed.
PowerShell takes the same options as parameters - -Version <tag>,
-Pre, -BinDir <dir>, -VerifyAttestation, -DryRun, -Quiet - and
reads the same environment variables. A piped command cannot pass
parameters; wrap the installer in a script block instead:
iex "& { $(irm https://raw.githubusercontent.com/rancher/rancher-cli/main/install.ps1) } -Pre"
Update, rollback & uninstall
To update, rerun the install command - it looks up the newer release
and switches to it atomically. To downgrade or roll back, rerun with
--version <tag> (-Version <tag>).
Uninstall on Linux and macOS: remove the rancher and
rancher-credential-vault symlinks from your bin directory, and remove
~/.local/share/rancher-cli and
~/.config/rancher-cli/install-receipt.json. On Windows: remove
%LOCALAPPDATA%\rancher-cli, which holds the bin Windows directory link
(NTFS junction) and the version directories; remove
%APPDATA%\rancher-cli\install-receipt.json; and remove the PATH entry
you added.
The login token is a Rancher
API key
in its access-key:secret-key form.
# Log in (the token is a Rancher API key in access-key:secret-key form)
rancher auth login prod --url https://rancher.example.com --default
# (prompts for token, or pass via --token-stdin; --default makes prod the
# default profile, which a login never does without it)
# Verify connectivity + credentials
rancher auth status
# Read clusters (shows the cluster id for the next step)
rancher get clusters
# Create a project: preview the change, then apply
rancher create project web --cluster c-m-abc123 --dry-run
rancher create project web --cluster c-m-abc123 --apply
# See what the CLI offers: table of contents, one command, one kind
rancher schema
rancher schema delete project # one command: contract + gates
rancher schema pod # one kind: aliases, routing, verbs
rancher schema --search kubeconfig # find commands by substring
rancher schema --all -o json # full manifest, for tools: write it to a file
Provisioning a cluster (machine configs, cloud credentials, waiting for the cluster to be ready): REFERENCE.md.
skills/rancher/SKILL.md teaches a coding agent
to operate this CLI: logging in, finding commands, the dry-run and apply
steps, structured errors, and waiting for resources. It follows the open
Agent Skills standard - install it into a
coding-agent harness such as Claude Code, Codex, or GitHub Copilot CLI:
rancher skill install
or point any other coding-agent harness at the whole skill directory: it
needs SKILL.md and the files in references/.
| Group | Commands |
|---|---|
| Authentication | login, logout, status, and the exec plugin (auth get-token) |
| Servers & configuration | servers, config file, completion settings |
| Create | project, namespace, secret, resource -f, token, kubeconfig, cluster, machine-config, cloud-credential |
| Projects & access | project namespace membership, grant, revoke |
| Cluster scaling & autoscaling | machine-pool scale, cluster-autoscaler set/clear/pause/resume, Kubernetes version upgrade, upgrade strategy (cluster set-upgrade-strategy), etcd snapshot (cluster save-etcd-snapshot), etcd snapshot restore (cluster restore-etcd-snapshot) |
| Nodes | drain a node (node drain) or stop a drain (node stop-drain); Rancher runs the drain, and get management-node shows its state |
| Read & inspect | cloud credentials, Kubernetes versions, composite cluster/pod/deployment/project/user reads, images, usage, charts |
| Apps | install a chart from a ClusterRepo as a Helm release (app install), upgrade one (app upgrade), uninstall one (app uninstall); Rancher runs Helm, previews come from server reads |
| Extensions | add one of the two Rancher extension repositories (extension add-repository), list what the ClusterRepos offer and what is installed (extension list), install an extension (extension install), upgrade it (extension upgrade), uninstall it (extension uninstall) |
| Access | who can do what, as the cluster's authorizer answers it (access can, access list, access who-can, access explain), which clusters a subject can reach through Rancher's proxy (access clusters), and which projects a subject can see and is a member of (access projects) |
| Logs & support | logs of Rancher components, support bundle |
| kubectl integration | kubeconfig that uses the exec plugin, legacy rancher token command |
| Telemetry | status, on, off, reset, show and upload for local usage recording; recording is on by default, and release builds send no event |
| Discovery & tooling | schema, shell completion, agent-skill install |
With a kubeconfig that authenticates through the exec plugin and no stored rancher auth login credential, the plugin asks you to log in once per cluster by default; rancher config set-token-reuse on lets the plugin keep one login credential per server instead (see REFERENCE.md, Token reuse for kubectl).
A kubeconfig from rancher kubeconfig records the config directory in use when it was created. kubectl then runs the exec plugin with that config directory from any shell or working directory. The kubeconfig works for this user on this machine only, and if the directory moves, the kubeconfigs that name it must be created again. It also names, with --user-id, the Rancher user its stored login belongs to. The exec plugin then refuses to give kubectl another user's token. The kubeconfigs Rancher writes name that user too, with --user-id and no --name, and the auth config used for its login, with --auth-provider: the plugin then uses the stored login that records that user (and auth config), gives kubectl only tokens created through that auth config, and, with no --cluster, creates a token that is not tied to one cluster. A stored login that has no auth config recorded takes it from the first token the plugin creates from that stored login for a call that names one, and rancher kubeconfig writes --auth-provider once the stored login has one. --exec-command names the binary kubectl runs when rancher is not on its PATH.
Composite reads (inspect *, images, usage) return what you can
see: each section you cannot read in full is named in the data.degraded
field, and each entry has one warning. The command still exits 0.
Generated get/patch/delete commands cover the 73 kinds that
rancher schema lists (delete only for the kinds that can be deleted).
The full catalog is COMMANDS.md, and rancher schema lists
the same for the version you have installed. Per-kind verb rules:
REFERENCE.md; project scoping:
REFERENCE.md.
Every request to Rancher carries a User-Agent that names the CLI version and platform, and whether the process ran inside an agent session, as kubectl's exec plugin or in CI. An administrator can see it in Rancher's audit log when that log is on at level 1 or higher (it is off by default); nothing in it affects which credential is used or grants access. What it holds and where it shows up: REFERENCE.md.
Every command that changes the server runs these steps, in order:
--dry-runpreviews the change (the action, the fields the command sets or changes, and warnings) and changes nothing. The preview succeeds only if the server-side dry-run succeeds. The last line of the text preview names every flag the apply needs, and the JSON preview lists them asdata.gates.--applyexecutes. A command that changes the server, run with neither--dry-runnor--apply, is refused withCONFIRMATION_REQUIRED, and the refusal names the exact flags required.--yesis required together with--apply(never alone) when the change is destructive: everydeleteandrevoke, writes to sensitive kinds, and creating secrets that are shown only once (create token,create kubeconfig).--allow-deprecatedis also required for a write whose stability isdeprecated.- Updates and deletes carry a
resourceVersion
precondition taken from their own dry-run preview: if the resource
changes between that preview and the apply, the change fails (exit
5) instead of overwriting it. A--dry-runrun on its own is a preview only; the later--applyrun takes a new dry-run preview and sets its precondition from the resource as it is at that time. Creating an object has no precondition (there is no existing object to check). When your role grantsdeleteand notget, a delete carries a uid precondition instead, from the response to its dry-run delete: it fails if the object was deleted and created again, and not if the object changed. Its preview says so (uid,conflictDetection: false, a warning), and the command does not wait for the object.delete project,delete token,delete kubeconfig, the day-2 operation deletes and the delete of the token the command uses still needget.
A delete also waits until the object is gone, for up to 5 minutes by
default (--timeout). --wait=false returns once the server accepts the
request and prints deletion started.
Every delete asks Kubernetes to delete the object's dependents in the
background (propagationPolicy: Background, the default of kubectl delete),
whatever the kind: rancher delete job <name> deletes the Job's pods too,
shortly after the Job is gone. The wait above ends when the Job is gone, not
when its pods are.
Rule of thumb: --apply means "yes, make the change"; --yes means "yes, I
saw it is destructive".
Why it works this way: the CLI is designed for coding agents first. Intent is stated in machine-checkable flags, never inferred, and there is no interactive "are you sure?" prompt - a prompt cannot be scripted, retried, or audited. Every refusal is a structured error that names exactly what is missing. An agent (or a script) can then add the missing flags on purpose or stop.
Note
--dry-run runs the
server-side dry-run
and needs the same RBAC verb
as the write - read-only credentials get an RBAC error. That means the
write would be denied, not that dry-run is broken.
Most commands carry a contract (public | internal) and a stability
(stable/beta/deprecated), shown in the schema manifest.
All the steps and gates in full: ARCHITECTURE.md.
Read-only mode: REFERENCE.md.
Nearly every command prints one JSON document per run under -o json,
versioned by apiVersion, that agents can depend on (exceptions:
REFERENCE.md):
{
"apiVersion": "cli.rancher.io/v1",
"kind": "LoginResult",
"data": { "server": "prod", "url": "https://rancher.example.com" },
"warnings": []
}Formats: -o table (default) · wide · json · yaml · name ·
template=<go-template>. Full format semantics:
REFERENCE.md.
-
Errors have the same shape as a success: under
-o json/-o yamlthey are the same document, with the error object underdata, and any warnings go in the document's ownwarningsarray. Use-o jsonto get the document, errors included:{ "apiVersion": "cli.rancher.io/v1", "kind": "Error", "data": { "error": { "code": "NOT_LOGGED_IN", "message": "...", "hint": "rancher auth login 'prod'", "retryable": false } } }Every other format, including the default, prints a short text message on stderr instead:
error (NOT_LOGGED_IN): ... hint: rancher auth login 'prod' -
Exit codes (act on the code without parsing output):
0ok ·2usage/validation ·3auth ·4not-found ·5conflict/precondition ·6RBAC ·8lock-timeout ·9Prime required ·10TLS trust ·11capability unsupported ·14credential store unavailable ·130interrupted ·1generic; every code with its meaning: REFERENCE.md. Ctrl-C or a termination signal ends the command withINTERRUPTED, exit130for either; a second signal forces a command that did not stop on the first to exit with 128 plus that signal's own number (130Ctrl-C,143SIGTERM). -
Discovery:
rancher schema -o jsonis the overview - each command group with its description and command count, the commands that belong to no group, kinds, and exit codes;rancher schema --all -o jsonis the complete manifest, and the single source for contract and stability.rancher schema <command|kind|group>shows only that command, kind or group.
- File:
${XDG_CONFIG_HOME:-~/.config}/rancher/config.yaml(mode0600):servers,currentServer(the name of the active server),credentialStore,completion,readOnly,telemetry. Credentials are not stored here. - Directory precedence:
--config <dir>>RANCHER_CLI_CONFIG_DIR>$XDG_CONFIG_HOME/rancher>~/.config/rancher. - Credential store: OS keychain or a
0600file; custom backends plug in as credential helpers (CREDENTIAL_HELPERS.md). The config directory records the credential store its first login used; change it withrancher auth login <name> --credential-store keychain|file|auto|exec:<name>. Changing the credential store applies only to that entry's credential, and requires the other entries to be logged out of the credential store you are leaving first. How the credential store is chosen, how the CLI checks the keychain, and the credential store pin: REFERENCE.md. - Environment variables: the full table, with each variable's flag and how the variable and the flag interact, is in REFERENCE.md.
- Migration: config and credentials are not imported - run
rancher auth loginonce per server.
source <(rancher completion bash) # ~/.bashrc
source <(rancher completion zsh) # ~/.zshrc
rancher completion fish > ~/.config/fish/completions/rancher.fish
rancher completion pwsh | Out-String | Invoke-Expression # add to $PROFILE
Completion is offline-only by default - it never touches the network and
offers no candidates instead of an error. Live resource-name completion
is an opt-in: rancher config set-completion --network=true. Minimum shell
versions, what completion does offline, and details of live completion:
REFERENCE.md.
- COMMANDS.md - the command catalog, by group (operators).
- REFERENCE.md - platforms and credential stores, install internals, completion, scoping, kinds and verbs, cluster provisioning, composites, access management, diagnostics, output formats, read-only mode, server-version support, kubectl integration, TLS (operators, automation authors).
- ARCHITECTURE.md - layer map and design decisions (readers of the source).
- CREDENTIAL_HELPERS.md - credential-helper protocol and examples (integrators).
- MIGRATING.md - moving from the legacy Rancher CLI (operators).
- skills/rancher/SKILL.md - the agent skill (agents and their authors).
Requires the Go version set in go.mod (1.27); with the default
GOTOOLCHAIN=auto, go downloads it:
make build # bin/rancher
make test # go test -cover ./... (-race everywhere but the source scans and the cache model)
make validate # gofmt + vet + lint + tests (race detector except the source scans and the cache model); the commit gate
make e2e # end-to-end suite against an envtest-backed fake Rancher
make e2e-fidelity # verify recorded fidelity goldens against a real Rancher in Docker
make e2e-fidelity-downstream # verify downstream-cluster fidelity goldens against your own Rancher
make # the full ci pipeline (build + validate)
make e2e-fidelity boots the pinned rancher/rancher image, imports a pinned
rancher/k3s container as a downstream cluster (~7-9 min in all), and
checks that the fake Rancher the e2e suite runs against still behaves
like the real one, downstream proxy behavior included; make e2e-fidelity-update re-records those goldens. make e2e-fidelity-downstream
compares a Rancher you already run, with a downstream cluster already
registered, against the same downstream goldens: point it at the server
via E2E_FIDELITY_URL, E2E_FIDELITY_ADMIN_TOKEN, E2E_FIDELITY_CACERT (a PEM, or
the literal system to trust your OS root store), and
E2E_FIDELITY_DOWNSTREAM (the cluster id); make e2e-fidelity-downstream-update
re-records the downstream goldens from that server instead.
One-time setup: git config core.hooksPath .githooks enables the
pre-commit make validate gate.
Manual testing: scripts/dev <args> - never run the binary directly; it
forces an isolated config directory and a file credential store, which keeps
a manual run from touching your real config or OS keychain. Build and test
rules: AGENTS.md.
We are not accepting code contributions at the moment. A clear issue helps most: open one with the bug report or feature request form, and read CONTRIBUTING.md for what to include.
Questions and discussion: the Rancher forums and Rancher Slack. A problem in the Rancher server itself goes to rancher/rancher issues.
For security issues, see SECURITY.md and email security-rancher@suse.com instead of opening a public issue.
Copyright (c) 2026 SUSE
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.