Guides

Reducing Technical Debt

Systematic approach to identifying and reducing technical debt

Technical debt accumulates over time and slows development. This guide shows how to use Stellarion to systematically identify, prioritize, and reduce technical debt.

Understanding Technical Debt

Technical debt includes:

  • Code complexity — Hard to understand and modify
  • Duplication — Same logic in multiple places
  • Poor organization — Files too large, structure unclear
  • Missing abstractions — Copy-paste instead of reuse
  • Outdated patterns — Legacy code not updated

Step 1: Inventory Your Debt

Get a complete picture of technical debt:

Generate a technical debt report for this project.
Include priority and effort estimates.

This identifies:

  • All debt items
  • Severity levels
  • Effort estimates
  • Priority rankings

Step 2: Categorize

Group debt by type to plan your approach:

Complexity Debt

Find all functions with complexity over 20.

Duplication Debt

Find code duplication in this project.

Organization Debt

Are there files over 500 lines or directories with too many files?

Architecture Debt

Check for circular dependencies and tight coupling.

Step 3: Prioritize

Use the debt quadrant to prioritize:

Low EffortHigh Effort
High ImpactDo FirstPlan Carefully
Low ImpactQuick WinsDefer or Skip

High Priority Items

Focus on debt that:

  • Blocks new features
  • Causes frequent bugs
  • Slows down the team
  • Affects critical paths
Show me high-priority technical debt items
that are blocking our API development.

Step 4: Plan

Create a Debt Backlog

List all technical debt items in src/api/
sorted by priority and effort.

Estimate ROI

Consider:

  • Time saved by fixing
  • Risk of leaving unfixed
  • Effort to fix
  • Dependencies on other fixes

Allocate Time

Common approaches:

  • 20% rule: Dedicate 20% of sprint to debt
  • Boy Scout rule: Leave code cleaner than you found it
  • Debt sprints: Occasional sprints focused on debt

Step 5: Execute

Work Incrementally

Don't try to fix everything at once:

What's the smallest change I can make
to reduce complexity in this function?

Test Coverage First

Before refactoring, ensure test coverage:

What test coverage exists for userService.ts?

Use Impact Analysis

Before changing shared code:

What would be affected if I refactor the
database connection module?

Step 6: Measure Progress

Track Metrics Over Time

Generate a quality report.
Save it to docs/reports/quality-2024-01.md

Compare monthly:

  • Average complexity trend
  • Debt item count
  • Maintainability scores

Celebrate Wins

Track improvements:

How has the complexity of src/api/ changed
since last month?

Debt Prevention

Code Review Standards

Use Stellarion in reviews:

Analyze the quality of code in this PR.
Does it introduce new technical debt?

Complexity Budgets

Set limits for new code:

Flag any new functions with complexity over 15.

Architecture Guidelines

Regular architecture reviews:

Analyze the dependency structure.
Are we maintaining clean module boundaries?

Common Debt Patterns

The God Function

Symptom: One function does everything Solution: Extract smaller, focused functions

Help me break down this 200-line function
into smaller pieces.

Copy-Paste Code

Symptom: Same logic in multiple places Solution: Extract shared utilities

Find duplicates of this validation logic
and help me consolidate them.

Circular Dependencies

Symptom: A imports B, B imports A Solution: Extract shared code or restructure

Find circular dependencies in src/
and suggest how to break them.

Deep Nesting

Symptom: Multiple levels of if/else/loops Solution: Use early returns, extract functions

Help me flatten this deeply nested function
using early returns.

Long-term Strategy

  1. Prevent — Set standards for new code
  2. Measure — Regular quality assessments
  3. Prioritize — Focus on high-impact items
  4. Allocate — Dedicate time to debt reduction
  5. Celebrate — Track and share progress