cmd/muster is a machine client for muster's JSON API, used by agents, scripts
and you. It builds as the muster binary.
The verb set is pinned in two places:
tests/verb-ledger.sh, run bymake verb-ledger, interrogates the built binary;cmd/muster/tree_test.gowalks the command tree.
| group | verbs |
|---|---|
| tasks | task ls, task get, task create, task comment, task status |
| an agent's own task | agent task get, agent task comment, agent task status |
| agents | agent ls, agent messages, agent resolve, agent rm (remove an agent; a host officer instance's left-over row needs no provisioner), agent create (creating an agent without the chief), chief ask, chief replace (replacing the chief) |
| browser flows | flow enqueue, flow ls, flow status, flow cancel |
| credentials | token ls, token revoke, whoami |
| session routing | route reply (a mirrored session's answer to a routed message) |
| plugins | plugins retry <message-id> (retry an unconfirmed message), plugins deliver-to <plugin-id> officer:<id> / --clear (bind a plugin to an officer) |
| content sets | content-set put <plugin> --file set.json (create an approved content set, pending until you approve it), content-set media <entry-id> <file>... (bind an entry's media, in order). Both need MUSTER_TOKEN to be your own personal API token (mst_…): the shared hook token is refused |
| pages | page publish <page-id> --blocks <file.json|-> [--title T] [--notify] [--if-version N] (publish the next version of one of your pages, current at once; quiet unless asked, always rolling). It needs MUSTER_TOKEN to be your own personal API token (mst_…): the shared hook token is refused (exit 3); another person's or a team's page is not found (exit 4); a stale --if-version is a conflict (exit 5; the server's error_code is stale_version), and a rolling page none of whose older versions may be dropped is exit 14 (error_code page_full: a retry does not help); either way nothing is published; blocks that are not JSON are refused before any request (exit 2) |
| pull requests | pr-session <owner>/<repo>#<n> (which of your sessions created a pull request: below) |
| setup | doctor (below) |
| scheduled host jobs | job list, job runs <name>, job run <name>, job pause <name>, job resume <name>, job forget <host> <name> (the jobs your machines declare, their runs, run one now, pause or resume one's schedule, forget one of a machine that is gone: host-jobs.md) |
| the ask log | asks log, asks summary (what your agents asked you, how you answered, how long it took: below) |
| chief nudges | nudge next (a host's oldest chief-nudge notice as a tmux target: below) |
| several servers | tenant list, tenant current, tenant use, tenant add, tenant remove (below) |
Global flags: --api-url, --token, --env-file (default
~/.muster/muster.env), --tenant and --timeout.
The CLI looks for each setting in three places, from lowest to highest priority:
- the env file;
- the environment;
- flags.
| setting | variable | flag |
|---|---|---|
| API URL (no default; it must be an absolute http(s) URL) | MUSTER_API_URL |
--api-url |
| credential | MUSTER_TOKEN (older name: MUSTER_HOOK_TOKEN; MUSTER_TOKEN wins within one source) |
--token |
A token from the env file goes only to that file's own server. When the
URL comes from --api-url or MUSTER_API_URL and its origin (scheme, host,
port) is not the env file's MUSTER_API_URL's, a token the file supplied is
not sent: the CLI exits 2 before any request and says so. That includes a file
holding a token and no URL, which names no server for it. For another server,
give its token with it (MUSTER_TOKEN, or --token), or add a tenant for it
(below). The file's MUSTER_AGENT_CREATE_TOKEN is
bound the same way (only agent create, which sends it, refuses). muster doctor is the one verb that does not refuse: it runs without the file's
token (its server-side checks SKIP, as on a machine with no credential) and
says so in one line, so muster doctor --api-url <hub> still checks a hub
from any machine.
The usual credential is a personal API token (mst_…). Mint it in the
browser at /account/tokens; it acts as you (auth.md). Tokens cannot
be minted from the CLI. muster token ls and muster token revoke <id> manage
them, and muster whoami says who a credential acts as.
On the machine it installs the server on, install.sh writes
~/.muster/muster.env (mode 600) with the local address and the server's
hook token: the one credential there before anyone has signed in. It acts
as the machine user, so whoami, doctor and most verbs work at once, but
token … and the verbs that need a person refuse it. To act as yourself,
replace its MUSTER_TOKEN with a personal token. The installer writes the file
only when there is none: an existing muster.env is never changed, and the
installer prints the two lines it would need for this server instead.
agent create is the one exception: it presents MUSTER_AGENT_CREATE_TOKEN, a
token of scope Start agents only (agent-create), and never sends
MUSTER_TOKEN. The server refuses every other token on POST /api/agents, a
full-access one included, so the ordinary credential cannot create agents.
Where it is read from:
- One tenant: from the env file, then the environment, like the token.
The file's one goes only to the file's own server, exactly as the file's
MUSTER_TOKENdoes: beside aMUSTER_API_URLor--api-urlfor another origin,agent createrefuses (exit 2, nothing sent). - More than one tenant: the pair rule below covers it too. It comes from
the selected tenant's file, or from the environment only beside an
environment
MUSTER_API_URL+MUSTER_TOKENpair. An exported one with neither makes it unusable for that tenant:agent createrefuses (exit 2, nothing sent) and says where to put it; every other verb runs as usual, since none of them sends it. - A flag pair (
--api-url+--token) cannot carry one: there is no flag for it, and an exported one beside a flag pair names no server's pair. On a host with more than one tenant,agent createwith a flag pair is therefore refused; use the tenant's file or an environment pair.
A tenant is a separate muster server, at its own URL, with its own credential. On this host each one is an env file:
⚠ Not on Windows. The Windows CLI refuses tenant files (it cannot open
them without following a symlink, nor check that only you can read them), so
muster tenant add there writes a file that every command selecting that tenant refuses. On
Windows use the default ~/.muster/muster.env, or --api-url and
MUSTER_API_URL / the token variables per call; WSL (Linux) has tenants.
~/.muster/muster.env # tenant "default": today's file, unchanged
~/.muster/tenants/work.env # tenant "work" (0600; the directory 0700)
~/.muster/current # one line naming the current tenant; absent = default
printf '%s\n' "$TOKEN" | muster tenant add work --api-url https://muster.example.com
muster tenant list # name, label, origin, current; never a token
muster tenant use work # writes ~/.muster/current
muster --tenant default task ls # one call on another tenant
muster tenant current # which tenant, and whether flag/env/file/default chose it
muster tenant use --clear # deletes ~/.muster/current
muster tenant remove work- Selection, highest first:
--tenant,MUSTER_TENANT,~/.muster/current,default.--env-filemeans "this file, not a tenant": it is refused next to--tenantand wins overMUSTER_TENANTandcurrent. tenant addreads the token from stdin, never argv (--tokenis refused there). It refuses the namedefault, a name that exists, and an origin another tenant already has. It checks the token withGET /api/whoamibefore it writes the file, and prints the origin and the principal.- A tenant file readable by group or others, or a symlink, is refused. An
optional
MUSTER_TENANT_LABEL=line in it sets the labeltenant listshows. tenant usere-targets every script on this host that runs the CLI without naming a tenant. Such a script should setMUSTER_TENANT.
The pair rule. A host with no tenant file (no entry at all under
~/.muster/tenants/), no current file, and nothing setting MUSTER_TENANT or
--tenant resolves field by field (configuration), with the
env file's token bound to the env file's URL.
Everywhere else the selected file supplies the URL and the token as a pair.
A URL override (MUSTER_API_URL, --api-url) and a token override
(MUSTER_TOKEN, MUSTER_HOOK_TOKEN, --token) are accepted only together, and
only from one kind of source: --api-url with --token, or MUSTER_API_URL with
MUSTER_TOKEN/MUSTER_HOOK_TOKEN. One without the other, or a flag paired with
an exported variable, exits 2 and sends nothing. This is what stops one server's
token reaching another server. tenant use --clear alone does not lift it while
tenant files remain. doctor --deploy-env follows it too: a deploy file that
sets MUSTER_PUBLIC_URL without MUSTER_HOOK_TOKEN is refused rather than
paired with the selected tenant's token (with one env file, only when that
file's token is another server's).
tenant add writes the file atomically (a temporary file, then a link that
never replaces an existing tenant), refuses a symlinked ~/.muster/tenants/,
tightens a group- or world-accessible one to 0700, and warns on stderr when the
origin is http:// (the token then travels in cleartext). A file under
~/.muster/tenants/ named with --env-file gets the same 0600 and
not-a-symlink checks as --tenant, and so does a symlink elsewhere that points
at one (it is refused as a symlinked tenant file).
Any entry under ~/.muster/tenants/ keeps the host off the zero-touch path,
including one that is not a tenant (a .add-* file left by an interrupted
tenant add, say). tenant list names such entries on stderr, and so does a
pair-rule refusal, so you can see why; remove what you do not need.
The design behind tenants is in docs/design/multi-tenant.md.
What is printed. stdout stays JSON. With more than one tenant, a tenant
chosen by ~/.muster/current is named on stderr (tenant: work (muster.example.com));
an explicit --tenant or MUSTER_TENANT is not echoed. With more than one
tenant, the version-skew note, the credential error and the route-absent error
name the tenant too, and the credential error names that tenant's file.
This repository is public, so the CLI can be fetched and pinned by revision. In
a downstream flake, add muster.url = "github:ZacxDev/muster" and use
muster.packages.${system}.muster.
- The output is
muster, the one binary (the client and the server and host roles), with amuster-mirrorsymlink beside it.muster-cliandmuster-mirrorare aliases of the same output, kept for flakes pinned to those names. - The binary answers to whatever name you invoke it as. It uses
argv[0]for its help text, its error prefix and its version-skew note. So you can symlink it under another name, and nothing else changes.
nix run github:ZacxDev/muster#muster -- task ls
go build -o muster ./cmd/muster # or plain GoChecks a muster installation end to end from the machine it runs on, and
prints how to fix each failure. INSTALL.md and install.sh end with it.
muster doctor --deploy-env <deploy-env-file> # on the machine running the server
muster doctor --api-url https://<your-muster-address> # on any other machineOn a machine other than the server, the doctor needs the server's address:
--api-url, or MUSTER_API_URL in the environment or in the env file. The API
URL has no default, so without one the doctor stops before checking anything.
INSTALL.md's "Check it" passes --api-url there.
The deploy file is the server's own .env when it sets the password and the hook
token; a Compose stack that generated them (no .env, quickstart-local.md)
prints them with docker compose exec muster /muster-server show-secret ui-password
(and hook-token), and INSTALL.md's "Check it" writes them into a private file for
--deploy-env.
| check | PASS means | read from |
|---|---|---|
server |
GET /health answers muster's document, over https |
the server |
manifest |
/manifest.webmanifest is a standalone manifest with icons |
the server |
hook-token |
the server enforces a hook token and accepts this one | GET /api/doctor |
database |
the server reached Postgres at boot, and says with which login: DATABASE_URL, or the fallback DATABASE_URL_FILE (Postgres refused DATABASE_URL's own login: configuration.md). Both pass; a server that does not say is a SKIP |
GET /api/doctor |
mirror-hosts |
every host holding a live mirror token is connected | GET /api/doctor (the tunnel hub) |
this-host |
the server accepts THIS machine's mirror token and holds a connection from it | GET /mirror/host, with the token muster-mirror's settings file names |
mirror-service |
the muster-mirror user service is active here, whatever it runs: muster host (what install.sh writes) or muster-mirror (an install from before the one binary, which still works; install.sh rewrites it when it runs again). A Linux machine with no systemd (no systemctl, or systemd not booted: a container, WSL without systemd) is a SKIP whose fix is the tmux command that runs muster host by hand (this binary's own, or a muster-mirror in a build without the host role); this-host is then the proof it runs. A booted systemd with the unit missing or inactive is a FAIL |
systemctl --user is-active (Linux), launchctl print (macOS) |
tmux |
tmux is installed here | tmux -V |
sign-in |
the operator password signs in, and the session opens the board | POST /login, then GET /tasks |
push |
the VAPID keys are set | GET /api/push/vapid-public-key (signed in), else GET /api/doctor |
dictation |
a bundled 1.7 s spoken sample comes back as text through POST /transcribe. Dictation off on the server is a SKIP: it is an optional feature. Misconfigured (MUSTER_STT_URL without MUSTER_STT_TOKEN) is a FAIL |
the server and its speech-to-text service |
features |
no feature the server reports is misconfigured (asked for, with a dependency missing); a feature that is merely off is not a failure. Every feature is listed below the checks, with its state and the line that turns it on | GET /api/doctor |
officers |
each officer declared for you (in MUSTER_OFFICERS or the database) can start an instance: a pod officer has the agent plane; a host officer's machine is connected, starts and closes agent windows, finds claude and is logged in to Claude Code, and has the officer's repository on -agent-spawn-repos (an officer with no repository needs none: it starts in a scratch directory). Each FAIL names the officer, what is in its way and the fix; no officer is a SKIP |
GET /api/doctor (the hub's view of each host's readiness) |
mcp-endpoint |
this machine's muster-mirror serves its local MCP endpoint (MUSTER_MIRROR_MCP_LISTEN in its settings) and has written its secret where muster-mirror keeps it (MUSTER_MIRROR_MCP_SECRET_FILE, else the user config directory: $XDG_CONFIG_HOME or ~/.config on Linux, ~/Library/Application Support on macOS). Unset is a SKIP: the agent ask tool is optional |
this machine's muster-mirror settings |
mcp-registration |
one of Claude Code's scopes for this directory registers that endpoint (any loopback spelling: localhost, 127.0.0.1, ::1; same port, path /mcp), so sessions here have muster's tools. A registration in only the local or project scope passes and says sessions elsewhere have none. A FAIL prints the exact claude mcp add-json command and the export MUSTER_MIRROR_MCP_SECRET=… line with the secret's path in it (where the secret is), after the install step when no claude is on PATH, in ~/.local/bin or in ~/.claude/local |
~/.claude.json (user scope, and projects[<this directory>]), ./.mcp.json |
ask-hook |
Claude Code runs muster-mirror ask before AskUserQuestion (ask cards; the hook's matcher is a regular expression, so AskUserQuestion|Bash counts). Absent is a SKIP with the hook to add |
~/.claude/settings.json |
usage-ping |
informational, PASS whether on or off: whether this machine's muster-mirror sends the anonymous usage ping, and why not when off (MUSTER_MIRROR_USAGE_PING=off, DO_NOT_TRACK). It is read from the mirror's settings file only, so a DO_NOT_TRACK set elsewhere in its service's environment is not seen. No settings file is a SKIP. The server's own usage ping is its usage-ping line in the features list below the checks |
this machine's muster-mirror settings |
- Feature off: a route whose feature is off on the server (session routing for
route reply, plugins forplugins retry, …) answers a typed 404, and the CLI printsfeature <id> is disabled on this server — enable with: …and exits 12. A plain 404 from a server that predates the route is still exit 7. - Exit status: 0 when no check FAILs, 1 when any does. A
SKIP(a check that cannot be made from this machine, or--skip) never fails the run. - Output: the report and the QR code go to stderr; stdout is one JSON
document,
{"url", "ok", "checks": [{"name", "status", "detail", "fix"}]}, as for every other verb, wherever the two streams go. To read only the report (a terminal, or an agent whose shell merges the streams), send stdout away:muster doctor >/dev/null. INSTALL.md's "Check it" does. - Credentials: the server-side checks need a token (the hook token, or a
personal token; a personal token sees only its owner's hosts); without one
they SKIP.
--deploy-envreads the compose.env: itsMUSTER_PUBLIC_URLandMUSTER_HOOK_TOKENbeat the env file and the environment (only--api-url/--tokenbeat them), and itsMUSTER_UI_PASSWORDis used for the sign-in, push and dictation checks. 🔴 The password is sent only to that file'sMUSTER_PUBLIC_URL; pointed at any other server, sign-in SKIPs. this-hostreads muster-mirror's settings file (--mirror-env, default~/.config/muster-mirror/env) for its token file and itsMUSTER_MIRROR_URL, and asks THAT server with the token. 🔴 The token is never sent anywhere else: when doctor is checking a different URL, this check SKIPs and names the mirror's server. A refused token is a FAIL; so is a connection under this host's name made with another token (two machines minted under one name). It SKIPs on a machine with no settings file. On a team host machine whose connection is held for a manager (mirroring.md), it FAILs with "held: … give this code to a team manager: XXXX-XXXX-XXXX": doctor reads the code muster-mirror left (MUSTER_MIRROR_ATTEMPT_CODE_FILEin the settings file, elsemuster-mirror/attempt-codein the user config directory) and sends it, with the token, to the same server only, which answers whether that code is held, is the live connection's, or neither. When machines are held for the team host and this machine's code is missing, unreadable or neither (held_unknown), it FAILs naming the code file ("this may be a held machine") rather than PASS "connected".- Flags:
--skip <check>[,<check>…],--mirror-env,--mirror-unit(defaultmuster-mirror.service),--mirror-label(defaultio.github.zacxdev.muster-mirror). - The QR code of the URL is drawn with
qrencodewhen it is installed; the URL is printed either way. GET /api/doctoris behind the armed hook token: a server with noMUSTER_HOOK_TOKENanswers 503 with"unarmed": true, which is what thehook-tokencheck reports.
A live chief nudge is a notice
on your Asks list: a pointer at a session that looks like it is waiting on you.
nudge next prints the oldest notice whose session is on one host, with its
tmux target, for a key binding to jump to:
muster nudge next --host laptop # the oldest notice that has a target, one JSON object
tmux switch-client -t "$(muster nudge next --host laptop | jq -r .target)"- Host:
--host, orMUSTER_MIRROR_HOSTwhen it is not given (the name the host's muster-mirror reports). Neither is a usage error (exit 2). - What a notice is:
key,host,target(<tmux session>:<window index>, resolved by the server when asked, so a renumbered window resolves to its new index;""when no mirrored window holds the session now),title,why,sinceandage_secs, andurlwhen the server knows its public URL. A notice with no target is skipped. - Exit status of
next: 0 with the notice on stdout; 11 with nothing on stdout when no notice with a target is waiting on that host; 1 when the queue could only be partly read and none was found (it does not claim none is waiting); and the usual codes otherwise (3 for a refused credential). - Credential: a personal token or a bar-summary token. It reads the attention summary, which is a user's own, so the shared hook token is refused (exit 3).
pr-session reads GET /api/pr-sessions:
the Claude Code sessions recorded as creating a pull request, newest first.
That is the sessions that created it (create rows, newest first_seen, not
limited to routing's 30-day window), which can differ from the session a review
is routed to (routing takes the newest last_seen inside that window and also
matches a pushed head branch). It takes <owner>/<repo>#<n> or the pull
request's GitHub URL:
muster pr-session acme/widget#12
muster pr-session https://github.com/acme/widget/pull/12
claude --resume "$(muster pr-session acme/widget#12 | jq -r '.sessions[0].claude_session')"- stdout is the server's answer with a
resumefield (claude --resume <id>) added to each row; stderr repeats each row as a line — session id, host (or that no window showed it),first_seen,kind— followed by itsclaude --resume <id>line. - Exit status: 0 with at least one row; 4 with nothing on stdout when no session of yours is recorded as creating it; 2 for an argument that is not a pull request (nothing is sent); 12 when the server does not have pull-request routing configured (the read is served only there); and the usual codes otherwise (3 for a refused credential, 6 for an unreachable server, 7 for a server older than the read — its answer to the GET is a 405, since it has only the hook's POST — and 9 for a server whose hook tier is not armed).
- Credential: the ordinary one — a personal token reads its owner's rows, the shared hook token the machine user's.
asks log reads GET /api/asks/log — your asks,
newest first — and asks summary reads GET /api/asks/summary: counts by
kind, outcome and who answered, the median and 90th percentile time to an
answer, and the questions asked at least twice with their most frequent
answer. Both take the same filters: --kind, --runtime, --outcome,
--answered-by, --host, --repo, --session, --since, --until
(--since 7d, --since 36h or an RFC 3339 time); asks log also takes
--limit and --before (the previous page's next), asks summary --top.
muster asks summary --since 30d
muster asks log --kind plain_text --answered-by owner --since 7d | jq -r '.asks[] | [.answer_secs, .question] | @tsv'- stdout is the server's JSON and nothing else (there is no
--jsonflag: there is no other stdout); stderr repeats it as lines a person reads — one block per ask (a row whose text expired says so), or the summary and one line per repeated question. - Exit status: 0; 12 when the ask log is off on the server (the message
names
MUSTER_ASK_LOG=1); 3 for the shared hook token or any other refused credential; 2 for a filter the server does not know (a 400 naming it); and the usual codes otherwise. - Credential: a personal token (
mst_…). The log is a person's own; the hook token acts as the machine user and is refused.
muster is also the server and the host daemon
(three-components.md). Each role takes its
arguments unparsed, so its flags, subcommands and environment are exactly
those of the program it replaces:
| command | is | notes |
|---|---|---|
muster server |
muster-server |
the service, configured by environment only (configuration.md). Subcommands below |
muster host |
muster-mirror |
the host daemon for mirrored sessions: every flag (-url, -interactive, …, also spelled --url) and ask, join, opencode, opencode-pair, agent-spawn-log (also spawn-log) |
muster host join <url> (also muster-mirror join <url>) gets this machine
its mirror token without the hub's terminal: it prints a code, an owner of
that muster approves it in a browser on Account → Hosts → Add a machine,
and the token is written to the token file (mode 600). It prints the approved
host name as host=<name> on stdout and everything else on stderr.
mirroring.md has the flow
and what protects it; muster host join -h has its flags (-host,
-token-file, -wait). A token file that already holds a token is refused: delete it first. Exit codes: 0 joined; 1 denied, expired,
cancelled or failed; 2 usage; 3 the hub cannot do it (older, or its mirror is
off: mint the token with muster server mirror token create instead); 4 not
approved within -wait (run it again: it resumes the same code).
A binary named muster-server, muster-mirror or muster-migrate (a
symlink to muster, or the image's /muster-server and /muster-migrate)
runs that program, arguments untouched, so unit files, Claude Code hook
settings (muster-mirror ask) and exec lines that name the old binaries
keep working. Any other name runs the client.
muster server's subcommands: show-secret <name>, healthcheck,
mirror token create <host> (also host-token create <host>),
mirror token create <host> --team <id> (a team host token, audited in the
team's log; mirroring.md), mirror token ls,
mirror token revoke <id>, vapid generate, version (the version /health reports), db rls-off, db rls-on (the row-level-security rollback, schema.md),
invite --claim-admin, user disable <id>, user enable <id>,
user reset-factors <id|email> [--new-password-stdin] (removes every passkey
and paired phone of the account, cuts off its sessions, revokes its personal
API and flow-runner tokens, optionally sets a new password piped on standard
input, and reopens its first-factor tier:
the recovery for a sole admin who lost every factor),
app install|rotate|uninstall|list (server apps),
app install … --link-to <id> and app unlink <id>
(linked server apps),
demo-seed reset|ensure|ask (a public demo's invented content; it refuses any
database not named …_demo: demo.md).
The copy of the CLI muster serves to its agents (/agent-cli/muster,
GET /agent/muster) is built with -tags muster_client_only: the client
alone, about 8 MB. There, and on Windows, muster server and muster host
say the role is not in the build.
| binary | what it is |
|---|---|
muster-server, muster-mirror |
Kept for existing builds: each is a thin main over the same role muster server and muster host run (cmd/muster-server, cmd/muster-mirror). |
muster-migrate |
Applies the schema to DATABASE_URL. The server also migrates itself at boot. --rls-off and --rls-on are the row-level-security rollback tools, also `muster server db rls-off |
ccd |
The supervisor inside the claude-code agent image (provisioner.md). |
The container image (Dockerfile) runs /muster server
(ENTRYPOINT ["/muster", "server"]). /muster-server and /muster-migrate
are symlinks to /muster, and /agent-cli/muster is the client-only build.
It also carries /muster-preview and /muster-ping-collector. The flake
builds muster-cli, muster-migrate, muster-mirror and a migrator image
(migrate-image).