# Global flags

These flags are accepted by every `kix` command and may appear before or
after the subcommand. A command that has no use for a flag ignores it, and its
`--help` does not list it. `kix --help` lists them all. Each flag except
`-o` and `--no-color` can also be set with the environment variable in the
table; the flag wins over the variable.

This page is hand-maintained. Check `GlobalArgs` and `SCOPED_GLOBALS` in
`cli/kix-cli/src/cli.rs`, `cli/kix-cli/src/main.rs`, and
`cli/kix-cli/src/output.rs` when in doubt, and `cli/kix-cli/src/plugin.rs`
for plugins.

## Flags

| Flag | Variable | Default | Meaning |
| --- | --- | --- | --- |
| `-o`, `--output <FORMAT>` | | Varies by command | `text`, `json`, `yaml`, `markdown`, `sarif`, `dot`, or `tree`. A command refuses a format it does not print. Its `--help` lists only the formats it prints, and names the flags a format needs, such as `--read-only` for `kix plan -o json`. See [Output formats](/docs/reference/cli/output-formats/) for the formats of each command. |
| `-v`, `--verbose` | `KIX_VERBOSE`, a count | Off | Log more to stderr. Repeat for more: `-v` logs Kix at info level, `-vv` at debug, `-vvv` everything at debug. Without it, warnings are logged, except those the Kubernetes client writes for an error response it then returns to Kix. |
| `-q`, `--quiet` | `KIX_QUIET` | Off | Suppress progress and informational output, and log errors only. Results still print. |
| `--no-color` | `NO_COLOR`, below | Off | Disable coloured result output. Deploy and gc progress lines currently still use terminal clear-line control sequences. |
| `--context <CONTEXT>` | `KIX_CONTEXT` | Current kubeconfig context | Kubeconfig context for every command that talks to a cluster. `logs` and `port-forward` pass it to `kubectl`. |
| `--flake <FLAKE>` | `KIX_FLAKE` | `.` | Flake to evaluate clusters from. A value without `:` is a local path, resolved against the working directory; anything else, such as `github:org/repo`, is passed as a remote flake reference. Commands that use the [eval cache](/docs/reference/cli/eval-cache-behavior/) currently fail on a remote reference. |
| `--no-cache` | `KIX_NO_CACHE` | Off | Skip the Kix eval cache and re-evaluate the cluster every time. See [Eval cache behavior](/docs/reference/cli/eval-cache-behavior/). |
| `--override-input <INPUT> <URL>` | `KIX_OVERRIDE_INPUT`, names and URLs separated by spaces, read only without the flag | None | Override a flake input's URL during evaluation. Repeatable, two values each time. Kix skips the [eval cache](/docs/reference/cli/eval-cache-behavior/) when this is set. Overriding the Kix library input for the command (`kix` by default, or the cluster's input in `kix.toml` [`[versions]`](/docs/reference/kix-toml/#the-versions-table)) runs with a [development Kix library](/docs/how-to/start-and-inspect/install-and-run-the-kix-cli/#work-on-the-kix-library-itself): Kix runs the version you started and compares no versions. |
| `-h`, `--help` | | | Print help. `-h` prints a summary, `--help` the long form. |
| `-V`, `--version` | | | Print the version. |

In a project with a `[versions]` table, pass `--override-input <INPUT> <URL>`
with the input assigned to that cluster in `[versions]`, such as
`--override-input kix-stable <url>`. Passing `--override-input kix` for a
cluster assigned to `kix-stable` is ignored with a warning:

```text
warning: ignoring `--override-input kix` because this cluster uses input `kix-stable` in kix.toml [versions]. Kix will evaluate with `kix-stable` from flake.lock. Pass `--override-input kix-stable <url>` to override this cluster's Kix library.
```

## Which commands read which flag

`-v`, `-q`, and `--no-color` apply to every command. The other flags apply only
where the table shows them. Elsewhere `-o` accepts only `text`, and the other
flags are accepted and have no effect.

| Command | `-o` | `--context` | `--flake` | `--no-cache` | `--override-input` |
| --- | --- | --- | --- | --- | --- |
| `build`, `check`, `graph`, `list` | yes | | yes | yes | yes |
| `status` | yes | yes | yes | | yes |
| `diff` | yes | | yes | | yes |
| `plan` | yes | yes | yes | | yes |
| `deploy`, `gc`, `migrate domain`, `logs`, `port-forward` | | yes | yes | | yes |
| `export` | | | yes | | yes |
| `rollback` | | yes | yes | | yes |
| `history` | yes | yes | yes | | yes |
| `snapshot` | | yes | yes | | yes |
| `compliance sbom` | yes | | yes | | yes |
| `compliance attest` | yes | yes | yes | | yes |
| `compliance audit` | | | yes | yes | yes |
| `pin` | yes | | yes | | |
| `lib`, `doctor`, `upgrade` | | | yes | | |
| `completions` | | | | | |

`--no-cache` applies only to commands that read the
[eval cache](/docs/reference/cli/eval-cache-behavior/). `kix pin` uses
`--flake` only as a place to look for `pins.json`, and `kix doctor` uses it to
locate [`kix.toml`](/docs/reference/kix-toml/). `rollback`, `history`,
`status <CLUSTER>`, and `snapshot` use `--flake` and `--override-input` only
when no Activation record in the current context matches `<CLUSTER>` and Kix
evaluates `flake.nix` to look up the cluster's deployed `name`. `-o` on `deploy`
applies only with `--dry-run`.

## Environment variables

| Variable | Effect |
| --- | --- |
| `NO_COLOR` | Any value disables colour, as `--no-color` does. Colour is also off when `TERM=dumb` or stdout is not a terminal. Deploy and gc have the progress-line exception noted above. |
| `KIX_LOG` | A tracing filter, such as `kix=debug` or `debug`, that replaces the level chosen by `-v` and `-q`. |
| `KIX_NO_INTERACTIVE` | Any value makes Kix treat the terminal as non-interactive, so commands that ask for confirmation refuse to prompt and need `--yes`. Stdin that is not a terminal has the same effect. |
| `KIX_RUNTIME_DIR` | Directory that holds the Kix runtime (`nix`, `helm`, `kubectl`, `sops`) and `manifest.json`. See [`kix doctor`](/docs/reference/cli/doctor/#how-kix-locates-its-runtime). |
| `KIX_OUTPUT` | Removed. Kix refuses to run while it is set. Pass `-o` to each command instead. |
| `KIX_STORE_ROOT` | Root directory for Kix's local store under the default `kix` builder. Defaults to `$XDG_CACHE_HOME/kix/store` (or `~/.cache/kix/store` when `XDG_CACHE_HOME` is unset). Setting `KIX_STORE_ROOT` on a project that sets `builder = "nix"` in [`kix.toml`](/docs/reference/kix-toml/) is an error. |

The variables that tune how Kix talks to the Kubernetes API are listed in
[API server retries and request limits](/docs/reference/cli/api-server-transport/).
Registry credentials for `kix pin` are listed on [`kix pin`](/docs/reference/cli/pin/).

A variable that turns a flag on or off is off when it is empty or one of
`false`, `f`, `no`, `n`, `off`, or `0`, in any case, and on for any other value.

## Plugins

`kix NAME ARGS...`, where NAME is not a `kix` command, runs the program
`kix-NAME` with ARGS. Kix looks for it in the absolute directories on `PATH`,
the way git and cargo find their external commands. A plugin can be any
executable; NAME may hold letters, digits, `-`, and `_`.

- **Global flags go before NAME.** Kix passes them to the plugin as the
  variables in the table above, and `--no-color` as `NO_COLOR=1`. `-o` is
  the exception: Kix passes it as the plugin's first two arguments, so
  `kix -o json NAME ARGS...` runs `kix-NAME --output json ARGS...`. Everything
  after NAME goes to the plugin unchanged. `KIX_FLAKE` is passed as given, so
  a relative path such as `../infra` is relative to the directory `kix` ran
  in. An `--override-input` value with a space can't be passed, and Kix
  refuses it.
- **`KIX_BIN`** is the path of the `kix` that ran the plugin. A plugin that
  runs `$KIX_BIN` gets the same version, and that `kix` reads the same
  variables, so it has the user's flags without being given them. It does not
  have the format: pass `--output` on to it when it should print the same
  one. Pass a flag to override one.
- **Kix replaces itself with the plugin**, so its exit status is the plugin's.
- **A NAME with no plugin** is an error, as before, with a suggestion when it
  is close to a command. `kix help NAME` does not reach a plugin; run
  `kix NAME --help`, if the plugin has one.

## Examples

<Command commands={[
  "kix --flake ../infra list clusters",
  "kix deploy demo --context kind-demo -v",
  "kix build demo --override-input kix git+file:///home/me/src/kix",
  "kix --context prod enterprise status",
]} />

:::tip[Use it in a task]
See [Install and run Kix](/docs/how-to/start-and-inspect/install-and-run-the-kix-cli/)
for setting up Kix against a flake.
:::