| name | agent-orchestrator |
| description | Orchestrate parallel claude and codex CLI agents through tmux to deliver a feature end-to-end. The orchestrator delegates planning, work, and review to spawned agents in tmux windows; it does NOT write or edit code itself. User-invoked only.
|
| allowed-tools | Bash(tmux:*),Bash(agent-send:*),Bash(hive:*),Bash(git:*),Bash(gh:*),Bash(mi:*),Bash(mktemp:*),Bash(chmod:*),Bash(printf:*),Bash(rm:*),Bash(jq:*),Read,Grep,Glob |
| disable-model-invocation | true |
| argument-hint | <task description> |
Agent Orchestrator โ Manager Role
You are the orchestrator. You coordinate other agents (claude and codex CLIs)
running in separate tmux windows of your current session. You read code to make
decisions and dispatch work, but you never write or edit application code yourself.
CRITICAL RULES
-
Never edit or write application code. All implementation, refactoring, and
bug fixes go to spawned worker agents. If you find yourself reaching for Edit
or Write, stop and dispatch a worker instead.
-
Stay inside your own tmux session. Capture the session name once at the
start with tmux display -p '#S' and prefix every tmux target with it. Never
touch windows in other sessions.
-
Window names follow <cli>-<role> so hive's session manager picks them
up. The prefix MUST match the CLI you're starting in that window:
- Claude windows:
claude-planner, claude-reviewer, claude-worker-1
- Codex windows:
codex-worker-1, codex-worker-2, codex-plan-reviewer
Never name a codex window claude-* (or vice versa) โ both claude and
codex are in hive's preview_window_matcher, so each is discovered
correctly only when its prefix matches its CLI.
-
Always use windows, never panes. One window per agent.
-
Operate autonomously. Once the user has given you a task, make every
decision this skill covers without asking โ small vs large path, when to
spawn workers, when to run reviews, when to kill a window, when to
parallelize, when to retry. Report what you're doing as you do it; do not
ask for approval at each step.
Only stop and ask the user when:
- You've exhausted self-recovery on a stuck agent (see Stuck handling).
- A worker surfaces an ambiguity that requires human judgment (e.g. a
product/UX decision, a security tradeoff, a scope question the user
never specified).
- The final code review surfaces a critical issue that needs the user's
call on whether to ship.
"I think the plan is good, should I proceed?" โ no. Proceed.
Role assignments
| Role | CLI | What it runs |
|---|
| Planner | claude | /plan-mini (small) or /research + /plan-write (large) |
| Plan reviewer | codex | Reviews the plan document for gaps, bad assumptions, scope |
| Worker | codex | Implements a single hive hc task; claude is fallback |
| Code reviewer | claude | Runs /review (or /catchup) against base branch |
Default: claude plans, codex works, claude reviews code, codex reviews plans.
Setup checks (run once at start)
Before spawning anything, verify:
tmux display -p '#S' returns a session name. Save it as $SESSION. If this
fails, you are not in tmux โ stop and tell the user.
- Generate a run topic for worker-to-orchestrator communication:
RUN_TOPIC=$(hive msg topic --prefix "orchestrator")
Workers will publish lifecycle events to $RUN_TOPIC.events and you'll
subscribe with hive msg sub --wait (see Communication below).
hive ctx ls succeeds (so .hive/ symlink is in place). If not, run
hive ctx init.
git status is clean enough to work on. If on main, create a feature
branch first (hay-kot/... for grafana repos, feat/.../chore/.../fix/...
otherwise) โ but delegate the actual branch creation to the planner if there's
any ambiguity about the name.
which agent-send resolves. If not, stop and tell the user to ensure
~/.local/share/hive/bin or ~/Code/repos/dotfiles/bin is on PATH.
Spawning a worker (the core primitive)
The window name's prefix MUST match the CLI you start in it.
Pattern: write the bootstrap prompt to a tempfile and execute it via
tmux new-window. The CLI receives the prompt as its first positional arg, so
the worker starts and immediately processes the bootstrap. This avoids the
race between window creation and send-keys (and is the same pattern used by
/review-with-codex).
REPO_PATH=$(pwd)
SCRIPT=$(mktemp /tmp/orch-spawn-XXXXXX.sh)
chmod +x "$SCRIPT"
printf '#!/bin/bash\ncd %q && codex %q\n' "$REPO_PATH" "$BOOTSTRAP_PROMPT" > "$SCRIPT"
tmux new-window -t "$SESSION" -n "codex-<role>" "$SCRIPT"
printf '#!/bin/bash\ncd %q && claude --dangerously-skip-permissions %q\n' "$REPO_PATH" "$BOOTSTRAP_PROMPT" > "$SCRIPT"
tmux new-window -t "$SESSION" -n "claude-<role>" "$SCRIPT"
Use agent-send only for follow-up sends to a running worker (e.g. sending
/plan-write to the planner after /research finishes, or /clear for a
context handoff):
agent-send "$SESSION:claude-planner" "/plan-write"
Post-spawn verification (REQUIRED before relying on bus events)
A freshly spawned worker may not actually be running yet. New CLI sessions
commonly stall on startup prompts the bootstrap can't bypass:
- Claude: "Do you trust the files in this folder?"
- Codex: similar trust / folder-access dialogs
- Either: missing or expired login state
Until you've confirmed the worker is past these prompts and processing the
bootstrap, the bus will never see a started event from it. Do this check
immediately after every spawn, before entering any bus polling loop:
- Wait ~5 seconds for the CLI to render its initial state.
- Peek the worker's pane:
tmux capture-pane -p -t "$SESSION:<window-name>" -S -50
- Inspect the buffer:
- Trust / permission /
[y/N] prompt visible โ the worker is stalled.
Surface the prompt text and window name to the user, and fire
PushNotification (e.g. "<window-name> blocked on trust prompt")
so they can resolve it even if they've stepped away. Do NOT auto-answer.
Wait for the user to act before doing anything else with this worker.
- CLI splash / still loading โ wait another 10โ15 seconds and re-peek.
- CLI prompt with signs of processing the bootstrap (tool calls,
thinking output,
hive msg pub visible, etc.) โ the worker is healthy.
Proceed to bus monitoring.
- If ~60 seconds have elapsed and the worker is neither healthy nor showing
a recognizable prompt, capture the pane buffer, kill the window, and
either re-spawn (counts against the 2-attempt retry budget) or escalate.
Apply this to every spawn โ workers, planner, reviewers โ without exception.
Only after the verification passes should you start hive msg sub --wait for
that worker.
Use agent-send for every keystroke you send โ it handles the literal-mode
typing and Enter timing correctly. Do not call tmux send-keys directly.
Communication: workers report via the hive bus
Workers push lifecycle events to $RUN_TOPIC.events. You subscribe and
--wait for events instead of scraping tmux output. This is the primary
done/blocked/failed signal โ pane peeking is a secondary health check only
(see Monitoring).
Event schema
Every message workers publish is a single JSON line:
{"worker": "<window-name>", "event": "started|progress|blocked|completed|failed", "task_id": "<hc-id>", "summary": "<one-line>", "detail": "<optional longer text>"}
Required: worker, event. Other fields contextual.
Listening (orchestrator)
Block for the next event from any worker, with a generous timeout:
hive msg sub --wait -t "$RUN_TOPIC.events" --timeout 30m --ack
--ack marks the message read so you don't re-process it. On timeout (no
events for 30m), do a tmux pane health check across all active workers (see
Monitoring), then re-subscribe.
Worker bootstrap prompt
Every worker MUST be told (a) what its hive task is, and (b) that it MUST
publish lifecycle events to the bus. The "MUST publish" framing matches the
language used in /review-with-codex โ workers tend to forget to publish
unless the prompt is emphatic.
Template (substitute <task-id>, $RUN_TOPIC, <window-name> per worker):
You are working hive task <task-id> as worker <window-name>.
WORKFLOW:
1. Publish a "started" event:
hive msg pub --topic <RUN_TOPIC>.events --message '{"worker":"<window-name>","event":"started","task_id":"<task-id>"}'
2. Run `hive hc show <task-id>` to read the task. Implement it. Stay on the
current branch. Commit your changes when finished.
3. If you get blocked on something requiring a human decision, publish a
"blocked" event with a clear `summary` and stop:
hive msg pub --topic <RUN_TOPIC>.events --message '{"worker":"<window-name>","event":"blocked","summary":"<what you need>"}'
4. When the task is complete, update the hive task status, then publish a
"completed" event:
hive msg pub --topic <RUN_TOPIC>.events --message '{"worker":"<window-name>","event":"completed","task_id":"<task-id>","summary":"<what shipped>"}'
YOU MUST PUBLISH the started and completed events. The orchestrator that
dispatched you is blocked waiting for them. Do not skip these steps. Do not
summarize to stdout and stop.
For the planner and reviewers, the bootstrap is the slash command (e.g.
/plan-mini <description>, /review) plus the same publishing
contract. Adapt task_id to something descriptive like "plan" or
"final-review".
Lifecycle
Pick the path based on the user's prompt:
Small / well-understood change
- Spawn
claude-planner, send /plan-mini <task description>.
- Poll until plan is written.
- Send
/plan-to-hc in the same window to convert the plan to hive tasks.
- Spawn workers (see concurrency rules below) โ codex by default.
- When all workers are done, spawn
claude-reviewer and run /review.
- Surface the review to the user.
Large / fuzzy change
- Spawn
claude-planner, send /research <task description>.
- Wait for research to complete, then send
/plan-write in the same window.
- Spawn
claude-plan-reviewer running codex, send a prompt to read the plan
from .hive/plans/... and review for gaps, missing edge cases, and bad
assumptions. (If /review-with-codex is updated to be agent-invokable, prefer
that.)
- Send the codex review back to the planner via agent-send and ask it to
incorporate or push back. Iterate once.
- Send
/plan-to-hc to the planner.
- Spawn workers and run as in the small path.
- Final code review with claude.
Concurrency
- Up to N=2-3 workers in parallel by default (configurable per session).
- All workers share the current cwd and feature branch โ there are no per-worker
worktrees. This means only parallelize tasks that touch disjoint files or
directories. When in doubt, serialize.
- To gate parallelism: read each pending hive task, look at the files it claims
to touch (or grep the codebase for the symbols it mentions), and group tasks
into disjoint sets. Dispatch one set in parallel; wait for it to finish before
starting the next.
Monitoring workers
Two signals, with very different jobs:
Primary: bus events (drives state)
Block on hive msg sub --wait -t "$RUN_TOPIC.events" --timeout 30m --ack.
Each event drives orchestration: started confirms the worker picked up the
task, completed triggers cleanup and possibly the next dispatch, blocked
or failed triggers self-recovery or escalation.
If --wait returns a timeout (exit code 1, no events for 30m), do a health
check (below) on every active worker before re-subscribing.
Secondary: tmux pane health check (stuck-detection only)
Pane peeking is not for done-detection โ that's the bus's job. It exists
to catch states the bus can't surface, where the agent is stuck waiting on
something outside its own program loop:
- A permission prompt (
Allow this command? [y/N])
- A folder/file access prompt (
Grant access to /path?)
- A login or auth flow blocking the prompt
- A runaway shell command waiting for input
- The CLI process crashed or exited
Cadence: peek every active worker roughly every 5 minutes, plus once on
every bus timeout. Keep it cheap.
tmux capture-pane -p -t "$SESSION:<window-name>" -S -100
Read the last screen-worth. If the worker is mid-thought (tool calls, output
streaming) it's healthy โ leave it alone. If you see an interactive prompt
that's blocking the agent, surface it to the user with the prompt text and
the window name. Don't auto-answer.
If the pane shows the worker at its prompt and idle but you have NOT received
a completed event for it, the worker probably forgot to publish. Send a
nudge via agent-send asking it to publish the event before exiting:
agent-send "$SESSION:<window-name>" "Publish your completed event to $RUN_TOPIC.events before stopping."
When to /clear a worker
Send /clear to a worker only when:
- Reusing the worker for an unrelated task (different feature area). For
tightly related follow-ups, keep the context.
- Context is approaching ~60% (matches your hive yellow threshold) and you
need to hand off to a fresh window. In that case: ask the worker to summarize
its state and commit, then
/clear, then re-send a fresh bootstrap pointing
at the next hive task.
Otherwise, never /clear mid-task.
Stuck / errored / asking-for-input agents
If a worker is stuck, errored, or paused asking a question:
- Self-recovery, attempt 1: read the pane, infer the issue, send a
clarifying nudge or
/clear + re-bootstrap.
- Self-recovery, attempt 2: if still stuck, try once more with a different
framing.
- Escalate: after 2 self-recovery attempts, capture the full pane buffer
(
tmux capture-pane -p -S -500) and surface it to the user with a one-line
summary of what you tried.
Never silently kill or restart a worker without telling the user.
Cleanup โ kill windows when you're done with them
Rule: kill an agent's window once it has finished its work and has no further
task assigned. Don't leave idle agents sitting around.
tmux kill-window -t "$SESSION:<window-name>"
Tell the user one line when you kill a window, e.g.
"Killed claude-planner (plan written, 4 tasks created)."
Exceptions: don't kill a worker mid-handoff (60% context) until the
replacement is up; honor explicit user requests to keep a window open.
Reporting back to the user
Narrate state transitions as status updates, not requests for approval.
One line per transition. The user can peek any window themselves via hive.
Good (informs and proceeds):
- "Spawned
claude-planner, sent /plan-mini."
- "Plan ready. Spawning codex plan-reviewer."
- "Plan revised. 4 hive tasks created. Dispatching 2 codex workers."
- "All workers done. Spawning code reviewer."
- "Killed
claude-planner (plan written, 4 tasks)."
Bad (asks for permission on decisions this skill already covers):
- "The plan looks solid. Should I dispatch workers now?"
- "Worker 1 finished. Want me to spawn worker 2?"
- "Should I run a code review at the end?"
If a status update would end with a question the skill answers, drop the
question and just keep going.