TypeClawTypeClaw
Reference

typeclaw compose

Fan host-stage commands out across every agent folder in cwd

Beta

typeclaw compose is beta. Flags, output format, and exit-code semantics may change between minor releases. Pin your typeclaw version if you script against it.

compose is a thin fan-out wrapper around the per-agent host-stage commands. It discovers every immediate subdirectory of cwd that contains a typeclaw.json, runs the matching per-agent command against each one in parallel, and aggregates results.

There is no shared lifecycle, no "compose project," and no inter-agent coordination at runtime. Each agent keeps its own container, port, mounts, env file, and config. compose is sugar over for d in */; do (cd "$d" && typeclaw <cmd>); done — with a single progress board, deterministic ordering, and per-agent failure isolation.

Discovery

Cwd is scanned one directory deep. A subdirectory is treated as an agent when:

  • the name does not start with . (skips .git/, .vscode/, etc.)
  • the name does not start with _ (park disabled or in-progress agents as _archived-coder/, _wip-foo/ without compose touching them)
  • the directory contains a typeclaw.json

Agents are sorted by folder name so output across start / stop / status / restart / logs is stable regardless of filesystem readdir order. When zero agents are discovered, every subcommand exits 0 with a No typeclaw agents found in immediate subdirectories of cwd. notice — discovery is not a failure.

Subcommands

CommandPer-agent equivalentParallelNotes
typeclaw compose starttypeclaw startyeshost port collisions fall back to ephemeral per agent
typeclaw compose stoptypeclaw stopyesalready-stopped agents report not running, not failure
typeclaw compose restarttypeclaw restartyesstop then start per agent; surfaces both phases on the progress board
typeclaw compose status(inspects Docker)yesrunning / stopped / absent + resolved host port for running agents
typeclaw compose logstypeclaw logsyesmultiplexed; each line prefixed with the agent name and a deterministic color
typeclaw compose usagetypeclaw usageyesaggregates per-agent token usage; one corrupt sessions/ dir does not blank out the report
typeclaw compose doctortypeclaw doctoryesper-agent doctor plus cross-agent checks (port collisions, container-name collisions)

Flags

start / restart

FlagDefaultEffect
--port <n>each agent's config.portpreferred host port for every agent; per-agent bind conflicts fall back to ephemeral
--buildfalseforce-regenerate each Dockerfile from the template and rebuild before starting

logs

FlagDefaultEffect
-f, --followfalsestream new log output as it arrives
-n, --tail <N|all>(none)show only the last N lines per agent (or all); non-negative integer or the literal all

Agents without a running container are skipped with a compose: skipping <name> (container not running) notice on stderr. Lines arriving at the same time from multiple agents are interleaved at line boundaries — partial lines are buffered, never shredded mid-character.

usage

FlagDefaultEffect
--since(none)ISO date or relative duration (today, 7d, 30d)
--until(none)ISO date upper bound, exclusive
--jsonfalseemit the aggregated report as JSON (one object covering every agent)

doctor

FlagDefaultEffect
-v, --verbosefalseshow per-check details
--jsonfalseemit the full report as JSON
--fixfalseattempt per-agent auto-fixes; on success, git add + git commit the changed paths inside each agent folder (skipped if the folder is not a git repo)
--only <a,b,c>(none)comma-separated category filter forwarded to each agent's doctor run
--shallowfalserun cross-agent checks only; skip per-agent doctor runs

status, stop take no flags.

Cross-agent checks (compose doctor)

Beyond fanning out per-agent doctor, compose doctor runs whole-fleet checks:

CheckStatus on conflictDetects
compose.no-port-collisionswarningtwo or more agents declaring the same typeclaw.json#port
compose.no-container-name-collisionserrortwo different agent folders hashing to the same Docker container name

Port collisions are warnings, not errors: start resolves them at runtime by falling back to ephemeral ports per agent. Container-name collisions are errors: Docker enforces unique names, and a collision means one agent will fail to start until you rename a folder.

Exit codes

CodeMeaning
0every agent succeeded, or zero agents were discovered
1at least one agent failed (the progress board shows which); for logs, a non-cancelled child exited non-zero
2invalid flag value (e.g. --tail not a non-negative integer or all)

Sigint/sigterm during logs --follow shuts every child docker logs down cleanly and exits 0; only real per-child failures bubble up.

Layout

~/agents/
├── alice/           # typeclaw agent
│   ├── typeclaw.json
│   └── ...
├── bob/             # typeclaw agent
│   ├── typeclaw.json
│   └── ...
├── _archived-coder/ # skipped (leading underscore)
│   └── typeclaw.json
└── .git/            # skipped (leading dot)

From ~/agents/:

typeclaw compose start            # starts alice and bob in parallel
typeclaw compose logs -f          # streams alice and bob's docker logs, interleaved
typeclaw compose doctor --shallow # cross-agent checks only, fast

On this page