AI coding agents · Claude Code · Codex · Configuration

Configuring AI Coding Agents: Subagents, Agent Teams, JSON and Markdown Files

Khairul Alam·October 2026·~25 min read
SubagentsAgent teamsClaude CodeCodexConfigurationGit worktrees

One coding agent in one chat is a good start. When the job grows (review a whole app, investigate a bug with several theories, build a feature across layers) you want helpers: small agents with their own instructions, tools and context. This article shows how to define them three ways (in the terminal, in JSON, and in Markdown or TOML files), how to run them, and how to arrange them into a team that does not trip over itself.

Team, I need a hand! Explorerfinds things Implementermakes changes Reviewerchecks the diff Test writerruns the tests
The cast of this article: one main agent and a few specialists, each with a single job.
The whole post in 60 seconds
  • A subagent is a helper with its own context window, system prompt, tools and model. It does a side task and sends back a summary. Your main chat stays small.
  • In Claude Code you define one as a Markdown file with a short YAML header (.claude/agents/name.md), or for one session as JSON with claude --agents '{...}'.
  • In Codex you define one as a TOML file (.codex/agents/name.toml) and tune limits in config.toml.
  • An agent team (Claude Code, experimental) is different: several full sessions that message each other and share a task list. It costs more and is worth it only for work that parallelises.
  • Parallel is faster only for independent work. Dependent steps should run in order; extra agents add cost and a merge step.
  • Start with read-only parallel work (review, research, debugging). Give every agent its own files or its own Git worktree. Never let two agents edit the same file.
  • Agents inherit your permissions. A “do not edit” sentence is a request, not a sandbox; restrict tools or the sandbox instead.
Contents
  1. The mental model: one agent, subagents, teams
  2. Three ways to configure an agent
  3. Markdown files (Claude Code)
  4. JSON and settings (Claude Code)
  5. Running and managing agents in the terminal
  6. Setting up a team of subagents
  7. Agent teams (Claude Code, experimental)
  8. Codex: TOML agent files
  9. Claude Code and Codex side by side
  10. Pros and cons: parallel vs serial
  11. Safety, cost and habits
  12. Common mistakes
  13. Takeaways and glossary

1. The mental model: one agent, subagents, teams

An agent is a language model running in a loop with tools: it reads files, runs commands, and decides what to do next. The problem with a single agent is its context window. Every file it reads and every log line it sees stays in the conversation, so a long task fills the window and quality drops. Helpers solve that by doing messy work somewhere else.

One session Main agentdoes everything Context fillswith file reads Subagents Main agent helper helper task results return as summaries Agent team Lead teammate teammate shared task list teammates talk to each other Each box has its own context window. Cost grows from left to right.
A subagent reports back to whoever called it. Teammates are full sessions that coordinate among themselves.
SubagentAgent team (Claude Code)
What it isA helper started inside one sessionSeveral separate sessions led by one lead
Talks toThe caller (returns a result)Each other, through messages and a shared task list
Best forFocused jobs where only the result matters: search, review, test runsWork that needs discussion: competing hypotheses, cross-layer features
Token costLower: summaries come backHigher: every teammate is a full session
StatusStable featureExperimental, off by default
Analogy: a kitchen

Subagents are cooks you send to the pantry: “find the three spices I need and tell me where they are.” You never see the shelves. An agent team is a few cooks each running a station, calling out to each other. It is faster for a banquet, but you pay more wages and the station boundaries must be clear.

Without helpers file.kt log.txt file.kt 😵 Everything in one head Context fills up, quality drops With subagents fileslogstests Short notes come back Main context stays light
A subagent does the heavy reading in its own head and returns only a summary.

2. Three ways to configure an agent

Where the definition lives decides who can use it and which one wins when two share a name.

WayFormatLivesUse it for
Markdown file (Claude Code)YAML header plus a prompt body.claude/agents/ (project) or ~/.claude/agents/ (you)Agents you keep, review in pull requests and share with the team.
JSON on the command line (Claude Code)claude --agents '{...}'One session onlyQuick experiments, scripts, CI jobs.
TOML file (Codex)One .toml per agent.codex/agents/ or ~/.codex/agents/Codex custom agents.
Plain prompt (both)Natural languageThe conversation“Use subagents to review this in parallel.” No setup at all.

For Claude Code the lookup order, from strongest to weakest, is:

  1. Managed settings (set by an organisation).
  2. The --agents flag for this session.
  3. .claude/agents/ in the project (the folder closest to your working directory wins).
  4. ~/.claude/agents/ for all your projects.
  5. Plugins, which ship their own agents/ folder.

Identity comes from the name field, not the file name or sub-folder. Two files with the same name collide, and the higher row in the list above wins.

3. Markdown files (Claude Code)

A subagent is a Markdown file. The part between the --- lines is YAML configuration; everything after it is the agent’s system prompt.

.claude/agents/code-reviewer.md

---
name: code-reviewer
description: Reviews code for bugs, security and maintainability. Use proactively after code changes.
tools: Read, Glob, Grep
model: sonnet
---

You are a senior code reviewer.
Review the changes you are pointed at. Report findings with file paths and line numbers,
ordered by severity. Do not modify files. If everything looks fine, say so briefly.

Save the file and it is picked up while the session runs (the very first agent file in a brand-new agents folder may need a restart). Only name and description are required.

The header fields you will actually use

FieldWhat it does
nameUnique identifier. Required.
descriptionTells Claude when to delegate. Required. Write it like a job posting; phrases such as “use proactively” make delegation more likely.
toolsAllowlist of tools, comma-separated or a YAML list. Leave it out and the agent inherits everything. A reviewer with only Read, Glob, Grep cannot change your code.
disallowedToolsDenylist, applied first. Use it when “everything except these” is easier to say.
modelsonnet, opus, haiku, a full model ID, or inherit. Route easy work to a cheaper model.
permissionModedefault, acceptEdits, auto, dontAsk, bypassPermissions or plan. The main session’s stricter modes can override it.
maxTurnsStops a runaway agent after N turns.
skillsSkills whose full text is preloaded into the agent.
mcpServersMCP servers the agent can use, by name or defined inline.
hooksScripts that run around the agent’s tool calls, for example to validate a command.
memoryuser, project or local: a folder where the agent keeps notes between runs.
backgroundtrue always runs it in the background.
isolationworktree runs the agent in a temporary Git worktree so its edits cannot collide with yours.
effortReasoning effort from low to max, where the model supports it.
colorLabel colour in the interface.

Field names are case-sensitive, and unknown fields are silently ignored. If an agent does not appear, run claude --debug and look for the reason, or check parsing with claude plugin validate .claude/agents. A file is skipped if the opening --- is not on line 1, the YAML is broken, or name or description is missing.

Fields change between versions, so treat this table as a map and check the subagent reference for your installed version.

Example: a read-only agent that cannot be talked into editing

---
name: db-reader
description: Runs read-only database queries to answer questions about data.
tools: Bash
hooks:
  PreToolUse:
    - matcher: "Bash"
      hooks:
        - type: command
          command: "./scripts/validate-readonly-query.sh"
---
You answer data questions by running SELECT queries only.

The script receives the pending command as JSON on standard input. Exiting with code 2 blocks the call. That is a real guard, unlike a sentence in the prompt.

Example: an agent that works in its own worktree

---
name: refactorer
description: Performs one mechanical refactor in an isolated branch checkout.
isolation: worktree
model: sonnet
maxTurns: 40
---
Apply the requested refactor. Run the unit tests. Summarise what changed.

With isolation: worktree the agent edits a temporary copy of the repository, so it can run beside your own work. The same idea is explained for people in the Git and branching guide (git worktree).

Where the prompt body goes

4. JSON and settings (Claude Code)

Define agents for one session with --agents

Each top-level key is an agent name. prompt takes the place of the Markdown body.

claude --agents '{
  "code-reviewer": {
    "description": "Expert code reviewer. Use proactively after code changes.",
    "prompt": "You are a senior code reviewer. Focus on quality, security and best practices.",
    "tools": ["Read", "Grep", "Glob", "Bash"],
    "model": "sonnet"
  },
  "debugger": {
    "description": "Debugging specialist for errors and test failures.",
    "prompt": "You are an expert debugger. Find root causes and propose fixes."
  }
}'

The same fields as the Markdown header are accepted (description, tools, disallowedTools, model, permissionMode, mcpServers, hooks, maxTurns, skills, memory, effort, background, isolation and a few more). color is ignored. In non-interactive runs (-p) newer versions also accept a file path:

claude -p "Review the staged changes" --agents ./agents.json

Because --agents outranks files on disk, it is a handy way to override an agent for a CI job without touching the repository. On Windows PowerShell use a here-string (@'...'@) to avoid quote trouble.

Make an agent the default with settings.json

To run the whole session as an agent (its prompt, tools and model replace the defaults), use the --agent flag, or set a project default:

// .claude/settings.json
{
  "agent": "code-reviewer"
}

The command-line flag claude --agent code-reviewer overrides the setting.

Control delegation with permissions and environment variables

// .claude/settings.json
{
  "permissions": {
    "deny": ["Agent(Explore)"]          // block one agent; deny "Agent" to block all delegation
  },
  "env": {
    "CLAUDE_CODE_SUBAGENT_MODEL": "sonnet",          // default model when the file names none
    "CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS": "6",     // default is 20 at once
    "CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH": "1"      // 1 turns off subagents spawning subagents
  }
}
SettingEffect
permissions.deny: ["Agent(Name)"]Stops delegation to that agent. The same works as --disallowedTools "Agent(Name)".
CLAUDE_CODE_SUBAGENT_MODELModel for subagents that do not name one. Add CLAUDE_CODE_SUBAGENT_MODEL_FORCE=1 to force it on all of them.
CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTSCap on subagents running at once.
CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTHHow many layers deep subagents may spawn subagents (the default is 3 on current versions; 1 disables nesting).
CLAUDE_CODE_DISABLE_EXPLORE_PLAN_AGENTS=1Removes the built-in Explore and Plan agents.

Which model does a subagent end up with? In order: the model named for that one call, then the model in the agent file (inherit means the main conversation’s), then CLAUDE_CODE_SUBAGENT_MODEL, then the main conversation’s model.

5. Running and managing agents in the terminal

Three ways to call an agent

HowExampleGuarantee
Natural languageUse the code-reviewer subagent to check the auth moduleClaude decides whether to delegate.
@-mention@"code-reviewer (agent)" look at the auth changesThat agent runs.
Whole sessionclaude --agent code-reviewerThe main thread becomes that agent.

Claude also delegates on its own when a task matches an agent’s description. Three built-in agents are always there: Explore (read-only search, with quick, medium and very thorough levels), Plan (read-only research for plan mode) and general-purpose (all tools). A file of your own with the name Explore replaces the built-in one.

Watching and steering

Subagents start with a fresh context and do not see your conversation. They also cannot ask you questions or enter plan mode. Put everything they need into the task message.

Quick start: a parallel read-only review, no files needed

Use subagents to review this project in parallel.

- Agent 1: find bugs and edge cases.
- Agent 2: review architecture and maintainability.
- Agent 3: review unit test coverage.
- Agent 4: identify performance and memory issues.

Return findings with file paths and line numbers. Do not modify files.

This is the safest first experiment: the agents only read, so there is nothing to conflict, and you get four independent opinions back as short summaries.

6. Setting up a team of subagents

A “team” of subagents is not a feature switch. It is a set of well-separated roles plus a rule for how work flows between them. Three patterns cover most needs.

Fan-out: parallel, read-only Main security lens performance lens test-gap lens findings mergein Main Pipeline: sequential hand-off explorer implementer reviewer fresh eyes at the end
Fan-out reads in parallel and merges. A pipeline hands one result to the next specialist.

Step 1: split by role, not by file count

Good roles have one job, a narrow tool list and a clear output. A reasonable starter set for an Android or backend project:

AgentJobToolsModel idea
explorerFind where something lives, map the code. Read-only.Read, Glob, GrepCheap and fast
implementerMake a defined change in an agreed set of files.Read, Edit, Write, BashMain model
test-writerAdd or fix tests for the change; run them.Read, Edit, Write, BashMain model
reviewerReview the diff with fresh context. Read-only.Read, Glob, GrepStronger model for hard reviews

Step 2: write the files

.claude/agents/explorer.md
---
name: explorer
description: Read-only codebase explorer. Use to locate code, trace a call path or list affected files.
tools: Read, Glob, Grep
model: haiku
---
Find what was asked and answer with file paths and one-line explanations.
Never edit files. Keep the answer under 40 lines.
.claude/agents/implementer.md
---
name: implementer
description: Implements one well-defined change in the files it is given. Use after the plan is agreed.
tools: Read, Edit, Write, Bash
model: sonnet
isolation: worktree
---
Make the smallest change that satisfies the task. Touch only the files named in the task.
Run the relevant tests before you finish. Report what changed and what you did not do.
.claude/agents/reviewer.md
---
name: reviewer
description: Independent reviewer of a diff. Use proactively after any implementation.
tools: Read, Glob, Grep, Bash
model: opus
---
Review the diff for correctness, security and missing tests. Use git diff to see it.
Report findings by severity with file and line. Do not edit files.

Step 3: give the orchestrating prompt

Add retry with backoff to the upload client.

1. Use the explorer subagent to list every file involved in uploads.
2. Propose a plan and wait for my OK.
3. Use the implementer subagent for the change, and test-writer for the tests.
   They must not edit the same file.
4. Finish with the reviewer subagent on the full diff and summarise its findings.

Do not commit, push or open a PR without my approval.

Step 4: keep agents from colliding

Two writers, one file Same file! One overwrites the other One owner each auth/ ui/ Separate files or separate worktrees
The cheapest conflict fix is not to create one: give every writer its own files or worktree.

7. Agent teams (Claude Code, experimental)

Agent teams go beyond subagents. One session is the lead. It spawns teammates, each a full Claude Code session with its own context. They share a task list and can message each other, and you can talk to any of them directly. The feature is experimental and disabled by default, with known limits around resuming sessions and shutdown.

Lead Shared task list ✓ map the auth module ● review token handling ○ add missing tests Found a snag in auth Which file is it? I'll write the tests reviewerandroidtests
In a team, teammates talk to each other and pick tasks from a shared list, not only report to the lead.

Turn it on

// settings.json
{
  "env": {
    "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1"
  }
}

You can also export the variable in your shell. Teams need an interactive session; with claude -p and in SDK sessions no teammates are spawned.

Once enabled, a subagent that Claude gives a name to may launch as a teammate even when you did not ask for a team. To go back to ordinary subagents, set the variable to 0.

What each value does

The variable is a plain on/off switch, not a number of teammates. Only a few words count as “on”; everything else, including bigger numbers, leaves teams off. This was checked against Claude Code 2.1.307, so re-test after big upgrades.

ValueEffectWhy
"1"OnRecognised as true. Teams can form when you ask for them, or when Claude names a subagent.
"0"OffRecognised as false. Named subagents launch as ordinary subagents again.
"5"OffNot a recognised true value. It does not mean five teammates.
"10"OffSame as "5": not recognised, so the feature stays off.
unset or emptyOffThe default.

Start a team with a prompt

There is no team configuration file. You describe the roles in plain language, and Claude creates the team, the task list and the teammates.

Create an agent team to investigate and improve this Android project.

Roles:
1. Lead developer: coordinate, inspect the architecture, integrate the findings.
2. Code reviewer: look for bugs, concurrency issues and architectural problems. Do not modify files.
3. Test engineer: find missing unit tests and implement tests for the agreed changes.
4. Android specialist: review Kotlin, coroutines, lifecycle handling and Android best practices.

First inspect the repository and make a plan. Give independent tasks to teammates and let
them work in parallel. Avoid having several agents edit the same files. Review their
findings, run the relevant tests and summarise the final changes.

Do not commit, push or open a PR without my approval.

Two more prompts that suit teams well:

Spawn three teammates to review PR #142: one for security, one for performance, one for test coverage.
Have them each review and report findings.
Users report the app exits after one message. Spawn 5 teammates to investigate different
hypotheses. Have them try to disprove each other's theories, then update the findings doc
with whatever consensus emerges.

The second one shows why teams exist: several investigators arguing beats one agent that stops at the first plausible cause.

Choose how teammates are displayed

ModeWhat you seeNeeds
in-process (default)All teammates inside your terminal. Select one in the agent panel with the arrow keys, press Enter to open it and message it.Nothing
autoSplit panes if you are already inside tmux or iTerm2 (with the it2 CLI), otherwise in-process.tmux or iTerm2
tmuxEach teammate in its own tmux or iTerm2 pane.tmux, or iTerm2 with it2 and its Python API enabled
iterm2Native iTerm2 split panes only.iTerm2, it2
// ~/.claude/settings.json
{
  "teammateMode": "auto"
}

# or for one session
claude --teammate-mode auto

Split panes do not work in VS Code’s integrated terminal, Windows Terminal or Ghostty. If panes do not appear, check which tmux, and kill leftovers with tmux ls and tmux kill-session -t <name>.

Control the team

Quality gates with hooks

HookRuns whenExit code 2 does
TeammateIdleA teammate is about to go idleSends feedback and keeps it working
TaskCreatedA task is being createdBlocks creation with feedback
TaskCompletedA task is being marked doneBlocks completion with feedback

For example, a TaskCompleted hook can run the unit tests and refuse to close a task while they fail.

How it behaves

Known limits (experimental)
  • /resume and /rewind do not restore in-process teammates; ask the lead to spawn new ones.
  • One team per session. No nested teams: only the lead manages the team. The lead cannot be handed over.
  • Task status can lag, which blocks dependent tasks. Nudge the teammate or update the task.
  • Shutdown can be slow because teammates finish their current call first.
  • Per-teammate permission modes cannot be set at spawn time.
Good first uses
  • Pull request review from several angles.
  • Debugging with competing hypotheses.
  • Research that explores options in parallel.
  • New modules where each teammate owns a separate set of files.

8. Codex: TOML agent files

Codex also splits work across parallel agents and gathers the results into one reply. It handles the delegation itself when you ask for it or when your AGENTS.md or a skill says so. There is no separate “team” mode; you describe how to split the work.

Ask for parallel work

Review this branch with parallel subagents. Spawn one subagent for security risks, one for
test gaps, and one for maintainability. Wait for all three, then summarize the findings
by category with file references.

A good prompt says how to split the work, whether to wait for all agents, and what to return. In the CLI, /subagents lets you inspect and switch between agent threads; in an IDE the background-agent panel shows status and can stop them all.

Built-in agents

AgentFor
defaultGeneral-purpose fallback.
workerExecution: implementation and fixes.
explorerRead-heavy exploration of the codebase.

A custom agent with one of these names takes precedence.

Custom agents: one TOML file each

Put personal agents in ~/.codex/agents/ and project agents in .codex/agents/. The name field is what counts; matching the file name is only a convention.

# .codex/agents/reviewer.toml
name = "reviewer"
description = "PR reviewer focused on correctness, security, and missing tests."
model_reasoning_effort = "medium"
developer_instructions = """
Review code like an owner.
Do not edit files.
Prioritize correctness, security, behavior regressions, and missing test coverage.
Lead with concrete findings and include reproduction steps when possible.
"""
FieldNotes
name, description, developer_instructionsRequired. The instructions play the role of the Markdown body in Claude Code.
model, model_reasoning_effort, model_reasoning_summary, model_verbosityOptional. Without them the agent inherits the parent’s model and effort.
features.*Switch features off for this agent (for example features.shell_tool = false).
skills.configEnable or disable individual skills for this agent.
Not overridablesandbox_mode, approval_policy, model_provider and mcp_servers follow the parent session.

Global limits in config.toml

# .codex/config.toml
[agents]
max_concurrent_threads_per_session = 8     # older name: max_threads
# enabled = true                          # turn multi-agent tools off with false
# default_subagent_model = "..."
# default_subagent_reasoning_effort = "medium"
Read this about safety
  • Codex subagents inherit the parent’s sandbox and approvals, including a changed /permissions or --yolo. A custom agent file cannot loosen or tighten them.
  • “Do not edit files” in the instructions is guidance, not a read-only sandbox.
  • In a non-interactive run, an action that needs new approval fails and the error returns to the parent.

Start with parallel read-heavy tasks. Parallel writes are riskier because of edit conflicts, and each subagent does its own model and tool work, so costs go up.

9. Claude Code and Codex side by side

Claude CodeCodex
Agent fileMarkdown with YAML headerTOML
Project folder.claude/agents/.codex/agents/
User folder~/.claude/agents/~/.codex/agents/
Prompt fieldMarkdown body (or prompt in JSON)developer_instructions
Per-session JSONclaude --agents '{...}'Not applicable: use files and prompts
Tool restrictiontools, disallowedTools, hooksfeatures.* switches; sandbox follows the parent
Own permission modepermissionMode (the parent can override)No, inherited
Built-insExplore, Plan, general-purposedefault, worker, explorer
Concurrency capCLAUDE_CODE_MAX_CONCURRENT_SUBAGENTSagents.max_concurrent_threads_per_session
Monitor/tasks, agent panel, split panes/subagents, IDE background-agent panel
Peer-to-peer teamsAgent teams (experimental)No separate mode; parallel subagents
Repo instructions fileCLAUDE.mdAGENTS.md

Both tools read a project instructions file, and every agent you start loads it. Put shared rules there (commands to build and test, style, “never commit without asking”) instead of repeating them in each agent. If you use both tools, many teams keep one source of truth and point the other file to it. The two series on this site cover those files in depth: start with the Claude Code and Codex series.

10. Pros and cons: parallel vs serial

Short answer: yes, parallel agents can make a job finish sooner, but only when the pieces are independent. Run dependent steps in parallel and it gets slower, costlier and messier than doing them one after another. Speed is not the only measure, so here is the full picture.

Serial longest wall-clock, cheapest, simplest Parallel, independent tasks merge about a third of the time, several times the tokens Parallel, dependent tasks conflicts, rework, re-running tests no faster than serial, and costs more
Illustrative, not measured. The gain comes from work that does not wait on other work; the merge step is the price.
Serial: wait for the baton ZzzZzzZzz workingwaiting…waiting…waiting… Time = step 1 + step 2 + step 3 + step 4, plus every hand-off Parallel: everyone runs at once task Atask Btask Ctask D finish Faster only because the four runs do not need each other
A relay is a dependent chain: runners wait. Side-by-side lanes are independent tasks.

Why parallel helps

Pros of running agents in parallel
  • Less waiting. Reading, searching and reviewing are mostly independent. Four reviewers finish in about the time of the slowest one.
  • Fresh, focused context. Each agent holds only its slice, so it is less likely to lose track than one agent juggling everything.
  • Independent opinions. A security lens and a performance lens catch different things. Competing hypotheses stop one agent from anchoring on the first theory.
  • Your main chat stays small. Noisy output (logs, search results) is summarised instead of filling your window.
  • Specialisation. A cheap, fast model can do the searching while a stronger one reviews.
Cons of running agents in parallel
  • More tokens and money. Each agent repeats setup work and does its own reading. Teams cost the most because every teammate is a full session.
  • Conflicts. Two agents editing the same file, or the same area through different files, produce overwrites or code that does not fit together.
  • A merge step you cannot skip. Someone (you or the lead) must reconcile the results, and that is where the saved time can disappear.
  • Hidden dependencies. Task B quietly needs the output of task A. Run together, B guesses, and its work is thrown away.
  • Less shared context. Each agent starts fresh and may repeat the same exploration or reach inconsistent decisions.
  • Harder to supervise. More output to read, more permission prompts, more places for a mistake to hide.
  • Limits. Rate limits, a cap on concurrent agents, and a slower machine when many run at once.

Why serial still has a place

Pros of serial work
  • Cheapest. One context, no repeated setup.
  • No collisions. One writer at a time, so no merge conflicts.
  • Each step builds on the last. The agent remembers what it just learned and what you corrected.
  • Easy to follow and steer. You can stop after step 2 and change direction.
Cons of serial work
  • Slowest wall-clock when the tasks could have run side by side.
  • One crowded context. A long chain fills the window and quality can drop; this is the problem subagents were made for.
  • One viewpoint. The same agent reviews its own work, with the same blind spots.

When one agent must wait for another

Many agents do not mean many things happening at once. If every step needs the output of the step before it, the agents take turns, and the total time is the sum of all steps, plus the cost of handing work over. Having five agents in that line is not faster than one; it is usually slower, because each hand-off adds setup, a fresh context and a summary to write and read.

A real example is the pipeline in Building Effective Agents in Practice. A Jira ticket, a plain spec or a Crashlytics crash goes through intake, an automatic prompt, the agent, checks, a draft pull request, a person’s review, merge and release, and finally monitoring. Each stage needs what the previous one produced, so for one ticket the stages run in a line.

One ticket: a chain, each stage waits for the last Intake Prompt Agent Checks Push+PR Review Merge, release Total time = sum of every stage. A person’s review is often the longest wait of all. Many tickets: the same chain, side by side Throughput rises (three tickets done together). Each single ticket is no faster.
Parallelism across independent items (tickets) helps. Parallelism inside one dependent chain does not.

Why it is slow: the critical path

The critical path is the longest chain of steps where each one needs the one before. It sets the minimum time for the whole job, no matter how many agents you add. If a task has 60 minutes that must run in order and 20 minutes that could run side by side, even a hundred agents cannot finish it in under 60 minutes. This is the idea behind Amdahl’s law: the part that must stay sequential limits the speed-up. Each extra agent on the sequential part only adds hand-off cost.

Everyday examples of one agent waiting for another

TaskChainWhy it cannot overlap
Add a field to an APIChange the data model, then the endpoint, then the callers, then the testsEach layer is written against the one below it. Starting early means guessing names and types.
Fix a crashReproduce, find the cause, fix, verifyYou cannot fix before you know the cause, or verify before there is a fix.
Database migrationWrite migration, run it, update the code, run the testsThe code depends on the new schema existing.
Plan, implement, reviewPlanner, implementer, reviewerThe reviewer needs the finished diff.
ReleaseBuild, test, sign, upload, roll outEvery step consumes the previous step’s artifact.
Anything with a human gateAgent opens a draft PR, a person reviews, then mergeNothing proceeds until the person answers. Waiting on people is usually the biggest delay.
What goes wrong when you force a chain into parallel
  • The tests agent writes tests for an API the implementer has not finished, and has to rewrite them.
  • The reviewer reviews code that changes under it.
  • Two agents invent different names for the same thing, and you spend the saved time reconciling.

What you can still do about a serial chain

Latency vs throughput. Latency is how long one item takes; throughput is how many items finish per hour. Parallel agents on independent items raise throughput. Only parallel agents on independent parts of one item reduce its latency. A serial chain of many agents improves neither.

A simple rule for choosing

Ask: does task B need anything produced by task A? If no, they can run in parallel. If yes, run them in order. Speed-up is limited by the part that must stay sequential, so adding more agents has diminishing returns.

SituationChooseWhy
Review a codebase from several anglesParallel, read-onlyIndependent, nothing to conflict, big time saving.
Search a large repo for different thingsParallel subagentsKeeps your context clean and finishes sooner.
Debug with several theoriesParallel (a team if they should challenge each other)Avoids anchoring on the first guess.
Separate modules with separate filesParallel in worktreesSafe if ownership is clear.
Change an API, then its callers, then testsSerialEach step depends on the previous result.
Edits to the same file or tightly coupled codeSerialParallel writers would collide.
Small task, a few minutes of workSingle agentSetup and merge cost more than the task.
Plan, implement, then reviewSerial pipeline with fresh reviewerSequential by nature, but the reviewer’s clean context is worth it.
The best of both

The usual winning pattern is parallel to read, serial to write: fan out read-only agents to explore and review, then let one agent (or several in separate worktrees) make the changes in order, and finish with an independent reviewer. You get most of the speed with few of the conflicts.

One honest caveat: the real gain depends on the task, the model and your setup, so measure on your own work. Time one task done serially and in parallel, count the tokens, and include the time you spend reading and merging the results.

11. Safety, cost and habits

Cost

Every agent does its own model and tool work, so tokens grow with the number of agents. Subagents are the cheaper option because only summaries come back; teams are the most expensive because every teammate is a full session. Use a cheaper model for search-type agents, set a cap on concurrency, and keep tasks well-defined so agents do not wander.

Agentopens a draft PR Human gate OK Youread the diff, run the tests merge
Let agents do the work, but keep a person at the gate before anything is committed, pushed or merged.

12. Common mistakes

13. Takeaways and glossary

TermIn plain words
AgentA model in a loop with tools that can read, run and edit.
SubagentA helper agent with its own context that returns a summary to its caller.
Agent teamA lead plus teammates: separate sessions that message each other and share tasks.
Context windowThe amount of text a model can hold in mind at once.
FrontmatterThe YAML block between --- lines at the top of a Markdown file.
HookA script that runs at a defined moment and can block an action.
WorktreeA second checkout of the same repository in another folder.
SandboxAn operating-system limit on what commands can touch.
MCPModel Context Protocol, a standard way to connect an agent to outside tools and data.
← Back to all writing