# Code review 流水线：一次改动从作者机器走到用户手里

> 这篇按 Claude Code 团队的文章，把一次改动从作者机器走到用户手里要过的九道关画成一张流水线图，其中只有按风险审批这一步由人决定。

Author: Shumin Fu  
Published: 2026-11-09  
Updated: 2026-11-10  
Tags: code-review, ai-agents, claude-code, agent-future  
Canonical: https://funfun.zone/posts/code-review-pipeline-life-of-a-change/

<div class="html-embed not-prose" lang="zh-CN">
<div class="crp">
  <p class="sub">这篇按 Claude Code 团队的文章《How the Claude Code team does code review》整理，主干来自原文的配图「The life of a change」。</p>
  <h2>Code review 干两件事，每个 PR 问三个问题</h2>
  <figure>
    <span class="figno">图 1　评审的两项工作和三个问题</span>
    <div class="struct">
      <div class="outer">
        <div class="h">Code review 的两项工作</div>
        <div class="s">两项工作同时进行。</div>
        <div class="stack">
          <div class="node b"><span class="t">找出问题并修掉</span><span class="d">改动上线之前，把问题找出来修好</span></div>
          <div class="node b"><span class="t">形成共享的上下文</span><span class="d">让团队对代码库有共同的理解</span></div>
        </div>
      </div>
      <div class="outer">
        <div class="h">Claude review 对每个 PR 问的三个问题</div>
        <div class="s">每个 PR 上的 Claude review 读 diff 时都问这三个问题。</div>
        <div class="stack">
          <div class="node"><span class="t">解决问题了吗？</span><span class="d">这次改动解决了它要解决的问题吗</span></div>
          <div class="node"><span class="t">合得来吗？</span><span class="d">这次改动和现有系统合得来吗</span></div>
          <div class="node"><span class="t">会弄坏别处吗？</span><span class="d">这次改动会不会弄坏别的地方</span></div>
        </div>
      </div>
    </div>
  </figure>
  <blockquote>
    <p class="en">“did a human read the code?” is an imprecise proxy for “what could go wrong with this change, and which check—automated or human—is the right one to catch it?”</p>
    <p class="zh">换句话说，「有没有人读过代码」只是一个不够精确的替代指标。真正该问的是这次改动可能出什么问题，以及哪一道检查（自动的或人工的）最适合把它拦下来。</p>
    <cite>— How the Claude Code team does code review</cite>
  </blockquote>
  <h2>一次改动的一生</h2>
  <p class="lede">九个阶段里，大部分由机器自动完成；只有按风险审批这一步由人来决定。</p>
  <figure>
    <span class="figno">图 2　一次改动从开 PR 前走到上线之后</span>
    <div class="lane"><div class="lane-h"><b>PR 前</b>Before the PR</div><div class="cells">
      <div class="node b"><span class="t"><span class="no">01</span>工作先自验</span><span class="d">跑测试和 linter，再换个 agent 审 diff</span></div>
    </div></div>
    <div class="link"><div class="arr"><svg viewBox="0 0 30 10" aria-hidden="true"><path d="M1 5H27" stroke="currentColor" stroke-width="1.6" fill="none"/><path d="M23 1.5L28 5L23 8.5" stroke="currentColor" stroke-width="1.6" fill="none" stroke-linejoin="round" stroke-linecap="round"/></svg><span class="al">开 PR</span></div></div>
    <div class="lane"><div class="lane-h"><b>每个 PR</b>On every PR</div><div class="cells">
      <div class="node b"><span class="t"><span class="no">02</span>必过 CI</span><span class="d">lint、类型、多平台测试、构建打包</span></div>
      <div class="arr"><span class="al">全绿</span><svg viewBox="0 0 30 10" aria-hidden="true"><path d="M1 5H27" stroke="currentColor" stroke-width="1.6" fill="none"/><path d="M23 1.5L28 5L23 8.5" stroke="currentColor" stroke-width="1.6" fill="none" stroke-linejoin="round" stroke-linecap="round"/></svg></div>
      <div class="node b"><span class="t"><span class="no">03</span>Claude review</span><span class="d">多个 agent 找 bug，投票后排序</span></div>
      <div class="arr"><span class="al"></span><svg viewBox="0 0 30 10" aria-hidden="true"><path d="M1 5H27" stroke="currentColor" stroke-width="1.6" fill="none"/><path d="M23 1.5L28 5L23 8.5" stroke="currentColor" stroke-width="1.6" fill="none" stroke-linejoin="round" stroke-linecap="round"/></svg></div>
      <div class="node b"><span class="t"><span class="no">04</span>安全审查</span><span class="d">单独一轮，发现没关闭就不能合</span></div>
      <div class="arr"><span class="al">发现关闭</span><svg viewBox="0 0 30 10" aria-hidden="true"><path d="M1 5H27" stroke="currentColor" stroke-width="1.6" fill="none"/><path d="M23 1.5L28 5L23 8.5" stroke="currentColor" stroke-width="1.6" fill="none" stroke-linejoin="round" stroke-linecap="round"/></svg></div>
      <div class="node y"><span class="t"><span class="no">05</span>按风险审批</span><span class="d">分类器定档，0、1 或 2 人批准</span></div>
    </div></div>
    <div class="link"><div class="arr fy"><svg viewBox="0 0 30 10" aria-hidden="true"><path d="M1 5H27" stroke="currentColor" stroke-width="1.6" fill="none"/><path d="M23 1.5L28 5L23 8.5" stroke="currentColor" stroke-width="1.6" fill="none" stroke-linejoin="round" stroke-linecap="round"/></svg><span class="al">批准够数</span></div></div>
    <div class="lane"><div class="lane-h"><b>合并</b>Merging</div><div class="cells">
      <div class="node b"><span class="t"><span class="no">06</span>Merge queue</span><span class="d">套到最新 main 上，检查全部重跑</span></div>
    </div></div>
    <div class="link"><div class="arr"><svg viewBox="0 0 30 10" aria-hidden="true"><path d="M1 5H27" stroke="currentColor" stroke-width="1.6" fill="none"/><path d="M23 1.5L28 5L23 8.5" stroke="currentColor" stroke-width="1.6" fill="none" stroke-linejoin="round" stroke-linecap="round"/></svg><span class="al">合入 main</span></div></div>
    <div class="lane"><div class="lane-h"><b>合并之后</b>After the merge</div><div class="cells">
      <div class="node g"><span class="t"><span class="no">07</span>内部先用</span><span class="d">藏在 flag 后，Anthropic 员工先用</span></div>
      <div class="arr fg"><span class="al"></span><svg viewBox="0 0 30 10" aria-hidden="true"><path d="M1 5H27" stroke="currentColor" stroke-width="1.6" fill="none"/><path d="M23 1.5L28 5L23 8.5" stroke="currentColor" stroke-width="1.6" fill="none" stroke-linejoin="round" stroke-linecap="round"/></svg></div>
      <div class="node g"><span class="t"><span class="no">08</span>渐进发布</span><span class="d">先发 latest，stable 随后跟上</span></div>
      <div class="arr fg"><span class="al"></span><svg viewBox="0 0 30 10" aria-hidden="true"><path d="M1 5H27" stroke="currentColor" stroke-width="1.6" fill="none"/><path d="M23 1.5L28 5L23 8.5" stroke="currentColor" stroke-width="1.6" fill="none" stroke-linejoin="round" stroke-linecap="round"/></svg></div>
      <div class="node g"><span class="t"><span class="no">09</span>盯着线上</span><span class="d">作者和 on-call 一起盯</span></div>
    </div>
    <div class="lane-note"><svg width="14" height="14" viewBox="0 0 24 24" aria-hidden="true"><path d="M4.5 12a7.5 7.5 0 1 0 2.2-5.3" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M5.8 3.6v3.6h3.6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>出了问题时，flag 很快关掉，坏掉的构建会被 revert。</div></div>
    <div class="legend">
      <span><i class="lb"></i>自动检查</span>
      <span><i class="ly"></i>由人决定，力度随风险变化</span>
      <span><i class="lg"></i>发布与补救</span>
      <span><i class="ld"></i>阶段分组</span>
    </div>
  </figure>
  <h3>按风险审批：唯一由人决定的一步</h3>
  <p>一个分类器读完改动以后定下风险档，风险档再决定需要几个人批准。风险档由改动本身决定，跟作者是谁无关；而且 agent 的批准从来不能顶替人的批准。</p>
  <figure>
    <span class="figno">图 3　第 5 步的三档审批</span>
    <div class="node b clf"><span class="t">分类器读完改动，定下风险档</span><span class="d">只看改动本身，不看作者是谁</span></div>
    <div class="fan" aria-hidden="true"><span><i></i><b></b></span><span><i></i><b></b></span><span><i></i><b></b></span></div>
    <div class="tiers">
      <div class="tier t0"><div class="n"><b>0</b><small>人批准</small><span class="pill">低风险</span></div><div class="what"><span>走这一档的改动</span>文档、文案、flag 后面的增量改动</div></div>
      <div class="tier t1"><div class="n"><b>1</b><small>人批准</small><span class="pill">中风险</span></div><div class="what"><span>走这一档的改动</span>普通产品改动和敏感区域</div></div>
      <div class="tier t2"><div class="n"><b>2</b><small>人批准</small><span class="pill">高风险</span></div><div class="what"><span>走这一档的改动</span>风险最高的代码和少数指定路径</div></div>
    </div>
    <div class="always">
      <div class="node g"><span class="t">不管落在哪一档，都必须有人批</span><span class="d">负责人列为敏感的代码、所有 CI workflow 文件</span></div>
      <div class="node g"><span class="t">agent 的批准不能顶替人的批准</span><span class="d">需要人批的地方，agent 批了不算数</span></div>
    </div>
  </figure>
  <h2>九个阶段逐个看</h2>
  <ol class="stages">
    <li><span class="k kb"><i></i>01</span><div><b>工作先自验</b><span class="ph">PR 前</span><p>Claude 先跑测试、构建和 linter；接着由另一个 agent 在全新的上下文里把 diff 审一遍。</p></div></li>
    <li><span class="k kb"><i></i>02</span><div><b>必过 CI</b><span class="ph">每个 PR</span><p>CI 会跑 lint、类型检查、多平台测试、构建和打包。只要有一项变红，这个 PR 就不能合并。</p></div></li>
    <li><span class="k kb"><i></i>03</span><div><b>Claude code review</b><span class="ph">每个 PR</span><p>几个 agent 同时找 bug，然后一组验证 agent 对每条发现投票，留下来的发现按严重程度排序。</p></div></li>
    <li><span class="k kb"><i></i>04</span><div><b>安全审查</b><span class="ph">每个 PR</span><p>安全审查是单独跑的一轮。bug review 和安全审查里只要还有没关闭的发现，PR 就不能合并。</p></div></li>
    <li><span class="k ky"><i></i>05</span><div><b>按风险审批</b><span class="ph">每个 PR</span><p>分类器定下风险档，风险档决定要 0、1 还是 2 个人批准，细节见上面的图 3。</p></div></li>
    <li><span class="k kb"><i></i>06</span><div><b>Merge queue</b><span class="ph">合并</span><p>merge queue 把改动套到最新的 main 上，再把所有检查跑一遍，因此两个各自通过的 PR 不会合起来弄坏 main。</p></div></li>
    <li><span class="k kg"><i></i>07</span><div><b>藏在 feature flag 后面，内部先用</b><span class="ph">合并之后</span><p>新行为先由 Anthropic 员工用起来，然后才推给所有用户。</p></div></li>
    <li><span class="k kg"><i></i>08</span><div><b>渐进发布</b><span class="ph">合并之后</span><p>公开版本先发到 latest 渠道，stable 渠道随后才跟上。</p></div></li>
    <li><span class="k kg"><i></i>09</span><div><b>盯着，往前修或者回滚</b><span class="ph">合并之后</span><p>作者和 on-call 一起盯着线上；出了问题时 flag 能很快关掉，坏掉的构建也会被 revert。</p></div></li>
  </ol>
  <div class="src">
    <p>来源：Addy Osmani、Morgan Westlee Lunt、Qing Wang，<a href="https://claude.dev/blog/solving-code-review-at-anthropic/">How the Claude Code team does code review</a>，claude.dev Blog，2026 年 10 月 15 日。</p>
    <p>阶段顺序按原文配图「The life of a change」排列；原文正文分层介绍时，把 CI 放在了 AI review 和安全审查之后。</p>
  </div>
</div>
</div>
