Technical Debt Analyzer
Identify and prioritize technical debt with evidence-ranked remediation plans.
When to Activate
- User mentions technical debt
- Code quality assessment needed
- Understanding what's slowing development
- Legacy code evaluation
- Maintenance burden analysis
Execution Process
Scope the target — Identify which packages, modules, or files to analyze. If no scope is given, use the entire repository.
Collect code signals — Use Glob and Grep to find: files over 500 lines, deeply nested code (≥4 levels of indentation), TODO/FIXME/HACK comments, and any types in TypeScript files.
Examine git history — Run git log --since="6 months ago" --format="%H %s" --stat to identify high-churn files. Run git log --oneline --grep="fix\|bug\|hotfix" -- <path> on suspect files to spot chronic bug areas.
Assess test presence — Use Glob("**/*.test.*") and Glob("**/*.spec.*") to find test files. Cross-reference with source files to identify untested modules. Compute the test-to-source file ratio (test file count / source file count) as a proxy for testing density — not a statement of line coverage.
Rank each item — Rate impact on a high / medium / low band and risk as critical/high/medium/low, then record the change's blast radius: how many files and call sites it touches, whether it changes a public interface, and whether the area has tests. Ground every band in the signals you actually collected (commit count, file size, nesting depth, missing tests), and cite that signal alongside the band.
Do not estimate hours lost per month or hours to fix, and do not compute an ROI number from them. You have no data on this team's velocity; a formula over two invented inputs produces a figure that reads as measured and is not. Rank by band, cite the evidence, and let the reader supply their own effort numbers.
Write the report — Output a Debt Metrics Dashboard followed by a Prioritized Roadmap. Group items by the scope of the change each one requires, which you can observe from the code: Mechanical, Structural, or Architectural (defined under Prioritized Roadmap below). Order within each group by impact band. Do not label a group with an ROI or a duration.
Debt Categories
Code Debt
- Duplicated Code: Copy-paste, repeated logic
- Complex Code: High cyclomatic complexity, deep nesting
- Poor Structure: Circular dependencies, coupling issues
Architecture Debt
- Design Flaws: Missing abstractions, violations
- Technology Debt: Outdated frameworks, deprecated APIs
Testing Debt
- Coverage Gaps: Untested paths, missing edge cases
- Test Quality: Brittle, slow, or flaky tests
Documentation Debt
- Missing API docs, undocumented complex logic
Infrastructure Debt
- Manual deployments, missing monitoring
Impact Assessment
Rate each item against evidence you collected, not against invented cost figures:
- Velocity impact band (high/medium/low), justified by churn and complexity signals
- Quality signal: count of fix/bug/hotfix commits touching the file
- Risk assessment (critical/high/medium/low)
- Blast radius: files touched, call sites found, interface changed or not, tests present or not
Output Format
Debt Metrics Dashboard
high_churn_files:
- path: src/auth/login.ts
commits_6mo: 47
files_over_500_lines:
count: 12
worst: src/legacy/processor.ts (1842 lines)
todo_fixme_count:
total: 83
hotspots: [src/payments/, src/legacy/]
test_to_source_ratio:
ratio: 45%
note: proxy for testing density, not line coverage
Prioritized Roadmap
Group by observable blast radius, not by a guessed cost:
- Mechanical: contained to one file, no public interface changes, and the area already has
tests — the change is a rewrite of existing behavior with a check already in place
- Structural: spans several files or changes an interface, so callers must be updated; state
how many call sites you found and whether they are covered by tests
- Architectural: design-level change across modules, or a change to code with no test coverage
at all — the shape has to be decided before it can be written
Order within each group by impact band.
Per-Item Format
Each item includes: location, description, impact band, its group from above, the specific signal
that justifies both (e.g. "47 commits in 6 months, 12 of them fix commits; 9 call sites, none
under test"), and the recommended fix. Cap the roadmap at the 20 highest-impact items and target under 200 lines;
say how many items were left out so nothing looks hidden.
Examples
"Analyze the technical debt in the auth module"
"What's slowing down development in packages/legacy?"
"Create a cleanup roadmap for next quarter"
"Where should we focus refactoring efforts this sprint?"
1---2name: analyze-tech-debt3description: Analyze and prioritize technical debt with remediation plans. Use when user says "analyze the technical debt in this codebase", "what's the code quality like in this module", "identify what's slowing down our development", "assess the maintenance burden of this legacy code", "create a plan to pay down our tech debt", or "where should we focus our cleanup efforts".4---56# Technical Debt Analyzer78Identify and prioritize technical debt with evidence-ranked remediation plans.910## When to Activate1112- User mentions technical debt13- Code quality assessment needed14- Understanding what's slowing development15- Legacy code evaluation16- Maintenance burden analysis1718## Execution Process19201. **Scope the target** — Identify which packages, modules, or files to analyze. If no scope is given, use the entire repository.212. **Collect code signals** — Use `Glob` and `Grep` to find: files over 500 lines, deeply nested code (≥4 levels of indentation), `TODO`/`FIXME`/`HACK` comments, and `any` types in TypeScript files.223. **Examine git history** — Run `git log --since="6 months ago" --format="%H %s" --stat` to identify high-churn files. Run `git log --oneline --grep="fix\|bug\|hotfix" -- <path>` on suspect files to spot chronic bug areas.234. **Assess test presence** — Use `Glob("**/*.test.*")` and `Glob("**/*.spec.*")` to find test files. Cross-reference with source files to identify untested modules. Compute the test-to-source file ratio (test file count / source file count) as a proxy for testing density — not a statement of line coverage.245. **Rank each item** — Rate impact on a **high / medium / low** band and risk as critical/high/medium/low, then record the change's blast radius: how many files and call sites it touches, whether it changes a public interface, and whether the area has tests. Ground every band in the signals you actually collected (commit count, file size, nesting depth, missing tests), and cite that signal alongside the band.2526 Do **not** estimate hours lost per month or hours to fix, and do not compute an ROI number from them. You have no data on this team's velocity; a formula over two invented inputs produces a figure that reads as measured and is not. Rank by band, cite the evidence, and let the reader supply their own effort numbers.27286. **Write the report** — Output a Debt Metrics Dashboard followed by a Prioritized Roadmap. Group items by the scope of the change each one requires, which you can observe from the code: **Mechanical**, **Structural**, or **Architectural** (defined under Prioritized Roadmap below). Order within each group by impact band. Do not label a group with an ROI or a duration.2930## Debt Categories3132### Code Debt3334- **Duplicated Code**: Copy-paste, repeated logic35- **Complex Code**: High cyclomatic complexity, deep nesting36- **Poor Structure**: Circular dependencies, coupling issues3738### Architecture Debt3940- **Design Flaws**: Missing abstractions, violations41- **Technology Debt**: Outdated frameworks, deprecated APIs4243### Testing Debt4445- **Coverage Gaps**: Untested paths, missing edge cases46- **Test Quality**: Brittle, slow, or flaky tests4748### Documentation Debt4950- Missing API docs, undocumented complex logic5152### Infrastructure Debt5354- Manual deployments, missing monitoring5556## Impact Assessment5758Rate each item against evidence you collected, not against invented cost figures:5960- Velocity impact band (high/medium/low), justified by churn and complexity signals61- Quality signal: count of fix/bug/hotfix commits touching the file62- Risk assessment (critical/high/medium/low)63- Blast radius: files touched, call sites found, interface changed or not, tests present or not6465## Output Format6667### Debt Metrics Dashboard6869```yaml70high_churn_files:71 - path: src/auth/login.ts72 commits_6mo: 4773files_over_500_lines:74 count: 1275 worst: src/legacy/processor.ts (1842 lines)76todo_fixme_count:77 total: 8378 hotspots: [src/payments/, src/legacy/]79test_to_source_ratio:80 ratio: 45%81 note: proxy for testing density, not line coverage82```8384### Prioritized Roadmap8586Group by observable blast radius, not by a guessed cost:8788- **Mechanical**: contained to one file, no public interface changes, and the area already has89 tests — the change is a rewrite of existing behavior with a check already in place90- **Structural**: spans several files or changes an interface, so callers must be updated; state91 how many call sites you found and whether they are covered by tests92- **Architectural**: design-level change across modules, or a change to code with no test coverage93 at all — the shape has to be decided before it can be written9495Order within each group by impact band.9697### Per-Item Format9899Each item includes: location, description, impact band, its group from above, the specific signal100that justifies both (e.g. "47 commits in 6 months, 12 of them fix commits; 9 call sites, none101under test"), and the recommended fix. Cap the roadmap at the 20 highest-impact items and target under 200 lines;102say how many items were left out so nothing looks hidden.103104## Examples105106```107"Analyze the technical debt in the auth module"108"What's slowing down development in packages/legacy?"109"Create a cleanup roadmap for next quarter"110"Where should we focus refactoring efforts this sprint?"111```