/debt
Track and visualize technical debt across the codebase. Identify, categorize, and prioritize refactoring work with data-driven scoring.
Quick Start
/agileflow:debtRuns a quick scan and generates a debt report with default settings.
Or with custom options:
/agileflow:debt SCAN=full OUTPUT=report THRESHOLD=mediumParameters
| Parameter | Required | Default | Description |
|---|---|---|---|
SCAN | No | quick | Scan depth: quick (flagged areas only) or full (entire codebase) |
OUTPUT | No | report | Output type: report, stories, or both |
THRESHOLD | No | medium | Minimum severity: high, medium, or low |
What It Detects
The debt scanner identifies multiple types of technical debt:
Code Quality Signals
- TODO/FIXME/HACK comments
- Long functions (>50 lines)
- High cyclomatic complexity (>10)
- Duplicated code blocks
- Large files (>500 lines)
- Deep nesting (>4 levels)
- God objects (>10 methods)
- Low test coverage (under 70%)
Story-Based Debt
Searches stories tagged with tech-debt: true or with "refactor" or "cleanup" in the title.
Architecture Debt
Checks ADRs for deprecated decisions or documented negative consequences.
Git History Analysis
- Files with high churn (frequently modified)
- Files with many authors (unclear ownership)
- Old branches not yet merged
Linter Output
Parses output from ESLint, TypeScript, Pylint, SonarQube, and coverage reports.
Debt Categories
Technical debt is organized into seven categories:
| Category | Description | Examples |
|---|---|---|
| Architecture | Wrong abstractions, tight coupling, missing patterns | Service coupling, circular dependencies |
| Code Quality | Duplication, complexity, inconsistent style | Copy-paste code, high complexity |
| Documentation | Missing, outdated, or incomplete docs | Undocumented APIs, stale guides |
| Testing | Low coverage, flaky tests, missing E2E | No unit tests, missing integration tests |
| Security | Outdated deps, exposed secrets, weak auth | CVE-vulnerable packages, hardcoded tokens |
| Performance | N+1 queries, memory leaks, slow ops | Inefficient algorithms, memory bloat |
| Dependencies | Outdated packages, unmaintained libraries | Years-old libraries, abandoned projects |
Scoring Formula
Each debt item receives a score from 0-100:
Score = (Severity × Scope × Pain) / 10
Severity: 1-10 (impact level)
Scope: 1-10 (files affected)
Pain: 1-10 (developer frustration)Severity Levels
- Low (1-3): Minor issue, doesn't block anything
- Medium (4-6): Moderate issue, slows down development
- High (7-9): Significant issue, blocks features or causes bugs
- Critical (10): Urgent, causes production issues or blocks work
Examples
Quick Scan (Default)
/agileflow:debtScans areas marked with TODO/FIXME and tagged stories. Generates report.
Full Codebase Scan
/agileflow:debt SCAN=fullDeep scan of entire codebase including complexity analysis, duplication detection, and coverage analysis.
Generate Stories for Critical Debt
/agileflow:debt SCAN=quick OUTPUT=stories THRESHOLD=highFinds critical debt items and optionally creates stories for them.
Generate Both Report and Stories
/agileflow:debt SCAN=full OUTPUT=both THRESHOLD=mediumCreates debt report and generates stories for debt items above medium severity.
Output Example
# Technical Debt Report
**Generated**: 2025-12-24T10:30:00Z
**Total Debt Items**: 42
**Critical**: 3 | **High**: 12 | **Medium**: 18 | **Low**: 9
**Total Estimated Effort**: 48 days
---
## Critical Debt (Score >80)
### 1. Auth service tightly coupled to database
**Type**: Architecture | **Score**: 87
**Impact**: Blocks US-0055 (Add OAuth), US-0061 (Add 2FA)
**Files**: src/services/auth.ts (287 lines, complexity 18)
**Estimate**: 3-5 days
**ADR**: ADR-0003 recommends service layer separation (not implemented)
### 2. Missing integration tests for payment flow
**Type**: Testing | **Score**: 85
**Impact**: High risk for regressions, blocking production
**Files**: src/api/payments/*.ts (12 files, 0% coverage)
**Last Incident**: 2025-09-15 (payment processing bug)
**Estimate**: 2-3 days
---
## High Debt (Score 60-80)
[12 items...]
---
## Summary by Category
| Category | Count | Avg Score | Estimated Effort |
|----------|-------|-----------|------------------|
| Architecture | 8 | 72 | 15 days |
| Code Quality | 15 | 58 | 8 days |
| Testing | 10 | 65 | 12 days |
| Security | 3 | 78 | 5 days |
| Performance | 4 | 61 | 6 days |
---
## Debt Heatmap (Most Problematic Files)
- src/services/auth.ts: 3 items (architecture, complexity, coupling)
- src/api/payments/process.ts: 2 items (no tests, deprecated API)
- src/utils/legacy.ts: 2 items (duplication, no docs)
---
## Recommendations
1. **Immediate** (Critical): Address auth refactor and payment tests
2. **This Sprint**: Tackle 3 high-severity items (by ROI)
3. **Next Sprint**: Reserve 20% capacity for debt reduction
4. **Ongoing**: Require tests for all new code (enforce in CI)Workflow
After generating a debt report, you can:
1. Review the Report
Understand what debt exists and where it is.
2. Generate Stories (Optional)
/agileflow:debt OUTPUT=storiesCreates stories for critical debt items with:
- Acceptance criteria focused on "before/after" state
- Impact analysis
- Estimated effort
- References to affected features
3. Save to Documentation
/agileflow:debt OUTPUT=reportSaves report to docs/08-project/tech-debt-YYYYMMDD.md and updates the README with a link.
4. Create Debt Epic
If many critical items exist, creates an epic:
- EP-XXXX: Technical Debt Reduction
- Stories for top 5 critical items
- Tracks debt reduction progress
Using Debt Information
Plan Sprints
Reserve 10-20% of each sprint for debt reduction:
/agileflow:sprint --include-debt --debt-threshold=highRetrospectives
Track debt reduction in retrospectives:
/agileflow:retro --analyze-debtDashboard
Create a debt dashboard that updates weekly:
docs/08-project/debt-dashboard.md
# Debt Dashboard (Weekly)
Week 52: 42 items (↑ from 39)
Week 51: 39 items (↓ from 43)
Critical: 3 items (target: reduce to 1 this sprint)Best Practices
- Be Honest About Estimates: Err on the high side
- Link to Features: Prioritize debt blocking new work
- Celebrate Reductions: Recognize debt paydown in retros
- Prevent Accumulation: Enforce testing in CI for new code
- Review Regularly: Run debt scan monthly or quarterly
Debt Prevention
Add debt review to your CI/CD:
# Run weekly technical debt scan
- cron: '0 0 * * 1' # Every Monday
name: Technical debt scan
run: /agileflow:debt SCAN=full OUTPUT=reportIntegration with Development
When implementing features, check if they create debt:
# Before completing story
/agileflow:debt SCAN=quick THRESHOLD=high
# If debt created, track in story
/agileflow:status STORY=US-0042 TECH_DEBT=true DEBT_SCORE=42Story Template for Debt
When creating stories for debt items:
---
story_id: US-XXXX
title: Refactor auth service to separate concerns
type: tech-debt
debt_score: 87
estimate: 3d
---
## Current State (Before)
- auth.ts contains DB queries, business logic, and HTTP handling
- 287 lines, complexity 18
- Hard to test, hard to extend
## Desired State (After)
- Clear separation: AuthService, AuthRepository, AuthController
- Each \<100 lines, complexity \<8
- 80%+ test coverage
- Enables US-0055 (OAuth)
## Acceptance Criteria
- [ ] AuthRepository handles all DB operations
- [ ] AuthService contains only business logic
- [ ] AuthController handles only HTTP/routing
- [ ] Tests cover each layer independently
- [ ] All existing auth tests still passRelated Commands
On This Page
/debtQuick StartParametersWhat It DetectsCode Quality SignalsStory-Based DebtArchitecture DebtGit History AnalysisLinter OutputDebt CategoriesScoring FormulaSeverity LevelsExamplesQuick Scan (Default)Full Codebase ScanGenerate Stories for Critical DebtGenerate Both Report and StoriesOutput ExampleWorkflow1. Review the Report2. Generate Stories (Optional)3. Save to Documentation4. Create Debt EpicUsing Debt InformationPlan SprintsRetrospectivesDashboardBest PracticesDebt PreventionIntegration with DevelopmentStory Template for DebtRelated Commands