@moda-ai/cli, installed as moda) queries your production conversation data from the terminal, manages prompt versions, and syncs your harness. This page covers installation, authentication, profiles, output formats, and exit codes. The full command list is in the CLI reference, and agent/CI integration patterns are in Using the CLI from agents and CI.
Install
Requires Node.js 18 or later.Authentication
The CLI uses two credentials for two different groups of commands:
API keys (called ingestion keys in the dashboard) are tenant-bound: a key always operates on the tenant it was created for, and
MODA_TENANT_ID cannot re-point it.
Log in (browser flow)
moda auth status— reports session state; exits 4 when logged out.--onlinealso probes the API.moda auth whoami— shows the authenticated user and available tenants.moda auth token— prints the raw session token (for scripting control-plane calls).moda auth logout— revokes the session server-side and clears local credentials, including the stored API key.
API key resolution order
Data commands resolve the API key in this order:MODA_API_KEYenvironment variable- The active profile’s stored key
~/.moda/config.json(api_key)
Headless provisioning: moda provision
moda provision mints (or reuses) a tenant API key without any interactive prompts and prints exactly one JSON document to stdout — nothing else. It is built for CI bootstrap scripts and agents:
Output
reused is true when an existing stored key passed a liveness check and no new key was created.
Behavior to script around:
- Provision requires an existing CLI session (
moda auth loginrun previously on that machine) and never opens a browser. Without a session it fails with exit code 4 and instructions to log in first. - With access to multiple tenants,
--tenant-id(or theMODA_TENANT_IDenv var; the flag wins) is required. Without it, provision fails with exit code 5 and a machine-readableinput_requestthat lists every tenant with its resume flags — it never prompts, even on an interactive terminal. --label=TEXTnames the key (default: machine hostname).--savealso persists the key and tenant to~/.moda/config.json; by default provision only prints, so headless callers own storage.
Profiles and configuration
CLI state lives in~/.moda/: config.json (API key, tenant ID, ingest URL), profiles.json, and per-profile secrets under ~/.moda/secrets/. Three profiles exist by default: prod (https://moda.dev, the default), staging, and local.
--profile=NAME or the MODA_PROFILE env var. Two env vars override URLs directly:
MODA_BASE_URL— the moda.dev host used for the Data API and control-plane calls.MODA_INGEST_URL— the Ingestion API host (used byskillscommands and remote harness analysis).
Output formats
The CLI picks an output mode automatically, in this priority order:- Explicit flags:
--human(or--prose),--json,--agent,--agent --stream MODA_FORMATenv var:human|json|agent|agent-stream|ndjson- Agent environment detection: a truthy
CLAUDECODE,CURSOR,CI, orMODA_AGENTenv var selectsagent - TTY detection: piped or redirected stdout selects
agent; an interactive terminal selectshuman
This means a piped or CI invocation gets machine-parseable output with zero flags. Three commands bypass envelopes in every mode because their stdout is meant to be captured directly:
moda provision (one JSON credentials document), moda auth token (the bare token), and moda tail (NDJSON — one JSON line per event, since a live tail is a stream rather than a single response).
The moda.agent.v1 envelope
In agent mode every command emits a single JSON envelope:
status is ok, degraded, or error; the command’s payload is always under data. The full field reference, the streaming event schema, and exit-code recipes are on Using the CLI from agents and CI. moda manifest --json and moda --json-schemas describe the protocol machine-readably.
Exit codes
Update check and telemetry
Both are on by default and both can be turned off:- Update check. At most once a day the CLI checks the npm registry for a newer
@moda-ai/cliversion and prints a notice to stderr. Disable with--no-update-checkorMODA_CLI_UPDATE_CHECK=0. The check is automatically skipped in CI and whenDO_NOT_TRACK=1is set. - Usage telemetry. The CLI reports command name, flag names (never values or arguments), exit status, and duration. Disable with
--no-telemetry,MODA_CLI_TELEMETRY=0, orDO_NOT_TRACK=1. - Feedback tip. Successful commands print a one-line
moda feedbacktip (stderr on a TTY,meta.tipin envelopes). Hide the stderr line withMODA_CLI_TIPS=0.
Environment variables
Next steps
- CLI reference — every command with flags and example output.
- Using the CLI from agents and CI — envelopes, exit-code recipes, and CI examples.
- Data API overview — the HTTP API behind the data commands.
- Authentication — how API keys and sessions work across Moda.