# `list`

`kix list` reads the flake and prints what it defines: its clusters, its
packages, or the resources and container images one cluster renders. It does
not contact a cluster. Use it to find the names other commands accept, to
confirm what a cluster contains before reading the full manifests with
[`kix build`](/docs/reference/cli/build/), and to collect the images an
environment without registry access needs.

This page is hand-maintained. Check `cli/kix-cli/src/cli.rs` and
`cli/kix-cli/src/commands/list/` when in doubt.

## Synopsis

```text
kix list clusters [-o text|json|yaml] [--flake <FLAKE>] [--no-cache]
kix list packages [<CLUSTER>] [-o text|json|yaml]
                  [--flake <FLAKE>] [--no-cache]
kix list resources <CLUSTER> [-o text|json|yaml]
                   [--flake <FLAKE>] [--no-cache]
kix list images <CLUSTER> [--sources] [-o text|json|yaml]
                [--flake <FLAKE>] [--no-cache]
```

| Argument or flag | Default | Meaning |
| --- | --- | --- |
| `<CLUSTER>` | | Cluster name to evaluate. Optional for `list packages`, where it adds a status column. |
| `--sources` | Off | `list images` only. In text output, list under each image the resources that reference it. |
| `-o`, `--output` | `text` | `text` prints a table or summary. `json` and `yaml` print the same data as one document. |
| `--flake <FLAKE>` | `.` | Flake to read. |
| `--no-cache` | Off | Read from Nix instead of the [eval cache](/docs/reference/cli/eval-cache-behavior/). |

## `list clusters`

Prints a `NAME` column with every cluster registered with `kix.lib.mkFlake`,
read from `legacyPackages.<system>.kixClusters`.

When the project's [`kix.toml`](/docs/reference/kix-toml/#the-versions-table)
has a `[versions]` table, text output adds `KIX` and `INPUT` columns:

```text
 NAME     KIX     INPUT
 dev      -       not listed in [versions]
 prod     0.12.3  kix-stable
 staging  0.14.2  kix
```

`KIX` shows the release version pinned for the cluster's input in `flake.lock`,
`development` when the input points to a local folder or branch, or `unknown`
when `flake.lock` has no version for that input. A cluster missing from
`[versions]` shows `-` and `not listed in [versions]`.

JSON and YAML output are unchanged: an array of cluster names. A flake with no
clusters prints `No clusters found in this flake.` on stderr.

## `list packages`

Without a cluster, lists every package the flake exposes in
`legacyPackages.<system>.kixPackages`, with `NAME` and `VERSION` columns.
Experimental packages are listed as `experimental.<name>`.

With a cluster, lists the cluster's instances and the packages it could
install, with a `STATUS` column:

| Status | Meaning |
| --- | --- |
| `installed [<namespace>]` | An instance declared in the cluster |
| `installed (auto) [<namespace>]` | An instance added by auto-instantiation |
| `import [<namespace>]` | An instance that stands for resources Kix does not manage |
| `available` | A package the cluster can use but has not instantiated |

Rows are sorted by name, then by namespace. Each cluster instance gets its own
row, so two instances with the same name in different namespaces appear
separately. An `OWNER` column appears when any package declares an owner; the
rest show `-`. JSON entries have `name`, `version`, `owner`, and `package`,
plus `status` and `isImport` with a cluster. For built-in Kix packages,
`package` is the package ID used in release notes, such as `harbor` or
`experimental/coredns`. For custom packages and imports, `package` is `null`.
An empty result prints `No packages found.` on stderr.

## `list resources`

Evaluates the cluster and prints an inventory of its rendered resources. Text
output has four parts:

1. The cluster name and total resource count.
2. Each namespace with its resource count. Cluster-scoped resources are
   listed as `(cluster-scoped)`.
3. A table of resource kinds, most frequent first.
4. Every resource as `Kind.group/name` (or `Kind/name` for core `v1` kinds), grouped by namespace and sorted by kind, group, and name.

JSON and YAML output is an object with `cluster`, `totalResources`,
`namespaces` (each `{ name, resources: [{ kind, group, name }] }`, omitting
`group` for core `v1` kinds), and `kindCounts` (counts keyed by `Kind.group`,
or `Kind` for core `v1` kinds). Cluster-scoped resources are under the
namespace name `_cluster`.

`kix list resources` reports rendered resources only. To see dependency
edges, use [`kix graph`](/docs/reference/cli/graph/).

## `list images`

Evaluates the cluster and lists the container images it needs. Use the list
to pull, mirror, or preload images before deploying to an environment without
registry access.

Kix reads the `image` of every container, init container, and ephemeral
container in Pods and in the pod templates of Deployments, StatefulSets,
DaemonSets, ReplicaSets, Jobs, and CronJobs. It adds the images a package
declares in `out.extraImages`, which cover pods an operator creates at run
time.

Text output prints one image reference per line. Each reference appears
once, sorted, exactly as written in the manifests: a tag, a digest, or both.
With `--sources`, the resources that reference each image follow it, as
`Kind namespace/name (container: <name>)`. A cluster with no images prints
`No container images found.`

JSON and YAML output is an array of `{ image, sources }`, whatever
`--sources` says. Each entry in `sources` has `kind`, `namespace`, `name`, and
`container`. Cluster-scoped sources have the namespace `_cluster`.

## Examples

<Command commands={[
  "kix list clusters",
  "kix list packages demo",
  "kix list resources demo -o json",
  "kix list images demo --sources",
  "kix list images demo | xargs -n1 docker pull",
  "kix --flake ../infra list clusters -o json",
]} />

## Exit status

`0` on success, including an empty list. `1` when the flake cannot be
evaluated or the cluster does not exist.

:::tip[Use it in a task]
See [List clusters and packages](/docs/how-to/start-and-inspect/list-clusters-and-packages/),
[Inspect an instance's deps, parts, and `out`](/docs/how-to/debug-dependency-wiring/inspect-an-instance-s-deps-parts-and-out/),
and [List images for air-gapped preloading](/docs/how-to/operate-a-cluster/list-images-for-airgap-preloading/).
:::