Skip to content

Ptah CLI

The Ptah CLI is the desktop app’s engine with no window attached. It hosts the full agent backend in-process and exposes it two ways: as ordinary subcommands you can run in a terminal, and as a JSON-RPC 2.0 session over stdio that another program can drive.

It ships as its own npm package, separate from the desktop app.

Terminal window
npm install -g @hive-academy/ptah-cli

The package installs one binary, ptah.

Terminal window
ptah --version
ptah --help
  • CI pipelines — run a review, a refactor, or a spec end to end on a build agent.
  • Scripted work — drive a change across many repositories from a shell script.
  • Agent-to-agent bridges — let another AI host delegate work to Ptah.
  • Headless machines — a server with no desktop still gets the whole engine.
Terminal window
ptah init

On a real terminal this walks you through license, provider, credentials, and a verification step. In machine mode it never prompts. It emits a structured init.plan listing the exact commands still needed, so an agent can finish the setup itself.

Check the result at any time:

Terminal window
ptah doctor

doctor reports license state, authentication, configured providers, and the effective route — which provider and model a session would actually use right now. When something does not work, start here.

The CLI emits newline-delimited JSON-RPC 2.0 on stdout by default. This is deliberate: the primary consumer is a program, not a person.

FlagEffect
--jsonNDJSON JSON-RPC 2.0 on stdout. The default.
--humanPretty-printed events with color and indentation

Never assume the CLI detects your terminal. If you want readable output, ask for it with --human.

These apply to every subcommand.

OptionPurpose
--jsonNDJSON output (default). Conflicts with --human.
--humanPretty output. Conflicts with --json.
--cwd <dir>Working directory for workspace operations. Defaults to the current folder.
--config <dir>Override the Ptah data directory. Default ~/.ptah.
--quietSuppress non-essential notifications. Conflicts with --verbose.
--verboseEmit additional debug.* notifications. Conflicts with --quiet.
--no-colorDisable ANSI codes in --human mode.
--auto-approveAuto-allow every permission request. run and execute-spec only.
--revealShow secrets verbatim. config list only.
-V, --versionPrint the version and exit.
-h, --helpPrint usage and exit.

--config has an environment-variable twin, PTAH_CONFIG_PATH. The flag wins. Settings, secrets, the SQLite database, and migrations all live under whichever directory you choose.

Scripts should branch on the exit code, not on the output text.

CodeNameMeaning
0SuccessThe command completed.
1General errorThe command failed.
2Usage errorBad arguments or a refused flag combination.
3Auth requiredNo usable credential, or an approval timed out.
4License requiredThe license server rejected the key.
5Internal failureAn unexpected fault. Worth reporting.

A SIGINT exits 130. A SIGTERM exits 143.

An approval-gated request waits five minutes and then exits 3. That is correct for a person at a keyboard and wrong for a build agent. For unattended runs, set:

Terminal window
PTAH_AUTO_APPROVE=true ptah session start --task "Run the review pass" --once

Run a task, stream the events, exit.

Terminal window
ptah session start --task "Summarize the auth module" --once --human
Terminal window
ptah interact

This blocks, reading newline-delimited JSON-RPC requests from stdin until EOF (Ctrl-D) or SIGINT. It is the surface for machine hosts and A2A bridges. For a one-off human run, prefer session start --once --human.

Terminal window
ptah mcp-serve

This turns Ptah into a stdio Model Context Protocol server. An external MCP host — another coding agent, an editor — launches it as a child process and delegates whole tasks to Ptah’s Team Leader through the standard protocol. See Driving Ptah via MCP.

Terminal window
ptah tui

tui launches an interactive terminal interface on top of the same engine. It needs a real TTY.