--- description: "Every hapi command and its main flags: agent launchers, hub, runner, auth, resume, peer tools, jobs, usage and diagnostics." --- # CLI Reference Every `hapi` command, its purpose and its main flags. Options for agent commands go after the agent name. For environment variables, see [Configuration](./configuration.md). ```bash hapi # Choose an installed agent interactively hapi [options] # Start an agent session hapi [options] # Run a HAPI command hapi --help # Short help (-h, help) hapi --version # Print the version (-v) ``` Running `hapi` with no arguments needs an interactive terminal. Scripts and services must name the agent or command explicitly. ## Agent sessions Each command starts the agent in the current directory and registers the session with the hub. If `HAPI_API_URL` and `apiUrl` are unset, this machine has run a hub before (its token is in `settings.json`), and nothing listens on port 3006, the CLI starts a hub in the background for the duration of the session. `hapi claude` also starts the runner if it is not running the installed version. | Command | Agent | |---------|-------| | `hapi claude` | Claude Code | | `hapi codex` | OpenAI Codex | | `hapi cursor` | Cursor Agent | | `hapi copilot` | GitHub Copilot | | `hapi grok` | Grok Build | | `hapi opencode` | OpenCode | | `hapi kimi` | Kimi Code | | `hapi pi` | Pi | | `hapi dsh` | DeepSeek Harness (ACP) | | `hapi agy` | Antigravity | `hapi gemini` only prints a notice: the Gemini CLI was retired in June 2026. Existing Gemini sessions remain viewable. See [Supported Agents](./agents.md) for installation, permission modes and agent-specific behavior. ### Common flags Support varies by agent. Claude, Codex and Cursor pass unknown flags through to the agent; the other agents ignore them. | Flag | Description | |------|-------------| | `--permission-mode ` | Initial permission mode. Allowed values depend on the agent (for example Claude `default`, `acceptEdits`, `auto`, `bypassPermissions`, `plan`). Pi has none. | | `--yolo` | Shortcut for the agent's auto-approve mode (`bypassPermissions`, `yolo` or `always-proceed`). Ignored when `--permission-mode` is given. | | `--model ` | Model to start with. | | `--effort ` | Reasoning effort, where the agent supports it. Codex uses `--model-reasoning-effort`; `hapi dsh` rejects it. | | `--resume ` | Resume a native agent conversation. Codex uses `hapi codex resume` instead. | ### Per-agent flags | Agent | Flags | |-------|-------| | Claude | Unknown flags pass through to `claude`, so `hapi claude --resume` and `--continue` work; when HAPI already owns that conversation, the existing HAPI session is reopened. `--dangerously-skip-permissions` is treated as `--yolo`. `--model=` is accepted. | | Codex | `--model-reasoning-effort `, `--service-tier fast\|standard`, `--collaboration-mode default\|plan`, `--dangerously-bypass-approvals-and-sandbox` (same as `--yolo`). `hapi codex resume ` or `hapi codex resume --last [--all]` resumes a native thread. `fork`, `exec`, `review`, `login` and `logout` must be run with native `codex`. | | Cursor | `--mode `, `--plan`, `--force` (same as `--yolo`), `--auto-review`, `--cursor-worktree [name]`, `--cursor-add-dir ` (repeatable), `--continue`. `hapi cursor resume ` or `--resume ` resumes a chat. | | Copilot | `--copilot-agent-mode interactive\|plan\|autopilot` (alias `--mode`). | | OpenCode | `-s` / `--session ` resumes an OpenCode session. | | Pi | `--session-id ` resumes a Pi session. | | DeepSeek Harness, Antigravity | Remote-only; there is no local terminal UI. The ACP server for `hapi dsh` is set with `HAPI_DSH_ACP_*`. | Flags beginning with `--hapi-` and `--started-by`, `--existing-session-id` are used internally when the runner spawns a session. ## Hub ### `hapi hub` Starts the hub: API, web app, Socket.IO and notifications. `hapi server` is an alias. | Flag | Description | |------|-------------| | `--host ` | Bind address (sets `HAPI_LISTEN_HOST`). Default `127.0.0.1`. | | `--port ` | Port (sets `HAPI_LISTEN_PORT`). Default `3006`. | | `--relay` | Expose the hub through the public relay tunnel and print a link and QR codes. | | `--no-relay` | Disable the relay (the default). The last of `--relay` / `--no-relay` wins. | `--host` and `--port` also accept `--host=` / `--port=`. Like the environment variables they set, they are saved to `settings.json` when `listenHost` / `listenPort` is not set there yet, and later runs without the flag keep the saved value. A flag always wins over the file for its run. ```bash hapi hub --relay hapi hub --host 0.0.0.0 --port 8080 ``` See [Installation → Hub setup](./installation.md#hub-setup) and [Deployment](./deployment.md). ## Runner ### `hapi runner` Manages the background service that spawns sessions on request from the web or native apps. | Subcommand | Description | |------------|-------------| | `start` | Start the runner in the background. Stops an existing runner first, so new flags and environment take effect. | | `start-sync` | Run the runner in the foreground. Use this under systemd, launchd or pm2. | | `stop` | Stop the runner. Sessions keep running. | | `status` | Show runner diagnostics. | | `list` | List sessions the runner is tracking. | | `stop-session ` | Stop one runner-managed session. | | `logs` | Print the path of the latest runner log. | `--workspace-root ` (repeatable, `~` expanded) restricts directory browsing and spawning to the given directories. It applies to `start` and `start-sync`. Running `hapi runner` without a subcommand prints help. See [Installation → Runner setup](./installation.md#runner-setup). ## Sessions ### `hapi resume [session-id]` Reopens an existing HAPI session on this machine in the terminal, with its original agent and settings. Without an id it shows a picker; in a non-interactive shell it prints the resumable sessions and exits. If the session is running remotely, control is handed back to this terminal. ### `hapi set-mode ` Changes the permission mode of a session, like the web permission picker. Active sessions switch immediately; inactive sessions use it on next resume. `` may be an id prefix (8 characters is usually enough). An invalid mode prints the allowed list. ### `hapi usage` Shows when agents were working across every machine on the hub. | Flag | Description | |------|-------------| | `--since