UNIXDEV

Technical debt in the AI era: keeping AI-assisted code maintainable

How AI-assisted coding adds technical debt and how to control it: pull-request review, CI gates, an internal AI policy and contract terms for vendors.

By UNIXDEV Team · 20 min read
Original published · English edition

Diagram of AI-assisted code passing human review and CI gates before merge, with remaining debt logged as tickets to repay in later iterations

AI coding assistants make code faster to write, not easier to maintain. Technical debt grows when the volume of code outpaces a team's capacity to review, test and understand it. The controls that hold it back are a human owner for every line, small changes, CI gates that actually block, and explicit rules on AI use in internal policy and in development contracts.

AI coding assistants here means tools such as GitHub Copilot, Cursor, Claude Code, ChatGPT or Gemini; the controls apply to any of them.

In short: (1) whoever opens a pull request owns and can explain every line in it, whoever or whatever wrote it; (2) keep changes small enough to review properly; (3) check AI-written tests against the requirement, not only that they pass; (4) make CI block vulnerable or unapproved dependencies, leaked secrets and failing tests; (5) record technical debt as visible work and reserve time each iteration to pay it down; (6) when you outsource, put AI-use disclosure, review evidence and scan reports into the terms of reference or contract.

What technical debt means

Technical debt is a metaphor for shortfalls in a system's internal quality: the extra effort every later change costs is the interest, and cleaning the code up is repaying the principal.

Ward Cunningham introduced it in his OOPSLA 1992 experience report, The WyCash Portfolio Management System: "Shipping first time code is like going into debt. A little debt speeds development so long as it is paid back promptly with a rewrite." and "Every minute spent on not-quite-right code counts as interest on that debt." Martin Fowler's article on technical debt describes the cruft (the untidy parts of the code) as "deficiencies in internal quality that make it harder than it would ideally be to modify and extend the system further".

Debt is not always a mistake. Fowler's Technical Debt Quadrant sorts it on two axes, deliberate or inadvertent and prudent or reckless. Taking on debt knowingly to hit a date, with a plan to repay it, can be a sound business decision. AI-generated code merged without anyone really understanding it is reckless debt, and if nobody notices, inadvertent too; the team usually discovers it only when the code has to change.

Why AI-assisted coding can increase technical debt

AI does not invent a new kind of debt; it changes how fast and in what shape debt accumulates. Code arrives faster than people can read and understand it, and it usually looks plausible enough to survive a quick read.

Google's DORA research on software delivery has picked up the signal. The announcement of the 2024 report (23 October 2024) states: "As AI adoption increased, it was accompanied by an estimated decrease in delivery throughput by 1.5%, and an estimated reduction in delivery stability by 7.2%." The same paragraph says a better development process does not improve delivery without "small batch sizes and robust testing mechanisms".

The same announcement also associates higher AI adoption with better documentation quality, code quality and code review speed, so the picture is mixed rather than one-sided. These are survey-based associations, not proof that AI is the cause.

The 2025 report (announced 24 September 2025 and titled State of AI-assisted Software Development) finds a positive relationship between AI adoption and delivery throughput, but adds that "AI adoption does continue to have a negative relationship with software delivery stability," because "Without robust control systems, like strong automated testing, mature version control practices, and fast feedback loops, an increase in change volume leads to instability."

How AI-assisted coding adds technical debt, and the control for each mechanism
MechanismEvidenceControl
Change volume outgrows review and testing capacityDORA 2024 and 2025 (above)Small pull requests, automated tests, CI gates
Plausible but insecure code, written by people who feel more confidentPearce et al.; Perry et al. (below)Review checklist, static analysis triaged by a person
Suggested packages that do not exist or are unsafeSpracklen et al. (USENIX Security 2025); OWASP LLM09:2025Dependency review, lockfiles, a package allow-list
New code written instead of reusing what the system hasNIST SSDF PW.4Reuse check in review, duplication report in CI
No knowledge of business rules, team conventions or architectural reasonsGitHub Docs; ETDA guidelineADRs, a repository conventions file, a reviewer who knows the domain
The same assistant writes the code and the tests that check itGitHub DocsReview tests against requirements; catch deleted or skipped tests
Unknown provenance and licences of code or dependenciesNIST SSDF PS.3.2; OWASP LLM03:2025SBOM, licence checks, provenance terms in the contract

Code that looks right but is insecure

Generated code compiles and reads sensibly, yet can be vulnerable. In Asleep at the Keyboard? (IEEE Symposium on Security and Privacy 2022), Pearce et al. had an early version of GitHub Copilot complete 89 scenarios, producing 1,689 programs, and found "approximately 40% to be vulnerable". The study tested a 2021 model, so the figure does not carry over to later tools, but the lesson does: code that looks correct still needs a security check.

The people matter as much as the code. In Do Users Write More Insecure Code with AI Assistants? (ACM CCS 2023), Perry et al. found that participants with an AI assistant wrote significantly less secure code and "were more likely to believe they wrote secure code"; those who trusted the assistant less and worked harder on their prompts produced fewer vulnerabilities.

Packages that do not exist

An assistant may tell you to install a package that does not exist, and an attacker can register that name and publish malicious code under it. Spracklen et al., in We Have a Package for You! (USENIX Security Symposium 2025), tested 16 LLMs on 576,000 code samples in two languages and found average hallucinated-package rates of "at least 5.2% for commercial models and 21.7% for open-source models", with 205,474 unique hallucinated package names.

OWASP LLM09:2025 Misinformation lists this under unsafe code generation, "The model suggests insecure or non-existent code libraries, which can introduce vulnerabilities", and among its mitigations: "Ensure that human reviewers are properly trained to avoid overreliance on AI-generated content."

Duplication instead of reuse

When a new function costs seconds to generate, writing one is easier than finding out whether the system already has it. The same logic ends up in several places, and every change to a business rule has to be made several times. The NIST Secure Software Development Framework (SSDF, SP 800-218) has a practice for exactly this, PW.4: "Reuse Existing, Well-Secured Software When Feasible Instead of Duplicating Functionality". It works as a review criterion as it stands.

Context the assistant does not have

An assistant sees only the prompt and the files its tool sends it. It does not know business rules held in people's heads, the team's conventions or why the architecture is the way it is. GitHub's guide to reviewing AI-generated code warns: "Be skeptical of code that 'looks right' but doesn't match your intent." Thailand's Electronic Transactions Development Agency (ETDA) makes the same point in its generative AI guideline for organisations (covered below): generative AI can produce answers that seem reasoned but are factually wrong, and its output cannot replace domain expertise.

What AI does not change

Technical debt is still a decision made by people and management, not a side effect of a tool. Teams that already have automated tests, real review and a way to record debt gain more from AI than teams that do not.

The DORA 2025 report puts it this way: "AI's primary role is as an amplifier, magnifying an organization's existing strengths and weaknesses." Its announcement is shorter still: "AI doesn't fix a team; it amplifies what's already there."

The bottleneck moves from writing to reviewing and understanding. If the number of people who really know the system stays the same while everyone produces code faster and review works as before, you get either a longer review queue or shallower reviews, and both add debt.

How to control quality in each pull request

Hold AI-assisted code to the same standard as any other code, add checks aimed at the mechanisms above, and make the person who opens the pull request answerable for all of it.

The author owns every line

Whoever opens the pull request must be able to say what the code does, why this approach and how it was tested. If they cannot, it is not ready for review. Write this into the team's Definition of Done; the wider Definition of Done for commissioned work is in keeping a software project on budget.

Changes small enough to read

An assistant can produce hundreds of lines at once; a reviewer cannot read them any faster. Google's engineering practices list why small changes help: they are "Reviewed more thoroughly.", "Less likely to introduce bugs." and "Simpler to roll back.", and each should be self-contained and address one thing. Split large generated work into several pull requests before asking for review.

A review checklist for AI-assisted code

NIST SSDF separates code review (a person reads the code) from code analysis (tools check it) in PW.7.1, and PW.7.2 gives the example "Use review checklists to verify that the code complies with the requirements." These are the items worth adding for AI-assisted code, drawn from GitHub's guide and the mechanisms above:

  • Matches the requirement: the code does what the ticket asks, no more and no less, and does not quietly change behaviour elsewhere.
  • New dependencies: each new package exists, is actively maintained, has a licence compatible with this system and is actually needed. GitHub warns about "hallucinated or suspicious packages (such as packages that don't actually exist), or slopsquatting", which GitHub describes as "a theoretical attack on LLMs using fake or malicious packages": registering names that assistants tend to invent.
  • Reuse first: does the system already have a function, library or pattern for this?
  • Tests: the tests check the requirement rather than restating what the code does, and nothing was removed to make them pass. GitHub: "Watch for tests that are deleted or skipped, instead of fixed."
  • Security: input handling, authorisation checks, database queries and secrets follow the team's standards.
  • Conventions: naming, structure, error handling and logging match the rest of the system.

Review depth by risk

Not every pull request needs the same scrutiny. We suggest each team decides which areas require a second reviewer, for example authentication and authorisation, payments, personal data, database migrations and infrastructure, while low-risk changes such as UI text or documentation get normal review. Then configure that list as an approval rule in your code-hosting platform so it is enforced, not remembered.

AI review supplements human review

AI code review tools can flag suspicious code, but GitHub does not position its own as a replacement for people. GitHub's responsible-use note says "Copilot code review should be supplemented with careful human code review." and that it may report problems that do not exist. Treat AI findings as input; approval stays with a person.

Which CI gates matter for AI-assisted code

A CI (continuous integration) gate is an automated check that must pass before a merge. A gate that only warns teaches people to ignore it. These gates apply to every line regardless of who or what wrote it; CI/CD basics are in the hidden costs of DevOps.

CI gates and the debt mechanism each one catches
GateCatchesNotes
Lint and type checksCode outside team conventions; wrongly shaped API callsUse the rule set the team already has
Automated testsUnintended behaviour changesSSDF PW.8.2 suggests adding tests for previously reported vulnerabilities "to ensure that errors are not reintroduced"
Coverage on changed linesNew code without testsThe team sets the threshold; measure only what the pull request changes
SAST (static application security testing)Insecure code patternsSSDF PW.7.2 has a person review what the tool reports
Dependency review or SCA (software composition analysis)Packages with known security flaws; disallowed licencesSSDF PW.4.4 example: "automatic detection of known vulnerabilities in software components"
Lockfile and package allow-listNon-existent or unvetted packagesA new dependency needs explicit approval
Secret scanningPasswords, tokens and keys committed to the repositorySome platforms check at push time
Duplication reportThe same logic in several placesBetter as reviewer input than as a blocker

Two GitHub examples (on another platform, check whether it has an equivalent): dependency review shows the dependency changes in each pull request with vulnerabilities and licences, and "A failed check blocks a pull request from being merged when the repository owner requires the dependency review check to pass." Note the condition, "when the repository owner requires": a gate only works once it is made mandatory. Push protection stops secrets from reaching the repository at push time.

For systems that are delivered or formally accepted, produce an SBOM (software bill of materials) for every release, in line with SSDF PS.3.2: "Collect, safeguard, maintain, and share provenance data for all components of each software release". Using SBOM and SCA tools on an existing system is covered in taking over an undocumented system.

Give the assistant context: ADRs and a conventions file

The way to get less code that does not fit is to write down, in the repository, the context that lives in people's heads. The same files help new team members.

  • Architecture decision records (ADRs): Michael Nygard's Documenting Architecture Decisions (2011) proposes one short text file per decision, with Title, Context, Decision, Status and Consequences. When an assistant or a newcomer proposes undoing a past decision, the ADR says why it was made.
  • A repository conventions file: one example is GitHub Copilot, which reads .github/copilot-instructions.md, and GitHub's documentation says "Repository-wide custom instructions apply to all requests made in the context of a repository." For any other tool, check its documentation for an equivalent. Include languages and frameworks, folder layout, how tests are written, allowed and banned libraries, and links to the ADRs.

These files make output fit the system better, but they enforce nothing. Enforcement is still review and CI.

How to tell whether debt is rising

Measure outcomes, not how many lines the assistant wrote. If a team ships more often but also has to fix more deployments in a hurry, debt is growing.

DORA defines five software delivery metrics in two groups:

  • Throughput: change lead time ("The amount of time it takes for a change to go from committed to version control to deployed in production."), deployment frequency and failed deployment recovery time.
  • Instability: change fail rate ("The ratio of deployments that require immediate intervention following a deployment.") and deployment rework rate ("The ratio of deployments that are unplanned but happen as a result of an incident in production.").

The two instability metrics map most directly onto DORA's warning about stability. Teams can add their own internal signals, such as how long pull requests wait for review, defects that reach users and work that has to be redone. Record a baseline before adopting AI tools or changing how you work, then set your own targets; there is no universal number.

Record debt as tickets

Debt nobody records never gets prioritised. We recommend logging it as tickets in the same backlog as other work, noting where it is, what it affects and what it was traded for, and reserving part of every iteration to pay it down. The size of that share is for the team and the product owner to agree from the metrics above.

What an internal AI coding policy should cover

A policy should answer three questions: which tools may be used, what code and data may be sent to an external AI service, and who is accountable for the output. Without one, every developer decides alone.

Organisations in Thailand can start from the Generative AI Governance Guideline for Organizations published by the AI Governance Center (AIGC) of ETDA, the Thai government agency for electronic transactions, and announced with the Ministry of Digital Economy and Society on 30 October 2024. It is voluntary guidance, not law, and says so itself. It:

  • names source code generation and optimisation as an organisational use case;
  • lists risks that apply directly to software work, including confabulation (hallucination), over-trusting output without checking, information security, intellectual property, and value chain and component integration;
  • recommends defined roles and accountability, human oversight to avoid over-reliance, and risk assessment of external tools, models and datasets.

For code and data leaving the organisation, read each provider's own data-use terms (retention, whether data trains models, where it is stored), and do not treat a tool setting as a security boundary.

GitHub Copilot's content exclusion keeps chosen files out of the tool, yet GitHub states it is "not a filesystem security boundary" and no substitute for operating-system permissions or other access controls. Files that must never leave, such as secrets or customer data, should not be readable by the tool in the first place.

If prompts or code sent to an AI service contain personal data, the cross-border transfer and data-processor rules of Thailand's Personal Data Protection Act (PDPA) are covered in our RAG guide for Thai organisations.

Outsourcing to a vendor that uses AI: questions and contract terms

A vendor using AI is not the problem; not knowing how they use it and check the result is. Ask before you choose, and write the evidence you expect into the terms of reference (TOR, the specification document Thai public and private buyers issue for bids) or the contract.

General questions on QA and ownership are in our ten checks for choosing a software development company. The AI-specific additions:

Ask: "Which AI tools will your team use on our project, how are their data-use settings configured, and where will our code or data be sent? Who reviews AI-assisted code, and can we see an example of a reviewed pull request? What do your CI gates block? How do you vet new packages and licences?"

Terms worth including (have your own legal counsel word them):

  • Disclosure of AI use: the vendor names the tools used and confirms their data-use terms meet your policy.
  • Review and test evidence for each milestone: code in your repository, with pull-request history, reviewers and automated test results.
  • Scan reports for each milestone: SAST, dependency/SCA and secret-scanning results, with open items and reasons.
  • SBOM and licences: an SBOM for every release and a licence inventory, in line with SSDF PS.3.2 and OWASP LLM03:2025, which recommends you "create an inventory of all types of licenses involved using BOMs and conduct regular audits".
  • Provenance: the vendor warrants it has checked the origin and licences of delivered code and states how. Some tools have settings that help, such as GitHub Copilot's code referencing, which compares suggestions with public code so that "matching suggestions can be blocked or shown with information about the matching code".
  • A maintainable handover: ADRs and the repository conventions file are deliverables. The full handover list is in our vendor handover checklist.

NIST SSDF describes itself as a common vocabulary buyers can use with suppliers, so citing practice IDs such as PW.4, PW.7, PW.8 and PS.3 in a TOR makes clear what evidence is expected. NIST also publishes SP 800-218A (July 2024), an SSDF community profile for AI model development, aimed at model producers, producers of AI systems that use those models and their acquirers; it does not cover using AI to write code.

On copyright in AI-assisted code we give no legal view. As one example from abroad, the US Copyright Office addressed the copyrightability of outputs created using generative AI in Copyright and Artificial Intelligence, Part 2: Copyrightability (29 January 2025). Put ownership and warranties in the contract and take legal advice. The default rule for commissioned work under Thailand's Copyright Act is summarised in check 6 of the vendor selection guide, and scope and budget control during a project in keeping a software project on budget.

Status as of 2026-11-17: standards, reports and features cited

These facts change; check the source page before writing them into a TOR or a policy.

Status of the standards, reports and features cited, checked on 2026-11-17
ItemStatus per the source pageSource
NIST SSDF v1.1SP 800-218 Version 1.1 final, published February 2022NIST CSRC
NIST SSDF v1.2 (draft)SP 800-218 Rev. 1 (SSDF Version 1.2) Initial Public Draft dated 17 December 2025NIST CSRC
NIST SP 800-218APublished July 2024; SSDF community profile for AI model development, for model producers, producers of AI systems that use those models and their acquirersNIST CSRC
OWASP Top 10 for LLM Applications2025 edition, including LLM03:2025 Supply Chain and LLM09:2025 Misinformation; written for LLM applications, not specifically for coding assistantsOWASP GenAI
DORA metricsFive metrics in throughput and instability groups; page last updated 5 January 2026dora.dev
DORA reports2024 report announced 23 October 2024 · 2025 report announced 24 September 2025 as State of AI-assisted Software Development2024, 2025
Copilot repository instructionsRead from the copilot-instructions.md file in the .github folderGitHub Docs
Copilot content exclusionAvailable on Copilot Business and Copilot Enterprise; not a filesystem security boundaryGitHub Docs
Copilot code referencingBlocks or annotates matches with public code, per policyGitHub Docs
ETDA generative AI guidelineVolume 1 (August 2024), announced 30 October 2024; voluntary guidance, not lawETDA

Checklist: keeping AI-assisted code under control

The checklist has four parts: organisation policy, every pull request, CI gates and the vendor contract. Copy it as a starting point and adjust it to your team size and system risk.

Organisation policy

  • Approved AI tools, with each one's data-use terms read and recorded
  • Code and data that must not be sent to external AI services, kept out by access controls rather than tool settings alone
  • A policy owner and a review cycle
  • "The pull-request author owns all of it" written into the Definition of Done

Every pull request

  • The author can explain what the code does and how it was tested
  • One purpose, small enough to review properly
  • Meets the requirement and reuses existing functions or libraries before writing new ones
  • New dependencies exist, are maintained, have acceptable licences and are approved
  • Tests check the requirement; none deleted or skipped
  • High-risk areas get a second reviewer, per the team's list

CI gates

  • Lint, type checks and automated tests must pass before merge
  • Coverage on changed lines meets the team's threshold
  • SAST, with findings triaged by a person
  • Dependency review or SCA blocking known vulnerabilities and disallowed licences
  • Lockfile and package allow-list
  • Secret scanning from push time
  • Every gate set as required, not advisory

Vendor contract

  • Disclosure of AI tools used and their data-use terms
  • Code in your repository with pull-request and reviewer history
  • Test results and SAST, SCA and secret-scanning reports at each milestone
  • SBOM and licence inventory for every release
  • Provenance and licence warranty, worded by your legal counsel
  • ADRs and the repository conventions file as deliverables

How UNIXDEV can help

UNIXDEV's custom software development runs on a process certified to ISO/IEC 29110-4-1:2018 by SGS Thailand, with sprint cadence, code review, automated tests, retrospectives and a risk log that can be inspected.

Where an existing system has accumulated debt to the point that changes are risky, our legacy application maintenance service starts by assessing the source code, dependencies and the parts without tests, then ranks the risks before improving the system step by step.

Our DevOps work sets up pipelines that really test and gates that can block. If a system is too far gone to repay in pieces, see the options in legacy system modernization.

Sources and further reading

Sources checked on 2026-11-17

How we checked: based on the primary sources above, reviewed by the UNIXDEV team

Continue reading