docs / Miri for Agents / Reading Diagnostics

Reading Diagnostics

Without --format json, miri check prints errors for people:

$ miri check tally.mi
error[MER_PAR_020]: Unsupported C-Style Operator
--> tally.mi:9:18
   |
 9 |         if s > 5 && s < 10
   |                  ^^ '&&' is not a valid operator in Miri
   |
  = help: Miri spells logical and as the word `and`: `if a and b`.
   |
exit status 1

With --format json it prints the same information as one JSON object on standard output. Every command that takes --format json — check, build, run, test, fix, explain, view, patch, skill — answers in this same shape, so an agent only learns to read it once.

The fields an agent needs most:

  • ok — whether the command did what was asked. Warnings never make it false.
  • exitCode — the same number the process exits with.
  • diagnostics — one entry per problem, each with:
    • code — a stable name such as MER_TYP_042. Pass it to miri explain for the full rule.
    • line, column and length — where the problem is, counted in characters from 1.
    • help — one sentence on what to do instead.
    • repair — when present, the exact edits that fix it: byte offsets start and end in the file, and the replacement text. miri fix applies them for you, or an agent can apply them itself.
    • fixSafety — how safe the fix is to apply without a person looking (see Repairs).

Every field is listed in the JSON reference.