tech-debt-analyzer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Technical Debt Analyzer

技术债务分析器

Systematically identify, analyze, and document technical debt.
系统性地识别、分析并记录技术债务。

When to Use

使用场景

Use for:
  • Analyzing code quality issues
  • Creating technical debt registers
  • Assessing code maintainability
  • Identifying dependency problems
  • Documenting security vulnerabilities
  • Planning refactoring efforts
Don't use when:
  • Writing new code → use
    generic-feature-developer
  • Code review → use
    generic-code-reviewer
  • Writing tests → use
    test-specialist
适用场景:
  • 分析代码质量问题
  • 创建技术债务登记册
  • 评估代码可维护性
  • 识别依赖项问题
  • 记录安全漏洞
  • 规划重构工作
不适用场景:
  • 编写新代码 → 使用
    generic-feature-developer
  • 代码评审 → 使用
    generic-code-reviewer
  • 编写测试 → 使用
    test-specialist

Quick Analysis Commands

快速分析命令

bash
undefined
bash
undefined

Find large files (>500 lines)

Find large files (>500 lines)

find src -name "*.ts" -exec wc -l {} + | awk '$1 > 500' | sort -rn
find src -name "*.ts" -exec wc -l {} + | awk '$1 > 500' | sort -rn

Find TODO/FIXME markers

Find TODO/FIXME markers

grep -rn "TODO|FIXME|HACK|XXX" src/
grep -rn "TODO|FIXME|HACK|XXX" src/

Check for console.log in production code

Check for console.log in production code

grep -rn "console.log" src/ --include=".ts" --include=".tsx"
grep -rn "console.log" src/ --include=".ts" --include=".tsx"

Find TypeScript 'any' usage

Find TypeScript 'any' usage

grep -rn ": any" src/ --include=".ts" --include=".tsx"
grep -rn ": any" src/ --include=".ts" --include=".tsx"

Check outdated dependencies

Check outdated dependencies

npm outdated
npm outdated

Security vulnerabilities

Security vulnerabilities

npm audit
npm audit

Unused exports (requires ts-unused-exports)

Unused exports (requires ts-unused-exports)

npx ts-unused-exports tsconfig.json
undefined
npx ts-unused-exports tsconfig.json
undefined

Debt Categories

债务类别

CategoryExamples
Code QualityLarge files, complex functions, TODO/FIXME markers
ArchitecturalTight coupling, missing abstractions, circular deps
TestMissing coverage, fragile tests, slow execution
DocumentationMissing README, outdated docs, no ADRs
DependencyOutdated packages, security vulnerabilities
PerformanceN+1 queries, memory leaks, large bundles
SecurityMissing validation, exposed secrets, XSS/SQL injection
类别示例
代码质量大文件、复杂函数、TODO/FIXME标记
架构紧耦合、缺失抽象、循环依赖
测试覆盖率不足、脆弱测试、执行缓慢
文档缺失README、文档过时、无ADR
依赖项过时包、安全漏洞
性能N+1查询、内存泄漏、大体积包
安全缺失验证、密钥泄露、XSS/SQL注入

Analysis Workflow

分析流程

1. Automated Detection

1. 自动化检测

Code Smells to Check:
  • Large files (>500 lines)
  • Complex functions (cyclomatic complexity >10)
  • Debt markers (TODO, FIXME, HACK, XXX)
  • Console statements in production code
  • any
    types in TypeScript
  • Long parameter lists (>5 params)
  • Deep nesting (>4 levels)
Dependency Issues:
  • Deprecated packages
  • Duplicate functionality
  • Loose version constraints
  • Known vulnerabilities
需检查的代码异味:
  • 大文件(超过500行)
  • 复杂函数(圈复杂度>10)
  • 债务标记(TODO、FIXME、HACK、XXX)
  • 生产代码中的console语句
  • TypeScript中的
    any
    类型
  • 过长参数列表(超过5个参数)
  • 深层嵌套(超过4层)
依赖项问题:
  • 已弃用的包
  • 重复功能
  • 宽松的版本约束
  • 已知漏洞

2. Severity Assessment

2. 严重程度评估

SeverityCriteriaAction
CriticalSecurity vulns, data loss riskImmediate fix
HighPerformance problems, blocking issuesCurrent sprint
MediumCode quality, missing docsThis quarter
LowMinor smells, optimizationsWhen convenient
严重程度判定标准处理措施
关键安全漏洞、数据丢失风险立即修复
性能问题、阻塞性问题当前迭代处理
代码质量问题、文档缺失本季度处理
轻微代码异味、优化项方便时处理

3. Priority Matrix

3. 优先级矩阵

Impact / EffortLowMediumHigh
High ImpactDo FirstDo SecondPlan & Do
Medium ImpactDo SecondPlan & DoConsider
Low ImpactQuick WinConsiderAvoid
影响/投入低投入中投入高投入
高影响优先处理次优先处理规划并处理
中影响次优先处理规划并处理考虑处理
低影响快速优化考虑处理避免处理

Debt Register Format

债务登记册格式

markdown
undefined
markdown
undefined

DEBT-001: Description

DEBT-001:问题描述

Category: Code Quality | Severity: High Location: src/services/UserService.ts
Description: Brief description of the issue
Impact:
  • Business: How it affects delivery
  • Technical: Why it's problematic
  • Risk: What could go wrong
Proposed Solution: What to do about it Effort: Days/hours estimate Target: Sprint/quarter
undefined
类别: 代码质量 | 严重程度:位置: src/services/UserService.ts
问题描述: 问题的简要说明
影响:
  • 业务层面:对交付的影响
  • 技术层面:问题的危害
  • 风险层面:可能出现的问题
建议解决方案: 处理方案 投入: 天数/小时预估 目标时间: 迭代/季度
undefined

Prevention Strategies

预防策略

Automated Guards

自动化防护

json
{
  "rules": {
    "complexity": ["error", 10],
    "max-lines-per-function": ["error", 50],
    "max-params": ["error", 5],
    "max-depth": ["error", 4]
  }
}
json
{
  "rules": {
    "complexity": ["error", 10],
    "max-lines-per-function": ["error", 50],
    "max-params": ["error", 5],
    "max-depth": ["error", 4]
  }
}

Maintenance Schedule

维护计划

FrequencyTasks
WeeklyReview TODO/FIXME, update register
MonthlyDependency updates, debt review
QuarterlyFull analysis, architecture review
频率任务
每周评审TODO/FIXME、更新登记册
每月依赖项更新、债务评审
每季度全面分析、架构评审

Self-Critique Checklist

自我检查清单

After completing debt analysis:
  • All automated checks run
  • Manual review of critical paths done
  • Severity assessments justified
  • Proposed solutions are actionable
  • Priority matrix applied consistently
  • Register entries are complete
完成债务分析后:
  • 已运行所有自动化检查
  • 已完成关键路径的人工评审
  • 严重程度评估有合理依据
  • 建议解决方案可执行
  • 优先级矩阵应用一致
  • 登记册条目完整

See Also

参考链接

  • Code Review Standards - Quality checks
  • Project
    CLAUDE.md
    - Workflow rules
  • 代码评审标准 - 质量检查
  • 项目
    CLAUDE.md
    - 工作流规则