| name | agent-teams-rex |
|---|---|
| description | Reproduce Claude Code's Agent teams (a lead plus teammates working through a shared task list and direct messages) with the Rex CLI, using Rex sessions on a machine where Rex Server runs. Use when the user asks to "work as a team", "spawn teammates and split the work", or runs /agent-teams-rex. |
This session is the lead. Teammates are separate Rex sessions started with rex new. The CLI's shared task list, teammate messaging, and plan approval are reproduced with Rex commands and a shared file.
Rex Server must be running on the machine (it starts automatically when Rex.app opens; rex starts a missing local server by default). If rex is not on the PATH, use its full path.
rex new <label>— create a teammate session. Add-c <dir>to set its working directory, and--jsonto get the created session as JSON.rex ls— list sessions with labels and ids. Userex ls --jsonfor the full session ids.rex send -s <label-or-id> <text>— type text into a session's terminal. This only types; it does not submit.rex send-key -s <label-or-id> enter— press Enter in a session. Always followrex sendwith this to submit the text.rex send-key -s <label-or-id> down— move the selection down in a prompt (for example, to pick an approval option).rex capture -s <label-or-id> --trim— read a session's screen and scrollback.rex kill <label-or-id>— end a session.
Sessions can be addressed by their label or their session id. Labels are the short role names, so use labels unless two sessions share one.
Do not send multi-line text with rex send: each line is submitted separately, because a newline acts as Enter. Send one line at a time, or put longer text in a file and send a one-line message telling the reader to read it.
- Call
rex ls --jsonto get the lead's session id. This assumes the lead is a Rex session. If the lead is external (for example driving the team over SSH), create a separate inbox session namedleadwithrex new leadto receive reports. - Before teammates report, run
catin the lead's session (or in theleadinbox session). Teammates' reports arrive as typed text at the lead's prompt; withoutcat, pressing Enter runs them as shell commands.catswallows the input without executing it. - Take the task and the teammate roles from the user. If they are missing, propose about three roles that can work independently. Use the agent CLI the user names (for example agy, Claude Code, Codex). Unlike the Desktop version, teammates may run different CLIs, so the team can be multi-provider.
- When a teammate first runs a
rexcommand (for example to report to the lead), its agent CLI may stop at a permission prompt (agy: "Requesting permission for: rex send -s lead ..." / "Run this command?"), even in Auto mode, becauserexis not on the allow list. Approve option 2, "Yes, and always allow in this conversation for commands that start with 'rex'", withrex send-key -s <label> downfollowed byrex send-key -s <label> enter. Do not use the permanent settings.json option. Watch for this the first time each teammate reports. - A teammate agent's first launch in a new folder may ask for trust confirmation ("Do you trust the contents of this project?"). Approve it with Enter (
rex send-key -s <label> enter).
Create team/tasks.md in the working folder as a table. Only the lead edits it.
| ID | Task | Status | Owner | Depends on |
|---|
Status is one of pending, in progress, completed. A task whose dependencies are unfinished stays pending; when they finish, the lead assigns it.
Create one session per teammate with rex new, using the short role name as the label (for example ux).
- Start the agent CLI inside the session:
rex send -s <label> "<agent-cli>", thenrex send-key -s <label> enter. - Teammates that write code create their own git worktree inside their session (
git worktree add); there is nouse_worktreeflag in Rex. Research-only teammates work in the shared folder. - For plan approval, tell the teammate in its first message to send its plan to the team lead and not implement until the lead approves.
- Watch teammates with
rex capture, not by opening the Rex app. Only open the app if the user asks to watch. - Write the teammate instructions below to a file first, one per teammate (
team/instructions-<role>.md). Then send each teammate a one-line first message telling it to read its instructions file and follow it, followed by the assigned task and the expected output (length, language, whether to create files). Put the overall goal and the other teammates' roles in the same first message. Do not paste the multi-line instructions intorex send— each line would be submitted separately.
After all teammates have started, send each of them the roster (name = label, with session ids) by rex send followed by rex send-key enter. Session ids come from rex ls --json. If a teammate's agent is still processing when the roster arrives, the text queues in its input field ("Press up to edit queued messages") and is handled later as a follow-up; that is not a failure, but the roster is not received immediately.
Fill in the <...> parts and write the result to team/instructions-<role>.md for each teammate. The teammate reads this file; do not send the text itself as a message.
IMPORTANT: You are running as an agent in a team. To communicate with anyone on your team, run this in your terminal, with `to` set to the teammate's label or session id:
rex send -s <to> "<message>"
rex send-key -s <to> enter
`rex send` only types the text; the second command submits it. Always run both.
Just writing a response in text is not visible to others on your team - you MUST send it with `rex send`.
The user interacts primarily with the team lead. Your work is coordinated through the task list and teammate messaging.
Your identity: <name>
Task list: <absolute path of the working folder>/team/tasks.md (read it, but do not edit it; the team lead updates it)
Team lead: session <lead's label or id>. Send updates and completion notifications to the team lead.
Teammates: the team lead will send you their labels and session ids once everyone has started.
1. After completing your current task, read the task list to find available work.
2. Look for tasks with status pending, no owner, and nothing they depend on left unfinished.
3. Prefer tasks in ID order (lowest ID first).
4. Ask the team lead to assign you an available task, or wait for the team lead's assignment.
5. If blocked, focus on unblocking tasks or notify the team lead.
When you and a teammate have agreed, do not reply just to acknowledge. Send the agreed result to the team lead once, then stop.
- Each time a teammate reports, update
team/tasks.mdand tell the user the gist in one to three lines. - When a task is unblocked, send its owner a summary of the results it depends on with
rex send(followed byrex send-key enter). Teammates do not receive each other's reports automatically. - The lead detects a teammate is idle or done by polling
rex capture -s <label> --trim. There are no idle or completion hooks; check on a regular rhythm and after every report. - If a teammate's report does not arrive, check with
rex capturewhether it stopped at a permission prompt for arexcommand, and approve option 2 as described in Setup. - Do not stop teammates from talking to each other directly. When they report an agreement, pass it to the user together with any open points.
- Treat a teammate's report as its own account. If it says it created a file, check the file before telling the user.
When every task is completed, tell the user what was agreed, what is still open, and where the run differed from the CLI. Ask the user before ending the teammate sessions (rex kill <label>).
- No structured messaging; teammates are reached by typing text into their terminal (
rex sendplusrex send-key enter). Incoming text lands at the lead's prompt, so the lead's session must runcator the reports execute as shell commands. - No
TeammateIdle,TaskCreated, orTaskCompletedhooks; the lead pollsrex captureto detect idle and done. - No automatic task claiming or file locking; the lead assigns tasks.
- Teammates are addressed by label or session id.
- Worktrees are created by the teammate itself (
git worktree add), not by a flag. - Teammates may run different agent CLIs, so the team can be multi-provider; the CLI version is single-provider.
- A teammate's agent CLI may ask for permission before running
rexcommands, and for trust confirmation in a new folder; the lead approves both. rex senddoes not accept multi-line text; instructions go in files and are read, not pasted.