跳到主内容
@wquguru
精选82The Pragmatic Engineer(RSS)产品与增长

AI生成代码激增下的代码审查:7种应对策略与实操案例

What is happening with code reviews?

原文
发到 X
推荐理由

直接给出了AI时代代码审查的7种具体落地方案及Duckbill、Uber等公司的实测数据,开发者可立即参考调整团队流程。

One question haunting the minds of CTOs and heads of engineering whom I’ve been talking with, is how to deal with large quantities of code review which have only been growing now that AI agents generate most code at many tech companies.

一个困扰着我所交谈过的 CTO 和工程负责人的问题是,如何应对大量的代码审查。随着 AI 代理在许多科技公司生成大部分代码,这种情况只会越来越多。

Since the end of 2025, it has seemed that the era of devs writing code by hand is over at startups and in Big Tech. AI agents work faster and generate more pull requests (PRs) than devs ever did, and the size of those pull requests is also increasing.

自 2025 年底以来,初创公司和大型科技公司的开发者手工编写代码的时代似乎已经结束。AI 代理的工作速度更快,生成的拉取请求(PR)也比开发者以往更多,而且这些拉取请求的规模也在增加。

Today’s article summarizes some approaches to code review at various workplaces in this new paradigm, covering:

本文总结了在新范式下各种工作场所进行代码审查的一些方法,包括:

  • Humans review the AI code reviews. The most popular approach: AI code review tools go through code changes, and devs review the review itself.
  • Triage by “blast radius” & decide an approach. Low-risk changes don’t need human review, and high-risk ones do. Adopted by OpenAI, Anthropic, and others.
  • Review the plan/tests/database schema, but not implementation. Focus on reviewing the “before” and “after” states of an implementation, rather than the implementation itself.
  • Produce less code. Set up AI agents to produce smaller PRs that are easier to review and reason about.
  • Review everything by hand. Not everyone has adopted AI code review tools – even those that have sometimes still expect devs to read through all the new code, before allowing it to go to prod.
  • No human code review? There’s more talk about dropping human code reviews than there is evidence of this actually happening, so far. The most I could find was AI startups doing it and building additional layers for safer production rollouts.
  • Why do we review code, anyway? Before figuring out whether or not code review should stay, it’s worth going back to the fundamental technical, team, and organizational reasons for code reviews.
  • 人类审查 AI 的代码审查结果。这是最流行的方法:AI 代码审查工具会检查代码变更,然后由开发者审查审查结果本身。
  • 根据“影响范围”进行分类并决定处理方式。低风险变更不需要人工审查,而高风险变更则需要。OpenAI、Anthropic 等公司采用了这种方法。
  • 审查计划/测试/数据库模式,但不审查实现细节。重点在于审查实现的“之前”和“之后”状态,而不是实现本身。
  • 减少代码产出。设置 AI 代理以生成更小的 PR,使其更易于审查和推理。
  • 全部手动审查。并非所有人都采用了 AI 代码审查工具——即使采用了一些,有时仍期望开发人员在允许新代码上线生产环境之前阅读所有新代码。
  • 没有人工代码审查?目前关于取消人工代码审查的讨论多于实际发生的证据。我能找到的最多情况是 AI 初创公司在这样做,并为更安全的生产部署构建额外的层。
  • 我们为什么要审查代码呢?在确定是否应该保留代码审查之前,值得回到代码审查的基本技术、团队和组织原因上来。

Unsurprisingly, it’s clear there’s no one-size-fits-all solution to the question of how to handle a deluge of AI-generated code review. Please leave a comment below about how your team or company deals with this new, pressing issue!

毫不奇怪,很明显,对于如何处理海量 AI 生成的代码审查问题,并没有一种放之四海而皆准的解决方案。请在下方评论中分享你的团队或公司是如何应对这一新的紧迫问题的!

A snapshot of what’s going on in code review at this stage of AI development is provided by the graphic from GitHub, below. The background context it provides is pretty stark. It shows the stats for the number of PRs and commits over the course of three years on the popular platform:

下面来自 GitHub 的图表展示了当前 AI 发展阶段代码审查的情况。它提供的背景信息相当严峻。该图显示了该平台三年期间 PR 数量和提交数量的统计数据:

Change in number of PRs, commits, and new repos across three years. Source: GitHub

三年内 PR 数量、提交数量和新增仓库的变化。来源:GitHub

Over that time, the number of PRs opened has increased fivefold, which is a lot! And growth sped up from the end of 2025, when PRs and commits nearly doubled just in that period alone! So, how are teams dealing with this avalanche of extra work? To find out more, I asked around.

在此期间,提交的 PR 数量增长了五倍,这是一个很大的增幅!而且从 2025 年底开始,增长速度加快,仅在那段时间内,PR 和提交量就几乎翻了一番!那么,团队是如何应对这雪崩般增加的额外工作的呢?为了了解更多情况,我四处打听了一番。

1. Humans review the AI code reviews

1. 人工审查 AI 代码审查结果

The most common approach is to add an AI code review step to every pull request in a variety of ways:

最常见的方法是通过多种方式在每次拉取请求(PR)中添加一个 AI 代码审查步骤:

  • Use one or more vendors to review PRs. There are dozens of vendors offering this functionality – ones like CodeRabbit, Gitar, Greptile, GitHub Copilot Code Review, Qodo, Claude Code Review, Ellipsis and more. Many teams choose one or more, and the bots then review PRs, leaving comments for devs. For example, the Bun project by Anthropic has CodeRabbit, GitHub Code Review, and Claude Code Review all generating comments on PRs.
  • Multi-agent code review. Build a custom solution which triggers several models/agents to review the code and suggest fixes.
  • Agents update PRs with fixes. Vendors and home-grown solutions can instruct agents to update PRs with fixes and then re-trigger reviews – if you trust agents to make sensible fixes, that is!
  • 使用一个或多个供应商来审查 PR。目前有数十家供应商提供此类功能——例如 CodeRabbit、Gitar、Greptile、GitHub Copilot Code Review、Qodo、Claude Code Review、Ellipsis 等。许多团队会选择一家或多家供应商,然后由机器人审查 PR 并为开发人员留下评论。例如,Anthropic 的 Bun 项目同时使用了 CodeRabbit、GitHub Code Review 和 Claude Code Review,它们都会对 PR 生成评论。
  • 多代理代码审查。构建一个自定义解决方案,触发多个模型/代理来审查代码并提出修复建议。
  • 代理更新 PR 以应用修复。供应商和自研方案可以指示代理用修复内容更新 PR,然后重新触发审查——当然,前提是你信任代理能做出合理的修复!

Typical processes:

典型流程:

AI code reviews increasingly part of the development cycle

AI 代码审查日益成为开发周期的一部分

In the above cases, engineers typically review the review itself, and not usually the code. Here’s Etienne Dilocker, cofounder and CTO at AI database software, Weaviate, explaining why he likes their approach:

在上述情况下,工程师通常审查的是审查本身,而不是代码本身。以下是 AI 数据库软件 Weaviate 的联合创始人兼 CTO Etienne Dilocker 解释他为何喜欢他们的做法:

“It’s very hard for agents to get the balance [of the code review] right. If you ignore human code review entirely and leave it to agents, every PR will either suffer from scope creep or ship critical issues. But, of course, you can’t review everything by hand. So my current favorite setup is:

“让代理准确把握[代码审查的]平衡点非常困难。如果你完全忽略人工代码审查而将其交给代理,每个 PR 要么会遭遇范围蔓延,要么会发布关键问题。但当然,你无法手工审查所有内容。因此,我目前最喜欢的设置是:

1. an (adversarial) agent does a review

1. 一个(对抗性)代理进行审查

2. a human makes a scope decision

2. 人工确定范围决策

3. an agent implements the feedback

3. 一个代理实施反馈

4. either repeat or break the loop (likely a human decision)

4. 重复或终止循环(可能是人工决策)

So basically, 90% is left to agents, with humans in the loop for critical scope decisions and exit criteria.”

所以基本上,90% 的工作留给代理,人类仅在关键的范围决策和退出标准方面介入。”

Noise is a big problem with AI code reviews. WeTravel, a Series C travel tech company, decided to not use AI for code reviews because of the amount of noise it generated. In June, they did an updated evaluation which showed lots of improvement, but still not enough to justify adopting AI for the task.

噪音是 AI 代码审查中的一个大问题。C 轮融资的旅游科技公司 WeTravel 决定不将 AI 用于代码审查,因为其产生的噪音太多。今年六月,他们进行了更新的评估,显示有很大改进,但仍不足以证明在该任务中采用 AI 是合理的。

As things stand, custom tooling is probably needed to reduce code-review noise. Uber built a clever approach for this; an agentic pipeline called uReview:

就目前而言,可能需要定制化工具来减少代码审查中的噪音。Uber 为此构建了一种巧妙的方案;一个名为 uReview 的代理管道:

What uReview does:

uReview 的作用:

  • Bots generate lots of code review comments
  • Comments are graded, and low-confidence comments removed
  • Comments are merged, categorized, and unimportant ones removed
  • … in the end, the AI review results in important comments being shown to devs
  • 机器人生成大量代码审查评论
  • 对评论进行评分,并移除低置信度的评论
  • 合并评论、进行分类,并移除不重要的评论
  • ……最终,AI 审查的结果是向开发人员展示重要评论

2. Triage by “blast radius” & choose an approach

2. 按“爆炸半径”分类并选择方法

Another common approach is to decide whether to review code by hand or with AI, based on how “risky” a change is:

另一种常见的方法是根据变更的“风险”程度来决定是人工审查代码还是使用 AI:

  • Low-risk change: only AI, without human review. It can ship to production once AI agents are happy
  • High-risk change: mandatory human review
  • 低风险变更:仅使用 AI,无需人工审查。一旦 AI 代理满意,即可发布到生产环境
  • 高风险变更:强制人工审查

This is the approach that Anthropic and OpenAI follow, which I confirmed by talking with both companies. At Anthropic, Jarred Sumner told me that a human merges even low-risk changes, but that their goal is eventually to get another Claude instance to merge low-risk changes.

这是 Anthropic 和 OpenAI 所采用的方法,我通过与这两家公司交谈进行了确认。在 Anthropic,Jarred Sumner 告诉我,即使是低风险变更也需要人工合并,但他们的目标是最终让另一个 Claude 实例来合并低风险变更。

And it’s not just at leading AI labs: five-person startup, Duckbill Group, a cloud and AI cost management company, changed their process, as explained by cofounder and CEO Mike Julian:

这不仅仅发生在领先的 AI 实验室:五人初创公司 Duckbill Group(一家云和 AI 成本管理公司)改变了他们的流程,联合创始人兼 CEO Mike Julian 对此进行了解释:

“We ditched code review at Duckbill Group (mostly)

“我们在 Duckbill Group 弃用了代码审查(大部分情况下)

About a month ago, we found ourselves with 60 open PRs for a team of five. They had been accumulating for a few weeks and we all had the sudden realization we were looking at two days of just code review.

大约一个月前,我们发现一个五人团队有 60 个待处理的 PR。它们已经积累了几周,我们突然意识到我们面临着两天只做代码审查的情况。

I had been tossing around the idea for a while about having AI do all code review and so I just asked the team: what if we just didn’t review the PRs?

我一直有一个想法,让 AI 来做所有的代码审查,所以我只是问团队:如果我们根本不审查 PR 会怎样?

We decided to do a couple of things:

我们决定做几件事:

  • Switch to a risk-based system. With a risk-based system, we agreed that if your change touched the public API/MCP, auth, design system, non-additive database schema changes, or agent skills, it needed a human review. We then enforced that with a shell script to add a GitHub label.
  • Improve our guardrails (unit and end-to-end testing, post-deploy observability, stricter linting and type checking, etc). Improving guardrails was pretty easy, just expensive in tokens and attention. We enabled nearly every rule in ruff/prettier/eslint/ty, and we improved our unit test coverage to a floor of 85%.
  • 切换到基于风险的系统。在基于风险的系统中,我们同意如果你的变更触及公共 API/MCP、身份验证、设计系统、非增量数据库模式更改或代理技能,则需要人工审查。然后我们通过一个 shell 脚本来添加 GitHub 标签以强制执行这一规定。
  • 改进我们的护栏(单元测试和端到端测试、部署后可观测性、更严格的 linting 和类型检查等)。改进护栏相当容易,只是在 token 和注意力方面成本较高。我们启用了 ruff/prettier/eslint/ty 中的几乎所有规则,并将单元测试覆盖率提高到了 85% 的底线。

Results before vs after:

结果前后对比:

  • PRs merged: 353 → 684 (80/wk → 154/wk, +94%)
  • Merged within 1h: 28% → 45%; within 24h: 76% → 80%
  • Human-reviewed PRs median merge time: 26h
  • No human-review median merge time: 1h.”
  • 合并的 PR 数:353 → 684(每周 35 → 每周 154,+94%)
  • 1 小时内合并:28% → 45%;24 小时内合并:76% → 80%
  • 经人工审查的 PR 中位合并时间:26 小时
  • 未经人工审查的中位合并时间:1 小时。”

Here’s how I’d visualize this approach:

以下是我对这种方法的可视化:

Selecting a code review approach by “blast radius”

按“爆炸半径”选择代码审查方法

Some companies have built additional tooling to make it easier for devs to know which reviews to focus on. For example, Uber’s custom-built Code Review Inbox highlights high-impact changes, so devs know to spend more time and effort on them:

一些公司构建了额外的工具,以便开发人员更容易了解应重点关注哪些审查。例如,Uber 自定义构建的代码审查收件箱会突出显示高影响范围的变更,因此开发人员知道应在这些变更上投入更多时间和精力:

Evolving code review tooling to separate high-impact changes. Source: How Uber uses AI for development

演进代码审查工具以分离高影响范围的变更。来源:Uber 如何利用 AI 进行开发

3. Review the plan/tests/database schema, but not the implementation

3. 审查计划/测试/数据库模式,但不审查实现细节

Some devs and teams have stopped reviewing the code (the implementation), and instead review the “before” and “after” states:

部分开发人员和团队已停止审查代码(即实现细节),转而审查“之前”和“之后”的状态:

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件