前些天 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 不是不需要纪律,是需要不同的纪律。
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.
maybe this is controversial, but i believe what Cursor shipped here is a wrong solution to routing intelligence
more generally, any attempt to do model routing at request level, while may yield some small gains, is fundamentally flawed and doomed to fail
here's why -
the complexity of a task only reveals itself when you start working on it. this is the same reason why we humans are often wrong when asked to give cost estimates upfront
the correct solution is have a smart model (often a tech lead in human teams) do some planning and understanding, and hand over the implementation to another agent with appropriate level of intelligence and reasoning effort
when the task is delegated to a less intelligent model, the smarter model also needs to continuously monitor the execution and examine outcomes to ensure things are on the right track
this is a system that proved to work really well in firstmate and helped me save a lot of tokens. routing should work at the boundary between agents and subagents, not per each LLM request
Now in beta: Notion as code.
Define an entire workspace in TypeScript: teamspaces, databases, custom agents, all of it… then deploy it through the API.
Build workspaces with coding agents, version-control your setup in git, and reproduce the same setup anywhere you need it.