← 回總覽

鲍勃大叔:我不看 AI 写的代码,而是用测试和指标约束 Agent

📅 2026-07-24 09:12 宝玉 软件编程 4 分鐘 4528 字 評分: 85
AI编程 代码审查 测试驱动开发 鲍勃大叔 AI Agent
📌 一句话摘要 鲍勃大叔分享了他不阅读 AI 生成代码而是通过大量测试和代码质量指标确保代码质量的新实践,宝玉总结代码审查正从读代码转向设约束定指标。 📝 详细摘要 前《Clean Code》作者鲍勃大叔(Robert Martin)坦言他不看 AI Agent 写的代码,以免拖慢效率。他的策略是用单元测试、Gherkin 测试、变异测试、覆盖率等建立层层约束,并打造四个 Agent 的分阶段流水线(需求、编码、重构、架构审查),通过指标而非直接读代码评估质量。宝玉原创点评指出,AI 时代代码审查的核心能力正在从读代码/写代码转向写测试、定约束、设指标,高质量的测试覆盖变得比代码本身更有价
Skip to main contentAudio 2 ![Image 1: LogoBest Blogs](https://www.bestblogs.dev/ "BestBlogs.dev")

Search Ctrl+K

Change language Switch ThemeSign In

Curated Daily BriefWeekly PicksTopics SettingsHelp CenterCollapse

Narrow Mode

Uncle Bob: I Don't Read AI-Generated Code; Instead, I Constrain Agents with Tests and Metrics

Uncle Bob: I Don't Read AI-Generated Code; Instead, I Constrain Agents with Tests and Metrics

![Image 2: 宝玉](https://www.bestblogs.dev/en/tweets?sourceId=SOURCE_2c263f) 宝玉

@dotey

前些天 X 上还一堆人讨论要不要看 AI 生成的代码,现在《Clean Code》作者鲍勃大叔都说:“我不看 AI 写的代码”

他的原话是,这是他能利用 AI 生产力的唯一方式。人类读代码太慢了,如果还逐行审查,就丧失了用 AI 的意义。

但不看不等于不管。他的做法是给 AI Agent 设置层层关卡:单元测试、Gherkin 测试(一种用接近自然语言描述软件行为的测试格式)、QA 流程、代码质量指标、变异测试(故意往代码里塞小错误,看测试能不能抓住)、测试覆盖率,等等。

他在今年早些时候还公开了自己的具体实践:一套四个 Agent 组成的流水线,分别负责需求规格化、编码、重构和架构审查,每个阶段都比上一个阶段更形式化,需要的人工干预也更少。他同时还会看测试覆盖率、依赖结构、圈复杂度、模块大小这些指标,从指标推断代码质量,而不是从代码本身。

【注:圈复杂度(Cyclomatic Complexity)衡量代码中独立执行路径的数量,数字越大说明逻辑越复杂,越难维护和测试。】

当 AI 生成代码的速度远超人类阅读代码的速度,代码审查的形态也在跟着改变。以前的核心能力是读代码、写代码,现在可能正在变成写测试、定约束、设指标。鲍勃大叔过去几十年一直在推测试驱动开发(TDD),现在 AI 时代高质量的测试覆盖反而比代码更有价值。

他今年在 O'Reilly 上开了一门课,叫《AI Agents for Clean Code》,也在自己的 Clean Coders 平台推出了新系列《Clean AI: Agentic Discipline》。主旨一样:AI Agent 不是不需要纪律,是需要不同的纪律。Show More

!Image 3: Uncle Bob Martin

#### Uncle Bob Martin

@unclebobmartin · 18h ago

I’m significantly older than you. I started coding in the late 60s. My current strategy is to not read any of the code written by my agents. That’s the only way I can take advantage of their productivity. What I do instead is to surround the agents with extreme constraints. Unit tests, gherkin tests, QA procedures, quality metrics, mutation testing, test coverage, and a plethora of others. In the end, I have very high confidence in the code they produce because they’ve had to run the gauntlet of all of my constraints and tests.Show More

302

886

9,704

1.8M

Jul 24, 2026, 1:12 AM View on X

55 Replies

113 Retweets

747 Likes

84.2K Views ![Image 4: 宝玉](https://www.bestblogs.dev/en/tweets?sourceid=2c263f) 宝玉 @dotey

Follow

One Sentence Summary

Uncle Bob shares his new practice of not reading AI-generated code but ensuring code quality through extensive testing and quality metrics; Baoyu summarizes that code review is shifting from reading code to setting constraints and defining metrics.

Summary

Former Clean Code author Uncle Bob (Robert Martin) openly admits he does not read the code written by AI agents to avoid slowing down efficiency. His strategy is to establish layers of constraints using unit tests, Gherkin tests, mutation testing, test coverage, and more, and to build a four-agent staged pipeline (requirements, coding, refactoring, architecture review), evaluating quality through metrics rather than directly reading the code. Baoyu's original insight points out that in the AI era, the core competency of code review is shifting from reading/writing code to writing tests, setting constraints, and defining metrics, making high-quality test coverage more valuable than the code itself.

AI Screening

88

Influence Score 229

Published Today

Language

Chinese

Tags

AI Programming

Code Review

Test-Driven Development

Uncle Bob

AI Agent

Make your daily reading actually fit you.A daily brief built from the sources you follow. Get started free HomeDiscoverSettings

查看原文 → 發佈: 2026-07-24 09:12:08 收錄: 2026-07-24 10:00:45

🤖 問 AI

針對這篇文章提問,AI 會根據文章內容回答。按 Ctrl+Enter 送出。