How one team merged nearly 11,000 mostly agent-written pull requests in a month with a revert rate under half a percent: a trust pyramid, a codebase agents copy safely, lint rules instead of rules files, almost no comments, layered verification, and why you should not automate a bad loop.
Reading map
- Part I — The trust problem: why agent output overwhelms review, and the low-trust and high-trust loops (sections 1 and 2).
- Part II — The trust pyramid: five layers and why cost rises toward the bottom (section 3).
- Part III — The codebase and static analysis: code as the agent’s input, a framework with built-in rules, three hard lessons, and turning corrections into checks (sections 4 to 8).
- Part IV — Verification: runtime verification, formal methods and property-based testing (sections 9 to 11).
- Part V — Results and the outer loop: what the investment returned, and when to automate (sections 12 to 14).
- A comparison table, a final perspective, a quick reference and a FAQ close the guide.
Why This Matters
Coding agents changed the economics of writing code. One engineer on the Grok Bot team went from 68 merged pull requests in March to 3,127 in October: 10,732 in eight months, many of them merged overnight. The whole team merged 10,926 pull requests in October alone.
At that volume, careful human review of every line is impossible. Most teams respond in one of two ways: they slow the agents down to the speed of review, or they stop looking and hope. Both fail. The first wastes the agents; the second fills the codebase with what the industry now calls slop: plausible-looking code that is subtly wrong, duplicated or fragile.
The Grok Bot team took a third path. Over about six months they invested in the environment around their agents until most changes could be trusted by default. The revert rate stayed under half a percent, and their desktop app got faster rather than slower. The approach does not depend on their product or their models; it is a way of organizing a codebase, and it transfers.
Trust in agents is not a feeling. It is something you build into the code.

Part I — The Trust Problem
1. Quality and quantity at once
The goal is not more code. Anyone can generate more code. The goal is to keep, or even raise, code quality while output rises dramatically. The team frames the whole problem as trust: not blind trust in a model, but confidence earned by an environment that makes agents do the right thing and proves when they did.
Some people call the end state a “software factory”, a system that writes, ships and deploys code with little human input. The team prefers a simpler framing: how much can you trust your agents, and what would it take to trust them more?
2. The low-trust loop and the high-trust loop
Most teams are stuck in a low-trust loop: the agent writes code of uneven quality, a human verifies it, issues are found, and the cycle repeats. The human is the quality gate, and the human does not scale.
The high-trust loop looks almost the same, with two differences: the agent writes good code, and the agent verifies it too. The human moves from reading code to looking at evidence. Getting from the first loop to the second is the entire project, and the question is where to spend your time to make that move.

Part II — The Trust Pyramid
3. Five layers, cost rising downward
The team’s answer is an upside-down pyramid. The wide top is where most of the investment goes; the narrow bottom is where the least should be needed.
| Layer | What it includes | Nature |
|---|---|---|
| Codebase | Good API design, architecture, refactoring | Deterministic |
| Static analysis | Lints, types, compilers, tests, CI | Deterministic |
| Verification | Runtime and formal verification | Evidence |
| Prose | Rules files, skills, AGENTS.md | Judgment |
| Human review | People reading changes | Judgment |
The top two layers are deterministic: they live in the code and force agents to do the right thing by default, every time. Verification catches errors and checks that the agent understood the intent. Prose is reserved for what genuinely needs judgment. The further down a fix lives, the more expensive and less reliable it is: a rule in a markdown file can be ignored, misread or overfitted; a lint error cannot.

Part III — The Codebase and Static Analysis
4. Your codebase is the agent’s biggest input
Agents generate output from their inputs, and the codebase is one of the largest inputs they have. Every pattern in it is an example the next agent may copy. So when you correct an agent, the instinct to add another line to the rules file is usually the wrong move. Turn the correction into a deterministic check in the code instead. A check repeats on every change, can be reproduced and can be trusted; a sentence in a document cannot.
The team’s image for this is a garden. In 2024 an engineer might review about three pull requests from colleagues at a time; today that number approaches three hundred. Each engineer now directs hundreds of agents, and code arrives in a near-continuous flow, growing almost organically around whatever structure exists.

5. Weeds spread: each copy makes the next copy more likely
In that garden, your constraints and safeguards are the concrete frame that new code grows around. Workarounds, anti-patterns, obsolete code and technical debt are weeds. To the next agent, a workaround looks like an established pattern, so it gets copied, and each copy makes the next copy more likely. Before long it is everywhere. The practical conclusion: keep the codebase as clean as you can, so agents only ever have good examples to copy.
6. Build the rules into a framework
The team encoded its lessons into an internal client framework called Dune, which works roughly like Next.js for Electron apps. On top of a normal app framework (navigation, rendering, inter-process communication) it adds three rules that are enforced by lints rather than by documentation:
- One folder per feature, so structure is predictable.
- Strict import bans, so code cannot reach across boundaries it should not cross.
- No comments in code, for reasons explained in section 7.
The first lesson behind it: anything that needs nuance to use well tends to produce slop. React’s useEffect is the classic example. It has legitimate uses, but it is easy to misuse, and agents misuse it often. Rather than explaining the nuance in a rules file, the team banned it in product code and allowed it only in a few places inside the framework’s own API. The problem disappeared, and reviewers stopped looking for it.
The second lesson: directory structure is context. In an earlier Electron app, agents kept importing main-process code into the renderer, which caused long tasks and lag. Now there are two top-level folders, electron/main and electron/renderer, and imports between them are blocked by a dependency-graph check and lint rules. The setup is simple; the payoff is one less thing anyone has to think about in review.

7. Quick fixes and comments are liabilities
The third lesson is about markdown in all its forms: comments, documentation, rules and skills. Agents tend to use these as a place to justify not doing things properly, and they can overfit a small correction into a rule that is never questioned again.
A real sequence from an earlier codebase shows how it goes wrong:
Sep 9 // release later, in case it comes back
setTimeout(() => release(id), 0)
-> fixes a flicker; agent: "it would be a larger change"
Oct 3 the same trick copied into a shared module
Oct 17 183 timers
Imperative timers such as setTimeout, requestAnimationFrame and requestIdleCallback were patching over a conflict between an imperative editor architecture and React’s declarative style. Timers created and destroyed rapidly cause heavy garbage collection, and the app slowed down. Worse, each copy came with a comment explaining why the quick fix was justified, which made the next copy look legitimate.
The team’s response was radical: ban about 99 percent of comments. Comments go stale quickly, people rarely read them, and they give agents an escape hatch for skipping the hard fix. Above all, they cannot be enforced; a well-meant note to “the next agent” is never something you can trust. Comments in the codebase fell from 65,824 on July 31 to 1,227. The lint rules that replaced them produce helpful error messages that push the agent toward the root cause instead of a patch.

8. Every correction becomes a check
The general principle fits in one line: whenever you correct your agent, lint against the mistake, or categorically eliminate it through better API design or architecture. A chart of these corrections climbed in steps from 7 in July to 167 by November. Each step is a class of problem that no longer needs a human to watch for it.
Do this often enough and review gets lighter, until there is very little left to look at. At that point agents can merge most of their own pull requests.

Part IV — Verification
9. Review becomes looking at evidence
The team calls verification the most important layer. Code review on the team has largely become a review of verification artifacts: videos, screenshots, diagrams and formal proofs, rather than line-by-line reading. The question shifts from “does this code look right?” to “has the agent shown that it works?”
10. Runtime verification
The simplest form is runtime verification: give the agent the ability to run the app itself, with the same debugging tools a human developer uses, such as the Chrome DevTools Protocol. Two details make it work well:
- A feature map: a map of every feature in the app from the user’s point of view, covering what features exist, how users reach them and what proves each one works. It gives agents and humans a shared vocabulary, so “that thing in the left panel” stops being ambiguous.
- A reusable CLI and driver that agents call every time instead of improvising, which cuts token use and can itself be tested.

11. Formal verification and property-based testing
The team has also started using formal methods, which agents have made affordable:
| Technique | What it does | Example use |
|---|---|---|
| TLA+ models | Models a flow as a state machine and checks every state is handled | Notifications across devices and platforms |
| Lean proofs | Proves properties of an algorithm step by step | A virtualization library that must never flicker or jitter |
| Property-based UI testing | Throws random input at the interface and checks invariants | Found several interface bugs |
None of this is a silver bullet; the team treats it as one more layer. But it has already found real bugs, and it also helps humans reason about how the product should behave and whether the agent understood the intent.
Another engineer’s experience illustrates the shift. Six months earlier, subtle bugs in AI-generated pull requests kept slipping through and took days to fix. After adding a verification process, about 70 percent of their daily token spend went into verifying patches and only 20 to 30 percent into creating them. The Grok Bot team reports a similar balance.
None of these tools are new: unit tests, fuzzing, property-based tests, formal methods, canaries and monitoring have always been good practice. They were simply too expensive to write and maintain. Agents cut that cost, which makes this a golden age for testing and verification.

Part V — Results and the Outer Loop
12. What the investment returned
The team shared numbers for the months after its desktop app launched:
| Measure | Figures |
|---|---|
| Pull requests merged | June 809, July 1,784, August 4,203, September 5,648, October 10,926 |
| People with at least one merged PR | June 15, July 48, August 95, September 163, October 227 |
| Desktop releases per month | August 7, September 19, October 15 (median 25 to 28 hours apart) |
| Commits reverted | June 0.98%, July 0.61%, August 0.47%, September 0.48%, October 0.47% |
Many of the October contributors were occasional, “drive-by” contributors without full context, which makes the stable revert rate more notable.
Performance improved at the same time. From May to November:
| Measure | May | Now | Change |
|---|---|---|---|
| Cold launch | 2,304 ms | 1,395 ms | −39% |
| Typing in a long chat (median) | 8.4 ms | 2.9 ms | −65% |
| Switching to a short chat | 88 ms | 49 ms | −44% |
| Idle memory | 488 MiB | 545 MiB | +12% |
Not every number improved, and the team is candid that an Electron app has a ceiling. But speed and quality held up under a tenfold increase in volume.

13. Don’t automate a bad loop
Should you build a software factory, then? Not first. If your inner loop, where code is written and checked, produces slop, automating it only produces more slop faster, and you will spend ever more tokens fixing it. Much of the work in the pyramid is a prerequisite for automation anyway. The order:
- Add lint rules that stop new anti-patterns from appearing.
- Clean the old anti-patterns out of the codebase.
- Make verification genuinely robust.
14. The outer loop
With that foundation in place, the outer loop becomes straightforward. The team’s bot starts agents from signals: feedback posted on X, a new ticket, a Slack message, a schedule, or an alert from monitoring. On every release it launches a project that fuzzes the whole application by using it like a real user, opens a pull request with a fix for each bug it finds, and merges them, because the codebase makes those pull requests succeed by default.

The Layers Compared
| Layer | Example | Enforced? | Cost of a fix here |
|---|---|---|---|
| Codebase design | useEffect banned in product code; one folder per feature |
Yes, by structure | Lowest |
| Static analysis | Import bans between main and renderer; no-comments lint | Yes, by tools | Low |
| Runtime verification | Agent runs the app and records evidence | Yes, by evidence | Medium |
| Formal verification | TLA+ state machines, Lean proofs | Yes, by proof | Medium to high |
| Prose | Rules files, skills, AGENTS.md | No | High |
| Human review | Reading diffs line by line | Partly | Highest |
Final Perspective
The core idea is a change of reflex. When an agent makes a mistake, the natural move is to write it down: a new line in a rules file, a comment, a note in AGENTS.md. This playbook argues that writing it down is the weakest possible fix. Prose is unenforceable, goes stale and invites agents to rationalize. The strong fix is structural: an API that cannot be misused, a folder layout that encodes boundaries, a lint rule with a helpful message, a test that proves behavior.
It is worth keeping the claims in proportion. The numbers come from one team, one codebase and six months of focused work, and removing nearly all comments or letting agents merge their own pull requests are choices that depend on that foundation. What transfers immediately is smaller: the next time you correct an agent for the same mistake, ask whether it can become a lint rule or a test, and let agents run the code and show evidence instead of asking you to read every line.
Quick Reference
| Step | What to do |
|---|---|
| 1 | When you correct an agent, write a lint rule or a test, not a rules-file line |
| 2 | Ban APIs that need nuance (e.g. useEffect) in product code; wrap them |
| 3 | Encode boundaries in folders and block cross-imports with lint |
| 4 | Remove explanatory comments for quick fixes; fix root causes |
| 5 | Lint new anti-patterns first, then clean out old ones |
| 6 | Let agents run the app and record screenshots, videos and logs |
| 7 | Keep a feature map: what exists, how users reach it, what proves it works |
| 8 | Add formal methods (TLA+, Lean) and property-based tests where bugs are costly |
| 9 | Review evidence, not every line |
| 10 | Automate the outer loop only after the inner loop is trustworthy |
FAQ
How does the Grok Bot team trust AI-written code?
By investing most of its effort at the top of an upside-down pyramid: a clean codebase and strict static analysis that force agents to do the right thing, then runtime and formal verification that prove changes work. Prose rules and human review are kept small.
Why replace rules files with lint rules?
A lint rule runs on every change, cannot be ignored and gives the agent a precise error message. A rule in a markdown file can be misread, overfitted or skipped, and it goes stale.
Why ban comments in code?
Comments go stale, are rarely read and cannot be enforced. Agents also used them to justify quick fixes, which then spread. Comments fell from 65,824 to 1,227 after the ban, replaced by lint rules that point to root causes.
What is runtime verification for AI agents?
Letting the agent run the application itself, with tools such as the Chrome DevTools Protocol, and produce evidence like screenshots and videos that a change works. A feature map tells it what to check and how.
Should I build a software factory?
Only after your inner loop is trustworthy. Automating a loop that produces slop produces more slop and burns more tokens. Lint new anti-patterns, clean out old ones and build solid verification first.
Further Reading
- Grok Bot explained: the 7 levels
- Learn Git before your AI breaks your code
- Claude Code best practices for today’s models
All figures are the Grok Bot team’s own and were not independently verified. They come from one team’s codebase and six months of investment; your results will depend on yours.
