AgentKit
DocsKitsCLI ReferenceDesktop App
BetaYou are reading docs for the beta channel (3.4.0-beta.1). Features may change before the next stable release.Switch to stable →

Reference

CLI conventions

Global flags, output modes, the JSON envelope, machine-readable command contracts, and exit codes shared by every ak command.

Every ak command follows the same conventions for flags, output, and exit codes. Command pages in the CLI reference list only what is specific to that command; everything on this page applies everywhere.

Global flags

FlagDescription
--jsonEmit machine-readable JSON (implies --no-interactive)
--no-interactiveDisable interactive prompts (CI-safe)
-q, --quietSuppress non-error output on stderr
-V, --verboseExtra diagnostic output on stderr (loses to --quiet)
-y, --yesAssume yes for all prompts
-h, --helpPrint help for the command
--help --all, --help --fullPrint the full help text (see Compact help)

Put -V or --verbose after a command. ak -V or ak --verbose with no command is a flag error (exit 2, remediation.reason cli.verbose_needs_command): -V means --verbose, not the version. Use ak --version to print the version.

Output modes

ModeBehavior
prettydefault on TTY (colors, ASCII markers)
plainauto when stdout piped or --no-interactive
json--json (see JSON output)

Every command shows the cause of an error by default. The error line carries the error's public summary when it has one, otherwise the first line of the error message. Known secret shapes and URL query strings are redacted; paths remain visible for recovery. Re-run with --verbose for diagnostic details. appears only when the default output withheld something (redacted, cut, or summarized). --verbose prints the full message and can expose raw diagnostics, so review them before sharing.

A non-fatal warning prints [!] <summary>, then the redacted cause lines (at most 8, followed by ... and N more when there are more), then -> <next step> when there is something to do.

Two failures also name the next command. A mistyped command or subcommand, such as ak kit lst, exits 1 with the closest commands and the group's --help. A command that needs a missing or expired AgentKit session names ak login.

Compact help

On an interactive terminal, help longer than about 50 lines prints a compact form: the summary, the leading details, usage, examples, one line per flag, and effects. Print the full text with ak <command> --help --all, ak <command> --help --full, or ak help <command> --full.

Piped or captured help, and runs with --json, --quiet, or --no-interactive, always print the full text.

JSON output

Result data goes to stdout; status, progress, warnings, and failures go to stderr. With --json, stdout carries one versioned envelope:

{
  "schema_version": 1,
  "kind": "domain.operation",
  "data": {}
}

Gate on schema_version, dispatch on kind, and decode the payload under data. Ignore fields you do not recognize; additive fields do not change the schema version.

A command can declare a different framing instead: ndjson for a stream of JSON lines (for example ak run), protocol for a stdio protocol, or json-legacy for an unwrapped document. ak config prefs resolve --json and ak skill verify --json keep their legacy unwrapped shape. Read a command's framing from ak describe rather than inferring it from the presence of --json.

Read the payload under data

Commands such as ak migrate, ak backups create, ak codex-agent-runtime register and unregister, ak config prefs set, unset, and validate, ak content-search, and ak data wrap their JSON payload in the envelope. Scripts written against an earlier unwrapped shape must read .data and dispatch on .kind. An applied ak backups restore or ak recover prints a backups.restore envelope.

When a --json run fails, stderr ends with an error envelope:

{"schema_version":1,"error":"unknown flag: --bogus","error_code":"validation_failed","exit_code":2}

This includes flag errors and unknown commands: with --json, a flag error always ends in this envelope. A command that already printed its result and then exits non-zero, such as a completed preview that exits 3, explains the exit in that result and adds no error envelope. A --json run does not print the one-time macOS first-launch hint, so no human notice precedes the envelope; the hint waits for a later run without --json.

The error_code lock_held means another operation holds a lock the command needs, so the run can be retried after it finishes. Kit lifecycle commands and ak migrate report it for the kit lifecycle lock (exit 4); ak backups restore, ak backups prune, and ak recover report it for backup lock contention (exit 4).

The error_code renewal_required (exit 15) means the registry refused a kit version because it was released after the kit's update window ended. The JSON error adds an updates object with kit_id, latest_entitled_version, updates_through, and renew_url. Installed kits are unaffected. See Update windows and renewal.

Describe a command contract

ak describe <command...> [--json] prints a command's contract as data. It is read-only and offline, and the same binary always gives the same answer. With no arguments it describes the root command; a path that matches no command exits 5.

ak describe kit install --json

The command.describe payload carries the command path, usage, aliases, flags (local and inherited), subcommands, help sections, declared exit_codes, and an agent contract: whether the command mutates, its risk tier, idempotency, preview, confirmation, snapshot, network, auth, long-running behavior, input and output framing, output kinds, and protocol.

  • A value the command does not declare reads unspecified. Treat it as unknown, never as a safe default. output_framing_source tells you whether the framing is declared or unspecified.
  • Confirmation prompt means the command asks on stdin unless --yes, --no-interactive, or --json is passed.
  • The contract describes the command itself. It does not cover the opt-in background auto-update that a human-mode run of some commands may start; that check never runs under --json.

See the ak describe reference for its flags and output fields.

Exit codes

Every runnable command declares 0 and 2, plus the custom codes it can return. Read them from the command's help (Exit status) or from ak describe exit_codes. The base outcomes are:

CodeMeaning
0success
1command failure
2invalid flags or arguments

Flag parse errors exit 2. Positional argument-count errors and unknown commands currently exit 1.

Codes 3 and above are command-specific, and the same number can mean different things on different commands. A command page's Exit codes section lists only those: 3 is user cancel on ak recover, ak backups restore, ak setup, and ak onboard, but reports a completed preview on the ak analytics subcommands and ak content-search delete. Consult the selected command's declared codes instead of applying one table everywhere.