Software Development

Technical Debt Explained: How to Measure and Reduce It

December 5, 2026 · 12 min read

Technical Debt Explained: How to Measure and Reduce It

Every software team takes shortcuts. A hard-coded value to hit a launch date, a copy-pasted function, a missing test, a library left three major versions behind. Each one is a small loan against the future, and like any loan it charges interest: every later change in that area takes longer and breaks more often. That accumulated cost is technical debt, and left unmanaged it can quietly consume a large share of an engineering budget.

Debt is not always bad. Taken on deliberately, it lets you learn faster and reach the market sooner. The problem is debt nobody tracks, measures or repays. This guide explains what tech debt is, the main types, what it costs, how to measure it with real data, including a tested script that finds hotspots in your Git history, and a practical plan to reduce it without stopping feature work.

What Is Technical Debt?

Ward Cunningham introduced the debt metaphor in 1992 to explain to business colleagues why code sometimes needs reworking. Shipping code that reflects your current, incomplete understanding is like borrowing money: it speeds you up today. If you then refactor the code as your understanding improves, you repay the loan. If you never do, you keep paying interest in the form of slower, riskier changes.

The useful insight is that debt is measured by its effect on change. A messy module that nobody ever touches costs almost nothing. A slightly untidy module that changes every week can cost a great deal, because every developer pays the interest every time. This is why measuring where debt hurts matters more than counting every imperfection.

Types of Technical Debt

Martin Fowler's technical debt quadrant separates debt by intent and by prudence. It helps teams discuss debt without blame:

RecklessPrudent
Deliberate"We don't have time for design." Shortcuts taken knowingly, with no plan to repay."We must ship now and will deal with the consequences." A conscious trade-off with a repayment plan.
Inadvertent"What's layering?" Debt created through lack of skill or knowledge."Now we know how we should have done it." Learning that only arrives after building.

Debt also shows up in different layers of a system:

  • Code debt: duplication, long functions, unclear names and tangled conditionals. Our guide to clean code covers the habits that prevent it.
  • Architecture debt: wrong boundaries between modules or services, shared databases and tight coupling that make every change touch many places.
  • Test debt: missing or slow tests, so nobody dares to refactor.
  • Dependency and infrastructure debt: outdated frameworks, unsupported runtimes and manual deployment steps.
  • Documentation debt: docs that no longer match behaviour, including stale API documentation that misleads every integrator.
  • Security debt: known vulnerabilities and weak defaults left unpatched because fixing them was never prioritised.

What Technical Debt Really Costs

Estimates vary widely because organisations define and measure debt differently, but they all point the same way. Keyhole Software's compilation of tech debt statistics brings several studies together:

  • CIOs surveyed by McKinsey in 2020 estimated that 10 to 20% of the technology budget meant for new products is diverted to resolving debt-related issues.
  • The Consortium for Information and Software Quality (CISQ) estimated the accumulated technical debt in US software at about $1.52 trillion in 2022.
  • Sonar's 2026 developer research found developers spend around 24% of their working week on toil, with 41% naming the management of tech debt among their top five sources of it.

Treat these as directional rather than precise. The cost inside your own organisation shows up as slower delivery, more incidents, harder onboarding and engineers who leave because every change feels like defusing a bomb.

Warning Signs Your Codebase Has Too Much Debt

  • Simple changes regularly take days and need several people who "know that part".
  • The same areas produce bugs release after release, and fixes cause new bugs elsewhere.
  • Developers avoid certain files, or add workarounds around them rather than changing them.
  • Tests are slow, flaky or missing, so releases rely on manual checking.
  • Upgrading a framework or runtime is postponed every quarter because it is "too risky".
  • New developers need weeks before they can ship confidently.
  • Debugging takes longer than fixing. Our guide to debugging techniques helps in the short term, but the root cause is usually structural.

How to Measure Technical Debt

No single number captures debt, so combine a few signals that point to where it hurts. Track them over time rather than chasing a perfect score.

MetricWhat it tells youHow to collect it
Hotspots (churn × complexity)Where debt actually slows the team downGit history plus a complexity measure, as in the script below
Lead time and change failure rateWhether delivery is getting slower or riskier over timeDORA metrics from your CI/CD and incident tools
Defect density by moduleWhich areas produce the most bugsIssue tracker labels joined to code paths
Technical debt ratioEstimated fix effort relative to build effortStatic analysis tools such as SonarQube
Dependency age and known vulnerabilitiesHow far behind supported versions you areDependabot, Renovate or npm audit reports
Developer survey scoresWhere engineers feel friction every dayA short quarterly survey: which areas are painful to change?

Static analysis is a good start but can mislead on its own, because it treats every issue as equally urgent. Combining code quality with change frequency, an approach popularised by Adam Tornhill's book Your Code as a Crime Scene, focuses attention on the small part of the codebase where debt is actually charging interest.

Find Technical Debt Hotspots With Git

The script below ranks files by commits in a period multiplied by a simple complexity measure: the number of decision points such as if, for, case, and and or. It needs only Python and Git. To make the output reproducible, the first script builds a small demo repository with a realistic history: a billing module that changes every sprint and keeps growing conditionals, a utility file that changes often but stays simple, a moderately complex auth module and a very complex legacy parser that nobody has touched this year.

# make-repo.sh - build a small demo repository with a realistic change history
set -euo pipefail
git init -q demo && cd demo
git config user.email dev@example.com && git config user.name Dev
mkdir -p src
week=0
commit() { # commit <message>, dated one week after the previous commit
  local when; when=$(date -u -d "2026-01-05 + $((week * 7)) days" +%Y-%m-%dT10:00:00)
  week=$((week + 1))
  git add -A && GIT_AUTHOR_DATE="$when" GIT_COMMITTER_DATE="$when" git commit -qm "$1"
}

# legacy.js: very complex but last touched in 2025, so lower priority
printf 'export function parse(x) {\n' > src/legacy.js
for i in $(seq 1 30); do printf '  if (x === %d || x === -%d) return %d;\n' "$i" "$i" "$i" >> src/legacy.js; done
printf '}\n' >> src/legacy.js
git add -A && GIT_AUTHOR_DATE=2025-03-01T10:00:00 GIT_COMMITTER_DATE=2025-03-01T10:00:00 git commit -qm "legacy parser"

# auth.js: moderate complexity, changed a few times
printf 'export function canEdit(user, doc) {\n  if (!user) return false;\n  if (user.role === "admin") return true;\n  return doc.ownerId === user.id && !doc.locked;\n}\n' > src/auth.js
commit "auth: canEdit"
printf 'export function total(cart, user) {\n  let sum = 0;\n' > src/billing.js
printf '  for (const item of cart.items) sum += item.price || 0;\n  return sum;\n}\n' >> src/billing.js
commit "billing: first version"

for i in $(seq 1 12); do
  # billing.js: complex and changed every sprint, the classic hotspot
  sed -i "3i\\  if (cart.coupon === \"C$i\" \&\& user.tier !== \"free\") sum -= $i;" src/billing.js
  commit "billing: handle coupon C$i"
  # utils.js: changed often but simple, so cheap to change
  if (( i % 2 == 0 )); then printf 'export const v%d = %d;\n' "$i" "$i" >> src/utils.js; commit "utils: add v$i"; fi
done

printf 'export function canView(user, doc) {\n  return doc.public || (user && doc.team === user.team);\n}\n' >> src/auth.js
commit "auth: canView"
# hotspots.py - rank files by change frequency x complexity (run inside a git repo)
# usage: python3 hotspots.py [--since 2026-01-01] [--top 5]
import argparse, re, subprocess
from collections import Counter
from pathlib import Path

ap = argparse.ArgumentParser()
ap.add_argument("--since", default="12 months ago")
ap.add_argument("--top", type=int, default=5)
args = ap.parse_args()

# 1. Churn: how many commits touched each file in the period
log = subprocess.run(["git", "log", f"--since={args.since}", "--name-only", "--format="],
                     capture_output=True, text=True, check=True).stdout
churn = Counter(line for line in log.splitlines() if line.endswith((".js", ".ts", ".py")))

# 2. Complexity proxy: decision points (if, for, while, case, catch, &&, ||, ?)
DECISIONS = re.compile(r"\b(if|for|while|case|catch)\b|&&|\|\||\?")
def complexity(path):
    text = Path(path).read_text(errors="ignore")
    return 1 + sum(len(DECISIONS.findall(line)) for line in text.splitlines())

rows = []
for path, commits in churn.items():
    if Path(path).exists():
        cx = complexity(path)
        rows.append((commits * cx, commits, cx, path))

print(f"{'score':>6} {'commits':>8} {'complexity':>11}  file")
for score, commits, cx, path in sorted(rows, reverse=True)[: args.top]:
    print(f"{score:>6} {commits:>8} {cx:>11}  {path}")

Run both, then compare with a churn-only view built from a Git one-liner:

bash make-repo.sh
cd demo
python3 ../hotspots.py --since 2026-01-01

# Churn alone, with no script at all:
git log --since=2026-01-01 --name-only --format= | sort | uniq -c | sort -rn | head -3

Output:

 score  commits  complexity  file
   351       13          27  src/billing.js
    12        2           6  src/auth.js
     6        6           1  src/utils.js

     13 src/billing.js
      6 src/utils.js
      2 src/auth.js

Three lessons stand out. The billing module scores far higher than anything else, so that is where refactoring pays back first. The utility file changes almost as often but is simple, so its debt costs little. The legacy parser, the most complex file in the repository, does not appear at all: since nobody changes it, its debt charges no interest right now. Fixing it first would be the classic mistake of spending refactoring time where it buys nothing. In a real project, run the script against twelve months of history and review the top ten files with the team.

How to Reduce Technical Debt

Paying down debt works best as a steady habit rather than a heroic rewrite.

  1. Keep a debt register. Record each known item with its location, impact, estimated effort and the risk of leaving it. Review it at planning.
  2. Reserve capacity. Many teams set aside a fixed share of each sprint, often somewhere between 10 and 20%, for refactoring, upgrades and tests, so debt work never has to win a priority fight.
  3. Refactor hotspots first. Use the data above to pick the files where improvements will speed up the most future work.
  4. Add tests before you refactor. Characterisation tests capture current behaviour so you can change structure safely. See unit vs integration testing and test-driven development.
  5. Follow the boy scout rule. Leave every file a little cleaner than you found it, especially files you touch for features.
  6. Replace large legacy parts gradually. The strangler fig pattern routes traffic to new components piece by piece, described in our guide to software architecture patterns.
  7. Automate dependency updates with Renovate or Dependabot, so upgrades arrive as small, frequent pull requests instead of a yearly crisis.
  8. Stop adding new debt carelessly. Strengthen your definition of done and use code review to question shortcuts that have no repayment plan.

AI-Generated Code and New Debt

AI coding assistants write code quickly, but speed without review creates debt quickly too. In Sonar's 2026 research, cited in the Keyhole compilation, 53% of developers said AI-generated code had looked correct but turned out to be unreliable. Duplicated logic, unused abstractions and code nobody on the team fully understands are all common outcomes. Treat AI output like any contributor's code: require tests, review it carefully and refactor before merging. Our guides to AI coding agents and vibe coding discuss where these tools help and where they need guard rails.

Explaining Tech Debt to Non-Technical Stakeholders

Business leaders rarely respond to "the code is messy". They respond to time, money and risk. Translate debt into those terms: "Changes to checkout take three times longer than elsewhere and caused four of our last six incidents. Two sprints of refactoring would cut feature time there by about half." Use your hotspot data, incident history and lead times as evidence, propose a fixed budget, and report the results afterwards. Debt work earns trust when it delivers measurable improvements.

Frequently Asked Questions

What is technical debt in simple terms?

It is the future cost of shortcuts and imperfect decisions in software. Like financial debt, it charges interest: each later change in the affected area takes longer and carries more risk until the debt is repaid.

Is technical debt always bad?

No. Deliberate, prudent debt can help you ship and learn faster. It becomes harmful when nobody records it, it grows in frequently changed code, or there is no plan to repay it.

How do you measure technical debt?

Combine signals: hotspots from Git history and complexity, delivery metrics such as lead time and change failure rate, defect density, static analysis results, dependency age and developer surveys.

How much time should teams spend on tech debt?

There is no universal figure, but many teams reserve a fixed share of each sprint, often 10 to 20%, and adjust it based on measured hotspots and incident trends.

What causes technical debt?

Common causes include deadline pressure, unclear requirements, missing tests, lack of experience, outdated dependencies, poor communication between teams and accepting AI-generated code without review.

Should we rewrite the system to remove debt?

Rarely. Full rewrites are risky and slow. Incremental refactoring of hotspots, supported by tests and patterns such as the strangler fig, usually delivers value sooner and with far less risk.

Get Help Reducing Technical Debt

We audit codebases, find the hotspots where technical debt slows delivery and refactor them safely while your team keeps shipping. If upgrades keep slipping or releases feel risky, talk to us about a debt reduction plan.

Want this built for you?

Our team offers Website Deploy On Vercel — get a free quote.

View Services