Building software in a high-growth environment requires constant speed. To meet tight deadlines, you inevitably make trade-offs: hardcoding temporary variables, skipping edge-case validation, or pushing untested microservices into production. Early on, taking shortcuts isn't a flaw—it is a survival mechanism.
The problem starts when technical debt accumulates without a clear classification system. Engineering teams frequently fall into one of two traps: either spending weeks refactoring working code (paralyzing product velocity), or completely ignoring messy code until a critical outage occurs during peak traffic.
To scale a backend cleanly without slowing down development, you need a system to classify, track, and triage technical debt.
The Four Types of Technical Debt
Treating all technical debt as a single, urgent problem leads to poor decisions. Instead, categorize every debt item into one of four distinct buckets:
- Toxic Debt: Bugs or vulnerabilities in core flows like authentication, payments, or security. This is an emergency and requires an immediate fix.
- Friction Debt: Poorly structured abstractions, missing integration tests, or messy code paths that engineers modify daily. It doesn't break production, but it slows down sprint velocity and hurts developer morale. Refactor this iteratively.
- Dormant Debt: Ugly, unoptimized code sitting in a legacy module that rarely changes and never breaks. The best decision here is to leave it alone.
- Blocker Debt: Architectural constraints that prevent you from launching a major new feature or expanding to new infrastructure. Addressing this is a strategic product decision, not a quick refactoring task.
Logging Debt Directly in Code
Shortcuts become dangerous when nobody remembers why or where they were taken. Rather than relying on forgotten backlog tickets, track technical debt directly inside your codebase using explicit metadata.
You can enforce this in Python using custom decorators or standardized comment markers that make debt visible during runtime and static analysis:
import functools
import logging
from typing import Callable
def track_debt(debt_type: str, ticket_id: str):
"""
Decorator to log technical debt context at runtime.
debt_type options: 'toxic', 'friction', 'dormant', 'blocker'
"""
def decorator(func: Callable):
@functools.wraps(func)
def wrapper(*args, **kwargs):
if debt_type == "toxic":
logging.error(
f"[CRITICAL DEBT] Executing toxic function '{func.__name__}'. "
f"Must be resolved in ticket {ticket_id}."
)
return func(*args, **kwargs)
return decorator
return decorator
@track_debt(debt_type="friction", ticket_id="ENG-402")
def calculate_cart_discount(cart_items: list) -> float:
# TODO(DEBT-FRICTION): Hardcoded rules bypass discount engine
total = sum(item['price'] for item in cart_items)
return total * 0.90 if total > 100 else total
Automating Triage in Your CI/CD Pipeline
Once debt is explicitly tagged, you can write lightweight scripts to enforce documentation rules during pull requests. This prevents engineers from adding untracked shortcuts.
Here is a Python script you can run in your CI pipeline to parse code changes and ensure every TODO is tied to a recognized debt category:
import re
import sys
from pathlib import Path
DEBT_PATTERN = re.compile(r"TODO\(DEBT-(TOXIC|FRICTION|DORMANT|BLOCKER)\):")
def audit_codebase(directory: str):
failed = False
for path in Path(directory).rglob("*.py"):
with open(path, "r", encoding="utf-8") as file:
for line_num, line in enumerate(file, 1):
if "TODO" in line and not DEBT_PATTERN.search(line):
print(f"CI Error: Unstructured TODO found at {path}:{line_num}")
print(f" --> {line.strip()}")
failed = True
if failed:
sys.exit(1)
if __name__ == "__main__":
audit_codebase("./src")
Integrating Debt Triage Into Sprints
With debt categorized and tracked, establish clear rules for how each type is handled during sprint planning:
- Toxic Debt: Bypasses standard sprint planning and gets patched immediately via hotfix.
- Friction Debt: Allocate 10-15% of your sprint capacity exclusively to refactoring friction debt in components touched by active tasks.
- Dormant Debt: Reject backlog tickets aimed at cleaning up stable, untouched legacy modules.
- Blocker Debt: Plan dedicated architectural rework sprints alongside your product roadmap.
A shortcut taken with a clear plan and explicit tracking is a calculated risk. A shortcut forgotten in your codebase is an outage waiting to happen.
About me
Tanmay builds AI agents and automation for businesses and is open to freelance projects. Feel free to connect with me on LinkedIn.
Top comments (0)