> ## Documentation Index
> Fetch the complete documentation index at: https://docs.thrindex.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI Reference

> Complete command reference for the thrindex command-line interface.

The THRINDEX CLI (`thrindex`, aliased as `thx`) exposes the Rust engine directly. It produces identical output to the Python SDK.

## thrindex run

Run a compiled artifact through the behavioral simulator.

```bash theme={null}
thrindex run <artifact.thx> [options]
```

**Options**

| Flag               | Default   | Description                                    |
| ------------------ | --------- | ---------------------------------------------- |
| `--seed N`         | `0`       | RNG seed for reproducibility                   |
| `--threads N`      | all cores | Number of worker threads                       |
| `--stdin`          | —         | Read spike raster JSON from stdin              |
| `--energy-coeff F` | `1.0`     | Energy coefficient in pJ per syn-op            |
| `--quiet`          | —         | Print only the final prediction, no transcript |

**Output format**

```
═══════════════════════════════════════════════════════════════
 thrindex run  ·  model.thx
 format:  m3  ·  target: sim  ·  seed: 0
═══════════════════════════════════════════════════════════════
 input:          [100 × 700]
 output:         [100 × 20]
 synaptic_ops:   124800
 wall_time_ms:   8.2
 energy_pJ:      124800
 prediction:     class 7
 spike_counts:   [3 12 47 0 8 1 0 2 94 0 ...]
═══════════════════════════════════════════════════════════════
```

The format is stable and snapshot-tested. Do not parse the separator lines; parse the `key: value` pairs.

## thrindex bench

Run the conformance harness against a registered backend.

```bash theme={null}
thrindex bench --conformance --target <target> [options]
```

**Options**

| Flag            | Default | Description                                     |
| --------------- | ------- | ----------------------------------------------- |
| `--target T`    | —       | Backend to test (`sim`, `loihi2`, ...)          |
| `--artifact F`  | bundled | Path to `.thx` artifact to use as test model    |
| `--fixtures D`  | bundled | Directory of fixture files (JSON spike rasters) |
| `--n-samples N` | all     | Number of fixture samples to use                |

**Output format**

```
═══════════════════════════════════════════════════════════════
 THRINDEX Conformance Report  ·  target: sim
═══════════════════════════════════════════════════════════════
 fixture_count:   120
 T_mean:          0.000  ≤ 0.020  PASS
 T_max (p99):     0.000  ≤ 0.130  PASS
 P_pred:          1.000  ≥ 0.900  PASS
─────────────────────────────────────────────────────────────
 PASS — THRINDEX Certified [v0]
═══════════════════════════════════════════════════════════════
```

Exit code is 0 on PASS, 1 on FAIL, 2 on error.

## thrindex doctor

Inspect the THRINDEX environment and optionally verify an artifact.

```bash theme={null}
thrindex doctor [--check <artifact.thx>] [--verbose]
```

**Without `--check`:**

```
Python:     3.12.4  ✓ (≥ 3.11 required)
thrindex:   0.2.0
torch:      2.4.0   ✓ (optional, found)
artifact:   —       (no artifact specified)
```

**With `--check artifact.thx`:**

```
artifact:   model.thx
format:     m3  (current)
version:    0.2.0
target:     sim
dt_ms:      1.0
crc32:      OK  (d3a4f82c)
layers:
  [0] Dense     700 → 512
  [1] LIF       512   alpha: 0.9512  threshold: 0.3
  [2] Dense     512 → 20
  [3] LIF       20    alpha: 0.9512  threshold: 0.3
total params:  399380
```

## thrindex targets

List available compilation and run targets.

```bash theme={null}
thrindex targets
```

```
sim      behavioral simulator (reference)  ·  dt_ms=1.0  ·  delay_max=∞
loihi2   Intel Loihi 2 (driver required)  ·  dt_ms=1.0  ·  delay_max=63
```

## Exit codes

| Code  | Meaning                                               |
| ----- | ----------------------------------------------------- |
| `0`   | Success (PASS for conformance)                        |
| `1`   | Application error (FAIL for conformance, model error) |
| `2`   | Environment error (missing driver, bad artifact)      |
| `130` | Interrupted by user (Ctrl-C)                          |
