Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from bundle
Launch and manage bounded Codex or Claude workers in tmux with inspectable artifacts. Use it when work splits cleanly by file ownership, when a dedicated review
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
1---2name: tmux-multi-agent3description: Launch and manage bounded Codex or Claude workers in tmux with inspectable artifacts. Use it when work splits cleanly by file ownership, when a dedicated reviewer should run separately from the implementer, when a worker must stay alive across multiple turns, or when the user explicitly asks to open or show the worker in a real terminal window on their desktop.4---56# Tmux Multi Agent78Use this skill when parallel agent work is actually cheaper than doing the task in one session, or when the user wants a long-running worker they can inspect directly. The coordinator stays in the current shell, launches workers in tmux, gives each worker a bounded task, and records the run on disk so another human or agent can inspect it later.910## When Not To Use It1112- Do not use this for small edits, single-file fixes, or tasks that need constant back-and-forth.13- Do not use it when multiple workers would touch the same files at the same time.14- Do not use it if you cannot run tmux plus at least one of `claude` or `codex`.1516## Preconditions1718Verify the tools first:1920```bash21command -v tmux22command -v claude23command -v codex24```2526The bundled launcher defaults to:2728```bash29TA_CLAUDE_CMD='claude --dangerously-skip-permissions'30TA_CODEX_CMD='codex --dangerously-bypass-approvals-and-sandbox'31```3233These flags are required for non-interactive orchestration. Override via env vars if your setup uses different approval modes.3435Optional env vars:3637- `TA_SESSION_ID`: run id used to prefix tmux session names38- `TA_CWD`: working directory for launched workers; defaults to the current directory3940## 1. Meta Step4142Before spawning workers, write a grounded brief. Do not launch sessions until this exists.4344The brief must state:4546- scope47- out-of-scope48- exact files or directories each worker may touch49- verification commands the reviewer must run50- definition of done with checkable criteria5152Example:5354```bash55export SESSION_ID="$(head -c2 /dev/urandom | xxd -p)"56export SESSION_DIR=".tmux-multi-agent/sessions/${SESSION_ID}"57mkdir -p "${SESSION_DIR}"/{tasks,handoffs,reviews,artifacts}5859cat > "${SESSION_DIR}/brief.md" <<'EOF'60# Scope61Implement the requested change in the target repo.6263# Out Of Scope64Anything not required for this task.6566# Owned Files67- worker-a: path/glob-a68- worker-b: path/glob-b6970# Verification Commands71- bun test ...72- bun run ...7374# Definition Of Done75- exact behavior exists76- verification commands pass77- reviewer writes approval or findings78EOF79```8081## 2. Session Setup8283Export the run id before using the helper script so every worker session is namespaced:8485```bash86export SESSION_ID="${SESSION_ID:-$(head -c2 /dev/urandom | xxd -p)}"87export TA_SESSION_ID="${SESSION_ID}"88export SESSION_DIR=".tmux-multi-agent/sessions/${SESSION_ID}"89mkdir -p "${SESSION_DIR}"/{tasks,handoffs,reviews,artifacts}90```9192Naming rules:9394- every tmux session must be `${SESSION_ID}-<worker-name>`95- the helper applies that prefix automatically when `TA_SESSION_ID` or `SESSION_ID` is set96- `ta kill all` only kills sessions with the current session id prefix9798Helper path:99100- local/live copies may expose `scripts/ta`101- stored marketplace bundles may expose `scripts/ta.sh` when the plain `ta` filename is inconvenient for packaging102- `scripts/ta.sh` must stay functionally identical to `scripts/ta`; treat it as a compatibility mirror, not a fork103- prefer `scripts/ta` in live checkouts; use `scripts/ta.sh` only when that is the path the bundle exposes104105## 3. Launch Workers106107Launch bounded workers from the repo root:108109```bash110TA_BIN="${TA_BIN:-$( [ -x scripts/ta ] && printf '%s' scripts/ta || printf '%s' scripts/ta.sh )}"111ui_session="$(${TA_BIN} claude ui)"112review_session="$(${TA_BIN} codex review)"113```114115Useful commands:116117```bash118${TA_BIN} ls119${TA_BIN} attach "${ui_session}"120${TA_BIN} attach "${review_session}"121```122123## 3a. Open The Worker In A Real Desktop Window124125If the user says things like "show it on the screen", "open it in a window", "launch it for me on my computer", or otherwise clearly wants the worker visible in a normal terminal window, do not stop at `ta read` output or an in-chat pane dump. Open a real desktop terminal and attach it to the managed tmux session.126127First verify that a GUI session and terminal emulator exist:128129```bash130printf 'DISPLAY=%s\nWAYLAND_DISPLAY=%s\nXDG_CURRENT_DESKTOP=%s\n' \131"${DISPLAY:-}" "${WAYLAND_DISPLAY:-}" "${XDG_CURRENT_DESKTOP:-}"132command -v gnome-terminal || command -v kitty || command -v x-terminal-emulator133${TA_BIN} ls134```135136Preferred GNOME example:137138```bash139export DISPLAY="${DISPLAY:-:0}"140export WAYLAND_DISPLAY="${WAYLAND_DISPLAY:-wayland-0}"141nohup gnome-terminal --title "Codex review" \142-- bash -lc "tmux attach-session -t ${review_session} || exec bash" \143>/tmp/tmux-window.log 2>&1 &144```145146Kitty fallback:147148```bash149export DISPLAY="${DISPLAY:-:0}"150nohup kitty --title "Codex review" \151bash -lc "tmux attach-session -t ${review_session} || exec bash" \152>/tmp/tmux-window.log 2>&1 &153```154155Rules:156157- Prefer opening the already running managed session instead of launching a second duplicate worker.158- Use the exact session name from `${TA_BIN} ls`.159- Only tell the user it is "open" after the desktop terminal process starts successfully.160- If tmux attach inside the current chat shell fails because the terminal does not support clear or alternate-screen behavior, opening an external desktop terminal is the correct recovery path.161162## 4. Send Bounded Tasks163164Every worker task must be self-contained. It should reference the brief, state owned files, forbid out-of-scope edits, and say exactly where the worker must write its handoff or review.165166Example worker task:167168```bash169cat > "${SESSION_DIR}/tasks/ui.md" <<EOF170Read ${SESSION_DIR}/brief.md first.171Own only src/components/settings/*.172Do not touch API, database, CI, or build files.173Run only the verification commands that apply to your slice if feasible.174Write your handoff to ${SESSION_DIR}/handoffs/ui.md with:175- files changed176- commands run177- tests run or not run178- blockers or open questions179EOF180181${TA_BIN} send "${ui_session}" "${SESSION_DIR}/tasks/ui.md"182```183184Rules:185186- split by file ownership, not vague themes187- do not assign the same file tree to multiple workers at once188- require written handoffs; do not trust scrollback alone189- use `${TA_BIN} send <session> <file-or-text>` for the common path190- use `${TA_BIN} send --file <session> <path>` or `${TA_BIN} send --text <session> <text>` when the payload is ambiguous191- the helper uses bracketed paste and a short pre-submit settle delay for Codex; do not add your own manual Enter unless you are deliberately recovering a broken session192193## 5. Monitoring194195Use the helper script instead of ad hoc tmux commands:196197```bash198${TA_BIN} ls199${TA_BIN} wait "${ui_session}"200${TA_BIN} read "${ui_session}" 80201${TA_BIN} watch "${ui_session}"202```203204Discipline:205206- use `ta wait` for blocking waits when you only need exit status; use `ta watch` when you want the final assistant text as soon as the turn completes207- use `ta read` for detail at most once per minute unless something broke208- treat `busy` as "leave it alone"209- if a worker is `idle`, read the tail before sending another prompt210211Monitoring model:212213- the helper writes sidecar state under `${SESSION_DIR}/ta-state/<session>/`214- `session.json` stores the last known state, launch cwd, last send timestamp, and any bound JSONL path215- `events.ndjson` is an append-only event log for launch, send, state changes, and JSONL binding216- for Codex and Claude, the helper first tries to bind the session to the agent's JSONL log via the tmux pane process tree and open file descriptors217- if no bound JSONL is available, `ta` falls back to pane-based heuristics instead of guessing from prompt characters218219Busy detection details:220221- Codex: `idle` means a `final_answer` record was observed after the last helper `send`222- Claude: `idle` means the last assistant record after the last helper `send` has `stop_reason=end_turn`223- pane fallback still looks for recent output such as `Working (...)`, `Churned`, `Computing`, `Flowing`, `• Ran`, `• Explored`, `• Searched`, or `• Called`224- do not use prompt characters as an idle signal225226## 6. Review And Verification227228Review must happen in a fresh session. Do not reuse the implementation worker as the reviewer.229230Typical loop:2312321. implementation worker writes `handoffs/<worker>.md`2332. coordinator inspects the handoff and changed files2343. fresh reviewer session reads the brief, handoff, and diff2354. reviewer runs actual verification commands2365. reviewer writes findings or approval to `reviews/<worker>.md`2376. coordinator records the commands and outcomes in `artifacts/verification.md`238239Example review task:240241```bash242cat > "${SESSION_DIR}/tasks/review.md" <<EOF243Read ${SESSION_DIR}/brief.md first.244Read ${SESSION_DIR}/handoffs/ui.md and inspect the diff.245Review for correctness, regressions, missing tests, and scope creep.246Run the verification commands from the brief yourself.247Write findings or approval to ${SESSION_DIR}/reviews/review.md.248Record command output and pass/fail status in ${SESSION_DIR}/artifacts/verification.md.249EOF250251${TA_BIN} send "${review_session}" "${SESSION_DIR}/tasks/review.md"252${TA_BIN} wait "${review_session}" 600253```254255Worker claims are not verification. The reviewer or coordinator must run the commands.256257## 7. Failure Recovery258259Keep recovery tied to observable failures:260261- launch failed: inspect `${TA_BIN} read <session> 100`, then relaunch262- worker never leaves `busy`: read the tail, then either wait longer or send one narrowed follow-up263- worker went idle with no handoff: ask for the missing artifact, not a full restatement of the task264- conflicting edits: stop parallel work on the shared files and reassign ownership265- claimed completion without evidence: require a handoff with files changed and commands run266- reviewer found concrete issues: send a new bounded task with those findings only267268If the same slice fails twice, reduce scope or switch owners.269270## 8. Routing Heuristic271272These are heuristics, not laws. Prefer the worker that matches the repo and the observable problem.273274| Work shape | Default | Why | Caveat |275| --- | --- | --- | --- |276| Backend, infra, debugging, review, verification | Codex | Usually stronger on correctness, systems work, and findings-first review | Keep the task bounded; do not ask for vague polish |277| Frontend UI, docs, copy, readability refactors | Claude | Usually better at presentation, polish, and large wording rewrites | Route technical verification back to Codex or another strict reviewer |278| Full-stack split with clean ownership | Claude for UI, Codex for backend/review | Lets each worker stay inside a real file boundary | Do not let both workers edit the same files concurrently |279| Pure planning with no grounding | Neither by default | Plans drift fast without repo evidence | Write the brief from the actual code and user constraints first |280281## 9. Artifact Contract282283After a real run, these artifacts must exist under `${SESSION_DIR}`:284285- `brief.md`286- `tasks/<worker>.md` for every launched worker287- `handoffs/<worker>.md` for every implementation worker288- `reviews/<worker>.md` for every reviewed slice289- `artifacts/verification.md` with exact commands and outcomes290291Optional artifacts:292293- `artifacts/*.log` or `artifacts/*.txt` for saved command output294- extra handoffs or follow-up tasks when review required another pass295296If these files do not exist, the run is not inspectable enough to trust.297