PragMentor Consulting Pvt. Ltd.
Back to blog
AI SDLCEngineering MetricsDORA Metrics

Metrics to Track When AI Writes the Code

1 December 202612 min read

A practical guide for engineering leaders: which metrics to drop, demote, keep and add now that AI writes much of the code.

The wrong question

"How much of your code does AI write?" has become one of the most common questions in engineering. It's the wrong one. The better question is: how much of that code holds up?

With AI, teams ship more code, more pull requests and more closed tickets. The dashboards go green. But reviewers, support teams and future maintainers see a different picture: longer review queues, more bugs reaching production, and more duplicated code that nobody cleans up.

This isn't a reason to slow down on AI. DORA (DevOps Research and Assessment), the long-running research program run by Google Cloud, found in its 2025 report that AI acts as an amplifier: it makes strong engineering practices stronger and weak ones worse. The difference shows up in what a team measures.

The trouble is that most engineering metrics were built for a world where humans typed every line. Some should go, some should be demoted, some should stay, and a few new ones are overdue:

  • 🔴 Off the dashboard: lines of code, raw PR counts, self-reported speed
  • 🟡 Move to an adoption report: AI acceptance rate, % of code written by AI
  • 🟢 Keep, but read with care: deployment frequency, lead time for changes, change failure rate, recovery time, escaped defects, review coverage, test coverage
  • 🔵 Add: code churn, reviewer load, refactoring rate, code duplication, defects split by AI-assisted vs. hand-written code

Here's what each group means, and what to do about it.

🔴 Off the dashboard

They measure volume and feeling, not value. These metrics made sense when effort and output moved together. AI breaks that link.

Lines of code

With an AI assistant, more lines cost almost nothing. A team using AI heavily will always "win" on this number, whatever it actually shipped, and every extra line is something to review, test and maintain.

Do this:

  • Remove lines of code from productivity dashboards and performance reviews.
  • If you still collect it, show it only next to code churn and duplication, so a spike reads as a possible warning rather than an achievement.

Raw PR counts

AI makes it easy to open more pull requests, and those pull requests are getting bigger. A rising count no longer tells you whether working software reached users safely, and PR counts no longer compare fairly across teams with different levels of AI use.

Do this:

  • Never report PR volume on its own. Always pair it with a quality signal such as review time, PR size or change failure rate.
  • Set a soft limit on PR size (for example, around 400 changed lines) so every change stays reviewable.

Self-reported speed

Controlled experiments, where developers do real tasks with and without AI and are timed, have found a striking gap between how fast developers feel with AI and how fast they actually are. More recent research suggests today's tools probably do help, but also shows how hard the effect is to measure.

Do this:

  • Keep asking developers how AI is working for them. Their view is valuable for spotting where tools help and where they get in the way.
  • Don't use "we feel faster" to justify roadmap, budget or hiring decisions. Compare it with measured cycle time first.

🟡 Move to an adoption report

They show AI is being used, not whether it's helping. These metrics were invented to track AI rollout. They're useful for that, but they shouldn't sit on a performance dashboard.

AI acceptance rate

This is the share of AI code suggestions developers accept in their editor. It's often presented as "AI ROI", but it only records a click, not whether the code survived review, shipped, or was rewritten a week later.

Do this:

  • Use it to judge tool fit: which languages, repositories or tasks the tool helps with. Never use it to rate developers or teams.
  • Read it next to code churn. High acceptance plus high churn means code is being accepted that people don't fully understand.

Percentage of code written by AI

This makes a good headline, but tells you nothing about outcomes. A codebase can be 60% AI-generated and healthier than before, or much worse.

Do this:

  • If leadership wants the number, report it in a separate adoption report, clearly apart from performance metrics.
  • Answer the real question, "is AI helping?", with the metrics in the next two sections.

🟢 Keep, but read with care

Speed only counts if failures don't rise; coverage only counts if reviews and tests are thorough. These metrics remain the backbone of good engineering measurement. What changes is how to read them.

Deployment frequency, lead time, change failure rate and recovery time

These four delivery metrics, known as DORA's four keys, fall into two pairs:

  • Speed: deployment frequency (how often you release to production) and lead time for changes (how long a change takes from commit to production).
  • Stability: change failure rate (the share of releases that cause a problem in production) and recovery time (how quickly you restore service when one does).

AI tends to push the speed pair up first, while stability lags. Read separately, the dashboard looks great. Read together, it tells the real story.

Do this:

  • Show speed and stability side by side on the same dashboard, never separately.
  • Each quarter, ask: is speed rising while stability holds, or while it slips?

Escaped defects

An escaped defect is a bug that got past review and testing and reached users. It's the ultimate outcome check, and it doesn't care who or what wrote the code.

Do this:

  • Track escaped defects and incidents per release, not just in total, so the numbers stay comparable as volume grows.
  • After each significant incident, ask: which check should have caught this?

Review coverage

Code review no longer means only a teammate reading a pull request. Most teams now run several automated checks before a human looks, and AI review tools are fast becoming one of them. Each layer catches different problems:

Review layerDesigned to check
Linters and formattersStyle, formatting, simple coding errors
Static analysis and quality gatesKnown bug patterns, complexity, duplication
Security scanning (code, secrets, open-source dependencies)Known vulnerability patterns, exposed secrets, risky packages
Automated tests in CIBehaviour the tests describe
AI code review toolsLikely bugs, edge cases and unclear code within the change
Human reviewIntent, design, risk, fit with the wider system

The table describes what each layer is built to check, not guaranteed results. Every layer misses some problems inside its own scope too, which is why teams stack them. Automated and AI review help teams keep up with AI-generated volume, but they don't replace judgment.

Do this:

  • Measure coverage per layer: what share of changes passed each check, not one overall "% reviewed" figure.
  • Tier review by risk. Let low-risk changes (docs, config, small refactors) merge on automated checks. Always require a human reviewer for authentication, payments, personal data and infrastructure.
  • Check how often developers act on AI review comments. If most are dismissed, tune the tool or its rules.
  • Watch for changes that skipped both human and AI review. Aim for close to zero.
  • If you add a second AI model from another provider as a reviewer, treat it as one more layer, not an independent check: different models share many blind spots. Let it comment rather than rewrite, and track how often its comments lead to real fixes.

Test coverage

Coverage, the share of code your automated tests exercise, is still a useful guardrail. But AI can write shallow tests as easily as it writes code, so the percentage is now easy to inflate.

Do this:

  • Keep a coverage threshold, but don't celebrate rising coverage on its own.
  • Add mutation testing on critical code: a tool deliberately introduces small bugs and checks whether your tests catch them.

🔵 Add

They show what AI-generated code costs after it's written. These metrics weren't standard practice a few years ago, because the problems they catch didn't exist at this scale. Most can be calculated from data you already have in git, your CI pipeline and your issue tracker.

Code churn

Churn is code that's rewritten or deleted within about two weeks of being written. Rising churn means code is being produced faster than it's understood.

Track it: most git analytics tools calculate it from commit history. Watch the trend per team.

When it rises: find which repositories or types of work drive it. Common fixes are smaller PRs, clearer task specs before prompting the AI, and pairing on unfamiliar parts of the codebase. Churn usually falls once teams adapt their process, so it's a metric you can move.

Reviewer load

Reviewer load means review time and PR size, read together. As AI-assisted pull requests get bigger, reviewers are handed more than they can properly check, and quality quietly leaks out.

Track it: plot median review time against median PR size for each team.

When it rises: enforce PR size limits, let automated and AI review take the first pass on routine issues, and protect reviewers' time with set review slots rather than constant interruptions.

Refactoring rate

This is the share of work spent improving existing code rather than adding new code. Industry data shows refactoring falling sharply as AI tools spread. A shrinking refactoring rate is an early warning of technical debt: the bill arrives later.

Track it: classify pull requests as feature, fix or refactor using labels or commit message conventions, and review the mix quarterly.

When it falls: reserve a fixed share of each sprint for clean-up, and add "is there existing code this should reuse?" to your review checklist.

Code duplication

This is new code that's a near-copy of code elsewhere. AI tools tend to generate fresh code rather than reuse what already exists, so copy-pasted code is piling up faster than teams refactor it.

Track it: most static analysis tools report duplication out of the box. Add a duplication threshold to your quality gate.

When it rises: give AI tools context about your shared libraries and conventions, and flag duplicates in review.

Defects split by AI-assisted vs. hand-written code

Overall bug counts can't tell you whether AI is helping or hurting your codebase. Splitting them can.

Track it: label AI-assisted pull requests (many tools do this automatically, or use a PR label), then link those labels to bugs in your issue tracker.

When the AI-assisted rate is higher: look for the pattern, such as particular repositories, task types or teams, and add targeted guardrails there (mandatory human review, extra tests) rather than restricting AI everywhere.

The old scorecard vs. the new one

Old scorecardNew scorecard
🔴 Off the dashboardLines of code, PR counts, "we feel faster"Removed, or shown only as context beside quality signals
🟡 Adoption reportAcceptance rate and % of code by AI as proof of successReported separately, as adoption data only
🟢 Keep, with careDelivery metrics as separate targets; "was it reviewed?"; coverage %Speed and stability read as a pair; review coverage per layer, tiered by risk; mutation testing
🔵 AddNot trackedChurn, reviewer load, refactoring rate, duplication, defects split by AI-assisted vs. hand-written code

A practical to-do list

None of this needs new tools. The data is already in your git history, CI pipeline, issue tracker and AI tool settings. Work through the list in any order that suits your team.

Dashboards and reporting

  1. Remove lines of code and raw PR counts from productivity dashboards and performance reviews.
  2. Put speed metrics (deployment frequency, lead time) and stability metrics (change failure rate, recovery time) side by side.
  3. Move AI acceptance rate and "% of code written by AI" into a separate adoption report.

Review

  1. Write down which changes can merge on automated checks alone, and which always need a human reviewer (authentication, payments, personal data, infrastructure).
  2. Enforce that policy with branch protection rules and code owners.
  3. Set a soft PR size limit so every change stays reviewable.
  4. Turn on AI code review for routine changes, and check every few weeks how often its comments are acted on.

Code health

  1. Start labelling AI-assisted pull requests so defects can be split by source.
  2. Add duplication and coverage thresholds to your quality gate.
  3. Add mutation testing for your most critical code.
  4. Track code churn and refactoring rate, and reserve a fixed share of each sprint for clean-up.
  5. Give AI tools context about your shared libraries and conventions, so they reuse code instead of rewriting it.

People

  1. Run a short quarterly survey that asks about review load and trust in AI-generated code.
  2. Compare how much faster teams feel with measured cycle time before using either in planning or hiring decisions.
  3. Review the full scorecard with engineering leads every quarter, and act on the two or three biggest problems it shows.

The bottom line

The old scorecard asked: how much did we produce? The new one has to ask: how much of it is still standing in 90 days?

At Pragmentor, we help engineering teams adopt AI in a way that shows up in outcomes, not just output. If you're rethinking how you measure an AI-assisted SDLC, get in touch.