Skip to content

Output formats

Almost every klim command that produces structured data accepts the same flag for choosing how that data is rendered:

Terminal window
--output text|json|yaml
  • text (default) — human-readable. Prose, progress, and summaries are written to stderr; only data goes to stdout.
  • json — indented JSON on stdout.
  • yaml — YAML on stdout.

--json is supported as a deprecated alias for --output=json and prints a one-line deprecation warning to stderr.

When --output=json or --output=yaml is set, klim is careful to keep stdout clean of any prose: even spinners and summaries that you’d normally see during an install or apply are moved to stderr. That means you can pipe stdout into jq, yq, or a file with no post-processing:

Terminal window
klim list --output json | jq '.tools[] | select(.installed==true) | .name'
klim score --output yaml > score.yaml
klim install kubectl --output json 2> install.log

The YAML encoder routes through JSON first, so YAML output uses the same key names the JSON output does — including snake_case, omitempty, and any custom MarshalJSON overrides:

Terminal window
$ klim score --output json | head -3
{
"total": 61,
"max_total": 100,
$ klim score --output yaml | head -3
total: 61
max_total: 100
grade: D

If a field is omitempty in the JSON schema it stays omitted in the YAML output too.

Passing --output=yaml to a command that hasn’t opted into YAML returns a UsageError and exits with code 2 — klim never silently falls back to text. Same for unknown values like --output=jsno:

Terminal window
$ klim graph --output yaml
Error: --output=yaml is not supported for this command
exit status 2

The matrix is large enough that we keep it in CLI-CONVENTIONS.md inside the main repo. As of klim’s current release:

  • Full matrix (text|json|yaml)apply, audit, check, config marketplace list, diff, health, health path, info, install, list, plan, remove, rollback, score, search, security compliance check, security vuln, share, tools path, trail log, trail show, trail diff, upgrade, watch, why, plus agents list, agents search, badge, env.
  • YAML by designexport (manifests are always YAML).
  • Text onlygraph (the output is a terminal drawing, not structured data).
  • JSON onlyaudit --sbom emits CycloneDX, which has no YAML form.
  • klim list — the canonical example of per-tool structured output.
  • klim score — environment health score as JSON, YAML, or a Shields.io badge URL.
  • klim env — full environment manifests for backup / share.