tech-debt-analyzer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTechnical 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
undefinedbash
undefinedFind 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
undefinednpx ts-unused-exports tsconfig.json
undefinedDebt Categories
债务类别
| Category | Examples |
|---|---|
| Code Quality | Large files, complex functions, TODO/FIXME markers |
| Architectural | Tight coupling, missing abstractions, circular deps |
| Test | Missing coverage, fragile tests, slow execution |
| Documentation | Missing README, outdated docs, no ADRs |
| Dependency | Outdated packages, security vulnerabilities |
| Performance | N+1 queries, memory leaks, large bundles |
| Security | Missing 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
- types in TypeScript
any - 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. 严重程度评估
| Severity | Criteria | Action |
|---|---|---|
| Critical | Security vulns, data loss risk | Immediate fix |
| High | Performance problems, blocking issues | Current sprint |
| Medium | Code quality, missing docs | This quarter |
| Low | Minor smells, optimizations | When convenient |
| 严重程度 | 判定标准 | 处理措施 |
|---|---|---|
| 关键 | 安全漏洞、数据丢失风险 | 立即修复 |
| 高 | 性能问题、阻塞性问题 | 当前迭代处理 |
| 中 | 代码质量问题、文档缺失 | 本季度处理 |
| 低 | 轻微代码异味、优化项 | 方便时处理 |
3. Priority Matrix
3. 优先级矩阵
| Impact / Effort | Low | Medium | High |
|---|---|---|---|
| High Impact | Do First | Do Second | Plan & Do |
| Medium Impact | Do Second | Plan & Do | Consider |
| Low Impact | Quick Win | Consider | Avoid |
| 影响/投入 | 低投入 | 中投入 | 高投入 |
|---|---|---|---|
| 高影响 | 优先处理 | 次优先处理 | 规划并处理 |
| 中影响 | 次优先处理 | 规划并处理 | 考虑处理 |
| 低影响 | 快速优化 | 考虑处理 | 避免处理 |
Debt Register Format
债务登记册格式
markdown
undefinedmarkdown
undefinedDEBT-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
问题描述: 问题的简要说明
影响:
- 业务层面:对交付的影响
- 技术层面:问题的危害
- 风险层面:可能出现的问题
建议解决方案: 处理方案
投入: 天数/小时预估
目标时间: 迭代/季度
undefinedPrevention 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
维护计划
| Frequency | Tasks |
|---|---|
| Weekly | Review TODO/FIXME, update register |
| Monthly | Dependency updates, debt review |
| Quarterly | Full 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 - Workflow rules
CLAUDE.md
- 代码评审标准 - 质量检查
- 项目- 工作流规则
CLAUDE.md