来源:https://academy.claude.com/courses/ai-native-sdlc-playbook/parallel-sessions-and-subagents 读这篇之前:05 CLAUDE.md(课说所有会话都读它);08 反馈环有帮助 不确定:ZH 是 Clint 译官方英文课体,不是 Anthropic 中文。
本课词汇
| English | 中文 | 怎么记 |
|---|---|---|
| parallel session | 并行会话 | 另一份完整 Claude Code,自己的 Git worktree,互不知情 |
| subagent | 子代理 | 同一会话里的范围助手,自己的上下文和工具上限 |
| worktree | 工作树 | claude --worktree name:单独检出、单独分支,避免抢文件 |
| orchestrating | 编排 | 工程师的活变成指路和审查,不是自己打字 |
对照正文
两种并行 / Two kinds of parallelism
EN One engineer can drive several streams of work at once.
ZH 一个工程师可以同时开几路活。
EN A parallel session is another full Claude Code instance, working a separate task in its own Git worktree. Each independent session knows nothing about the others, and the engineer steering them is the only thing they share.
ZH 并行会话是另一份完整的 Claude Code,在自己的 Git worktree 里干另一件事。独立会话彼此不知情,它们唯一共享的是在掌舵的那位工程师。
EN A subagent runs inside a single session as a scoped helper with its own context window and tool limits and suits jobs that recur in multiple tasks, such as verifying the app runs as expected.
ZH Subagent 跑在单次会话里,是有范围的助手,自己有上下文窗口和工具上限,适合在多个任务里反复出现的活,比如确认应用按预期跑。
EN Parallel sessions raise the number of tasks an engineer can have in flight, while subagents keep each session focused on its own task. The engineer’s job is steering and reviewing all of them.
ZH 并行会话提高工程师同时在飞的任务数;subagent 让每个会话盯住自己的任务。工程师的活是给它们指路和审查。
什么变了 / What changes
EN
| Traditional | AI-native |
|---|---|
| One engineer works one task at a time and spends a significant portion of their day/week on builds, tests, and reviews. Switching between tasks while waiting is possible, but the context switch is tiring enough that few people choose to. | One engineer runs several Claude sessions at once, each in its own worktree on its own task. Repeated jobs become subagents with their own context and tool limits. The engineer’s job shifts to orchestrating and, eventually, to building and monitoring loops. |
ZH
| 传统 | AI-native |
|---|---|
| 一个工程师一次干一件,一天/一周很大一块花在构建、测试、审查上。等的时候切任务可以,但上下文切换累到没几个人愿意。 | 一个工程师同时开几个 Claude 会话,各自 worktree、各自任务。重复的活变成带自己上下文和工具上限的 subagent。工程师的活转向编排,最终是建环、盯环。 |
怎么起步 / Getting started
EN Prerequisites: The CLAUDE.md, since all sessions read the file. The feedback loop (Stage 4: Test) also helps here, because less supervision from the engineer is needed when a session can verify its own work.
Infrastructure: A Git repository, since isolation comes from worktrees, and permission settings tuned so sessions are not waiting on approval prompts for commands the organization considers safe.
ZH 先决条件:CLAUDE.md,因为所有会话都读它。反馈环(Stage 4: Test)也有帮助:会话能自己验收时,工程师少盯一点。
基础设施:Git 仓库(隔离靠 worktree);权限调到组织认为安全的命令不必等批准提示。
怎么做 / How to execute it
EN 1. The engineer splits the work into tasks that touch different files, using the plan from the plan mode play (Stage 3: Build) to see where the work is independent. Tasks that share files run in a single session, one after another.
2. Each parallel task gets its own worktree, for example claude --worktree feature-auth in one terminal and claude --worktree fix-rate-limit in another. A worktree is a separate checkout on its own branch, which stops sessions colliding on files.
3. Two or three sessions is a sensible starting point. The practical ceiling is how many streams one person can review properly, so add sessions only while review is keeping up.
4. Turn repeated jobs into subagents, as defined in Markdown files in .claude/agents/, each with a name, a description of when to use it, and the tools it may touch. Examples include a code simplifier that strips needless complexity after the main agent finishes, a verifier that runs the app and checks behavior, and a researcher that explores the codebase and reports back without flooding the main context. Check the definitions into Git so the whole team shares them.
ZH 1. 工程师按碰不同文件来拆任务,用 plan mode 打法(Stage 3: Build)的计划看哪里互相独立。共享文件的任务放同一会话里排队。
2. 每个并行任务自己的 worktree,例如一个终端 claude --worktree feature-auth,另一个 claude --worktree fix-rate-limit。Worktree 是单独分支上的单独检出,避免会话抢文件。
3. 两三个会话是合理起点。实际上限是一个人能审得过来多少路,审查跟得上再加。
4. 重复的活做成 subagent,定义在 .claude/agents/ 的 Markdown 里:名字、何时用、能碰哪些工具。例如主 agent 干完后去冗余的简化器、跑应用查行为的验证器、探代码库再汇报、不灌主上下文的研究员。定义提交进 Git,全队共用。
长什么样 / What it looks like
EN .claude/agents/verifier.md:
ZH .claude/agents/verifier.md:
---
name: verifier
description: Runs the app and checks the change works before the session reports done
tools: Bash, Read
---
Start the app with make run. Exercise the changed behavior and the two
nearest neighboring flows. Report what you ran, what you saw, and any
behavior that does not match plan.md. Do not fix anything; report only.
ZH 官方示例,保持英文。验证器:make run,练改过的行为和最近两条邻流,对照 plan.md 汇报。只报不修。
治理 / Governance considerations
EN More sessions means more output, so the controls have to come from configuration in the repo. Hooks and permission settings there apply to all sessions, and what a session does is logged and attributed to the engineer who ran it.
ZH 会话越多产出越多,控制必须来自仓库里的配置。那里的 hooks 和权限对所有会话生效;会话做了什么记下来,算在开它的工程师头上。
怎么衡量 / How to measure it
EN Leading indicator: Concurrent sessions per engineer while review quality holds, counted from the OpenTelemetry export, and the share of the day spent steering rather than waiting.
Lagging indicator: Changes merged per engineer per week read alongside the rework rate as determined per the PR history.
ZH 领先指标:审查质量还撑得住时,每位工程师的并发会话数(OpenTelemetry 导出),以及一天里花在掌舵而不是干等的比例。
滞后指标:每位工程师每周合并的改动,旁边对照 PR 历史算出的返工率。
读完能记住的三句话
EN A parallel session is another full Claude Code in its own worktree. A subagent is a scoped helper inside one session. ZH 并行会话是另一份完整 Claude Code,自己的 worktree。Subagent 是一次会话里的范围助手。
EN Start with two or three sessions. Add more only while you can still review them. ZH 从两三个会话起。还能审得过来再加。
EN Controls live in repo config so every session inherits them, and output is attributed to the engineer. ZH 控制写在仓库配置里,每个会话继承;产出算在工程师头上。