Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

Orchestration

Have one agent fan work out into several sessions, on this machine or others, review its work with a second model, and pass messages between parent and child sessions.

Orchestration is one agent starting other sessions with wain. You ask the agent in one session to “work through these four issues”, and it starts four sessions, one per issue, each with its own worktree, branch and sidebar row. You watch them beside the conversation that started them.

Use it for work that is truly separate: separate branches, separate pull requests. Steps of one task belong in one session.

Before you start

Install wain and its skill. See Install. The skill tells Claude Code, Codex and pi when and how to use wain, so you can ask in plain words. You do not type the commands yourself.

Fan work out

Ask in the conversation, for example:

Start a session for each of DRA-51, DRA-52 and DRA-53.

The agent runs wain session new once per piece of work. Each new session:

  • gets its own worktree, starting at origin/<default branch>, unless the agent passes --base or --no-worktree
  • inherits the caller’s agent, model, effort, fast mode and permission mode, unless the agent passes flags
  • starts working at once, on the prompt the agent wrote for it

The new session has none of the calling conversation. A good prompt carries the issue text, the steps to reproduce and the constraints. See Sessions for every flag.

Where spawned sessions show

In the sidebar, each new row appears under the session that started it. The app does not switch to it, so you stay in the conversation you were in. A session started by a spawned one nests a level deeper.

Cards come to you. When a session this conversation started asks for permission or asks a question, the card shows above the composer, under that session’s title. Answer it there without leaving. When several are waiting you see one at a time, with arrows and a count to step through the rest.

Hidden sessions

A session started with --hidden stays out of the sidebar. You see it only when it asks for permission or asks a question, as a card in the session that started it. The skill has agents hide review sessions by default. Everything a bot starts runs hidden, on any machine, whatever the flag says.

Bots

A bot is the same idea made permanent: one ongoing chat you run everything from, with its own instructions and memory. Every task it starts runs hidden, on whichever machine, and reports back to it after every turn on its own, so you do not poll. Its tasks’ cards, pull requests and stalls come to its chat. See Bots, and Bots for wain bot.

Review with a second model

--base starts a session’s worktree from existing work. Point it at a session id and the new session gets its own checkout of that session’s branch:

wain session new --hidden --harness codex --base <session-id> \
  "Review the work on this branch. Send your findings back to <session-id> with wain session send."

Ask for this in plain words: “have Codex review this”. The reviewer reads the same commits in its own worktree, so it collides with nobody.

  • Committed work only. Changes not yet committed are not in the reviewer’s tree. Commit first, or the review misses them.
  • A new branch. The reviewer works on its own worktree-<name> branch. It never checks out yours, so it cannot commit onto your work.
  • wain prints what the id resolved to: Started "…" in worktree calm-owl, based on worktree-brisk-jade.

--base also takes a tag or a commit, or a branch. A branch is different: the new session works on that branch by its own name, so its commits land there. See Start from existing work.

Messages between sessions

wain session send <session-id> "Review done: two findings, both fixed on worktree-calm-owl."

Any session can message any other. A child reports back to its parent, or a parent hands a child more context. The message starts a turn in the receiving session, or waits for the current turn to end. The receiver is told which session sent it and its id, so it can reply.

Each message costs the receiver a whole turn, so agents should send one when the other session needs it, not to say “done”.

Check on sessions

wain session ls

Lists the project’s sessions with their status. Outside a bot, nothing reports back on its own. If you want to know when sessions finish, watch the sidebar, or ask the children to send a summary when they are done. A bot’s tasks report to it after every turn without being asked.

Work outside a worktree

Some work changes no repository: setting up a machine, reading logs, research. --no-worktree runs such a session in a folder as it is, with no worktree or branch:

wain session new --no-worktree --project '~' "Install Docker and report the version"

Never use it to edit a repo: the session shares that checkout with you and every other session in it. See Worktree or not.

Fan out to other machines

wain --machine <name> session new starts a session on another machine you have added, in its checkout of the same repository. A session id finds its machine on its own, so send, model, stop and the rest need no flag. See On another machine.

Permission prompts

A spawned session inherits the permission mode of the session that started it, and wain session new has no flag to change it. If the calling session asks before it edits files or runs commands, so does every session it starts. Each one stops at its first permission card and waits for you.

Answer those cards above the parent’s composer, or open the session. To have children run without stopping, change the permission mode of the parent before it fans out.

wain itself never raises a permission card in a Claude Code session.

Limits

  • Two levels deep. A spawned session may start sessions; those may not. Start the next batch from a top-level session.
  • No reading transcripts. A session can create, list and message others, but cannot read what another session wrote. Ask it to send a summary.
  • No shared worktree. Every spawned session gets its own worktree, or none with --no-worktree. Two sessions never share a worktree.
  • No permission flag. Children always take the parent’s permission mode.