Branchwell

Become a Pro / website · becomeapro.ai / content / tutorials / claude / run-a-team-of-agents.mdx

Raw 20.6 KB on 5069836c1e4c4e369ebe86b13dc7d299c5bed8c0
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 tutorial's video the same way."
4level: Advanced
5minutes: 15
6publishedAt: 2026-11-04
7updatedAt: 2026-12-01
8video: be-the-operator
9videoUploadedAt: "2026-11-05T07:51:58-08:00"
10---
11
12AI 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**.
13
14The 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.
15
16This 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 tutorial's video the same way, mostly from a phone.
17
18## What you need
19
20- Claude Code, signed in with a Pro, Max, Team or Enterprise plan
21- A project in git with at least one commit, because parallel sessions use git worktrees
22- A test, build or lint command Claude can run to check its own work
23- About 30 minutes to set it up the first time
24
25Each 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.
26
27## From chatbot to agent
28
29A chatbot answers questions. An agent takes a task and works on it until it's done. That difference is what makes the operator possible.
30
31| | Chatbot | Agent |
32| --- | --- | --- |
33| What you give it | A question | A task, with a goal and a finish line |
34| What it does | Answers in text | Reads files, edits code and runs commands |
35| How you check it | Read the answer | Read the changes and the test output |
36| How many at once | One conversation | Several sessions in parallel |
37
38## What a talented operator can do
39
40None of these jobs is new. The multiplier is running several of them at the same time while you review.
41
42- **Fix several bugs at once.** One agent per bug, each on its own branch, so the fixes never collide.
43- **Build and test in parallel.** One agent builds a small feature from a written spec while another writes its tests.
44- **Keep the docs current.** An agent updates the README and the changelog after every change.
45- **Turn data into a report.** Give an agent a spreadsheet or a log file and ask for a short summary with charts.
46- **Research before building.** An agent reads a library's docs and comes back with a plan before anyone writes code.
47
48## How the pieces fit
49
50| Piece | What it is | Where it lives |
51| --- | --- | --- |
52| Rules | Standing instructions every agent reads | `CLAUDE.md` |
53| Brief | One task, written like a ticket | Your prompt |
54| Agents | One Claude Code session per task | A git worktree each |
55| Helpers | Focused assistants for side jobs, like review | `.claude/agents/` |
56| Guardrails | Rules Claude Code enforces, not just reads | Hooks in `.claude/settings.json` |
57| You | Approve plans, review results and merge | Terminal, desktop app or phone |
58
59## Step 1: Write the rules once
60
61Every 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:
62
63```markdown
64# How to check your work
65- Run `npm test` and `npm run lint` before you say a task is done
66- In your summary, paste the command you ran and the last lines of its output
67
68# How we work
69- One task per session. If you find a second problem, tell me instead of fixing it
70- Stay on your own branch. Never push to main
71- Ask before you add a dependency or change the database schema
72
73# When you finish
74- Summarize what changed in 3 to 5 bullets
75- List anything you skipped or couldn't check
76```
77
78Swap in your own commands. Our [CLAUDE.md guide](/claude/claude-md-guide) covers where the file goes and how to check that Claude loaded it.
79
80## Step 2: Write the brief like a ticket
81
82A vague task gets a vague result. Give each agent a brief with a clear finish line:
83
84```prompt
85Task: [one sentence]
86Why: [the problem this solves]
87Done means: [the test or check that proves it works]
88Stay inside: [the files or folders it may change]
89Don't: [what to leave alone]
90Before you change anything, show me a short plan and wait for my OK.
91```
92
93Here's one filled in:
94
95```prompt
96Task: Fix the order dates that show one day early for customers in Asia.
97Why: Dates are converted to UTC twice before they're displayed.
98Done means: A new test for a Tokyo customer passes, and npm test passes.
99Stay inside: src/lib/dates.ts and its tests.
100Don't: Change the database or any API responses.
101Before you change anything, show me a short plan and wait for my OK.
102```
103
104| Vague | Clear |
105| --- | --- |
106| Fix the dates | Fix the order dates that show one day early in Asia |
107| Make sure it works | A new test for a Tokyo customer passes |
108| Clean up the code | Stay inside `src/lib/dates.ts` and its tests |
109
110The 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.
111
112## Step 3: Run agents side by side
113
114Two agents editing the same folder will overwrite each other's work. Claude Code solves this with git worktrees: each session gets its own copy of the project on its own branch. Open a terminal for each task:
115
116```bash
117claude --worktree fix-date-bug
118claude --worktree add-checkout-tests
119claude --worktree update-docs
120```
121
122`-w` is the short form. Each worktree lives in `.claude/worktrees/<name>/` on a branch called `worktree-<name>`. Add `.claude/worktrees/` to your `.gitignore`. When you exit a session with no changes left, Claude Code removes its worktree and branch, and if there are changes, it asks whether to keep them. Paste a brief into each session and let them work.
123
124If you'd rather not keep a terminal open for every agent, start them in the background and check on them from one place:
125
126```bash
127claude --bg "Fix the order dates that show one day early in Asia. Done means npm test passes."
128claude agents
129```
130
131`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.
132
133<Callout type="note">
134Claude 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.
135</Callout>
136
137## Step 4: Give side jobs to subagents
138
139A 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:
140
141```markdown
142---
143name: reviewer
144description: Reviews a finished change for bugs, missing tests and edits outside the task. Use after a task is done and before it is merged.
145tools: Read, Glob, Grep, Bash
146model: sonnet
147---
148
149You review changes. Read the diff against main and run the tests, then report:
1501. Bugs or risky edits, with the file and line
1512. Missing tests
1523. Anything that doesn't match the task
153Don't edit any files. Report only.
154```
155
156Then, in any session:
157
158```prompt
159Use the reviewer subagent to check this branch before I merge it.
160```
161
162The `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.
163
164## Step 5: Add guardrails Claude Code enforces
165
166A 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.
167
168### Pick a permission mode
169
170Press `Shift+Tab` in a session to switch modes, or start with `claude --permission-mode plan`.
171
172| Mode | What it does | Use it for |
173| --- | --- | --- |
174| Default | Asks before edits and commands | Getting started, or any risky task |
175| Plan | Reads and plans, but changes nothing | Checking an agent's plan before it starts |
176| Accept edits | Edits files without asking, still asks for commands | Agents you trust on a small task |
177| Auto | A separate model checks each action and blocks risky ones | Long tasks where prompts would stall the work |
178
179Auto 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.
180
181### Block what must never happen
182
183Hooks 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`:
184
185```json
186{
187 "hooks": {
188 "PreToolUse": [
189 {
190 "matcher": "Bash",
191 "hooks": [
192 {
193 "type": "command",
194 "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-risky-git.sh"
195 }
196 ]
197 }
198 ]
199 }
200}
201```
202
203Then save this script as `.claude/hooks/block-risky-git.sh` and run `chmod +x` on it. It needs `jq`:
204
205```bash
206#!/usr/bin/env bash
207# Stops force pushes and pushes to main. Exit code 2 blocks the command,
208# and Claude sees the message on stderr.
209cmd=$(jq -r '.tool_input.command // ""')
210if echo "$cmd" | grep -Eq 'git push.*(--force|-f( |$))|git push.* main( |$)'; then
211 echo "Blocked: no force pushes and no pushes to main. Open a pull request instead." >&2
212 exit 2
213fi
214exit 0
215```
216
217We 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.
218
219### Get a ping when an agent needs you
220
221With 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:
222
223```json
224"Notification": [
225 {
226 "matcher": "",
227 "hooks": [
228 {
229 "type": "command",
230 "command": "osascript -e 'display notification \"Claude Code needs your attention\" with title \"Claude Code\"'"
231 }
232 ]
233 }
234]
235```
236
237## Step 6: Review before you merge
238
239Reviewing is the operator's real job. Before you merge anything, ask for evidence, not a promise:
240
241```prompt
242Show 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.
243```
244
245If 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.
246
247## Run it from your phone
248
249Your 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.
250
251Start a session with Remote Control on:
252
253```bash
254claude --remote-control
255```
256
257Or 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.
258
259- **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.
260- **Your computer stays on.** The session runs on your machine, so the computer has to stay awake with Claude Code running.
261- **Talk instead of typing.** Your phone's dictation works in the prompt box, so you can speak each brief.
262
263<Callout type="tip">
264On 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).
265</Callout>
266
267## Watch your token use
268
269Running agents in parallel spends your plan's limits faster. Check where it's going:
270
271- `/usage` shows your plan's usage limits and an estimate for the current session. `/cost` and `/stats` open the same screen.
272- `/context` shows what's filling the current session's context window.
273
274To 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.
275
276## When it goes wrong
277
278| If you see | Do this |
279| --- | --- |
280| An agent drifts into other work | Press `Esc`, restate the task, and keep one task per session |
281| It says "done" but never ran the tests | Make "Done means" a command, and ask for its output |
282| Two agents change the same files | Give each one a worktree and a "Stay inside" line |
283| Your limits run out fast | Run fewer agents at once, and put helpers on a smaller model |
284| You type the same correction every day | Add it to `CLAUDE.md` |
285| Something must never happen | Use a hook, not a line in `CLAUDE.md` |
286
287## How we made this tutorial's video
288
289We made the video for this tutorial the same way. Much of the orchestration was done by voice dictation in the Claude Code mobile app. A Mac did the work. Claude used computer use to operate its apps, Claude in Chrome for the browser, and the terminal for rendering. The computer was only the worker, and permissions were approved on the computer itself.
290
291<Steps>
292 <Step title="Script">
293 Claude Code wrote the script from our outline, in short, plain sentences.
294 </Step>
295 <Step title="Narration">
296 [ElevenLabs](https://elevenlabs.io) read the script in the voice "Eric", one section at a time and in order, with request stitching, so the voice stays the same from start to finish. The timing of every character placed each word on screen and built the captions.
297 </Step>
298 <Step title="Demos">
299 Each demo is a real Claude Code session in a small sample project. A script typed the prompts and recorded the terminal, and [Playwright](https://playwright.dev) recorded the browser clips. The video replays those recordings.
300 </Step>
301 <Step title="Motion">
302 [HyperFrames](https://github.com/heygen-com/hyperframes) rendered the diagrams, titles, captions and terminal playback from HTML. The moving particles behind them are a small WebGL shader, and [Three.js](https://threejs.org) draws the 3D logo at the end.
303 </Step>
304 <Step title="Music">
305 The background music is a track made with [Suno](https://suno.com), looped under the voice.
306 </Step>
307 <Step title="Final cut">
308 [FFmpeg](https://ffmpeg.org) mixed the voice and music. HyperFrames rendered the final video with that mix, and FFmpeg checked its loudness.
309 </Step>
310 <Step title="Review">
311 We watched short samples first, then the full cut at 1080p, fixed what we found, and only then rendered the final 4K version.
312 </Step>
313</Steps>
314
315### What it takes to run this
316
317| What | Why it's needed | Good to know |
318| --- | --- | --- |
319| Claude Code on Pro or Max | Computer use needs one of these plans | Not available on Team or Enterprise |
320| Computer use | Lets Claude see the screen and use the mouse and keyboard | Research preview, macOS only. Turn it on with `/mcp`, then allow Accessibility and Screen Recording for your terminal in macOS settings |
321| Claude in Chrome | Lets Claude open pages, click and fill in forms | Chrome or Edge with the extension, version 1.0.36 or later. Start with `claude --chrome` |
322| Remote Control | Steer from your phone | The computer stays on the whole time |
323| An ElevenLabs account | The narration | Keep the API key in an environment variable, never in a prompt |
324| HyperFrames | Renders video from HTML | Needs Node.js 22 or later and FFmpeg |
325| Disk space | Video frames take a lot of room | We render to an external drive |
326
327Only one session can use computer use at a time, and pressing `Esc` stops it. Anthropic's [computer use page](https://code.claude.com/docs/en/computer-use) covers the setup.
328
329### The code behind it
330
331Narration, one section at a time and in order. Each request passes the IDs of up to three earlier requests, plus the text around it, so ElevenLabs keeps the same tone across the whole script. The response also includes the timing of every character, which is what we used for the captions:
332
333```python
334import base64
335import os
336
337import requests
338
339VOICE_ID = "your-voice-id" # from the voice's page in ElevenLabs
340MODEL_ID = "your-model-id" # use the same model for every section
341URL = f"https://api.elevenlabs.io/v1/text-to-speech/{VOICE_ID}/with-timestamps"
342HEADERS = {"xi-api-key": os.environ["ELEVENLABS_API_KEY"]}
343
344sections = open("script.txt").read().split("\n\n")
345request_ids = []
346for i, text in enumerate(sections):
347 body = {
348 "text": text,
349 "model_id": MODEL_ID,
350 "previous_request_ids": request_ids[-3:],
351 "previous_text": sections[i - 1] if i > 0 else None,
352 "next_text": sections[i + 1] if i + 1 < len(sections) else None,
353 }
354 response = requests.post(URL, headers=HEADERS, json=body)
355 response.raise_for_status()
356 request_ids.append(response.headers["request-id"])
357 data = response.json() # audio_base64, plus per-character timings in "alignment"
358 with open(f"section-{i:02d}.mp3", "wb") as f:
359 f.write(base64.b64decode(data["audio_base64"]))
360```
361
362Request IDs only work for about two hours, and stitching isn't available for the `eleven_v3` model. ElevenLabs' [request stitching guide](https://elevenlabs.io/docs/eleven-api/guides/how-to/text-to-speech/request-stitching) has the rest.
363
364Motion graphics, from a HyperFrames project:
365
366```bash
367npx hyperframes init operator-video
368npx hyperframes preview
369npx hyperframes render --fps 60 --output chapter-1.mp4
370```
371
372The sound mix. This puts the music about 12 dB under the voice and sets the loudness YouTube expects. The HyperFrames render then uses `mix.wav` as its soundtrack:
373
374```bash
375ffmpeg -i narration.wav -i music.wav \
376 -filter_complex "[1:a]volume=0.25[m];[0:a][m]amix=inputs=2:duration=first:normalize=0,loudnorm=I=-14:TP=-1.5[a]" \
377 -map "[a]" mix.wav
378```
379
380## Your first week as an operator
381
3821. **Write the brief like a ticket.** A task, a reason, and a finish line Claude can check.
3832. **Give each agent one job.** One task, one session, one worktree.
3843. **Make every result easy to review.** Ask for the diff, the test output and what was skipped, every time.
385
386Start with two agents on small, separate tasks. Add a third once reviewing the first two feels easy.
387
388## How we checked this
389
390We 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.
391
392## Anthropic's docs
393
394<Resources>
395 <Resource kind="Docs" source="Anthropic" title="Run parallel sessions with worktrees" href="https://code.claude.com/docs/en/worktrees">
396 How `--worktree` works, where worktrees live and how they're cleaned up.
397 </Resource>
398 <Resource kind="Docs" source="Anthropic" title="Subagents" href="https://code.claude.com/docs/en/sub-agents">
399 Every field for `.claude/agents/` files, and when to use a subagent instead of a new session.
400 </Resource>
401 <Resource kind="Docs" source="Anthropic" title="Hooks guide" href="https://code.claude.com/docs/en/hooks-guide">
402 Run your own commands at fixed points, including blocking a tool call before it runs.
403 </Resource>
404 <Resource kind="Docs" source="Anthropic" title="Remote Control" href="https://code.claude.com/docs/en/remote-control">
405 Control a Claude Code session on your computer from the Claude app or claude.ai/code.
406 </Resource>
407 <Resource kind="Docs" source="Anthropic" title="Computer use" href="https://code.claude.com/docs/en/computer-use">
408 Let Claude Code see your screen and use your Mac's apps, and the permissions it needs.
409 </Resource>
410 <Resource kind="Docs" source="Anthropic" title="Claude in Chrome" href="https://code.claude.com/docs/en/chrome">
411 Let Claude Code open pages, click and fill in forms in Chrome or Edge.
412 </Resource>
413</Resources>
414
415## Keep going
416
417New to the rules file? Start with [How to write a CLAUDE.md that Claude Code follows](/claude/claude-md-guide). For more on agents that drive a screen, read [What computer-use agents can do, and how to run them safely](/computer-use/what-is-computer-use), then [Let Claude Code drive a browser with Playwright MCP](/computer-use/playwright-mcp-claude-code).