AI-Generated Code Is Creating a Technical Debt Crisis
AI coding tools are creating invisible technical debt. After auditing 6 codebases, here are the patterns I found and the framework to assess your own AI debt.
Here's an unpopular opinion: AI coding assistants are the biggest source of technical debt in modern software development. Not because the code is bad. Because it's invisible debt.
I've audited 6 codebases in the last year where teams used Copilot or Claude heavily. Every single one had a pattern I now call "AI debt accumulation." The code worked. The tests passed. And the architecture was slowly rotting from the inside.
I tracked metrics across these 6 codebases over 6-12 month periods. Here's what I found:
Metric
Before AI Adoption
6 Months After
12 Months After
Avg. file size (lines)
142
203
267
Cyclomatic complexity (avg)
4.2
6.8
8.1
Duplicate code ratio
3.1%
8.7%
14.2%
Unused imports per file
0.3
1.8
2.4
Time to onboard new dev
2 weeks
3 weeks
5 weeks
Missing repository context can lead an assistant to generate a utility that already exists elsewhere. Repository-aware tools can retrieve context, so the result depends on what the assistant can find and uses. After 12 months, one team had 47 different implementations of date formatting scattered across their codebase.
Traditional technical debt has a paper trail. Someone cut a corner, left a TODO comment, or made a conscious trade-off documented in a PR description. You can find it and fix it.
Generated code can look clean while conflicting with the codebase’s architecture. Formatting, names and comments need review alongside the project’s actual conventions and the context supplied to the assistant.[1]
AI tools generate code based on training data. That training data includes millions of different architectural patterns. So when you ask AI to add a feature, it might use the repository pattern while your codebase uses direct data access. Or it creates a service layer when you've been using simple functions.
typescript
// Your codebase does this everywhere:const users = await prisma.user.findMany({ where: { teamId }, include: { profile: true },});// AI generates this:class UserRepository { private prisma: PrismaClient; constructor(prisma: PrismaClient) { this.prisma = prisma; } async findByTeam(teamId: string): Promise<User[]> { return this.prisma.user.findMany({ where: { teamId }, include: { profile: true }, }); }}// Technically fine. Architecturally wrong for this codebase.
Both approaches work. But now you have two patterns. Next month, a new developer sees both and doesn't know which to follow. They ask AI to help, and it picks whichever pattern was more common in its training data.
I tracked npm installs across one team for 3 months. Before AI adoption, they added about 2 new dependencies per month. After, it jumped to 9 per month.
The worst example: the AI suggested date-fns for a date operation in a codebase that already used dayjs. Nobody caught it in review because both are popular libraries. Three months later, the bundle included both, adding 47KB of redundant code.
This one's subtle and dangerous. AI generates different error handling patterns depending on the prompt context:
typescript
// In one file, AI generated:try { const result = await fetchData(); return result;} catch (error) { console.error("Failed to fetch:", error); return null;}// In another file, for similar logic:const result = await fetchData().catch(() => undefined);if (!result) throw new ApiError("FETCH_FAILED", 500);// In a third file:const [error, result] = await to(fetchData());if (error) return { success: false, error: error.message };
Three different error handling strategies in the same codebase. Each works individually. Together, they make the system unpredictable. When something fails in production, debugging is a guessing game because you don't know which pattern was used where.
For the first few months of using AI assistants, I thought the solution was better prompting. Give the AI more context, more constraints, more examples. I was wrong.
Prompting helps when it supplies the context a change needs. Make architecture decisions and planned migrations available through the assistant’s supported instruction files and repository context, then verify that the generated code follows them.
The solution isn't better AI. It's better systems around AI.
Figure 1. The assessment groups six dimensions to inspect when reviewing AI-related debt.
Use this proposed triage matrix to evaluate your codebase for AI debt. The score bands are author-selected review prompts, with no calibration study supplied here:
Dimension
Score 1 (Critical)
Score 2 (Concerning)
Score 3 (Healthy)
Pattern consistency
3+ patterns for same concern
2 patterns
1 consistent pattern
Dependency overlap
Multiple libs for same purpose
Occasional duplication
Clean dependency tree
Code duplication
> 10% duplicate ratio
5-10%
< 5%
Error handling
Inconsistent across files
Mostly consistent
Single pattern enforced
Test quality
Tests mirror implementation
Tests cover happy path
Tests cover contracts
Naming conventions
Mixed styles
Mostly consistent
Enforced by linting
Score yourself: Add up your scores across all 6 dimensions.
6-9: You have an AI debt crisis. Stop generating and start consolidating.
Custom ESLint rules beat code review for pattern enforcement. Here's why: reviewers miss pattern violations because the code "looks right." Linters don't have that bias.[4]
AI code generation isn't going away. The teams that thrive will be the ones that treat AI output like they treat any other external input: with validation, transformation, and quality checks.
The irony is that fixing AI debt requires the same discipline that prevented traditional debt: consistent patterns, automated enforcement, and a culture that values long-term maintainability over short-term velocity.
Start with the assessment matrix, investigate the lowest-scoring areas and track the maintenance work they create. Revisit those observations after remediation to judge whether the changes helped.
Frequently asked questions
How can a team identify AI technical debt?
Compare repeated logic, dependency overlap, error handling and naming conventions across the codebase. Use the article’s matrix to organise a review, then investigate the concrete modules behind each weak area.
Does a low assessment score prove AI caused the debt?
The matrix is a proposed triage aid. Its thresholds do not establish causation or isolate AI from existing architecture, team practices and delivery pressures, so inspect the history of each issue before attributing it.
Where should the first remediation effort go?
Start with repeated code and conflicting patterns that cause maintenance work. Record the intended approach in the architecture documentation and add automated checks for rules that can be expressed precisely.
Can better prompts solve the whole problem?
Prompts can supply relevant context and conventions. The article also recommends duplication analysis, automated enforcement and regular review so the team can detect mismatches that remain in generated changes.
Five predictions for where code intelligence is heading by 2028, based on 6 years of building tools in this space. Includes what's real, what's overhyped, and a maturity model for planning.
Most code quality dashboards fail because they track too many metrics and live outside the team's workflow. Here are exactly 7 metrics and a 3-week adoption plan that actually works.
Architecture fitness functions are automated tests for your system's structural properties. Here's how to implement the 5 most impactful ones and integrate them into your CI pipeline.
A 3-tier succession planning framework for engineering orgs, with a 90-day sprint for accelerating candidates from potential to ready. Based on succession plans built at 4 companies.
The CTO's real job in product development isn't attending every meeting or making every technical call. It's connecting feasibility, viability, and capacity while letting EMs handle the day-to-day.
Four years of data from a fully remote engineering team across 4 time zones. Specific metrics on productivity, retention, and onboarding with the frameworks that actually worked.