> For the complete documentation index, see [llms.txt](https://krynix.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://krynix.gitbook.io/docs/reference/cli.md). Agents can also search and read this documentation through its [MCP server](https://krynix.gitbook.io/docs/~gitbook/mcp).

# Command line

The Krynix CLI checks evidence and policies on your own machine or in CI, with no network and no account. Install it from npm with your organisation's read token:

```bash
npm install -g @krynix/cli
krynix --help
```

## Verify evidence

Check a session exported from Krynix, with no trust in Krynix.

```bash
# the bundle downloaded from the session's page
krynix compliance verify --bundle session-bundle.json

# pin the signature to a public key you hold
krynix compliance verify --bundle session-bundle.json --public-key krynix.pub

# a trace with its signature
krynix verify --trace session.trace.jsonl --signature session.trace.sig --public-key krynix.pub
```

Each exits `0` when the evidence verifies and `1` when it does not.

## Check policies

```bash
# is the file valid?
krynix validate --policy policies/

# what does this policy decide for this recorded session?
krynix policy test --policy policies/no-shell.policy.yaml --trace session.trace.jsonl
krynix policy test --policy policies/no-shell.policy.yaml --trace session.trace.jsonl --expect-verdict fail

# did a change weaken the policy?
krynix policy diff --old no-shell-v1.policy.yaml --new no-shell-v2.policy.yaml
```

`policy diff` exits `2` when a rule's severity was lowered or its action weakened, so a CI job can stop the change.

## Evaluate a trace in CI

```bash
krynix evaluate --trace session.trace.jsonl --policy policies/ --format text
```

| Exit code | Meaning                                                                         |
| --------- | ------------------------------------------------------------------------------- |
| `0`       | Nothing failing.                                                                |
| `1`       | An `error`-severity violation, a broken chain, or an error running the command. |
| `2`       | A `critical`-severity violation.                                                |
| `3`       | A call needs approval, and nothing else failed.                                 |

A violation fails CI when its severity is `error` or `critical`, or when the rule sets `ci_failure: true`. `evaluate` checks the hash chain first; add `--public-key` to check the signature too. Narrow what is evaluated with `--filter-type`, `--filter-agent`, `--after` and `--before`.

## Sign your own traces

For traces you record yourself with the packages:

```bash
krynix keygen --out-private signing.key --out-public signing.pub
krynix sign --trace session.trace.jsonl --private-key signing.key
krynix verify --trace session.trace.jsonl --signature session.trace.jsonl.sig --public-key signing.pub
```

Keep the private key out of reach of the agent that produced the trace.

## Inspect traces

| Command                                                        | What it does                                                                                                                  |
| -------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `krynix replay --verify --trace <file>`                        | Checks a trace's structure and hash chain. `--golden-dir <dir>` checks every trace in a folder. It does not re-run the agent. |
| `krynix replay --compare --baseline <file> --candidate <file>` | Compares two traces for changes in behaviour. `krynix diff` does the same.                                                    |
| `krynix stats --trace <file>`                                  | Counts for one session: events, tool calls, model requests, errors, tokens, duration.                                         |
| `krynix export --format otlp-json --trace <file>`              | Converts a trace to OpenTelemetry JSON.                                                                                       |

Run `krynix <command> --help` for every option.
