# Metrics

`mb metrics` (alias: `mb metric`) lists and manages evaluation metrics — both system (the fixed set MorganaBench ships) and custom (your own LLM-judge scorers) — in one place. For what each metric measures and how to author a custom one, see [Metrics](../reference/metrics.md).

```bash
# List all metrics: system and custom together
mb metrics list

# Create a custom metric from flags
mb metrics create "Conciseness" \
  --scoring-instructions "Score how concise the answer is: 1 rambling, 5 tight and complete." \
  --direction higher_is_better --scale 1..5 \
  --conversation required --agent-response required \
  --description "Penalizes verbose answers"

# ...or from a config file (YAML or JSON; '-' reads stdin)
mb metrics create "Conciseness" --config-file ./conciseness.yaml

# Manage custom metrics
mb metrics get <id>
mb metrics update <id> --description "Updated description"
mb metrics delete <id>

# Restore a soft-deleted custom metric (under a new name if the original now collides)
mb metrics restore <id> [--new-name "Conciseness v2"]
```

## The unified list

`mb metrics list` merges two backend concepts into one view: the fixed system
metrics (`ground_truth_alignment`, `refusal`, `tool_call_correctness`, ...)
and the custom metrics you've created.

**In human mode** (the interactive default), they print as two separate
sections, since system and custom metrics share almost no real fields
with each other. The CLI's own labels read `built-in` for the system
metrics — in the section heading below and in the `type` field:

```text
Built-in metrics:
id                     name                   direction         range
------------------------------------------------------------------------
ground_truth_alignment ground_truth_alignment higher_is_better  0-1
...

Custom metrics:
id                                name         status
-----------------------------------------------------
019ffaf2...                       Conciseness  active

Total: 9
```

**In `--output json`/`--output table`**, they stay one merged list with a
`type` column/field — splitting there would break `cut`/`awk`/`jq`
pipelines that expect one uniform row shape:

```bash
mb metrics list --output json | jq '.items[] | {type, name}'
```

| Column | System | Custom |
|--------|--------|--------|
| `id` | metric name (no separate ID) | UUID |
| `direction` / `range` | e.g. `higher_is_better`, `0-1` | not applicable (`null`) |
| `status` | not applicable (`null`) | `active` / `deleted` |

The human/table view (like every other `list` command in this CLI) doesn't
print a `description` column — it's in `--output json` and in `mb metrics
get <id>`, same as every other resource's own description.

`--status`, `--sort`, `--limit`, and `--offset` (see [List Filtering](index.md#list-filtering))
apply only to the custom side — system metrics have no such concept and
are always shown in full. `--search` filters both by name. Full custom-metric
detail (the scoring config, exact timestamps) still requires `mb metrics get
<id>`; system metrics have no further detail beyond what the list already
shows.

## Custom metrics

A custom metric is an LLM-judge scorer. Its **config** says what the judge
reads, how it scores, and which direction is better:

| Field | Flag | Values | Default |
|-------|------|--------|---------|
| `scoring_instructions` | `--scoring-instructions <text>` or `--scoring-instructions-file <path\|->` | the prose the judge follows (aka the prompt) | none — must be set |
| `direction` | `--direction` | `higher_is_better`, `lower_is_better` (`higher` / `lower` also accepted) | none — must be set |
| `score_type` | `--score-type` | `binary`, `integer_scale` | none — must be set, or implied by `--scale` |
| `integer_scale` | `--scale <min>..<max>` | e.g. `1..5`, `-2..2` — implies `--score-type integer_scale` | none — needed by `integer_scale`, rejected for `binary` |
| `input.conversation` | `--conversation` | `required`, `optional`, `disabled` | `disabled` |
| `input.agent_response` | `--agent-response` | `required`, `optional`, `disabled` | `disabled` |
| `input.retrieved_context` | `--retrieved-context` | `required`, `optional`, `disabled` | `disabled` |
| `input.reference` | `--reference` | `required`, `optional`, `disabled` | `disabled` |

The four fields with no default must be set, as flags or in a `--config-file`
file; `input` counts as set once any one of its four fields is. Beyond that,
nothing is assumed on your behalf except one rule: an input field you don't
name is **disabled**, and at least one must be `required`.

`--reference` is the reference answer, which the judge reads as a list of
claims.

`--scale` implies `integer_scale`, but omitting it never implies `binary`:
`--score-type integer_scale` without a scale is an error, as is `binary` with
one, and so is neither.

**Config files.** `--config-file <path|->` takes a whole config as YAML or
JSON and sends its fields to the server as written. Two consequences worth
knowing. Write **wire values** in a file — `HIGHER_IS_BETTER`, not `higher`
(the shorthands belong to the flags) — exactly as `--dry-run --output json | jq
.config` prints them. And a misspelled field name is reported by the server,
where it usually surfaces as `Field required` for the field you meant.

Flags override a config file field by field, whatever order you pass them in —
handy for creating a family of metrics off one file:

```bash
mb metrics create "Conciseness (strict)" --config-file ./conciseness.yaml --scale 1..3
```

The easiest way to get a config file is to write one out of flags:

```bash
mb metrics create "Conciseness" \
  --scoring-instructions "..." --direction higher --scale 1..5 \
  --conversation required --agent-response required \
  --dry-run --output json | jq .config > conciseness.json
```

`--dry-run` resolves the config before printing it, so it doubles as an offline
lint of your flags: YAML syntax, flag values, the fields a flag would have set,
and the `--score-type`/`--scale` rules. Everything past that is the server's —
including unknown keys and value spelling inside a `--config-file` file — so a
config that passes `--dry-run` can still be rejected on create.

**Read-only once saved.** Name and config cannot change afterward; only
`--description` can be updated in place. To change either, create a new metric
("Save As").

**Scoring instructions are sent verbatim.** The web UI wraps them in a judge
preamble it composes from the config; here they reach the judge as you wrote
them, so put any framing you want into `--scoring-instructions` yourself.

**Restoring under a new name.** `mb metrics restore` first tries the
metric's original name. If another active metric has since taken that name,
the restore fails with `METRIC_NAME_CONFLICT` — resubmit with `--new-name`.

## Next steps

- Use a metric's ID with [Evaluation](evaluation.md) create or add-metrics via `--custom-metrics <id>`.