[KongchangAI]
· 2 min read· 1,227 words

Addy Osmani's Guide to Preventing AI Code Slop: A Verification-First Engineering Playbook

Addy Osmani's Guide to Preventing AI Code Slop: A Verification-First Engineering Playbook

Addy Osmani proposes a verification-first playbook that governs AI code slop with four disciplines.

Addy Osmani, a Google Chrome engineering lead, proposes a verification-first playbook against "AI code slop"—AI-generated code that passes smoke tests but hides pitfalls in edge conditions and maintainability. Its four principles: spec-first prompts, diff budgets, property tests, and human final merge verdicts. The conclusion: when generation is nearly free, engineering value shifts from writing code to verifying it.

AI coding assistants are changing the way software is developed, but the accompanying "AI code slop" has also become a headache for many engineers. Addy Osmani, an engineering lead on the Google Chrome team, has proposed a "verification-first" engineering playbook, whose core idea is: treat AI as a rapid drafting tool, while keeping the power of verification firmly in human hands.

Addy Osmani on AI code slop and the verification-first playbook

What Is "AI Code Slop"

What Addy Osmani calls AI code slop refers to code generated by AI that looks plausible but has not actually been sufficiently verified. It is often syntactically correct, stylistically consistent, and may even pass simple smoke tests, yet it hides pitfalls in edge conditions, performance characteristics, and long-term maintainability. The root of the problem is not that AI cannot write code, but that engineers tend to skip the verification step and merge code that "looks right" directly into the mainline.

Osmani's position is clear: AI is a drafting tool, not a decision-maker. The final merge decision must be made by humans, and that decision must be grounded in systematic verification.

Spec-First: Turning Prompts into Contracts

The first rule of the playbook is "spec-first prompts." Rather than giving the AI a vague description of requirements, write out the input/output contract, edge conditions, and failure modes first, then use that spec as the basis for the prompt.

The benefits are twofold. On one hand, the AI gets more precise context and produces code that is closer to a usable state; on the other hand, the spec itself becomes a checklist for subsequent verification. Once the code is generated, engineers can go through the spec item by item to confirm whether the behavior meets expectations, rather than judging by feel that it "looks about right."

The essence of spec-first is moving prompt engineering upstream into requirements engineering. The time spent writing the spec is not wasted—it translates directly into efficiency during the verification phase.

Diff Budgets: Controlling the Size of Each AI Submission

The second rule is "diff budgets." Osmani recommends limiting the amount of code change in each AI-assisted commit, to avoid merging large blocks of unreviewed generated code all at once. The larger the change, the more easily reviewers tire and the higher the probability of missing problems.

In practice, diff budgets can be implemented as a line-count cap or by splitting commits by feature. The key is to keep every AI-involved change small enough to be reviewed carefully. This is consistent with the classic lesson of code review: small batch submissions yield a noticeably higher defect discovery rate than large batch submissions.

For teams, diff budgets are also a cultural signal—it shows that AI-generated code does not get an exemption from review just because it was "generated quickly."

Property Tests: Constraining AI Behavior with Invariants

The third rule is "property tests." Traditional unit tests target specific inputs and outputs, whereas property tests focus on the invariants that code should satisfy: elements remain in the same order after sorting, serialization followed by deserialization should round-trip, concurrent operations should not break consistency, and so on.

Osmani advocates property testing because AI-generated code is most prone to problems on edge cases and exception paths, and property tests are particularly good at catching such defects. Engineers do not need to hand-write assertions for each case; they only need to clearly define the properties the code must always satisfy, and let the testing framework generate and explore the input space.

Property tests and spec-first form a closed loop: the spec defines the contract, and property tests verify that the contract still holds across a wide range of inputs. Combined, the verification coverage of AI code increases significantly.

Representative implementations of property-based testing include QuickCheck for Haskell, Hypothesis for Python, and jqwik for Java, among others. The core mechanism is that the testing framework automatically generates a large number of random inputs based on declared types and constraints, and when a test fails, automatically shrinks to the minimal counterexample, helping engineers quickly locate the problem. Compared with traditional example-based tests, the assertion in a property test is not "f(2) should equal 4" but "for any valid input, the result of f should satisfy a certain property." This paradigm is especially well suited to AI-generated code: AI can often write implementations that cover typical paths, but is prone to errors in scenarios such as empty inputs, extreme numeric values, and concurrency races—and randomized inputs happen to hit these areas with high frequency. Notably, the properties themselves still need to be designed by humans, which requires engineers to truly understand the business semantics and further confirms the premise in the playbook that "the judgment belongs to humans."

The Final Merge Verdict Belongs to Humans

The last and most critical rule of the playbook: owning the final merge verdict—humans hold the final say on merging. No matter how many automated checks AI-generated code passes, the merge decision must be made by an engineer, and the engineer must be accountable for that decision.

The significance of this principle is not just procedural gatekeeping. It establishes ownership of responsibility: AI bears no responsibility; the engineer using AI does. When engineers know they are accountable for the merge outcome, their review behavior becomes more careful, and their default trust in AI output drops to a reasonable level.

The Engineering Philosophy Behind This Playbook

Taken together, Osmani's verification-first playbook is actually answering a question: when the cost of generating code approaches zero, where does the center of engineering value shift? The answer is from "writing code" to "verifying code."

This is not a rejection of AI programming but a repositioning of the engineer's role. AI makes drafting faster, so verification becomes the new bottleneck—and the new core competency. Engineers who master spec writing, diff control, property testing, and merge judgment become more valuable in the AI era, because they determine what kind of code can enter the production environment.

For teams, this playbook can be directly translated into process standards: prompts must come with specs, AI commits have a change cap, critical modules require property tests, and merge approvals must name a human owner. None of these rules is complicated; the hard part is sticking to them.

AI code slop is not a technical problem; it is a process problem. The solution Osmani offers has no magic—only discipline.

One-line Summary

Addy Osmani proposes a verification-first playbook that governs AI code slop with four disciplines.

Paragraph Summary

Addy Osmani, an engineering lead on the Google Chrome team, proposes a verification-first engineering playbook to address "AI code slop." AI code slop refers to code that is AI-generated, syntactically correct, and able to pass smoke tests, yet hides pitfalls in edge conditions, performance, and maintainability; the root cause is engineers skipping verification and merging directly. The playbook contains four principles: spec-first prompts, which move requirements engineering upstream and serve as a verification checklist; diff budgets, which limit the size of each AI-assisted commit to ensure review quality; property tests, which constrain AI code behavior with invariants and are good at catching defects on edge and exception paths; and humans owning the final merge verdict, which establishes ownership of responsibility. Together they point to one conclusion: when generation costs approach zero, engineering value shifts from writing code to verifying code.

#AI code slop#Addy Osmani#verification-first#property-based testing#diff budgets#spec-first prompts#AI coding
Share:

Related articles