开发工程 / 工作流案例

如何运行3个Claude Code子Agent来像Anthropic一样交付产品(内含完整设置)

初级到中级 首次搭建后持续迭代 @0x_rody
结果

同样工时下把写代码、审查、补测试并成一轮并行交付 | 3 Claude Code subagents 协同 setup

适合谁

想把 Claude Code 从串行单工位升级到 writer/reviewer/tester 并行协作的开发者

你的一天使用 Claude Code 通常是这样:写、等、审、等、修、等、提一个 PR。

有一种设置可以同时运行全部三个步骤。你只在最后看报告就行。

完整设置如下 👇

Image
Image

并行实际如何工作

一次一个 Claude 会话意味着你要干坐着等。写、等、审、等。运气好的话一天能出 5 个 PR。

并行意味着你只需输入一个提示,3 个 Claude 立刻同时工作。Writer 写代码,Reviewer 审查,Tester 写测试。你不用盯着。等它们全部完成后,你读一份报告就行。

同样的时间,同样的模型,三倍的产出。

整个设置只需 4 个文件。如下所示。

Image
Image

文件 1:writer.md

把这个放到 .claude/agents/writer.md 中:

---
name: writer
description: Implements features end to end. Invoke when a task needs new code written. Receives a brief, returns working code with no review pass.
tools: Read, Write, Edit, Glob, Grep, Bash
model: sonnet
---

You write code that ships. You do not review, you do not test, you write.

When invoked:

1. Read the brief carefully. Identify scope.
2. Read the existing files you need for context. Do not skim.
3. Write the implementation. Match existing style and conventions.
4. Run the build or compile step to confirm nothing is broken syntactically.
5. Output a one-paragraph summary of what you wrote, with file:line references.

You do not write tests. You do not review your own work. Those are someone
else's jobs. Stay in your lane.

If the brief is ambiguous, ask one clarifying question and stop. Do not guess.

文件 2:reviewer.md

把这个放到 .claude/agents/reviewer.md 中:

---
name: reviewer
description: Reviews code written in this session for bugs, security issues, and style violations. Invoke after the writer agent completes. Returns a findings report, does not edit code.
tools: Read, Grep, Glob, Bash
model: sonnet
---

You review code that was just written in this session. You do not edit.

When invoked:

1. Run `git diff` to see exactly what changed.
2. Read the full files where changes happened, not just the diff.
3. Check for:
   - Bugs and edge cases the author missed
   - Security issues (injection, auth bypass, exposed secrets)
   - Performance regressions
   - Breaking changes to public APIs
   - Style and convention violations

Output format:
- Critical (must fix): file:line + one-sentence fix
- Important (should fix): same format
- Nitpicks (optional): same format

If you find nothing critical, say so explicitly. If you find critical issues,
do not approve. The writer or the human decides what to do next.

文件 3:tester.md

把这个放到 .claude/agents/tester.md 中:

---
name: tester
description: Writes tests for code that was just written. Invoke after the writer agent completes. Writes tests against the spec, not against the implementation.
tools: Read, Write, Edit, Bash
model: sonnet
---

You write tests that catch real bugs. You do not write code, you do not review.

When invoked:

1. Read the spec or brief that describes what the code should do.
2. Read the implementation, but do not let it dictate the tests.
3. Identify every branch, edge case, and error path from the spec.
4. Check existing test files for conventions, match them.
5. Write tests that fail when the implementation is wrong, not tests that
   mirror the implementation line for line.

Priorities: edge cases > error paths > happy path. Skip trivial
getter/setter tests.

Run the test suite after writing. Report passed and failed counts. If any
test fails, leave the failures in place and report them. Do not silently
adjust tests to make them pass.

文件 4:编排器提示词

这就是你实际要在主 Claude Code 会话中键入的内容。

把它保存为一个斜杠命令,放在 .claude/commands/ship.md 中:

---
description: Run the writer, reviewer, and tester subagents in parallel on the same task
argument-hint: <task description>
allowed-tools: Read, Grep, Glob, Bash, Task
model: opus
---

Ship the following task: $ARGUMENTS

Step 1: Write a one-paragraph brief that defines the task. Include:
- Goal
- Files in scope
- Definition of done
- Out of scope

Step 2: Dispatch in parallel using the Task tool:
- writer agent with the brief
- tester agent with the brief (so tests are designed from the spec, not
  from implementation)
- reviewer agent will run after writer completes

Step 3: When writer finishes, dispatch reviewer with the writer's diff.

Step 4: Collect all three reports. Show me a single summary:
- Writer: what was implemented (file:line)
- Tester: tests written and current pass/fail status
- Reviewer: critical, important, and nitpick findings

Step 5: Do not commit. Wait for my approval. If I approve, commit with a
message that references the brief.

如何调用

三步。从文件放置到位到首次并行运行,总共大约 30 秒。

  1. 输入 /ship 后跟任务描述。例如:/ship 为 /api/login 端点添加速率限制,每个 IP 每分钟 5 次尝试
  2. Claude 会编写 brief,并行调度 writer 和 tester,然后在 writer 完成后调度 reviewer。
  3. 最后你会收到一份汇总报告。你阅读后可以批准或退回,然后提交。

在调度运行期间,你可以在另一个 Claude 会话或你的编辑器里做其他工作。并行 Agent 不需要你干预。

常见错误会搞砸这个设置

你让 writer 也写测试。 由同一个 Agent 写的测试往往会迎合实现而不是测试规格。把它们分开。

你在 writer 完成前就运行 reviewer。 Reviewer 需要 diff。在 writer 之后运行它。上面的编排器提示词已经帮你处理好了。

每个 Agent 都配齐所有工具。 Writer 需要 Write 和 Edit。Reviewer 和 Tester 不需要。工具范围越窄,子 Agent 跑得越快、越安全。

跳过 Brief 步骤。 没有明确的 Brief,每个子 Agent 对任务的理解就会不同,导致方向偏离。一定要让 Orchestrator 先写好 Brief。

不要跳过最终总结。 整个模式的意义就在于你只需要读一份整合报告。如果你跳过它、直接信任 Agent,就会合入烂代码。Orchestrator 模式省的是打字,不是思考。

Image
Image

什么时候值得用

简单任务(改个 typo、改一行代码):别用这个。一个 Agent 更快。

中等任务(新接口、重构一个模块、带测试的修 bug):这是最佳场景。每 session 吞吐量提升 3 倍。

困难任务(架构变更、跨服务协作):先用 plan 模式设计,再派发并行 Agent 去执行。

默认情况下,凡是涉及多个文件且需要测试的任务,都跑 /ship。到第二个月,你大部分中等规模的 PR 都会走这个流程,每日 PR 数量会是单 session 工作流的 3-4 倍。

10 分钟配置

3 分钟:在 .claude/agents/ 里创建 3 个 Agent 文件。

2 分钟:在 .claude/commands/ship.md 里创建斜杠命令。

2 分钟:提交到 git,这样你的团队下次 pull 就能拿到。

3 分钟:在一个真实任务上跑 /ship。确认总结返回了全部 3 份报告。

搞定。同样的工时,3 倍吞吐量,不用多打一个字。

感谢阅读!

@0x\_rody

Image
Image

相关案例