Branchwell

Become a Pro / website · becomeapro.ai / content / lessons / knowledge-work / using-ai / run-a-team-of-agents.mdx

Raw 15.6 KB on f63bc385c0fa362af985bfb576a8b5aa2a3df60f
1---
2title: "Be the operator: run a team of Claude Code agents"
3description: "How one person runs several Claude Code agents at once: the rules file, the brief, parallel sessions, review steps and guardrails, steering it all from your phone, and how we made this lesson's video the same way."
4level: Advanced
5minutes: 15
6updated: 2026-12-01
7order: 7
8---
9
10AI is a force multiplier. With the right setup, one person can get through work that used to need a small team. We call that person the **operator**.
11
12The operator doesn't type most of the code. The operator splits the work into tasks, gives each task to its own Claude Code agent, and reviews what comes back. It uses a lot of tokens. In the hands of a skilled operator, it's worth it.
13
14This guide is the setup we use: a rules file every agent reads, a brief for each task, several sessions running side by side, and review steps before anything is merged. At the end, we show how we made this lesson's video the same way, mostly from a phone.
15
16## What you need
17
18- Claude Code, signed in with a Pro, Max, Team or Enterprise plan
19- A project in git with at least one commit, because parallel sessions use git worktrees
20- A test, build or lint command Claude can run to check its own work
21- About 30 minutes to set it up the first time
22
23Each agent uses its own tokens, so five agents use up your plan's limits roughly five times as fast as one. Start with two or three.
24
25## From chatbot to agent
26
27A chatbot answers questions. An agent takes a task and works on it until it's done. That difference is what makes the operator possible.
28
29| | Chatbot | Agent |
30| --- | --- | --- |
31| What you give it | A question | A task, with a goal and a finish line |
32| What it does | Answers in text | Reads files, edits code and runs commands |
33| How you check it | Read the answer | Read the changes and the test output |
34| How many at once | One conversation | Several sessions in parallel |
35
36## What a talented operator can do
37
38None of these jobs is new. The multiplier is running several of them at the same time while you review.
39
40- **Fix several bugs at once.** One agent per bug, each in its own worktree, so the fixes never collide.
41- **Build and test in parallel.** One agent builds a small feature from a written spec while another writes its tests.
42- **Keep the docs current.** An agent updates the README and the changelog after every change.
43- **Turn data into a report.** Give an agent a spreadsheet or a log file and ask for a short summary with charts.
44- **Research before building.** An agent reads a library's docs and comes back with a plan before anyone writes code.
45
46## How the pieces fit
47
48| Piece | What it is | Where it lives |
49| --- | --- | --- |
50| Rules | Standing instructions every agent reads | `CLAUDE.md` |
51| Brief | One task, written like a ticket | Your prompt |
52| Agents | One Claude Code session per task | A git worktree each |
53| Helpers | Focused assistants for side jobs, like review | `.claude/agents/` |
54| Guardrails | Rules Claude Code enforces, not just reads | Hooks in `.claude/settings.json` |
55| You | Approve plans, review results and merge | Terminal, desktop app or phone |
56
57## Step 1: Write the rules once
58
59Every agent reads `CLAUDE.md` at the start of every session, so it's where you write down what you'd otherwise repeat to each one. For a team of agents, the most useful rules say how to check the work, how to stay in its lane, and how to report back:
60
61```markdown
62# How to check your work
63- Run `npm test` and `npm run lint` before you say a task is done
64- In your summary, paste the command you ran and the last lines of its output
65
66# How we work
67- One task per session. If you find a second problem, tell me instead of fixing it
68- Stay in your own worktree. Never push to main
69- Ask before you add a dependency or change the database schema
70
71# When you finish
72- Summarize what changed in 3 to 5 bullets
73- List anything you skipped or couldn't check
74```
75
76Swap in your own commands. Our [CLAUDE.md guide](/knowledge-work/using-ai/claude-md-guide) covers where the file goes and how to check that Claude loaded it.
77
78## Step 2: Write the brief like a ticket
79
80A vague task gets a vague result. Give each agent a brief with a clear finish line:
81
82```prompt
83Task: [one sentence]
84Why: [the problem this solves]
85Done means: [the test or check that proves it works]
86Stay inside: [the files or folders it may change]
87Don't: [what to leave alone]
88Before you change anything, show me a short plan and wait for my OK.
89```
90
91Here's one filled in:
92
93```prompt
94Task: Fix the order dates that show one day early for customers in Asia.
95Why: Dates are converted to UTC twice before they're displayed.
96Done means: A new test for a Tokyo customer passes, and npm test passes.
97Stay inside: src/lib/dates.ts and its tests.
98Don't: Change the database or any API responses.
99Before you change anything, show me a short plan and wait for my OK.
100```
101
102| Vague | Clear |
103| --- | --- |
104| Fix the dates | Fix the order dates that show one day early in Asia |
105| Make sure it works | A new test for a Tokyo customer passes |
106| Clean up the code | Stay inside `src/lib/dates.ts` and its tests |
107
108The last line of the brief puts a review step before any edit. You can also start the session in plan mode, covered in Step 5.
109
110## Step 3: Run agents side by side
111
112Two agents editing the same folder will overwrite each other's work. Claude Code solves this with git worktrees: each session gets its own separate copy of the project. Open a terminal for each task:
113
114```bash
115claude --worktree fix-date-bug
116claude --worktree add-checkout-tests
117claude --worktree update-docs
118```
119
120`-w` is the short form. Each worktree lives in `.claude/worktrees/<name>/`. Add `.claude/worktrees/` to your `.gitignore`. When you exit a session with no changes left, Claude Code removes its worktree, and if there are changes, it asks whether to keep them. Paste a brief into each session and let them work.
121
122If you'd rather not keep a terminal open for every agent, start them in the background and check on them from one place:
123
124```bash
125claude --bg "Fix the order dates that show one day early in Asia. Done means npm test passes."
126claude agents
127```
128
129`claude agents` opens agent view, where you can see every background session, open one, and read its progress. Background agents are a research preview, so details may change.
130
131<Callout type="note">
132Claude Code also has agent teams, where one session leads and other sessions work as teammates that message each other. It's experimental, off by default, and uses many more tokens. Start with worktrees, and see Anthropic's [agent teams page](https://code.claude.com/docs/en/agent-teams) when you outgrow them.
133</Callout>
134
135## Step 4: Give side jobs to subagents
136
137A subagent is a helper that a session calls for one focused job, with its own context window and its own tools. A reviewer is the most useful one to start with, because it checks work with fresh eyes. Save this as `.claude/agents/reviewer.md` in your project:
138
139```markdown
140---
141name: reviewer
142description: Reviews a finished change for bugs, missing tests and edits outside the task. Use after a task is done and before it is merged.
143tools: Read, Glob, Grep, Bash
144model: sonnet
145---
146
147You review changes. Read the diff against main and run the tests, then report:
1481. Bugs or risky edits, with the file and line
1492. Missing tests
1503. Anything that doesn't match the task
151Don't edit any files. Report only.
152```
153
154Then, in any session:
155
156```prompt
157Use the reviewer subagent to check this work before I merge it.
158```
159
160The `model` line lets a helper run on a smaller, cheaper model than the main session. Anthropic's [subagents page](https://code.claude.com/docs/en/sub-agents) lists every field.
161
162## Step 5: Add guardrails Claude Code enforces
163
164A line in `CLAUDE.md` works most of the time. For anything that must never happen, use settings that Claude Code enforces whatever the model decides.
165
166### Pick a permission mode
167
168Press `Shift+Tab` in a session to switch modes, or start with `claude --permission-mode plan`.
169
170| Mode | What it does | Use it for |
171| --- | --- | --- |
172| Default | Asks before edits and commands | Getting started, or any risky task |
173| Plan | Reads and plans, but changes nothing | Checking an agent's plan before it starts |
174| Accept edits | Edits files without asking, still asks for commands | Agents you trust on a small task |
175| Auto | A separate model checks each action and blocks risky ones | Long tasks where prompts would stall the work |
176
177Auto mode needs a supported model, and Team and Enterprise admins can turn it off. Anthropic's [permission modes page](https://code.claude.com/docs/en/permission-modes) has the details.
178
179### Block what must never happen
180
181Hooks are commands Claude Code runs at fixed points. A `PreToolUse` hook runs before every tool call, and if it exits with code 2, the call is blocked. This one stops force pushes and pushes to main. Add it to `.claude/settings.json`:
182
183```json
184{
185 "hooks": {
186 "PreToolUse": [
187 {
188 "matcher": "Bash",
189 "hooks": [
190 {
191 "type": "command",
192 "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-risky-git.sh"
193 }
194 ]
195 }
196 ]
197 }
198}
199```
200
201Then save this script as `.claude/hooks/block-risky-git.sh` and run `chmod +x` on it. It needs `jq`:
202
203```bash
204#!/usr/bin/env bash
205# Stops force pushes and pushes to main. Exit code 2 blocks the command,
206# and Claude sees the message on stderr.
207cmd=$(jq -r '.tool_input.command // ""')
208if echo "$cmd" | grep -Eq 'git push.*(--force|-f( |$))|git push.* main( |$)'; then
209 echo "Blocked: no force pushes and no pushes to main. Open a pull request instead." >&2
210 exit 2
211fi
212exit 0
213```
214
215We tested it with sample commands. It blocks `git push origin main`, `git push -f` and `git push --force-with-lease`, and allows `git push -u origin worktree-add-tests` and `git push origin main-menu-fix`. PreToolUse hooks run before the permission mode is checked, so this block holds in every mode.
216
217### Get a ping when an agent needs you
218
219With several agents running, you won't be watching each one. On a Mac, this `Notification` hook shows a system notification whenever Claude Code is waiting for you. Add it inside the same `"hooks"` object:
220
221```json
222"Notification": [
223 {
224 "matcher": "",
225 "hooks": [
226 {
227 "type": "command",
228 "command": "osascript -e 'display notification \"Claude Code needs your attention\" with title \"Claude Code\"'"
229 }
230 ]
231 }
232]
233```
234
235## Step 6: Review before you merge
236
237Reviewing is the operator's real job. Before you merge anything, ask for evidence, not a promise:
238
239```prompt
240Show me what you changed: a short summary of the diff, the test command you ran with its output, and anything you couldn't check. Don't merge anything yet.
241```
242
243If it looks right, ask the agent to commit and open a pull request. If it doesn't, say what's wrong in one or two sentences. After two failed corrections, it's usually faster to run `/clear` and write a better brief than to try a third time.
244
245## Run it from your phone
246
247Your agents don't need you at the desk. Remote Control connects the Claude app on your phone to a Claude Code session running on your own computer, so you can send prompts, read results and steer from anywhere.
248
249Start a session with Remote Control on:
250
251```bash
252claude --remote-control
253```
254
255Or turn it on in a session that's already open with `/remote-control` (or `/rc`). Then open the Claude app on your phone and go to the **Code** tab. Run `/mobile` in Claude Code for a QR code that gets you the app.
256
257- **Plans:** Remote Control works on Pro, Max, Team and Enterprise. On Team and Enterprise, an owner has to turn it on first. It doesn't work with an API key.
258- **Your computer stays on.** The session runs on your machine, so the computer has to stay awake with Claude Code running.
259- **Talk instead of typing.** Your phone's dictation works in the prompt box, so you can speak each brief.
260
261<Callout type="tip">
262On Pro and Max, Claude Code's Projects beta takes this further: one project conversation splits work into threads that run in parallel, and you can check and steer every thread from your phone. It's rolling out gradually. See Anthropic's [Projects page](https://code.claude.com/docs/en/claude-projects).
263</Callout>
264
265## Watch your token use
266
267Running agents in parallel spends your plan's limits faster. Check where it's going:
268
269- `/usage` shows your plan's usage limits and an estimate for the current session. `/cost` and `/stats` open the same screen.
270- `/context` shows what's filling the current session's context window.
271
272To spend less: keep one task per session, run `/clear` before starting a new task in the same session, put helpers on a smaller model, and stop background agents you no longer need.
273
274## When it goes wrong
275
276| If you see | Do this |
277| --- | --- |
278| An agent drifts into other work | Press `Esc`, restate the task, and keep one task per session |
279| It says "done" but never ran the tests | Make "Done means" a command, and ask for its output |
280| Two agents change the same files | Give each one a worktree and a "Stay inside" line |
281| Your limits run out fast | Run fewer agents at once, and put helpers on a smaller model |
282| You type the same correction every day | Add it to `CLAUDE.md` |
283| Something must never happen | Use a hook, not a line in `CLAUDE.md` |
284
285## Your first week as an operator
286
2871. **Write the brief like a ticket.** A task, a reason, and a finish line Claude can check.
2882. **Give each agent one job.** One task, one session, one worktree.
2893. **Make every result easy to review.** Ask for the diff, the test output and what was skipped, every time.
290
291Start with two agents on small, separate tasks. Add a third once reviewing the first two feels easy.
292
293## How we checked this
294
295We checked every command, flag and setting on this page against Anthropic's Claude Code documentation and the HyperFrames and ElevenLabs docs on November 4, 2026, and ran the hook script and the FFmpeg command on sample files. Background agents, computer use and Projects are previews or betas, so check the linked pages if something looks different.
296
297## Anthropic's docs
298
299<Resources>
300 <Resource kind="Docs" source="Anthropic" title="Run parallel sessions with worktrees" href="https://code.claude.com/docs/en/worktrees">
301 How `--worktree` works, where worktrees live and how they're cleaned up.
302 </Resource>
303 <Resource kind="Docs" source="Anthropic" title="Subagents" href="https://code.claude.com/docs/en/sub-agents">
304 Every field for `.claude/agents/` files, and when to use a subagent instead of a new session.
305 </Resource>
306 <Resource kind="Docs" source="Anthropic" title="Hooks guide" href="https://code.claude.com/docs/en/hooks-guide">
307 Run your own commands at fixed points, including blocking a tool call before it runs.
308 </Resource>
309 <Resource kind="Docs" source="Anthropic" title="Remote Control" href="https://code.claude.com/docs/en/remote-control">
310 Control a Claude Code session on your computer from the Claude app or claude.ai/code.
311 </Resource>
312 <Resource kind="Docs" source="Anthropic" title="Computer use" href="https://code.claude.com/docs/en/computer-use">
313 Let Claude Code see your screen and use your Mac's apps, and the permissions it needs.
314 </Resource>
315 <Resource kind="Docs" source="Anthropic" title="Claude in Chrome" href="https://code.claude.com/docs/en/chrome">
316 Let Claude Code open pages, click and fill in forms in Chrome or Edge.
317 </Resource>
318</Resources>
319
320## Keep going
321
322New to the rules file? Start with [How to write a CLAUDE.md that Claude Code follows](/knowledge-work/using-ai/claude-md-guide). For more on agents that drive a screen, read [What computer-use agents can do, and how to run them safely](/knowledge-work/using-ai/what-is-computer-use), then [Let Claude Code drive a browser with Playwright MCP](/knowledge-work/using-ai/playwright-mcp-claude-code).