- Home
- Learn
- Deep Dives
- Claude Code Workflows: Loops, Swarms and Orchestration
Claude Code Workflows: Loops, Swarms and Orchestration
Four ways to run more than one agent in Claude Code, what each costs and when one agent wins. Checked against Anthropic's docs on 27-10-2026.
Published 27-10-2026. Last verified against Anthropic's documentation on 27-10-2026. Reviewed monthly, because Claude Code ships these features fast and several are still experimental.
Quick answer
Claude Code has four documented ways to run more than one step of work: subagents inside one session, agent teams of separate sessions, dynamic workflows that run a script, and /loop for repeating a prompt on a timer. This page is for a developer or tech lead who has outgrown one agent in one terminal and has to decide which pattern fits a task without draining a plan. Our advice: stay with one agent until a task splits into independent pieces, reach for subagents first when it does, and use a workflow only for dozens of items that need the same treatment. We ran none of these patterns, so every number here is Anthropic's, read on 27-10-2026.
How we checked the information in this article
Our method is to read the vendor documentation, write down what it says with the date and mark what we did not run. On 27-10-2026 we read Anthropic's pages on dynamic workflows, subagents, agent teams, scheduled tasks and costs, the announcement of dynamic workflows and the engineering post Building effective agents. Our gate for this page: a pattern is in only if Anthropic documents it for Claude Code with a named way to start it and a stated limit or cost. Three things failed it. We dropped "swarm" as a pattern, because none of the Anthropic pages we read defines the word, and we treat it as everyday talk for agent teams or workflows. We dropped MindStudio's five pattern names, Operator and Split-and-Merge among them, because they are the vendor's labels with no matching Anthropic term. And we dropped TrueFoundry's latency and throughput claims, because the page gives no source for them. Every figure below is vendor-reported and was read on 27-10-2026.
What is a Claude Code workflow?
A workflow is any setup that makes Claude Code do a task in several steps instead of one answer, and Anthropic ships it in four shapes. Subagents are workers Claude spawns, each in its own context window. Agent teams are separate sessions that message each other. A dynamic workflow is a JavaScript script that Claude writes and a runtime executes. A loop re-runs a prompt on a timer. Anthropic's workflows page sorts them by who holds the plan: with subagents and agent teams Claude or a lead agent decides turn by turn what runs next, and with a workflow the script does. That is why our ranking below follows the plan: the more of it lives in code, the more you can repeat and the more tokens it can burn.
| Pattern | Who decides the next step | Scale per Anthropic | How you start it | Documented limit or cost note |
|---|---|---|---|---|
| Subagents | Claude, turn by turn | A few delegated tasks per turn | Ask Claude to use them | 20 concurrent by default, each sends its own requests |
| Agent teams | A lead agent | A handful of long-running peers | Set CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 | Experimental, roughly 7x tokens in plan mode |
| Dynamic workflows | The script | Dozens to hundreds of agents per run | Ask for a workflow or include ultracode | 16 concurrent by default, 1,000 agents per run |
| /loop | Your prompt on a timer | One prompt, repeated | Type /loop with an interval | Seven-day expiry, 50 tasks per session |
Sources: Anthropic's dynamic workflows page, agent teams page, scheduled tasks page and cost page, read on 27-10-2026 and listed under Sources below. The 20 concurrent subagent default comes from Anthropic's subagents page.
How does the loop pattern work in Claude Code?
/loop re-runs a prompt on an interval while your session stays open. Give it an interval and a prompt, such as /loop 5m check the deploy, and it runs on a fixed schedule. Give it only a prompt and Claude picks a delay between one minute and one hour after each pass. Give it nothing and it runs a built-in maintenance prompt, or your .claude/loop.md if one exists.
Loops belong to the session. They fire only while Claude Code is running and idle, a recurring one expires after seven days and a session holds up to 50 scheduled tasks. A fixed-interval loop does not stop on Esc or Ctrl+C: you ask Claude to cancel it. For work that has to run with your machine off, Anthropic points to cloud scheduled tasks instead. We rank the loop as the cheapest pattern to start and the easiest to forget, so we would write the end condition into the prompt on day one. We did not run it.
Our guide to scheduled tasks and skill automation shows the setup, and the Claude workflow automation collection holds skills for the jobs you would put on a timer. For a loop that tests ideas instead of polling, Autoresearch: Autonomous Experiment Loops costs USD 5 per its listing and describes two loops with state files and a rule to write predictions before running an experiment. No reviews were shown on 27-10-2026 and we have not run it. It fits the Claude research and analysis collection better than a coding task.
What do subagents add, and when do you fan out?
A subagent runs in its own context window with its own tools and permissions, and only its result comes back to your conversation. That is the whole value: exploration stays out of your main context. Anthropic's advice for fan-out is to spawn several subagents for independent investigations, and it adds that this works best when the research paths do not depend on each other.
The limits are plain. By default a 21st concurrent subagent fails with "Concurrent subagent limit reached", and there is no cap on how many Claude can spawn over a whole session. Every subagent sends its own requests, which count toward the same usage limits, and many detailed results returning at once can fill your context. Anthropic suggests routing simple tasks to a smaller model such as Haiku. This is where we send almost everyone first: it needs no flag, no script and no new habit. What would push it down the list is work whose pieces depend on each other, because then the workers wait on one another and you pay for the idle context.
Our Claude Code subagents guide covers the setup and our multi-agent orchestration guide puts it next to the other options. The Claude agents orchestration collection lists skills for the delegation itself. We did not run any subagent setup for this page.
Are swarms and agent teams the same thing?
No. Anthropic's term is agent teams: a lead session spawns teammates, each a full Claude Code session with its own context window, and they share a task list and message each other directly. We found "swarm" defined on none of the pages we read, so treat it as a casual word for this pattern or for a workflow, not as a feature name.
Agent teams are experimental and off by default. You enable them with the environment variable CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS set to 1. Anthropic advises starting with 3 to 5 teammates and 5 to 6 tasks each, and warns that two teammates editing the same file overwrite each other, so give each one its own files. The documented limits are one team per session, no nested teams and no resume for in-process teammates. On cost, the agent teams page says "significantly more tokens" than a single session and the cost page puts it at roughly 7x when teammates run in plan mode. We would not hand this to a team without a technical lead who has read the limits.
What moves it up: the two uses Anthropic names first, research or review split into independent lenses, and debugging with competing hypotheses. A review split into security, performance and test coverage is the example in the docs. To keep parallel agents from stepping on each other's files on your own, Swarm Workspace: Multi-Agent Git Worktrees costs USD 5 per its listing. The listing says each agent gets its own git worktree and only the coordinator merges, in dependency order. It showed no use count and no reviews on 27-10-2026, its scan result read "passed" and we have not run it.
Read our guide to agent teams and multi-agent skills before you switch the flag on.
What is the orchestrator pattern and when does a workflow beat subagents?
An orchestrator is a central model that breaks a task down, hands the pieces to workers and combines what comes back. Anthropic's post Building effective agents of 19-12-2024 defines orchestrator-workers as "a central LLM dynamically breaks down tasks, delegates them to worker LLMs, and synthesizes their results". In Claude Code, Claude plays that role when it spawns subagents. A dynamic workflow moves the role into a script, so the loop, the branching and the intermediate results live in code and Claude's context holds only the final answer.
Anthropic's examples for a workflow are a codebase-wide bug sweep, a 500-file migration and research that cross-checks its sources. The runtime allows up to 16 concurrent agents by default, 1,000 agents in total per run and 4,096 items in a single parallel or pipeline call. Claude Code flags a run that schedules more than 25 agents or projects more than 1.5 million tokens with a Large workflow warning, and the default size guideline aims for fewer than 10 agents, or fewer than 5 on a Pro plan. You start one by asking for a workflow or by putting the keyword ultracode in your prompt, and /deep-research is the bundled example. Anthropic's announcement of 28-05-2026 reports a rewrite of Bun with about 750,000 lines of Rust, 99.8% of the existing test suite passing and eleven days from first commit to merge, and adds that it is not yet in production. That is one vendor case, not a benchmark.
The same page shows a "keep fixing until a check passes" shape, where a workflow runs the type checker and repeats until it passes or two rounds make no progress. We would use that for a mechanical cleanup and not for design work. Once you change how agents are wired, check that behavior did not regress. Agent Regression Gate costs USD 19 per its listing, compares recorded agent runs offline and needs Python 3.10 or later. Its scan showed one warning on 27-10-2026 and the details were not visible. It is for the Claude testing and debugging collection. We have not run it.
Which pattern fits which task size?
Match the pattern to how many independent pieces the task has, and start at the top of this list. We put one agent first because every other pattern adds tokens and coordination.
- One agent in one session. Use it when the steps depend on each other or the task fits one context. It sits first because Anthropic itself recommends the simplest solution that works.
- Subagents. Use them when you can name two or three independent questions, such as three modules to read. They sit second because only a summary returns to your context.
- A loop. Use it to poll or babysit, such as a deploy or a pull request. It sits third because it repeats work over time and does not add parallel workers. It moves up the moment the job is "check every few minutes".
- Agent teams. Use them when teammates need to challenge each other. They sit fourth because they are experimental and token heavy. They move up for competing-hypothesis debugging.
- A dynamic workflow. Use it when the same step must run across dozens of items. It sits last because the bill grows with the agent count, and it moves up when the item list is long and the checks are mechanical.
What do these patterns cost?
Anthropic publishes no dollar figure per pattern that we found, so our measured column stays empty. What it does publish is one planning figure and a few directions. Across enterprise deployments the average cost is around USD 13 per developer per active day and USD 150 to 250 per developer per month, with costs below USD 30 per active day for 90% of users. That average covers all Claude Code use, not these patterns, and it is not a budget.
For the patterns, the direction is the same everywhere. Workflows use "substantially more tokens" than a normal session per the announcement, subagents send their own requests, and agent teams use roughly 7x in plan mode. To size a workflow before you commit, Anthropic suggests running it on a small slice first, and the /workflows view shows each agent's token use so you can stop a run. The /usage command splits recent usage by subagents, skills and plugins on a subscription plan, and our guide to Claude Code usage limits explains the session and weekly caps these patterns draw from.
If you suspect a loop or a retry pattern is eating tokens, Agent Loop Cost Rescue costs USD 5 per its listing and ranks which loop, tool or retry pattern uses the most tokens. Its shipped sample shows 15,000 tool-result tokens out of 16,000 in total, and the listing says it claims no savings from that sample. We would try it before we buy anything bigger, and we have not run it. Our guide to reducing Claude Code costs with skills and the Claude LLM ops collection go further.
We sell skills that load into Claude, Cursor, Codex CLI and Copilot, and we name four of ours on this page. No vendor paid to be listed.
When does a single agent win?
A single agent wins whenever the work is sequential or small. Anthropic's post says to find "the simplest solution possible, and only increasing complexity when needed", and that agentic systems "often trade latency and cost for better task performance". The agent teams page says the same in its own terms: for sequential tasks, same-file edits or work with many dependencies, a single session or subagents are more effective. Our rule is blunt: if you cannot name the independent pieces, use one agent. We would talk you out of a workflow for a task that touches a handful of files, and out of agent teams for anything you could finish in one sitting.
Where to go next
Re-read Anthropic's own pages for anything that changes after 27-10-2026, starting with the workflows page, because workflows and agent teams are new and the limits above can move. Read Anthropic's post Building effective agents (listed under Sources below) for the reasoning behind the single-agent rule. This page contains no guarantee about results or cost, so test a pattern on a small task and read your own usage numbers before you scale it. We will recheck it monthly and mark what changed.
Written by Samuel Rose, Founder of Agensi.