TL;DR: Measure AI technical debt by tracking the signals that move before incidents do, such as duplicated code, churn, untested changed lines, security findings and new dependencies. It builds because AI coding tools raise code volume much faster than review and testing capacity can grow, so it piles up quietly in duplicated logic, untested paths, insecure patterns and new dependencies. That matters because accumulated US software technical debt was already estimated at about $1.52 trillion by CISQ before AI assistants went mainstream. Treat testing as the control: gate changed lines on coverage, generate tests with the code, and scan every new package.
We talk with engineering leaders every week who adopted AI coding assistants and saw pull request counts jump within a quarter. The harder question comes a few months later: is the codebase getting healthier, or just bigger? This guide shows how to measure that: the forms AI-era debt takes, the signals that show it early, and the pipeline guardrails that keep it out of production. For a hands-on fix list, see our guide to spotting and stopping AI generated code technical debt.
Quick answers
How do you measure AI technical debt?
Track a small set of signals per repository every sprint: test coverage on changed lines, duplicated code, churn on recently merged code, new security findings and new direct dependencies. Rising trends matter more than any single number.
Is AI-generated code always lower quality than human code?
No. Individual suggestions are often fine. The problem is volume and review depth: when output doubles and review time stays flat, more flawed code gets through, and the flaws compound.
What is the first guardrail a leader should add?
A coverage gate on changed lines in every pull request. It costs little to set up, it targets exactly the code AI is producing, and it forces tests to arrive with the code instead of later.
Why does AI technical debt build faster than teams notice?
AI-generated code creates debt faster because it raises the rate of change without raising the rate of verification. Review, testing and refactoring are still mostly human and time-boxed. When code volume outruns them, defects and design shortcuts accumulate in the gap.
The best causal evidence so far comes from a Carnegie Mellon team that compared GitHub projects adopting the Cursor agent with matched projects that did not. They found a large but transient increase in development velocity, plus a substantial and persistent increase in static analysis warnings and code complexity. The authors also concluded that those quality increases were a major factor behind the later slowdown in velocity, and they named quality assurance as a major bottleneck for early adopters.
That pattern is the whole story in miniature. The speed is real, but it fades. The debt is also real, and it stays. Leaders who only track throughput will see the gain and miss the cost until delivery slows for reasons nobody can point to.
Three mechanics drive it:
- Generation is cheap, comprehension is not. An assistant writes 200 lines in seconds. A reviewer still needs real time to understand them, and fatigue sets in fast.
- Assistants optimize for the local prompt. They rarely know your shared utilities, conventions or architecture decisions, so they write new code where reuse was the right call.
- Tests are optional in the default workflow. Unless your pipeline demands them, generated features arrive with thin tests or none, and nobody notices until a regression escapes.

Which forms of AI technical debt should you measure?
AI-era technical debt takes six main forms: duplication, churn, untested paths, security weaknesses, dependency sprawl and pattern drift. Each one is familiar from classic debt. What changes is how fast it accumulates and how hard it is to see in a normal review.
1. Duplication and bloat
Assistants tend to write a fresh helper instead of calling the one that already exists three folders away. Every copy becomes a separate place to fix the next bug. Bloat also hides intent: reviewers skim long diffs, and skimmed code is where debt starts.
2. Churn
Churn is code that gets rewritten or reverted within a few weeks of merging. Some churn is healthy iteration. Persistent churn on AI-heavy changes usually means the first version was accepted before anyone understood the requirement.
3. Untested paths
Generated code often handles the happy path neatly and the edge cases loosely. Error branches, retries, null handling and permission checks are exactly where coverage drops. These paths fail in production, not in the demo.
4. Security weaknesses
Insecure patterns are a measurable risk, not a hypothetical one. Georgetown's Center for Security and Emerging Technology tested five large language models with the same prompts and reported that almost half of the code snippets they produced contained bugs, often impactful ones that could be exploited. The authors note their evaluation was narrow, but the direction is hard to ignore. We cover the security question in more depth in our post on whether AI-generated code is safe.
5. Dependency sprawl and hallucinated packages
Every package an assistant imports is a long-term maintenance and supply chain commitment. Worse, some suggested packages do not exist. A USENIX Security 2025 study analyzed 576,000 code samples from 16 models and found that the average share of hallucinated packages was at least 5.2% for commercial models and 21.7% for open-source models, with 205,474 unique invented package names. Attackers can register those names and wait.
OWASP lists this exact risk in its Top 10 for LLM applications, warning that models can suggest non-existent code libraries, which can introduce vulnerabilities, and that attackers publish malicious packages under commonly hallucinated names.
6. Pattern drift
When five engineers prompt five assistants, you get five styles of error handling, logging and data access. No single change looks wrong. Together they erode the consistency that makes a codebase cheap to change.
Which metrics show AI technical debt early?
Track signals that compare code volume against verification capacity, not volume alone. If lines changed rise faster than tests added, review time per change and coverage on new code, debt is building. Read the trend monthly and per team, never as a single company number.
These are the signals we would put on a leader's dashboard:
- Changed-line coverage: the share of new or modified lines executed by tests in each pull request. A falling trend is the clearest early signal.
- Test-to-code ratio of merged changes: lines of test code added per line of production code. Watch for features merging with no test files at all.
- Review depth: review minutes per 100 changed lines and the share of approvals with zero comments. Rubber-stamp approvals rise when diffs get long.
- Churn rate: the share of lines rewritten or reverted within 21 days of merge, split by AI-assisted and other changes if your tooling can tag them.
- Duplication index: duplicated blocks flagged by static analysis per thousand lines, trended monthly.
- Static analysis and security findings on new code: count of new warnings per release, not the legacy backlog.
- New direct dependencies per month: and the share approved through a named review step.
- Escaped defects tied to recent AI-heavy changes: incidents and rollbacks traced back to pull requests from the last 90 days.
One signal teams forget is test suite health. If generated tests are brittle, maintenance cost lands on QA instead of disappearing. Our guide to legacy test automation maintenance covers how that hidden cost builds when suites grow faster than anyone curates them.
Want generated code to arrive with tests your team can actually own? See how ContextQA code export turns validated tests into Playwright, Selenium, Cypress or WebdriverIO code in your repo.
Which pipeline guardrails keep AI debt out of production?
The guardrails that work are automated, run on every pull request and block merges when they fail. Policy documents do not scale with AI output. Pipeline checks do. Four layers cover most of the risk: test generation, coverage gates on changed lines, review policies and security scanning.
Generate tests alongside the code
If AI writes the feature, AI can draft the tests too, but a human must approve them. Ask for tests derived from the requirement or acceptance criteria, not from the implementation, so they check intent instead of mirroring whatever the code happens to do. Keep generated tests in draft until someone reviews them.
Gate coverage on changed lines, not the whole repo
A repository-wide coverage target barely moves when one large change lands untested. A changed-line gate does. Google's long-running study of coverage across a billion lines of code argues that coverage should be applied at the level of changesets and code review. That is precisely where AI output enters your system.
- Start at a level your teams can hit, such as 70% of changed lines, and raise it each quarter.
- Exempt generated boilerplate deliberately, with a reviewed exclusion list, not ad hoc skips.
- Pair coverage with assertions. A test that executes code without checking results inflates the number and catches nothing.
Set review policies that match AI volume
Long AI diffs defeat careful review. Cap pull request size, require authors to explain intent in their own words, and review the tests before the code. Our post on test review versus code review explains why reviewing tests first catches misunderstood requirements earlier. For line-level items reviewers should check, use our AI-generated code checklist.
Scan for security weaknesses and new dependencies
- Static application security testing on every pull request, with new high-severity findings blocking merge.
- A dependency allowlist or approval step so any new package triggers a named reviewer and a registry check.
- Software composition analysis for known vulnerabilities and license issues in everything you pull in.
- Secret scanning, since assistants sometimes reproduce placeholder keys or inline credentials.
What does AI technical debt look like in numbers?
It looks like a small percentage change on a much bigger base. The figures below are illustrative, not measured. They show how untested code can quadruple even when nothing seems broken.
Consider a hypothetical team of 40 engineers. Before AI assistants, they merged 400 pull requests a month, averaging 150 changed lines each. That is 60,000 changed lines a month. Changed-line coverage sat at 78%, so about 13,200 lines a month shipped without a test touching them.
Six months after rollout, the same team merges 600 pull requests a month at 220 changed lines each. That is 132,000 changed lines, 2.2 times the old volume. Review hours did not change, so each line gets less than half the attention. Generated features often arrive without tests, and changed-line coverage slips to 61%.
- Untested lines per month: 132,000 x 39% = 51,480, up from 13,200. Nearly four times as much unverified code now reaches main every month.
- With an 80% changed-line gate: untested lines are capped at 132,000 x 20% = 26,400, roughly half the ungated number.
- New dependencies: if direct packages added per month rise from 6 to 15, an approval step means 15 short reviews instead of 15 silent commitments.
The point is not the exact numbers. It is that a team can feel faster while its unverified surface area grows several times over. Dashboards that show only pull request throughput will make this look like a win.

What operating cadence keeps AI technical debt under control?
Run a layered cadence: automated checks on every pull request, a weekly look at trends, a paydown slot every sprint, and monthly and quarterly reviews. Debt control fails when it is a one-time cleanup. It works when it is part of how the team ships every sprint.
- Every pull request: changed-line coverage gate, security and dependency scans, size limit, tests reviewed before code.
- Weekly: team leads review the signal dashboard for their area. Any metric moving the wrong way for two weeks gets an owner and a note.
- Every sprint: reserve capacity for refactoring duplicated or churning code, and write tests for the highest-risk untested paths. Our guide to in-sprint test automation shows how to keep test work inside the sprint instead of trailing it.
- Monthly: compare AI-heavy areas against the rest on churn, escaped defects and coverage. Prune or consolidate flaky and redundant tests.
- Quarterly: raise the coverage gate if teams are clearing it easily, revisit the dependency allowlist and update assistant instructions with your conventions.
In our view the sprint paydown slot matters most. Without protected capacity, debt work always loses to the next feature, and AI makes the next feature arrive sooner.
How do you score your AI technical debt guardrails?
Score each guardrail 0, 1 or 2: 0 means absent, 1 means present but not enforced, 2 means automated and blocking. A total under 10 out of 20 means AI output is likely outrunning your controls. Use it as a quarterly self-assessment, per team.
- Changed-line coverage gate runs on every pull request and blocks below threshold.
- Tests arrive with code: features cannot merge without new or updated tests.
- Generated tests are reviewed by a human before they join the suite.
- Pull request size limit is enforced, with exceptions logged.
- Static analysis on new code blocks new high-severity findings.
- Dependency approval step exists for every new direct package.
- Duplication and churn are tracked monthly per team.
- Sprint paydown capacity is reserved and actually used.
- Escaped defects are traced back to source changes and reviewed monthly.
- Assistant instructions include your conventions, shared utilities and banned patterns, and are updated quarterly.
How does ContextQA help control AI technical debt?
ContextQA helps by making tests arrive at the same pace as AI-generated code, and by keeping those tests maintainable. It generates test cases from requirements, heals tests when the UI changes and diagnoses failures, so verification capacity grows with output instead of lagging behind.
- Tests from requirements, with approval: you can import specifications as documents, images or recordings, answer clarifying questions, and review generated cases. In Require Approval mode, generated cases stay in draft until someone approves them, and each one maps back to a requirement with a Gaps view of what is still uncovered.
- Self-healing in CI: AI-based self-healing detects broken locators and failed steps during a run, repairs them and logs every repair with before and after context. That keeps fast-moving UI changes from turning into a pile of brittle tests.
- Root cause analysis: failures are checked across visual, DOM, network, code and data layers, and related failures are clustered across builds, so teams see systemic problems instead of one-off reds.
- Tests you own as code: code export produces Playwright, Selenium, Cypress or WebdriverIO projects in TypeScript, JavaScript, Java or Python that run in Jenkins, GitHub Actions or CircleCI with no proprietary runtime.
None of this replaces a coverage gate or security scanning. It fills the part those checks cannot: producing enough meaningful tests to pass the gate honestly.
If AI has doubled your code volume but not your test capacity, book a demo and we will walk through how requirement-based test generation fits your pipeline.
Bottom line
AI coding tools are not the problem. Unverified volume is. When code output grows faster than review and testing, debt builds in places no single pull request reveals.
Make testing the control. Gate changed lines, require tests with features, scan every dependency and protect paydown time each sprint. Teams that do this keep the speed and skip the slowdown.
Sources
- Cost of Poor Software Quality in the U.S.: A 2022 Report, CISQ (Consortium for Information and Software Quality), https://www.it-cisq.org/the-cost-of-poor-quality-software-in-the-us-a-2022-report/. Cited for the estimate of about $1.52 trillion in accumulated US software technical debt.
- Speed at the Cost of Quality: How Cursor AI Increases Short-Term Velocity and Long-Term Complexity in Open-Source Projects, He, Miller, Agarwal, Kästner and Vasilescu, arXiv, https://arxiv.org/abs/2511.04427. Cited for the transient velocity gain and persistent rise in static analysis warnings and code complexity.
- Cybersecurity Risks of AI-Generated Code, Center for Security and Emerging Technology, Georgetown University, https://cset.georgetown.edu/publication/cybersecurity-risks-of-ai-generated-code/. Cited for the finding that almost half of model-generated snippets contained bugs.
- We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs, USENIX Security 2025, https://www.usenix.org/conference/usenixsecurity25/presentation/spracklen. Cited for hallucinated package rates of 5.2% and 21.7% and 205,474 unique invented names.
- LLM09:2025 Misinformation, OWASP Top 10 for LLM Applications, OWASP GenAI Security Project, https://genai.owasp.org/llmrisk/llm092025-misinformation/. Cited for the risk of non-existent library suggestions and malicious packages under hallucinated names.
- Code Coverage at Google, Google Research, https://research.google/pubs/code-coverage-at-google/. Cited for applying coverage at the level of changesets and code review.