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
 宝玉@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
#### 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  宝玉 @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