, I’ll discuss how to orchestrate a lot of different agents using Claude Code or any other coding agents
When you work with coding agents, you want to run as many agents in parallel as possible. This is what makes working with agents so effective. The fact that you can do work in parallel and thus get more total work done.
However, one of the challenges with spinning up a lot of agents at once is keeping an overview of all the agents and answering the agents whenever they have questions for you.
In this article, I’ll discuss how you can deal with this and how you can move even one more abstraction layer up by talking directly to agents coordinating a set of other agents. I use these techniques on a daily basis to run 100+ agents in parallel.
Why orchestrate a lot of agents?
First of all, I like to cover why I’m talking about the specific topic. In this article, I’ll be discussing, or I want to highlight, why you should orchestrate a lot of agents.
The simple answer is that orchestrating a lot of agents allows you to do more work.
And then you might ask yourself why doesn’t everyone just orchestrate a bunch of agents? The reason for this is that there are some challenges when running a lot of agents:
- How do you define and scope specific tasks different agents can work on, so the agents don’t interfere with each other’s work
- How do you keep track of all your agents?
- How do you answer all the requests when the agents have questions for you? And how do you pick up on the context of each agent whenever you have to give an answer to the agent?
All these are challenges that make it hard to orchestrate a lot of agents at once. However, there are ways to orchestrate more agents, and the answer is basically to move one abstraction layer up. You need to move to a layer where you talk to one agent which can itself orchestrate several other agents.
This is the topic I’ll be discussing today. I’m not gonna be discussing running sub-agents with Claude Code or Codex. I’ll literally be discussing how to run multiple Claude Code or Codex sessions at the same time.
How to orchestrate a lot of agents
Starting headless sessions
The short answer to the question of how to orchestrate a lot of agents is to use headless mode.
Headless mode in both Claude Code and Codex is basically a mode where you can spin up a session using the CLI and have the agent work on a particular task and only come back to you with the answer.
I use this extensively, for example, to perform code reviews with Codex, which is a topic I’ve covered in numerous previous articles and is one of the most effective techniques I have to reduce the amount of bugs in your application.
You can activate headless mode with Claude Code using:
claude -p "your prompt here"
And you can activate headless mode with Codex using:
codex exec "your prompt here"
What’s gonna happen once you run this is that you’re gonna spin up a completely separate Codex or Claude Code session, and that session is gonna work on the command you provided until it’s completed the task. The orchestrator agent, which you are talking to, will then only see the logs if it chooses to, and the final result of the command will be the output of the agent, for example, if work was completed. An example response you might get from the agent is:
The task was fixed and merged to dev.
Typically, when running the command, you might also add some other settings, for example, allowing the agents to run without asking for permissions. Allowing tools, setting max turns, specifying which model to use, and so on.
Being effective with headless mode
I’ll cover three main techniques to be effective with headless mode:
- Providing a way for the agent to verify its own work
- Finding suitable tasks for headless modes, such as refactoring
- Give the agent all the tools it needs
Providing a way for the agent to verify its own work
Now, one thing is, of course, to be able to spin up a lot of sessions and agents using headless mode. Another thing, which is of course important, is how are you gonna be effective with the agents like this?
One of the challenges is that you can’t be directly involved in all of the decision-making. Since you’re moving one abstraction layer up, you have to make the agents perform more decisions. Which gives you less control in a way. Thus, you have to change the way you prompt the model to be more high-level, and you have to tell it how to verify its work.
Again, we come back to the same topic, which I covered a lot previously, highlighting how you need to provide the agents with ways to verify the work.
Finding suitable tasks for headless modes, such as refactoring
Another important thing when you use agents like this is to apply them to tasks that are well suited to headless mode. More complicated tasks in themselves aren’t suited for headless mode and are probably better off with more of your input. Also, for tasks that are very vague and where you don’t fully understand it yourself, you should also interact directly with the coding agents
However, one task that is particularly well suited for headless mode is refactoring.
After the release of Claude Fable, I used it, of course, to detect issues and refactoring opportunities in my code to make my coding agents more effective. This could be discovering issues such as:
- Poor separation of concerns
- Security vulnerabilities
- Poor architecture decisions
You can easily do this right now using the command below:
look for refactor opportunities in this repository and provide
them to me in a prioritized manner in an HTML file and make a plan on how
to fix it
This will almost certainly find a bunch of issues which you should definitely fix, especially if you’re using the most powerful coding agents out there, such as Claude Fable.
After you’ve done this, you have a full plan. You should now convert this plan using the following prompt
Take the plan <path to plan> and structure a way for us to implement it.
I'll be using the most powerful coding agent as an orchestrator, and that
coding agent should spin up a bunch of Claude Code headless sessions using
Claude Opus to get each individual task done. Make sure that tasks that
can be done in parallel are spun up in parallel and continue working until
you finish the refactoring completely.
I’ve been using this in the past few days now that Fable became available again with the Claude Code subscription, and I think it’s worked really well. First of all, I haven’t had to spin up a lot of Claude Code sessions myself with all the tasks and refactoring opportunities that the agent discovers, and it’s actually been very effective at getting stuff to production.
Give the agent all the tools it needs
Lastly, it’s also important to give the agent all the tools that it needs. When you run Claude in Headless Mode, it’s hard for the orchestrating agent to interact with it, and you want minimal interactions. The goal of Headless Mode is to simply provide a one-stop shop prompt which gets some work done and reports back when it’s done, just like a normal sub-agent, but even more powerful, of course. If you want this done, you need to give the agent all the tools that it needs; it might need MCP access, it definitely needs to be allowed to perform actions autonomously, and so on. Thus, I urge you to give the agents a lot of freedom, of course, while still keeping control over them to let them perform work autonomously and report back to their orchestrating agent when they’re done.
Conclusion
In this article, I discussed how to orchestrate 100+ agents by utilizing agents as orchestrating agents to spin up a bunch of other agents. I believe this is a very powerful technique that you can apply to your own coding right away to gain a massive advantage and become even more productive with your programming. I use this technique daily to spin up hundreds of agents to work in parallel and to get work done. I believe the future of programming will just be that we move further and further up the abstraction layers, and the techniques I presented in this article are a way to get one abstraction layer up from your normal Claude Code interactions.
👉 My free eBook and Webinar:
🚀 10x Your Engineering with LLMs (Free 3-Day Email Course)
📚 Get my free Vision Language Models ebook
💻 My webinar on Vision Language Models
👉 Find me on socials:
💌 Substack