Non-interactive mode

Pipe cortex into scripts with --prompt.

The split: stdout for answers, stderr for everything else

--prompt runs a single turn with no TUI, then exits. The assistant's answer goes to stdout; tool activity, notices and errors go tostderr. That separation lets you compose:

cortex --prompt "list every exported function in internal/ui" > api.txt
cortex --prompt "summarize the TODOs" | fold -s | head -40

Objective verification

When a command can judge the result, add --verify. A failing verifier is sent back to the same session for up to --repair-attempts extra turns, then run again.

cortex --prompt "fix the failing report total" --verify "python3 -m pytest -q" --repair-attempts 1

The extra turn only happens on failure, so cheap smoke tasks do not pay repair tokens when the first answer is already correct.

Cancellation

In non-interactive mode, Ctrl-C ends the process — the ordinary expectation for a one-shot command. This is different from interactive mode, where Ctrl-C cancels the turn.

Iteration limits

A --prompt run is bounded by maxIterationsOnce, a cap on how many tool turns the agent may take before it must answer. Interactive mode is unbounded — a human is watching, and Ctrl-C ends a turn that has lost its way.

ℹ️
Why bounded? With no one watching, an agent that loops forever is a bill, not a bug. The cap is deliberately conservative for one-shot use.

Combining with a config

cortex --config reviewer.yaml --prompt "review the last commit"

--config disables the cascade and reads only that file plus the environment. Combine with --prompt for reproducible one-shot runs against a fixed configuration.