kortecxdocs

kx CLI Reference

Every command the kx binary ships, grouped by purpose, with its key flags, the shared client flags, and the exit codes.

kx is one binary. It is the whole agentic runtime: the local engine, the server, and every client command you use to author, run, inspect, and govern work.

This page lists every command the binary actually has. Each row is one line about what the command is for, plus the flags you are most likely to reach for. For the complete per-command usage — every flag, every subcommand — run:

kx help invoke

kx --help prints the same grouped summary you see below. kx --version prints the version.

Two kinds of command

A few commands run entirely on your machine with no server (run, replay, digest, the offline scaffolders kx new skill / kx new connector, kx blueprint import, kx eval run, kx connections doctor, and chain / swarm with --dry-run). Everything else is a client command: it talks to a running server over the network, so it takes the shared client flags in the next section.

Shared client flags

Every client command accepts these. The first four decide which server you are talking to and how you authenticate to it; --json changes the output shape.

FlagDefaultWhat it does
--endpoint <url>http://127.0.0.1:50151the server to talk to
--token <t>a bearer token, passed inline. Visible in ps — prefer the file form
--token-file <path>read the bearer token from a file
--tls-ca <pem>the CA certificate to trust. Requires an https:// endpoint
--jsonoffmachine-readable output instead of the human table

--token and --token-file are mutually exclusive.

kx runs list --endpoint https://kx.internal:50151 --token-file ~/.kx-token --json

Exit codes

Every command uses the same four codes, so you can branch on them in a script.

CodeMeaning
0success
2a usage or config error — a bad flag, a missing required value, a server that refuses to start
3a --wait timed out. The run is still in progress and still resumable — nothing was lost
1everything else

Code 3 is the one worth handling deliberately. It does not mean the run failed. It means you stopped waiting. Fetch the result later with kx runs list and kx projection.

Local engine (no server)

These three drive the engine directly against a journal on disk. No server, no network, no model. They are how you see the durability guarantee for yourself — run a workflow, crash it, replay it, and compare the digest.

CommandWhat it does
kx rundrive the canonical demo workflow from scratch
kx replayrecover an existing journal and finish the run
kx digestprint the projection digest of a journal

The flags they share:

FlagWhat it does
--journal <path>the journal file (required)
--content <dir>the content store directory (required)
--crash-at <point>run only — inject a deterministic crash at a named point: pre-commit-stc, post-commit-vtc, or shaper-children-pending. Passing it to replay or digest is a usage error (exit 2)
--checkpoint-every <N>checkpoint interval (0 disables checkpointing)
--audit-log <path>write a JSONL record of the run lifecycle. Honored by run and replay. Off the truth path — it never changes the digest
--jsonmachine-readable output
kx run --journal /tmp/kx.db --content /tmp/kx-content --audit-log /tmp/kx-audit.jsonl
kx replay --journal /tmp/kx.db --content /tmp/kx-content
kx digest --journal /tmp/kx.db --content /tmp/kx-content

kx serve — the runtime as a server

One command starts the server, the embedded worker, and the live-event bridge. It is zero-config: leave the data paths off and the journal, content store, and catalog resolve under ~/.kortecx, are created on first run, and are reused across restarts. A startup banner prints every resolved path and endpoint.

kx serve --dev-allow-local

You must pick an auth posture

The server refuses to start with no auth posture and exits 2 with a hint. Pass --dev-allow-local (loopback callers only, for local development) or one or more --auth-token <token>=<party> / --auth-token-file <path>. The two postures are mutually exclusive — pick one. It never opens an unauthenticated server for you.

FlagDefaultWhat it does
--dev-allow-localoffdev auth: accept loopback callers. Alias: --allow-local-dev
--auth-token <token>=<party>accept a bearer token as a named party (repeatable)
--auth-token-file <path>one token=party per line (# comments allowed)
--journal <path>under ~/.kortecxthe durable journal
--content <dir>under ~/.kortecxthe content store
--catalog-dir <dir>beside the journalthe catalog and its sidecars
--listen <addr:port>127.0.0.1:50151the gRPC endpoint
--ws-listen <addr:port>127.0.0.1:50152the live-event WebSocket bridge
--console-listen <addr:port>127.0.0.1:8888the embedded web console (loopback only)
--no-consoleturn the web console off
--cors-origin <scheme://host[:port]>deny allallow one browser origin (repeatable, never a wildcard)
--tls-cert <pem> / --tls-key <pem>plaintextTLS for the gRPC listener
--max-lease <N>16the worker lease batch size
--workers <N>1the worker pool size
--content-max-bytes <N>32 MiBthe upload payload cap (fail-closed)
--metrics-listen <addr:port>offan opt-in Prometheus /metrics endpoint
--webhook-listen <addr:port>offan opt-in inbound webhook surface for event triggers
--audit-log <path>offa JSONL record of the run lifecycle

The web console needs a console build

The embedded browser console is a build-time feature. The prebuilt release binaries carry it. A kx built without it refuses --console-listen with an exit-2 config error that names the remedy; everything else on this page works either way.

Set KX_DATA_DIR to move the whole zero-config layout somewhere else. The runtime is single-system by default; multi-node is on the roadmap.

Author & run

These are the commands that make something happen. Each one submits work to the server, which compiles it, derives every identity, and builds every permission from the calling party's grants. The client sends the shape of the work — never the authority to do it.

CommandWhat it does
kx invoke <handle>run a published blueprint by handle and get a committed result
kx chat --message <text>one chat turn — plain, grounded in a dataset, or a bounded agentic turn
kx agent run --goal <text>give a goal; get a reasoned answer plus the audited set of actions taken
kx chain run "<dsl>"compose task handles into a DAG with a small string DSL, then run it
kx swarm "<agent>"…run a multi-agent pattern without hand-writing the DSL
kx blueprint run|importrun a portable DAG from a file, or validate and summarize one offline
kx app …author, run, and share Apps — the durable, portable unit

Key flags

CommandFlags worth knowing
kx invoke--args <json> / --args-file <path> · --wait · --stream · --out <file> · --timeout-secs <N> · --context <handle> (repeatable) · --context-ref <hex>
kx chat--message <text> · --dataset <name> · --k <N> (default 4, clamped to 1–16) · --tools <id@ver,…> · --max-turns <N> (default 8) · --max-tool-calls <N> (default 20) · --image <path> · --timeout-secs <N>
kx agent run--goal <text> · --context <handle> · --context-ref <hex> · --input k=v · --image <path> · --dataset <name> · --max-turns <N> · --max-tool-calls <N> · --timeout-secs <N>
kx chain run--tasks <file.json> / --tasks-json '<json>' / --task <name>='<json>' · --seed <N> · --wait · --dry-run · --emit-blueprint <file> · --out <file> · --context <handle>
kx swarm--pattern swarm|supervisor|consensus · --planner <p> · --gather <p> · --vote judge|majority · --goal <g> · --seed <N> · --wait · --dry-run
kx blueprintrun --file <dag.json> [--wait] [--out <file>] · import --file <dag.json> (offline, no server)
kx appnew save list get manifest run export import clone scaffold files structure cat edit lock unlock

On kx chat, --tools does not yet combine with --dataset or --image — the parser rejects the pairing rather than silently dropping one. Run them as separate turns.

kx invoke without --wait prints an async handle and returns immediately. With --wait it polls to completion and prints the committed result — the runtime called like a function.

kx invoke kx/recipes/echo --args '{"topic":"durable agents"}' --wait
kx invoke kx/recipes/echo --args '{"topic":"hello"}' --wait --out /tmp/result.bin
kx chat --message "What changed in the Q3 notes?" --dataset notes --k 6
kx agent run --goal "Summarize the open incidents and name the riskiest one."

Agents chain inside one app — a blueprint DAG, or the multi-agent patterns kx swarm composes. There is no mechanism for one app to call another app.

kx chain run "a > [b & c]" --tasks tasks.json --wait
kx chain run "[a & b] > c" --tasks tasks.json --dry-run --emit-blueprint chain.json
kx swarm "Find the risks" "Find the upside" --pattern consensus --vote judge --wait

--dry-run on chain and swarm lowers and validates the topology without submitting it, and needs no server at all.

An App is the shareable unit: a blueprint wrapped with by-reference context, tool, connection, and dataset references plus a steering config. It carries no authorityrun and import re-resolve every permission against the caller's own grants.

kx app new my-agent --from-blueprint chain.json --max-turns 4 --output my-agent.app.json
kx app save my-agent.app.json --handle apps/local/my-agent
kx app run apps/local/my-agent --wait
kx app export apps/local/my-agent --bundle my-agent.appbundle
kx app import my-agent.appbundle

An exported bundle carries a source_digest lineage hint. That is a record of where the bundle came from, not a signature and not a trust decision — read an imported bundle before you run it. Connections and secrets never travel in a bundle; the importer re-registers them by name.

Inspect & observe

Everything a run did is a durable fact you can read back. These commands are all read-only unless noted, and none of them is truth-bearing input to anything — they are for looking.

CommandWhat it does
kx runs listdurable run history, newest-first
kx runs rerun <instance>re-run a prior run with edited arguments
kx projection --instance <id>render a run as a DAG of step states
kx mote show <instance> <mote>inspect one committed step's definition
kx content get|putfetch a committed result, or upload a blob to the content store
kx eventsprint or live-tail one run's events, or the global cross-run tail
kx telemetry list|summaryper-step execution telemetry and the per-model output-token rollup
kx cost <instance>a run's local spend estimate
kx alerts listthe inbox of terminal failures
kx feedback submit|listrecord and read back a thumbs-up/down on an answer
kx capture listthe captured-action join-key records for a run
kx react listthe ReAct turn trail — what the agent reasoned and fired
kx replan listthe re-plan rounds — where a plan failed and was rewritten
kx rerank listthe retrieval-rerank rounds
kx eval run|scorethe local golden gate, and a per-run quality summary
kx healthliveness. Exits 0 only if the server is serving
kx infothe non-secret server configuration

An instance id is 32 hex characters; a mote id, content ref, or chain id is 64.

Key flags

CommandFlags worth knowing
kx runs list--limit <N> · --before-seq <N> (page older runs)
kx runs rerun--set k=v (repeatable; a JSON-parseable value keeps its type) · --wait · --out <file>
kx projection--instance <id> · --at-seq <N> (time-travel to any point)
kx content get--ref <ref> · --instance <id> (omit for the uploads scope) · --out <file>
kx content put<file> · --media-type <mime> · --filename <name>
kx events--instance <id> or --all (mutually exclusive) · --since <N> · --follow · --kind committed,failed,… (--all only — with --instance it is a usage error)
kx telemetry list--instance <id> · --mote <mote-id> · --limit <N> · --before-seq <N>
kx alerts list--instance <id> · --limit <N> · --before-seq <N>
kx feedback submit--rating up|down · --message-id <id> · --instance <id> · --comment <s>
kx react list--instance <id> · --chain <chain-id> · --limit <N>
kx evalrun [--tolerance <per_mille>] (local, no server) · score <INSTANCE_ID>
kx runs list --limit 20
kx projection --instance 0123456789abcdef0123456789abcdef --at-seq 3
kx events --instance 0123456789abcdef0123456789abcdef --follow
kx events --all --follow --kind committed,failed
kx telemetry summary --instance 0123456789abcdef0123456789abcdef
kx cost 0123456789abcdef0123456789abcdef
kx alerts list --limit 50
kx health
kx info --json

A few honest limits worth stating here:

  • Cost is a local spend estimate at rates you configure, with a ceiling — not a bill. It prices the run's durable turn and tool-call counters at your own KX_PRICING_PER_TURN_MICRO_USD and KX_PRICING_PER_TOOL_CALL_MICRO_USD. Input-token counts are not measured.
  • Alerts means terminal failures land in an inbox instead of vanishing. There is no acknowledge or resolve lifecycle here, and nothing is sent anywhere.
  • Metrics are an opt-in Prometheus /metrics endpoint, enabled with kx serve --dev-allow-local --metrics-listen <addr:port>.

Catalog, data & memory

What your agents can find, read, and remember.

CommandWhat it does
kx recipe list|searchdiscover the blueprint handles this server publishes
kx signatures list|get|registerthe sharable task-signature catalog
kx models list|load|offload|pull|usesee the models this server offers, and manage which is loaded and default
kx datasets list|ingest|querythe retrieval data-plane — content-addressed document corpora
kx memory add|list|recall|forget|decay|stats|restore|consolidatedurable memory that survives across runs
kx context add|list|get|edit|describe|remove-item|removereusable named bundles of files and content
kx branch create|snapshot|list|get|edit|advance|removecontent-addressed file branches

Key flags

CommandFlags worth knowing
kx recipe search<intent> positional · --keyword <k> (repeatable) · --limit <N>
kx signaturesget --id <sig-id> · register --manifest-file <path>
kx modelsload <id> · offload <id> · pull <tag> or pull --url <url> --sha256 <hex> · use <id> / use --clear
kx datasets ingest<name> positional · --text <s> / --file <path> (repeatable)
kx datasets query<name> positional · --text <q> · --k <N> · --mode dense|hybrid · --rerank on|off
kx memory add<text> positional · --kind semantic|episodic
kx memory recall--text <q> · --k <N>
kx memory decay--dry-run / --apply · --ttl-days <N> · --min-access <N>
kx memory consolidate--query <q> · --k <N> · --window-hours <H> · --dry-run / --apply
kx context add<handle> positional · --item <name>=<ref> / --file <name>=<path> (repeatable) · --description <s>
kx branch snapshot<handle> positional · --path <subpath> (repeatable) · --parent <handle>
kx recipe list
kx recipe search "summarize a document" --limit 5
kx models list
kx datasets ingest notes --file ./q3-notes.md --file ./q4-plan.md
kx datasets query notes --text "what slipped in Q3" --k 5
kx memory add "The team ships on Thursdays." --kind semantic
kx memory recall --text "when do we ship" --k 3
kx context add briefing --file style=./style-guide.md --description "House style"
kx invoke kx/recipes/echo --args '{"topic":"x"}' --context briefing --wait

What datasets and memory require

Datasets require an hnsw build. A server without it answers Unimplemented.

Durable memory needs three things together: KX_SERVE_MEMORY=1, a served model, and an hnsw build. Without all three the memory commands answer Unimplemented rather than pretending.

Ingest and recall use the server-embed path, so they also need a served model. Every similarity score these commands print is display-only — a ranking aid, never an identity decision.

Branches read host files only when you open the door

kx branch snapshot reads files from your machine into the content store, so it is off unless the operator sets KX_SERVE_FS_ROOT to the directory the server may read. Without it, snapshot fails closed. The host is never written to; create, advance, edit, list, get, and remove work on content already in the store.

Tools, integrations & config

What your agents are allowed to do, and the credentials and gates around it.

CommandWhat it does
kx connections add|list|test|discover|fire|remove|doctorconnect to an external tool server, and call its tools
kx tools list|score|discover|register|deregisterbrowse and rank tool manifests; write the durable tools registry
kx skills add|list|show|removethe declarative skill catalog — instructions plus a set of tool wishes
kx secrets set|list|rmthe local OS-keychain secret store
kx triggers add|list|test|fire|rmevent ingress — a webhook, a schedule, or a gRPC call starts a run
kx approvals list|grant|denythe human gate in front of world-changing actions
kx new skill|connector <name>scaffold a skill pack or a connector crate, offline

Key flags

CommandFlags worth knowing
kx connections add--name <n> · --command <path> (+ --arg <a>) or --url <url> (+ --tls-required) · --provider <id> · --credential-ref <ENV_VAR> · --session-mode stateful|stateless
kx connections fire--name <n> · --tool <remote-name> · --args '<json>'
kx tools score--intent <text> · --tool <id>@<ver> (repeatable) · --language-tag <t> · --tolerance-threshold-bp <N>
kx tools register--name <n> · --version <v> · --server-host <host[:port]> · --idempotency-class Token|Readback|Staged|AtLeastOnce · --remote-name <r> · --param <name>[:<ty>]
kx skills add--dir <pack-dir> or --manifest <file> (+ --instructions <md>)
kx secretsset --name <NAME> --value <VALUE> · list · rm --name <NAME>
kx triggers add--name <N> · --kind webhook|cron|grpc · --recipe <handle> or --app <handle> (exactly one) · --auth none|hmac_sha256|bearer · --secret-ref <NAME> · --schedule <secs or 5-field cron> · --timezone <IANA zone> · --require-approval · --enabled
kx triggers fire--name <N> · --payload '<json>' · --idempotency-key <K>
kx approvalsgrant <REQUEST_ID> · deny <REQUEST_ID> · --reason <s>
kx new--dir <parent> (connector default: integrations)

Which command actually reaches out

kx connections is the path that really calls an external tool server: add dials the server, lists its tools, and registers them. kx tools register on its own records a tool in the registry — it does not give you a working integration, because dialing that host is a Cloud capability. If you want a tool that fires, use kx connections.

kx connections add --name notes --command ./kx-connector-notes --credential-ref NOTES_TOKEN
kx connections test --name notes
kx connections discover --name notes
kx connections fire --name notes --tool search --args '{"q":"launch"}'
kx connections doctor
kx tools list --json
kx tools score --intent "read a file from disk" --tool fs-read@1
kx secrets set --name NOTES_TOKEN --value "s3cr3t"
kx skills add --dir ./my-skill
kx new skill triage
kx new connector notes

kx connections doctor runs on your machine — it checks whether the bundled connector programs can be found — so it needs no server. Add --provider <id> to check one of them.

A secret's value is write-only: you send it once, and no command ever returns it. kx secrets list shows names and timestamps only. A connection or a trigger references a secret by name. Writing a secret (set / rm) is accepted only from a loopback caller, so run it on the same machine as the server.

Adding a skill grants nothing. A skill declares a wish for tools; at run time the server intersects that wish with your actual grants and with what can actually fire.

Approvals are the human gate: a world-changing tool call on a chain that requires approval is held, uncommitted, until an operator grants it (it then fires exactly once) or denies it (the chain fails closed). kx approvals list prints the 32-hex REQUEST_ID you pass to grant or deny.

A cron trigger's --schedule is either a plain interval in seconds or a standard five-field crontab expression, evaluated in --timezone (an IANA zone name; empty means UTC).

kx approvals list
kx approvals grant 0123456789abcdef0123456789abcdef --reason "checked the target account"
kx triggers add --name nightly --kind cron --recipe kx/recipes/echo --schedule 86400 --enabled
kx triggers add --name weekdays --kind cron --recipe kx/recipes/echo --schedule "0 9 * * 1-5" --timezone America/New_York --enabled
kx triggers test --name nightly

Help and version

CommandWhat it does
kx --helpthe grouped summary of every command
kx help <command>the full usage for one command, with its subcommands and examples
kx --versionthe version of the binary you have
kx --help
kx help chain
kx --version

The help text is the authority

This page is a map. The binary you installed is the territory. When the two disagree, believe kx help <command>, and check it against kx --help on the version you installed.