With time, the codebase became harder to maintain, more fragile, and more difficult to change. When teams tried to identify the source of the decline, they couldn't point to a single problematic merge because there wasn't one. The cause was the cumulative effect of hundreds of small changes that were acceptable on their own and harmful together.
Most AI-era quality gates validate individual pull requests. Few ask whether AI code quality across the whole system is moving in the right direction. The ratchet pattern fixes it.
In this blog post, we will cover the practices that keep a ratchet working once AI coding agents are writing the code, from mechanical gates and gaming-resistant metrics to a hand audit of tests and a named owner for the floor.
Define Quality Gates for AI-Assisted Development
An AI development quality gate, sometimes called a code quality gate, is an automated check that blocks a change from merging unless it meets a stated standard.
A conventional gate asks whether this change passes.
A ratchet gate asks whether the system is still at least as good as it was at the last recorded floor, for every metric the team has chosen to track.
The floors live in a checked-in file, and a human resets one only deliberately and with a recorded reason. Platform-level controls such as Azure DevOps branch policies are where the gate is enforced at merge time.
A per-merge gate cannot see gradual regression. Each change clears its own bar, the system gets slightly worse, and no review ever has a single culprit to point at. Agents raise the volume of changes moving through the pipeline, which raises the rate of that drift. A gate that tracks the net direction of quality is the only kind that catches it.
How the Ratchet Pattern Maintains AI Code Quality
A team running three or four parallel AI coding agent sessions can generate code in an afternoon at the volume a human team might take two weeks to produce. A review process already stretched at human velocity does not scale linearly when the input triples or quadruples.
The arithmetic shows why.
Reviewers can properly cover 20 pull requests a day
Agents triple the volume to 60
Forty pull requests a day go unreviewed
Backlog grows by 200 in a five-day week
A sufficiently rested reviewer with enough time could notice that coverage dipped in a file nobody touched in months. With the ratchet, the whole quantifiable category leaves the human queue, so it stops competing with architecture for the same finite hours.
The gate never gets tired and never builds a backlog, and it will not wave a Friday afternoon deploy through on the assumption that someone will circle back Monday.
1. Keep Architectural Judgment with Humans
I know of no metric that puts a floor under architectural coherence. Nothing measures whether a new module respects the intent of the system it joined, whether an abstraction will age well, or whether what an agent built solves the problem the ticket described.
The judgment stays human in agentic coding, however sophisticated the gates get. The ratchet narrows what the human has to look at and leaves the judgment on the remainder untouched.
We design the same narrowing in every custom AI/ML development engagement: mechanical gates absorb what can be measured, and a senior engineer's limited hours go to the calls that cannot be. Our blog post on embedding AI into daily development covers what senior engineers learned doing it.
2. Expect AI Coding Agents to Game Code Coverage Targets
When a measure becomes a target, it stops being a good measure.
This is the problem with applying the ratchet to code coverage. Human developers sometimes write tests just to meet a coverage requirement. For example, they might write a test that executes a piece of code but never checks whether it produces the correct result. The coverage number goes up, but the test provides little real protection.
AI coding agents can make this problem worse. Agents are designed to achieve the objectives they are given as efficiently as possible. If an agent is instructed to maintain a minimum branch coverage, it may find the easiest way to satisfy that requirement: write tests that execute every branch without checking the actual behavior.
These tests pass, and the coverage target is met. But if the code starts producing incorrect results, the tests may not catch it.
The ratchet is working as it was designed to work. The problem is that code coverage measures how much code a test executes, not whether the test actually verifies that the code works. AI agents can exploit this gap much faster than human developers, making it even more important to measure what matters, not just what is easy to count.
3. Choose Quality Metrics That Resist Gaming
The practical response keeps the quantifiable gates and weights them by how hard they are to satisfy without improving what they claim to measure.

Common mistake: Answering a gamed coverage number by raising the coverage floor. A higher floor adds a few more assert-free tests to the bill, and agents satisfy it the same way. When agents game a coverage number, swap in a metric that is harder to satisfy without real assertions.
Picking harder metrics does not solve the problem permanently. Metric selection is an ongoing adversarial exercise, because whatever the ratchet enforces also tells agents what to optimize for. A team that sets a coverage floor and never revisits it runs the same gate for years against agents that keep improving.
4. Run a Ten-Test Sampling Audit
A periodic human audit earns its keep alongside the automated check. It is the only process that tells a team whether the check has quietly stopped meaning what it was built to mean.
A reviewer pulls ten tests at random from the merges the ratchet approved in the last two weeks and opens each one. The single question for each: if the behavior this test claims to cover broke tomorrow, would this test fail? A test that calls a function and checks it did not throw differs from a test that checks the function returned the right answer, and coverage tooling cannot tell them apart. A human reading ten tests for fifteen minutes every two weeks can.
A few tests out of ten that exercise the target code without pinning down its behavior, usually concentrated in whichever part of the codebase saw the most agent-generated churn that cycle. The pattern is the signal. It shows whether the coverage floor still works as a regression check or has become a number that gets satisfied without being earned. It also costs far less than formalizing "does this test assert something meaningful" into a rule a linter could enforce.
5. Assign an Owner to the Floor
Once the ratchet is running and the easy regressions are caught mechanically, the harder question moves up a level: who decides what the floor measures, and who is accountable when a metric gets gamed?
It is an engineering leadership question, the one that appears whenever a team automates a category of oversight and has to decide what human judgment keeps a seat. I have worked through it from the opposite direction in adversarial reasoning architectures. A mechanical gate catches what it was built to measure, and someone still has to own deciding whether it measures the right thing.
My answer is that the floor's metrics need an owner who revisits them on a cadence, the way a security team revisits a threat model. A ratchet installed once and forgotten still defines what quality means for that codebase, in a form that increasingly capable agents optimize against. With nobody maintaining it, the gate keeps passing while the quality it was built to protect erodes. The layered approach in our multi-layered testing overview is a useful companion for deciding which layers get a floor.
6. Treat Quality Gates as a Living Specification
AI development quality gates cannot eliminate regression, and nothing else does either. What the ratchet can do is turn an entire category of drift, the quantifiable kind, from something that demands vigilance into something that needs only configuration, at a moment when the volume of code moving through a pipeline has outgrown what vigilance can cover.
The floor holding is the minimum bar. The stronger signal is a team that keeps asking what the floor measures, because the agents on the other side of the gate will find the answer whether or not anyone is watching.
Next Step
If you run AI agents against production code today, one narrow question is worth bringing to your next engineering review. Pick the single most-trusted quality metric, and ask when someone last read a sample of the tests or checks that pass it instead of the number they produced. In our experience, most teams can say what their floor currently is.
Fewer can say who last checked that it still means what it was built to mean. If agents in your pipeline already touch multiple model providers or reasoning paths, the dispatcher pattern for keeping business logic decoupled from any single model pairs well with the ratchet.
Final Words
Setting the floor is the easy part. Choosing metrics that agents cannot satisfy cheaply, and naming someone who owns them, is where most pipelines need help. Improving's AI practice works with engineering leaders on exactly this: deciding where a ratchet belongs in an agent-assisted pipeline, which metrics deserve a floor, and how to audit that the floor still measures something real.


