Reference

Exit codes

Memory Layer follows normal CLI conventions: 0 means success, non-zero means the command did not complete the requested operation. Treat command output contracts (--json, stdout/stderr) as more important than hard-coding every possible failure number.

Common cases

Exit codeMeaningTypical cause
0SuccessCommand completed.
2CLI usage errorUnknown subcommand, missing required flag, invalid argument shape from clap.
1Operational failureService down, database/migration error, invalid token, provider failure, failed postcondition, or command-specific error.

Some subcommands may return other non-zero values through wrapped tools or platform service managers. Scripts should handle any non-zero as failure unless a command's JSON contract says otherwise.

Scripting guidance

Use --json where available. Machine-readable output is written to stdout; diagnostics and errors should be treated as stderr.

if ! memory status --project memory --json >status.json; then
  echo "Memory Layer status failed" >&2
  exit 1
fi

Usage errors are quick to detect:

memory query --project memory
# exits 2 because --question is required

Operational failures need diagnostics:

memory doctor
memory health
memory service status

For write-capable commands, run dry-runs first when supported:

memory scan --project memory --dry-run --json
memory embeddings reindex --project memory --dry-run
memory bundle import --project memory ./memory.mlbundle.zip --dry-run

Next

Use Doctor and health when a command exits non-zero for operational reasons.

© 2026 Olivier Van Acker (3vilM33pl3). Memory Layer is AGPL-3.0-or-later with commercial licensing available.

On this page