# CmdBrief CLI reference for headless Linux and terminal control

> Complete copyable reference for every cmdbrief subcommand — install.sh, serve, service, pairing, builders, project control, routines, allowlisted settings, stdin secrets, updates, and the Linux cgroup security model.

- **Category:** Setup and safety
- **Updated:** 2026-12-01
- **Reading time:** 10 min
- **Canonical page:** https://cmdbrief.com/guides/cmdbrief-cli-reference

## Quick verdict

- Every `cmdbrief` subcommand runs from the same native binary: use `cmdbrief serve` and `cmdbrief service install` to run headless on Linux (systemd user unit) or Windows (Task Scheduler), and control running projects, settings, routines, pairing, and updates from your shell.
- Add `--json` to project commands, `settings`, `routines`, `update` (except `rollback`), `computers`, `unpair`, `access`, `builder`, `approve`, `deny`, `handoff`, and `remote-host` for structured output; pass `--workspace <profile>` before any command to target a named profile.
- On Linux, **write** commands are accepted **only from a terminal or SSH session outside CmdBrief’s own cgroup** so agents spawned by CmdBrief cannot answer their own prompts, approve computers, or edit settings. Off Linux, running-app commands are read-only.

## What you get

- **Your terminal or SSH session:** Outside CmdBrief’s systemd cgroup; Runs read and write `cmdbrief` commands; Pipes secrets via stdin (never command-line args)
- **`cmdbrief.service` (`cmdbrief serve`):** Runs leads, crews, coordination, cloud link, and direct peer line; Verifies caller PID & `/proc/<pid>/cgroup` via `SO_PEERCRED`; Refuses write commands from its own cgroup (agents & child shells)
- **Your terminal or SSH session → `cmdbrief.service` (`cmdbrief serve`):** control-socket commands (`--json` optional)
- **`cmdbrief.service` (`cmdbrief serve`) → Your terminal or SSH session:** human-readable reports or JSON answers
- **Connection:** Local AF_UNIX control socket; agents inside CmdBrief’s cgroup can read but never write

General syntax: `cmdbrief [--workspace <profile>] <command> [arguments]`. Use `cmdbrief version` (`-V`, `--version`) to print the version and build number, and `cmdbrief help` (`-h`, `--help`) to inspect the built-in command reference on your installed release.

> **Tip:** Looking for guided end-to-end walkthroughs? Follow [Install CmdBrief](https://cmdbrief.com/guides/install-cmdbrief), [Run agents on a Linux server](https://cmdbrief.com/guides/run-agents-on-a-linux-server), [Add a Linux build machine](https://cmdbrief.com/guides/linux-build-machine), or [CmdBrief on a rented cloud machine](https://cmdbrief.com/guides/cmdbrief-on-a-rented-machine).

## Install and run headless with serve and service

**One-line Linux server install and service management**

```bash
# Install or upgrade ~/.local/bin/cmdbrief (checks Ed25519 signature + SHA-256),
# installs cmdbrief.service, signs in, turns sharing on, and prints a pairing code:
curl -fsSL https://cmdbrief.com/install.sh | sh

# Run headless in the foreground (Linux and Windows):
cmdbrief serve

# Manage the background user service:
cmdbrief service install            # Linux: ~/.config/systemd/user/cmdbrief.service
                                    # Windows: Task Scheduler task "CmdBrief" (at sign-in)
cmdbrief service status             # State and recent logs (same as bare `cmdbrief service`)
cmdbrief service uninstall          # Stop and remove the service

# Linux: keep the systemd user service running after SSH logout:
sudo loginctl enable-linger "$USER"
journalctl --user -u cmdbrief -f    # Follow service logs

# Windows only (headless serve):
cmdbrief service start              # Start the Task Scheduler task now
cmdbrief service stop               # Ask serve to quit cleanly (logs: <app support>\logs\serve.log)
```

| Exit code / Unit detail | Meaning |
| --- | --- |
| Exit code `3` (`IN_USE`) | Another CmdBrief instance (window or `serve`) already owns this profile; `cmdbrief.service` does not restart on exit code 3. |
| Exit code `75` | An update finished installing and asked systemd to restart into the new binary cleanly (`SuccessExitStatus=75`, `RestartForceExitStatus=75`). |
| `KillMode=mixed` | Only CmdBrief gets `SIGTERM` first so it runs its normal quit sequence and records interrupted agents cleanly. |

*Headless service behavior on Linux (x86_64, glibc 2.35+, systemd). See Pair another Mac or Windows PC for Windows headless details.*

## Account sign-in and computer approval

`login`, `logout`, and `whoami` talk to the local account store directly and notify any running CmdBrief instance, so they work before `cmdbrief.service` exists. Accounts allow up to **5 signed-in computers** at once; new computers wait for approval from an existing computer on the account.

**Sign in, check account status, and approve new computers**

```bash
cmdbrief login [email]              # Prompts for emailed one-time code; waits if approval is needed
cmdbrief logout                     # Sign out, or stop waiting for approval
cmdbrief whoami                     # Print signed-in email and subscription plan

# Run on an existing Linux computer (whole computer name or device id — never a prefix):
cmdbrief approve "<computer name>"
cmdbrief approve "<computer name>" --remove "<old computer>"   # Free a slot at the 5-computer cap
cmdbrief deny "<computer name>"
```

## Sharing, remote control, pairing, and build computers

**Configure computer identity, pairing, and builders**

```bash
# Computer visibility & remote-host preset (omit on|off to read current state):
cmdbrief share [on|off]             # Let your other computers see this computer's leads
cmdbrief remote [on|off]            # Remote control from Grok, ChatGPT, and MCP chat apps
cmdbrief remote-host [on|off]       # On: resumes interrupted agents, starts cold chats fresh,
                                    # keeps What's new & alert sounds off, turns sharing on.
                                    # Off restores what it changed while keeping sharing on.
cmdbrief computer                   # Show computer name, use, sharing, and remote status
cmdbrief computer name <name>       # Set the name shown on other computers and chat apps
cmdbrief computer use <words>       # Describe what this computer is for

# Pairing & paired-computer access (needs signed-in account + `cmdbrief share on`):
cmdbrief pair [--leads]             # Print a 6-digit code for another computer (Full use default; --leads for leads only)
cmdbrief pair --with <name> [--full] # Pair from this side by typing <name>'s 6-digit code (leads default; --full for full use)
cmdbrief computers                  # List paired computers, access level, and direct-line state
cmdbrief access <name> full|leads   # Change what a paired computer may do here
cmdbrief unpair <name>              # Forget a paired computer

# Build computer controls:
cmdbrief builder on                 # Take builds and tests from paired computers with full use
cmdbrief builder off                # Stop taking new builds (in-flight runs finish first)
cmdbrief builder status             # Show OS, cores, memory, free disk, slots, toolchains, copies (works even if stopped)
cmdbrief builder clean <project> [--from <computer>]   # Remove a cached project copy kept here

# Windows build computer launcher (early; run in an Administrator terminal):
cmdbrief builder launcher install|uninstall|status
```

For `unpair` and `access`, `<name>` matches case-insensitively, by unique prefix, or by device ID. For `pair --with <name>`, pass the computer’s exact name or device ID. See [Pair another Mac or Windows PC](https://cmdbrief.com/guides/pair-mac-and-windows) for pairing from the desktop window.

## Control projects, agents, models, and handoffs

**Start, inspect, message, steer, and stop leads and crews**

```bash
# Start a new project and lead (--lead: claude, codex, grok, cursor, opencode, or antigravity):
cmdbrief start "Add dark mode" --lead claude --folder ~/src/app
cmdbrief start "Build API" --lead codex --clone https://github.com/org/repo.git --name api --autopilot once
cmdbrief start - --lead opencode --github < brief.txt   # "-" reads brief from stdin

# Inspect projects, CLIs, and waiting questions/approvals:
cmdbrief status [project]           # Summary of every project or one project
cmdbrief agents                     # Installed and signed-in agent CLIs, git, and gh
cmdbrief needs-you [project]        # Waiting agent asks, host asks (host:<source>:<key>), and sign-in requests
cmdbrief messages <project> [--count N]   # Read the lead's recent conversation

# Answer waiting items and message leads:
cmdbrief answer <id> Allow          # Answer by option label(s) from needs-you
cmdbrief answer <id> --text "Use option B"   # Or pass free text ("-" reads stdin)
cmdbrief tell <project> "Add print styles"   # Default: steer working lead at its next step
cmdbrief tell <project> "After this, write tests" --queue
cmdbrief tell <project> "Stop — wrong branch" --interrupt

# Tune models, stop runs, hand off, or remove workspaces:
cmdbrief model <project> Ada                 # Inspect what Ada runs and can take
cmdbrief model <project> Ada --effort medium # Lower/in-tier effort change (applied after current turn)
cmdbrief model <project> --crew --model sonnet --yes   # Model switch or higher tier needs --yes
cmdbrief stop <project>                      # Stop lead and crew (same as Stop lead & crew)
cmdbrief handoff <project> --to <computer> [--anyway]  # Move project to a paired computer (--anyway cuts an active turn)
cmdbrief handoff back <project>              # Bring the project back here
cmdbrief remove <workspace> --yes            # Remove workspace from CmdBrief (folder stays; omits --yes to preview & exit 1)
```

`needs-you` also surfaces host dialogs as `host:<source>:<key>` IDs (`dev-stack`, `mcp-layout`, `ssh`, `plan`, `cli-update`, `files`, `account`), which you answer with `cmdbrief answer <id> <Choice>` — for example `Allow` on a `dev-stack` or `ssh` request (allowing `ssh` via CLI grants that single request only, never “Keep allowing”).

## Routines, allowlisted settings, secrets, and updates

**Schedule routines, change allowlisted settings, pipe secrets, and manage updates**

```bash
# Routines (works offline on routines.json when CmdBrief isn't running, except `run`):
cmdbrief routines
cmdbrief routines add --lead Ada --name "Daily report" --message "Summarize PRs" --daily 09:00 --days mon,tue,wed,thu,fri
cmdbrief routines add --lead Ada --name "One-off check" --message "Check deploy" --once "2026-12-05 14:00"
cmdbrief routines add --lead Ada --name "Monitor" --message "Check queue" --every 2 --between 09:00-18:00
cmdbrief routines edit <id> --off            # Accepts any add option plus --on or --off
cmdbrief routines run <id>                   # Deliver immediately to the lead
cmdbrief routines remove <id>

# Allowlisted settings (same Save path as the Settings window — never hand-edit settings.json):
cmdbrief settings                            # List every allowlisted key by Settings page with current value
cmdbrief settings get agent_sleep            # Print one setting in full (secrets show "set" or "not set")
cmdbrief settings set agent_sleep never      # Accepts JSON, on/off, or plain words

# Secrets MUST be piped on stdin (never passed as an argument or typed on a TTY):
printf '%s' "$OPENROUTER_API_KEY" | cmdbrief settings set openrouter
printf '%s' "$DEEPSEEK_API_KEY" | cmdbrief settings set deepseek
printf '%s' "$CONNECTOR_TOKEN" | cmdbrief settings set connector.posthog
cmdbrief settings unset openrouter           # Remove openrouter, deepseek, or connector.<id>

# Updates & rollback:
cmdbrief update --check                      # Check for a newer release without installing
cmdbrief update                              # Download, install, and follow restart
cmdbrief update auto [on|off]                # Headless / Remote host auto-install after 2 min idle (on by default)
cmdbrief update rollback                     # Linux only: restore cmdbrief.previous and dismiss the rolled-back release
```

Add `--json` anywhere on the command line (even before the subcommand) to receive structured JSON from project commands (`start`, `status`, `agents`, `needs-you`, `answer`, `tell`, `messages`, `stop`, `model`, `remove`), `settings`, `routines`, `update` / `update --check`, `computers`, `unpair`, `access`, `builder`, `approve`, `deny`, `handoff`, and `remote-host`. Other commands (`serve`, `login`, `logout`, `whoami`, `service`, `pair`, `remote`, `share`, `computer`, `update auto`, `update rollback`, `help`, `version`) print human-readable output only (and `pair` / `update rollback` reject `--json`). See [Set up Routines, Goal mode, and Autopilot](https://cmdbrief.com/guides/routines-goal-mode-and-autopilot), [Connect Grok Bot and answer agents from your phone](https://cmdbrief.com/guides/grok-bot-remote-control), [Managed SSH and secrets](https://cmdbrief.com/guides/managed-ssh-and-secrets), [Features](https://cmdbrief.com/features), and the [changelog](https://cmdbrief.com/changelog).

## How the Linux cgroup security model works

Coding agents run as your Linux user and can read the local control socket token. To stop an agent from approving its own permission prompt, pairing a rogue computer, or modifying settings, CmdBrief enforces a **cgroup boundary** on every write command:

- **Kernel peer verification:** when a CLI command connects to the local control socket, CmdBrief reads the caller PID from `SO_PEERCRED` and compares `/proc/<pid>/cgroup` against CmdBrief’s own cgroup.
- **Why agents stay inside:** every process CmdBrief spawns — and every child those processes spawn, even if it calls `setsid`, double-forks, or reparents — stays inside CmdBrief’s cgroup because only systemd moves a process into a different unit.
- **Reads vs writes:** read commands (`status`, `needs-you`, `messages`, `agents`, `settings`, `settings get`, `builder status`) are accepted from any local peer. Write commands (`answer`, `tell`, `start`, `stop`, `model`, `remove`, `handoff`, `pair`, `unpair`, `access`, `approve`, `deny`, `remote`, `share`, `remote-host`, `computer`, `builder on|off|clean`, `settings set|unset`, `routines add|edit|remove|run`, `update`, and `update rollback`) are accepted **only on Linux** and **only from outside CmdBrief’s cgroup**.
- **Avoid running `cmdbrief serve` inside your SSH/tmux session:** if you launch `serve` directly inside tmux, both `serve` and your shell share the same user-session cgroup, so write commands will be refused. Always run headless CmdBrief as the systemd user service (`cmdbrief service install`) so it gets its own `cmdbrief.service` cgroup.
- **Honest boundary:** as documented in the app, this blocks casual and detached child-process self-approval, not a hostile same-user process that asks systemd directly for a separate unit (`systemd-run --user`) — the same OS user boundary that applies to `0600` secret files on Linux.
- **macOS and Windows:** off Linux, running-app CLI commands are read-only (`login`/`logout`/`whoami`, `service`, and Windows `builder launcher` still work). Make pairing, approval, and settings changes in the desktop window or via a paired computer.

**Check it worked**

| Where | Run or do | Pass |
| --- | --- | --- |
| Linux SSH session | `systemctl --user is-active cmdbrief && cmdbrief status` | Prints `active` and lists your workspaces cleanly. |
| Linux SSH session | `cmdbrief settings get remote_host --json` | Returns a valid JSON object showing the current `remote_host` value. |

## If it fails

| What it says | Fix |
| --- | --- |
| Write command refused because it came from inside CmdBrief | **You:** Run the command from your own terminal or SSH session outside `cmdbrief.service`. If you started `cmdbrief serve` in tmux, stop it and install the systemd service with `cmdbrief service install`. |
| `cmdbrief serve` exits immediately with code `3` | Another CmdBrief window or `serve` process already owns this profile. Stop the other copy and keep only the service running. |
| `cmdbrief settings set openrouter <key>` is refused | Secrets (`openrouter`, `deepseek`, `connector.<id>`) are never accepted as command-line arguments or from a TTY. Pipe them on stdin: `printf '%s' "$KEY" \| cmdbrief settings set openrouter`. |
| `cmdbrief remove <workspace>` exits `1` without deleting anything | Without `--yes`, `remove` only previews what will be removed. Re-run with `--yes` (the project folder on disk is never deleted). |
| `cmdbrief model` refuses to switch models or raise effort | Switching to a different model or an effort level higher than a lead may set on its own requires `--yes`. |
| `cmdbrief update rollback` asks you to quit CmdBrief first | When CmdBrief runs as a window or foreground `serve` instead of `cmdbrief.service`, quit it first and run `cmdbrief update rollback` again (under the systemd service, rollback restarts the unit automatically). |
| A write command on macOS or Windows says to use Settings | Off Linux, the CLI only reads state from the running app. Make pairing, approval, and settings changes in the desktop window. |

## Questions

### Can I sign coding agent CLIs in with a cmdbrief command?

Sign agent CLIs in with their own commands (`claude auth login`, `codex login --device-auth`, `gh auth login`) over SSH, or from your paired Mac under **Settings › Computers › `<server>` › Setup › Sign in**.

### Does `cmdbrief remove <workspace> --yes` delete my source code folder?

No. Like **Delete workspace…** in the app, it removes the workspace from CmdBrief while leaving the folder on disk untouched.

### How does `cmdbrief update auto` avoid interrupting active agents?

When auto-update is on (the default under `serve` and **Remote host**), CmdBrief downloads the signed release in the background and waits until no agent has been busy for 2 minutes before installing and restarting with exit code `75`.

### Can I run two isolated headless profiles on one Linux machine?

Yes. Pass `--workspace <profile>` before `service install`, `serve`, and every CLI command (for example `cmdbrief --workspace staging service install`) to keep each profile’s data, socket, and service isolated.

## Primary sources

Provider terms and product behavior can change. Confirm plan, pricing, model, and permission details in the current official documentation.

- [systemd: systemd.service manual](https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html)
- [systemd: loginctl manual](https://www.freedesktop.org/software/systemd/man/latest/loginctl.html)
- [Linux Kernel: Control Group v2](https://docs.kernel.org/admin-guide/cgroup-v2.html)
- [Linux manual: unix(7) SO_PEERCRED](https://man7.org/linux/man-pages/man7/unix.7.html)

## Keep reading

- Setup and safety: [Run your agents on a Linux server and close your laptop](https://cmdbrief.com/guides/run-agents-on-a-linux-server)
- Setup and safety: [Add a Linux build machine for your Mac’s agents](https://cmdbrief.com/guides/linux-build-machine)
- Workflows: [Set up Routines, Goal mode, and Autopilot](https://cmdbrief.com/guides/routines-goal-mode-and-autopilot)
- Setup and safety: [Use CmdBrief on a rented cloud machine](https://cmdbrief.com/guides/cmdbrief-on-a-rented-machine)
- Setup and safety: [Managed SSH (1Password), sending keys, and ${NAME} secrets](https://cmdbrief.com/guides/managed-ssh-and-secrets)

---

Markdown mirror of https://cmdbrief.com/guides/cmdbrief-cli-reference, generated at build time from the same data the HTML page renders. Machine-readable index: https://cmdbrief.com/llms.txt
