# `check`

`kix check` evaluates a cluster and reports the result of each validation step
in a table. It does not contact a cluster. Use it as the local and CI gate
before a deploy.

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

## Synopsis

```text
kix check <CLUSTER> [-o text|json|yaml|sarif] [--flake <FLAKE>]
          [--override-input <INPUT> <URL>]... [--no-cache]
```

| Argument or flag | Default | Meaning |
| --- | --- | --- |
| `<CLUSTER>` | | Cluster name to evaluate. |
| `-o`, `--output` | `text` | `text` prints a `TOOL`, `RESULT`, `DETAILS` table, then the scorecard findings. `json` and `yaml` print an array of `{ tool, result, details }`. The `scorecard` entry also has `findings`, and so does the `eval` entry when there are library warnings or errors. `sarif` prints SARIF 2.1.0 JSON, described below. |
| `--flake <FLAKE>` | `.` | Flake to evaluate. |
| `--override-input <INPUT> <URL>` | None | Override a flake input for the evaluation. Repeatable. |
| `--no-cache` | Off | Evaluate from Nix instead of reading the [eval cache](/docs/reference/cli/eval-cache-behavior/). |

## Steps

| Tool | What it reports |
| --- | --- |
| `eval` | `pass` with the number of manifests and of library warnings, or `fail` with the evaluation error. Evaluation runs the constructor validators, the cross-resource checks, and every error-severity scorecard rule, so a failure in any of them appears here. |
| `scorecard` | The counts of error, warning, and info findings. `fail` when there is at least one error, `skip` when the cluster does not enable the scorecard. |

When `eval` fails, the `scorecard` step does not run, and the evaluation error
is printed under the table.

Text output lists the error and warning findings under the table, grouped by
rule. Add `-v` to list the info findings too.

## Library warnings

The Kix library warns about problems that do not stop the build. For example,
it warns when it skips a `meta.compatibleWith` check because a dependency
reports no version, or when an instance cannot reach the availability you asked
for. A package's own `warnings` and its structural warnings are listed here
too. When `eval` passes, text output lists these warnings under the table. Each
starts with the instance it is about, such as `monitoring/prometheus:`, and
shows the object, option, dependency, cluster option, or fix on a line of its
own.

In `json` and `yaml`, the `eval` entry lists each warning in `findings`. A
warning has the same fields as a library error, and `severity` is `warning`:

| Field | Meaning |
| --- | --- |
| `message` | What is wrong. |
| `instance` | The instance, as `namespace/name`. Missing for a warning about the whole cluster. |
| `object` | The Kubernetes object, as `kind`, `name`, and an optional `namespace`. |
| `option`, `dependency`, `clusterOption` | What to change: a path in the instance's `config`, the name of one of its `deps`, or a path in the cluster definition. |
| `fix` | How to fix it. |
| `id` | The change record id, such as `K0001`, for a warning about a coming change. |

`kix build`, `kix plan`, `kix deploy`, and the other commands that build a
cluster print the same warnings to stderr. A plan saved with `kix plan --out`
or printed by `kix diff -o json` lists them in `warnings`, and
`kix plan -o markdown` shows them in a section of their own.

Scorecard warnings are not repeated here. They appear only as scorecard
findings.

`kix check` runs constructor validators, cross-resource checks, and scorecard
rules. It does not validate rendered manifests against external Kubernetes
OpenAPI schemas or check for deprecated API versions.

## SARIF output

With `-o sarif`, each scorecard finding becomes a SARIF result with its rule
ID, level (`error`, `warning`, or `note`), message, and a logical location of
the form `namespace/instance/resource`. Each library warning becomes a
`warning` result with the rule ID `kix/library-warning`. A cluster with no
findings and no library warnings produces an empty run.

An error-severity finding stops evaluation, so there is no report to convert.
Kix then writes the evaluation failure as one error result. Its rule ID is
`scorecard/<rule>` when the error message names a scorecard rule, and
`kix/eval-failure` otherwise.

## Examples

<Command commands={[
  "kix check demo",
  "kix check demo -o sarif > kix-results.sarif",
]} />

## Exit status

| Code | Meaning |
| --- | --- |
| `0` | No step reported `fail` |
| `1` | A step reported `fail`, or the cluster was not found. With `-o sarif`, a failed step exits `1` after printing the SARIF document, whereas an unknown cluster errors on stderr before printing any SARIF. |

:::note[Reference]
See [Finding schema](/docs/reference/scorecard-and-rules/#finding-schema) for the
fields each scorecard finding carries.
:::

:::tip[Use it in a task]
See [Run `kix check -o sarif` in CI](/docs/how-to/policy-ci-and-compliance/run-kix-check-sarif-in-ci/)
for a CI job that uploads the SARIF file.
:::