@moda-ai/cli, installed as moda) queries your production trace 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 api-key— prints the savedmoda_sk_API key for$(moda auth api-key)and pipes.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.
MODA_BASE_URL (localhost, 127.0.0.1, ::1) is used only on a non-prod profile (local, staging, dev). On a prod profile the command fails with exit code 5 (input_required) before sending anything: the CLI never sends a prod profile’s key to a loopback server, and it does not send the request to production in its place. Re-run with --profile=local (or MODA_PROFILE=local) to use the local stack, or unset MODA_BASE_URL to use production. moda config show reports such a URL as refused, and moda auth status --online reports online.baseUrl, the URL every request uses.
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. These commands bypass envelopes in every mode because their stdout is meant to be captured directly:
moda provision (one JSON credentials document), moda auth token / moda auth api-key (the bare credential), 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 on a terminal; agent envelopes carry it asmeta.update. A failed check (offline, unreachable registry) also waits a day before the next try. In agent and JSON modes the check runs in a detached background process, so it never delays a command. Disable with--no-update-check(or--no_update_check) orMODA_CLI_UPDATE_CHECK=0. The check is automatically skipped in CI and whenDO_NOT_TRACK=1is set. - Usage telemetry. The CLI reports command name, the names of flags the command accepts (never values or arguments; any other
--wordis only counted), exit status, and duration. It is sent to the same base URL and with the same key the command uses, and not at all when--profileorMODA_PROFILEnames a profile that does not exist. Events wait in a private local file (~/.moda/telemetry/, which never holds the API key) and are sent in batches by one background process once 20 have collected or the oldest is 30 seconds old (every run in CI). Disable with--no-telemetry(or--no_telemetry) for one run, or withMODA_CLI_TELEMETRY=0orDO_NOT_TRACK=1, which also delete events still waiting to be sent. - 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.
- Connect the MCP server — the core read commands as MCP tools for Claude Code, Cursor, and other MCP clients (some CLI commands are CLI-only; see parity).
- Authentication — how API keys and sessions work across Moda.