Skip to content

Claude Code guide in three levels, Beginner to Advanced: hands-on lessons with checked exercises, every volatile fact cited to its source. Independent community guide.

11.3 KB
Raw Blame

Choose an orchestration pattern

Advanced · Lesson 2 of 7 · about 20 minutes · Needs: Parallel sessions with worktrees · Verified against Claude Code v2.1.308 (stable) on 2026-10-25

Goal

By the end of this lesson you can choose between the main conversation, subagents, a dynamic workflow, /batch and an agent team by what a job needs and what it costs, and run a job as parallel subagents.

You need

  • Your repository from lesson 1, with at least three top-level folders that hold files, and your copy of the practice template with Node.js LTS: the check runs from the copy. Set up the repository's .practice/ folder as the Intermediate index describes, if you haven't yet.
  • macOS, Linux or WSL 2, and jq: the delegation log from Intermediate lesson 6 uses it.
  • Usage: moderate. Each subagent works in its own context window and sends its own requests, which count toward the same usage limits as your main conversation (Create custom subagents). For a lighter run, use two folders in the Worked example and two files in job 1.

The idea

Subagents, a dynamic workflow and an agent team all split a job across workers; what differs is who holds the plan (When to use a workflow). With subagents, Claude decides turn by turn, and each result comes back into your conversation. A dynamic workflow is a script Claude writes: it holds the loop and the intermediate results, so it can run many agents, cross-check their findings and rerun the same way. In an agent team, a lead supervises teammates who message each other directly (Choose an approach). The bundled /batch skill is subagents, packaged: it splits one large change into independent units and, once you approve its plan, runs each in its own worktree (Commands).

Every pattern past one conversation adds usage (Why usage climbs). So pick the cheapest pattern the job needs: ask these questions in order, and stop at the first answer that settles it.

A big job is not always a job to split. Keep it in the main conversation when its steps share a lot of context, such as planning, making the change and testing it (Choose between subagents and main conversation). And workers that only report back to you are not a team; a team is for workers who must share findings and challenge each other as they go (Compare with subagents).

flowchart TD
  accTitle: Who holds the plan
  accDescr: A path for choosing how to split a job. If one conversation can do it without filling up, keep it in the main conversation. Otherwise, if the workers must talk to each other, a lead holds the plan in an agent team, which is experimental. If they need not talk and the job needs cross-checked findings or a rerun, a script holds the plan in a dynamic workflow. If it is one large change that splits into independent units, /batch runs one subagent per unit in its own worktree. Otherwise Claude holds the plan and subagents return summaries.
  A["A job"] --> B{"Can one conversation do it without filling up?"}
  B -- yes --> M["Main conversation"]
  B -- no --> C{"Must the workers talk to each other?"}
  C -- yes --> T["Agent team: a lead holds the plan"]
  C -- no --> D{"Does it need cross-checked findings or a rerun?"}
  D -- yes --> W["Dynamic workflow: a script holds the plan"]
  D -- no --> E{"Is it one large change that splits into independent units?"}
  E -- yes --> X["/batch: one worktree per unit"]
  E -- no --> S["Subagents: Claude holds the plan"]

[!NOTE] "Agent teams are experimental and disabled by default." (Orchestrate teams of Claude Code sessions) This lesson names them as one option and doesn't run one; the Agent teams Elective does.

Worked example

  1. Pick three top-level folders in your repository, such as src, test and docs, and start claude. Keep auto mode, the mode it starts in, for this lesson.

  2. Ask the chart's questions about one job: a newcomer's summary of each folder. One conversation would fill with file reads it won't need again, so not the main conversation (Choose between subagents and main conversation). The summaries needn't talk to each other, so no team. Nothing needs cross-checking or a rerun, and nothing changes, so neither a workflow nor /batch: subagents.

  3. Ask for them, with your own folder names, as the docs' parallel research example does (Run parallel research):

    Research the src, test and docs folders in parallel using separate subagents, and give me two sentences on each.
    

    By default, an interactive session runs subagents in the background, so your prompt stays free (Run subagents in foreground or background).

  4. While they work, run /tasks. It lists each item running in the background and lets you check on, attach to, or stop it (Check on running work). Claude may start built-in Explore or general-purpose subagents, or forks of your conversation, so your rows will differ.

  5. When the summaries arrive, run /usage to see what that cost. On a Pro, Max, Team or Enterprise plan, it attributes your recent usage to skills, subagents, plugins and MCP servers, and recommends changes (Plan usage breakdown). The figures are estimates.

Your turn

Brief: pick the cheapest pattern for five backlog jobs, then run the one that needs parallel readers. Write your choices down, then run job 1.

  1. Before Friday's release, audit the three largest source files for errors that are caught and then dropped. You want suspects by file and line; nothing gets fixed yet.
  2. Add that audit to the release checklist for the whole codebase. The release manager has been burned by false alarms, so nothing goes on the list until it has been confirmed in the code.
  3. Rename a helper that about 40 files call, update every call site in one commit, and keep the build passing.
  4. A checkout test fails about one run in ten. There are three suspects: a race in a cache, an assertion that depends on the clock, and the order the tests run in. Have each suspect checked and bring back what each check found; you'll decide.
  5. Move every package under packages/ from the old logging library to the new one. Each package builds and tests on its own, and each package's change can land on its own.

Acceptance criteria:

  • .practice/a-2-choices.md has one line per job, <job number>: <pattern> because <reason>, and each pattern is main conversation, subagents, workflow, /batch or agent team.
  • Job 1 ran as parallel subagents, one per file, in a session you started with the delegation log from Intermediate lesson 6, claude --settings .practice/i-6-hook.json (CLI reference). If this repository doesn't have that file yet, save it as that lesson's Your turn shows.
  • Job 1 changed no file: the reviewers only report, and git status shows no change from them.
  • Only job 1 ran. The other four are choices.

Check

You are done when all of these are true:

  • .practice/a-2-choices.md picks the cheapest pattern that fits each job.
  • .practice/i-6-agents.txt shows at least two subagents other than Intermediate lesson 6's test-gaps starting: grep -vxc test-gaps .practice/i-6-agents.txt prints 2 or more.
  • Self-check (not tested): for one real job from your own backlog, you can name its pattern, the question that decided it, and why a cheaper pattern wouldn't do.

Run npm run check -- a-2 --dir <your repo> from your practice copy.

If a job's pattern is wrong, ask the chart's questions in order: the check's hint names the question that settles that job. If the log has fewer than two new lines, start the session with the hook file and ask for one subagent per file, in parallel.

Watch out

  • If Claude Code asks about a background subagent's tool call, the prompt appears in your main session, and an answer that lasts beyond that one tool call, such as a grant for the rest of the session, applies to the whole session, your main conversation included (Tools, permissions, and results of background subagents). Answer such a prompt for that one call only, and ask reviewers only to read.
  • Each subagent's result returns to your conversation, and each subagent spends tokens of its own while it runs, so many detailed results crowd your context and add to your usage. Ask for short results (Run parallel research).
  • If you've turned agent teams on, a subagent that Claude names launches as a teammate instead (Claude spawns teammates instead of subagents): turn teams off for this lesson.

Go further


Sources: Run agents in parallel · Orchestrate subagents at scale with dynamic workflows · Commands · Orchestrate teams of Claude Code sessions · Create custom subagents · Manage costs effectively · Choose a permission mode · CLI reference

← Parallel sessions with worktrees · Advanced index · Run and save a dynamic workflow → · Topic: Subagents and parallel work · Stuck on this lesson?