ykononov.com / Vibe coding from scratch: bb, Claude Code, Codex, and OpenCode / Module 09
Run several AI agents in parallel: worktrees and threads in bb
Separate worktrees, parallel threads, and which agent gets which task.
To keep two agents from editing the same files, give each thread a Worktree environment, a separate copy of the project. Merge finished work into the main version one thread at a time. Use the strongest model for planning and hard bugs, and OpenCode’s free models for small changes and review. The real limit on the number of agents is your own attention.
Worktree: every task gets its own desk
So far, you’ve had only one agent working at a time. That’s convenient, but you’ve probably noticed the pauses: the agent writes, you wait. The natural urge is to fill that time with a second task.
If you simply open a second thread in the same folder and give it a different task, two agents will start changing the same files at the same time. One rewrites a page while the other, in the same second, tweaks a button on it, and the result is no good to anyone. Picture two editors marking up the same paper copy of a manuscript at once.
The fix is to give each of them their own copy. In git this is called a worktree: a separate folder with a copy of the project and its own branch of history. bb creates one for you when you choose the Worktree environment for a new thread instead of Project checkout.

What to keep in mind:
- The main folder doesn’t change while the agent works in its copy. It still holds the last version you checked
- The copy is made from the saved state. Anything not committed in the main folder won’t be in it. One more reason to commit
- The result has to be merged back. When the task is done and checked, the changes on the branch are merged into the main version
- The reviewer sits at the same desk. To have a second agent review work done in a worktree, create its thread in that same environment, not a new one
Practice: two tasks in parallel
Take two improvements that don’t overlap. For the habit tracker, for example: a dark theme and exporting the data to a file. If you’re building your own app, pick any two small, independent changes.
- Save your work. In the main thread: “Make a commit.” Copies are created from the saved state.
- First thread. Create a new thread with the Worktree environment and your main agent. The task:
Add a dark theme with a toggle in the corner of the screen. It should remember my choice. Show me a short plan first. Once I confirm, build it, start the app, and give me the address so I can check it.
- Second thread. Without waiting for the first one, create another thread, again with the Worktree environment. Pick a different agent if you have one. The task:
Add an Export button that saves all my habits and their checkmarks to a CSV file I can open in Excel. Show me a short plan first. Once I confirm, build it, start the app, and give me the address so I can check it.
- Watch. The sidebar shows which thread is working and which is waiting for your reply. Switch between them, approve the plans, answer the questions.
- Check each result separately. Each copy has its own address; the port numbers will differ. Don’t mix them up: the copy with the dark theme doesn’t have the export yet, and vice versa.
- Merge what’s ready. In each thread in turn:
This task is done and approved. Commit it and merge this branch into the project's main branch. If it conflicts with other changes, stop and explain in plain language what the conflict is and what my options are.
- Check the main version. Go back to the main thread, start the app from the main folder, and make sure both improvements are there.

When you’re done, clean up after yourself. Finished threads can be archived, and after a while bb deletes their worktrees from disk. Archive only after merging: uncommitted changes in a deleted worktree can’t be recovered.
Which agent gets which task
Now that you have several agents, you have to decide who does what. I won’t give you a ready-made table saying “this one is better at interfaces, that one at data.” The balance shifts with every model release, and any such table is out of date within two months. Instead, here are principles that don’t go out of date.
| Task | Who gets it | Why |
|---|---|---|
| Spec, plan, a hard bug | Your main agent’s strongest model, with the reasoning level set to High | A mistake at this stage costs the most; this isn’t the place to economize |
| Routine work on an approved plan | The default model | When it’s clear what to do, you don’t need a genius |
| Small changes: wording, colors, spacing | A fast, lightweight model, or a free one in OpenCode | It’s faster and doesn’t eat into your main usage limit |
| Review | An agent from a different company | An independent view |
| Your main agent is stuck | A different agent, in a new thread | A different model makes different mistakes |
| You’ve hit your usage limit | Any other agent | The work doesn’t stop |
There are two ways to hand a task to another agent partway through. The simple one: open a new thread with a different agent and write “Continue the work started in the other thread. The current state is in the project files, and the task is such-and-such.” The convenient one: bb has a Hand off to new thread action. It creates a new thread that links to the original, so the new agent can read what was discussed.
This works because everything important lives in files, not in the agents’ heads: the spec is in SPEC.md, the rules are in AGENTS.md, and the current state is in the code and the git history. An agent is replaceable as long as the project is written down.
/connect command, and free ones such as DeepSeek V4.1 Flash Free, Big Pickle, MiMo, and Nemotron. They’re a fallback for when you’ve used up the limits on your main agents, and a way to avoid spending your subscription on small stuff. A practical setup: your main agent writes, and DeepSeek in OpenCode reviews or fixes wording and spacing for free. Keep the free models away from hard tasks: they make more mistakes and are worse at keeping track of a long context.How many agents make sense
After a first success, it’s tempting to launch ten threads at once. Technically, bb lets you. In practice, you become the bottleneck.
Every parallel thread needs your attention at least three times: to set the task, to approve the plan, and to check the result. An agent writes code in minutes, but checking is still a human job, and it hasn’t gotten any faster. Three threads whose results you looked at carefully are worth more than ten you accepted without looking.
Some rules of thumb:
- Two or three threads at a time is a comfortable ceiling while you’re learning
- The tasks have to be independent. If the second task builds on the result of the first, that’s a queue, not parallel work
- The clearer the task, the less supervision it needs. A thread with a good spec and an approved plan can run for half an hour without you. A thread told to “improve the app” will either pester you with questions or wander off in the wrong direction
- Keep an eye on your usage limits. Three agents use up a subscription three times as fast. bb shows how much is left with each provider
A word about long tasks. The agent doesn’t need you sitting next to it. Set the task, approve the plan, go to lunch: you’ll come back to a finished result or to the question the agent stopped on. Module 11 covers how to get notified about that on your phone and reply from there.
- I’ve created a thread with the Worktree environment
- Two threads worked on different tasks at the same time
- Both improvements are merged into the main version and work together
- I’ve given a task to an agent other than my main one at least once
Review questions
What happens if two threads with different tasks work in the same project folder?
The agents change the same files at the same time and wreck each other’s work. Agents in different threads don’t know about each other. To keep them out of each other’s way, each needs its own copy of the project: a worktree.
What goes into a new worktree?
The project’s committed state; uncommitted changes aren’t included. The copy is made from the git history, which is why you need to commit before creating parallel threads.
What limits the number of agents working in parallel?
Your attention: every task has to be set and every result checked. Agents write fast, but checking is still a human job. Ten threads accepted without looking are worse than three you checked.
Why can you hand a task to a different agent partway through?
Because everything important is in the project files: spec, rules, code, history. An agent is replaceable as long as the project is written down. SPEC.md, AGENTS.md, and the git history are available to any agent in any thread.
This page covers a single module. The interactive version of the course has steps, quizzes, and checklists that save your progress.
Open this module in the course →By Yury Kononov, Chief Technology Officer. The course is free and licensed under CC BY 4.0. Updated 2026-11-28. Contact the author: @ykononov.