Measuring code quality regressions in AI-assisted PRs over 6 months

Between May and November 2026, four hundred pull requests were merged across our primary backend services. Half of our engineering team adopted autonomous coding assistants daily, while the other half used traditional IDE setups. Instead of relying on subjective claims about developer velocity, we measured objective static analysis findings, test assertion density, and post-merge defect rates across all four hundred PRs.

The symptom

The 6-month comparative metrics per 1,000 changed lines:

Metric                       Human-written    AI-assisted
-----------------------------------------------------------
Lines of code per PR          185              490 (+164%)
Test code to app code ratio   1.4 : 1          0.8 : 1 (-42%)
Assertion density per test    3.2              1.1 (-65%)
Cyclomatic complexity / fn    2.8              4.1 (+46%)
Uncaught exception findings   0.4              2.1 (+425%)
Post-merge hotfixes (30d)     1.2%             3.8% (+216%)

The data revealed an unambiguous pattern. AI-assisted PRs shipped significantly more code, but the code had lower assertion density, higher cyclomatic complexity, and twice the rate of post-merge hotfixes. The assistant was remarkably effective at generating plausible code that passed superficial review while silently neglecting defensive edge-case handling.

Why it happens

The generative path rewards completeness over conciseness. When asked to handle a business case, an assistant tends to write multiple nested conditionals rather than leaning on existing domain abstractions. Reviewers experiencing “review fatigue” from 500-line diffs skimmed tests that looked comprehensive but contained tautological assertions like $this->assertTrue(true) or asserting only on HTTP 200 status codes without verifying side-effects in the database.

The fix

Infection mutation gates in CI

# .github/workflows/quality-gate.yml
- name: Run Infection Mutation Testing on Changed Files
  run: |
    vendor/bin/infection 
      --git-diff-filter=AM 
      --git-diff-base=origin/main 
      --min-msi=85 
      --min-covered-msi=90 
      --threads=4

We instituted an automated mutation testing gate strictly on changed lines. If an assistant generated code accompanied by tests that did not catch mutants (such as altering boolean conditions or stripping arithmetic operators), CI rejected the pull request before human review.

Verifying it worked

$ ./bin/audit-pr-regressions --since=60d
  Average PR line delta:          220 lines (down from 490)
  Test to app code ratio:         1.3 : 1 (restored)
  Assertion density per test:     2.9 (restored)
  Post-merge hotfix rate:         1.4% (normalized)

Enforcing mutation scores immediately curtailed PR bloat. Developers stopped accepting five-hundred-line AI completions because generating the rigorous mutation-proof tests required for that volume of code took more effort than writing the feature cleanly.

What this costs

Increased CI build times. Running Infection on changed files adds sixty to ninety seconds per pull request build. We mitigated this by caching AST tokens between runs.

And cognitive resistance. Developers who enjoyed the speed of accepting large generated blocks were forced to slow down and verify invariants. The honest lesson: AI tooling increases output volume; only rigorous mechanical constraints ensure that volume maintains quality.