name: Swarm Orchestration
This skill defines a pattern for an orchestrator agent to spawn, track, and control multiple sub-agent instances (a "swarm") using tmux for environment isolation and command-line interfaces supporting session resumption.
tmux installed on the host system.-conversation="<ID>").Create a tmux session with multiple windows or panes, depending on the desired layout.
Windows Layout (Clean separation):
tmux new-session -d -s <session_name> -n agent1 tmux new-window -t <session_name> -n agent2 ...
Grid Layout (All-in-one view):
tmux new-window -t <session_name> -n grid tmux split-window -t <session_name>:grid tmux select-layout -t <session_name>:grid tiled
Send execution commands to the specific panes/windows.
tmux send-keys -t <session_name>:<target> "/path/to/cli --args" C-m
Extract the unique identifiers generated by the agents to enable future resumption.
tmux capture-pane -p -t <target> to read the screen./ commands).Store the mapping of Pane/Window -> Session ID in a persistent file (e.g., swarm_sessions.md) so the orchestrator can resume tracking after context breaks or restarts.
To automate communication, use a file-based message bus.
Create a directory tmp/swarm/ in the project root:
requests/: For dropping request files.responses/: For reading results.scripts/: For the orchestrator script.Request File (request_<id>.json):
{
"request_id": "req_123",
"target_agent": "grid.0",
"prompt": "Your instruction here",
"response_file": "tmp/swarm/responses/res_123.json"
}
Response File (res_123.json):
{
"request_id": "req_123",
"status": "success",
"output": "... captured terminal output ..."
}
A script running in the background polls requests/, executes the tmux send-keys command, captures the results, and writes the response file.
Example implementation at: tmp/swarm/scripts/swarm_orchestrator.py
This pattern applies to any CLI-based tool or agent system that allows isolated instances and session targeting. It is not limited to any specific project or workspace.