skills/tmux-agent-comms/SKILL.md
Manage AI agents in tmux: spawn sessions, send messages, wait, capture replies, inspect fleets, and tear down safely. Use for tmux-hosted CLI agents. Don't use for SSH, GNU screen, or GUI apps.
npx skillsauth add luongnv89/skills tmux-agent-commsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Manage CLI agents in separate tmux sessions. Treat each session as one agent; orchestrate it with send-keys and capture-pane. Relay reply deltas instead of whole screens to protect the context/token budget.
New sessions open in a terminal tab inside the current app by default. If the environment cannot open one, create the session detached and print the exact attach command. Never invoke attach-session from a non-TTY tool.
Use herdr-agent-comms instead when agents live in Herdr.
Route directly to the required mode; do not read unrelated references.
| Task | Start | |---|---| | Spawn an agent | Phase 1 | | Message or steer an existing agent | Phase 2 | | Read a pane, show status, or inspect | Phase 5 | | Broadcast to a fleet | Phase 6 | | Shut down an agent | Phase 6 |
command -v tmux; stop with installation guidance if it fails.references/tmux-recipes.md when messaging, waiting, or broadcasting.exit//quit, kill a session, or kill the server without explicit approval.references/tmux-recipes.md.capture-pane -S -40 and widen only when the reply is truncated.Run the six phases in order for a send. A read-only status/inspect operation may jump to Phase 5.
List sessions:
tmux list-sessions 2>/dev/null || echo "no tmux server running yet"
Name new sessions <folder>-<short-task> (for example, myrepo-reviewer). Avoid collisions with tmux has-session before creating one. Launch the requested interactive CLI in a new app terminal tab; if no tab facility exists, use detached mode and print tmux attach-session -t <name> for the human.
After spawn, require readiness before assigning work:
python3 "$here/wait_for_idle.py" "$name" --ready --timeout 60 --no-print
Exit 0 is ready, 3 is blocked, 2 is timeout, and 1 is error. Spawn fleets first, then check readiness concurrently. Read references/tmux-recipes.md for naming, tab/detached branches, script resolution, and fleet readiness.
Complete when: every created session has an exact name and passes the ready gate, or the failure is surfaced without sending work.
tmux has-session -t "$target" 2>/dev/null
If missing, list sessions and ask on ambiguity; never guess. Use session:window.pane for a specific pane.
Complete when: one existing tmux target is confirmed.
Read references/delivery-and-waiting.md before sending. Follow its contract:
-S -80 to a temporary baseline file.completion_marker="TAC_DONE_$suffix".TAC_DONE_ joined with the suffix only after completion.preflight_send.py immediately before dispatch; send only on exit 0.Enter in a separate call.On multiline/code-heavy input, use paste-buffer rather than shell escaping. Always clean up temporary files on failure.
Complete when: post-send activity proves delivery, or a descriptive failure is surfaced. Typed text alone is not proof.
python3 "$here/wait_for_idle.py" "$target" --timeout 180 --scrollback 80 \
--baseline-file "$baseline_file" --completion-marker "$completion_marker"
rc=$?
rm -f "$baseline_file"
Handle exit 0 as settled, 1 as error, 2 as timeout, and 3 as blocked. Before relaying an actionable result, independently compare two short capped-tail captures. Changing output/spinner means working; unchanged output without completion means stalled.
Read references/delivery-and-waiting.md for delivery recovery, wait modes, advisory verdicts, and the anti-deadloop budget.
Complete when: a fresh marker and independent bounded read verify the reply, or the bounded wait ends with an explicit state.
Read a reply with:
tmux capture-pane -t "$target" -p -S -40
Widen stepwise if capture starts mid-sentence; use unbounded scrollback only as a last resort. Relay substantive lines, not TUI chrome or old turns.
For status, remain read-only and report: agent ID, exact session, state (in-progress, done, blocked, unknown), short progress, start time, and workdir. For inspect, resolve one exact session, include a bounded tail and pane details, then print—but do not run—the human attach command.
Read references/tmux-recipes.md for classification commands, periodic fleet status, scrollback, and troubleshooting.
Complete when: the requested reply or status is concise, target-specific, and not truncated.
"$here/broadcast.sh" "<message>" <session...>; it preflights, sends first, then waits concurrently. Do not serialize send/wait by agent.tmux kill-session -t <name> over tmux kill-server.Complete when: every follow-up has an independent proof cycle, broadcast failures are reported per target, or confirmed teardown affects only named sessions.
target=reviewer
tmux has-session -t "$target" 2>/dev/null || { echo "Error: missing $target" >&2; exit 1; }
# Resolve $here, then follow references/delivery-and-waiting.md for the
# baseline → preflight → send → delivery → wait → verify cycle.
Expected result: the agent's new reply is relayed, the joined marker proves this turn completed, and the report records each gate.
-S stepwise.Ctrl-b d; never kill merely to return control.references/delivery-and-waiting.md — read for any send/wait cycle, recovery, marker contract, or timeout.references/tmux-recipes.md — read only for script resolution, spawn modes, fleets, status/inspect, multiline sends, attach, scrollback, or troubleshooting.scripts/preflight_send.py — fail-closed check before every send or recovery Enter.scripts/wait_for_idle.py — readiness and settled-reply waiter.scripts/broadcast.sh — safe concurrent fleet broadcast.After each operation, emit only applicable rows:
◆ Tmux Agent Comms ([operation])
··································································
Target resolved: √ pass ([exact session])
Preflight: √ pass (idle)
Baseline captured: √ pass
Message delivered: √ pass (activity vs baseline)
Completion marker: √ pass (fresh and joined)
Reply verified: √ pass (bounded independent read)
Destructive action: — none (or: √ confirmed)
Result: PASS | FAIL | PARTIAL
For spawn, report Session created and Ready gate; for status, report Read-only; for teardown, report Confirmed and Session killed. Use ⚠ for recovered delivery or an escalated stall.
tools
Run Herdr loops for one open GitHub issue (resolve→review→fix) or an existing PR (review→lazy fixer) until CLEAN. Don't use for plain resolution without review, review-only/no-fix requests, backlog automation, or merging.
tools
Manage AI agent fleets in Herdr: split root + sub-agents into one tab as a tiled grid, message/wait/read via herdr CLI, steer any pane. Use for Herdr multi-agent fleets. Don't use for tmux, screen, or non-Herdr terminals.
development
Generate or update docs to match the code, citing each claim to path:line and asking on ambiguity; runbook docs also get a check-only validation script. Don't use for API-reference autogen (JSDoc/Sphinx), landing pages, or CLAUDE.md/AGENTS.md.
testing
Generate a diagram and route to the right engine — draw.io XML (precise, editable, C4, swimlanes) or Excalidraw JSON (hand-drawn, sketch, wireframes). One entry for flowcharts, architecture, ER, sequence, mind maps. Don't use for Mermaid or slides.