tech-debt-analyzer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTech Debt Analyzer
技术债务分析器
Systematic technical debt inventory, prioritization, and remediation planning.
Multi-pass analysis with confidence scoring and evidence-based findings.
Scope: Debt inventory and tracking only. NOT for code review (review), refactoring execution, or dependency updates.
系统化的technical debt清单、优先级排序与修复规划。
多轮分析,附带置信度评分和基于证据的发现结果。
适用范围: 仅用于债务清单整理与跟踪。不支持代码评审、重构执行或依赖更新。
Canonical Vocabulary
规范术语表
| Term | Definition |
|---|---|
| debt item | A discrete tech debt finding with category, severity, confidence, and evidence |
| category | Debt classification: design, test, documentation, dependency, infrastructure |
| severity | Impact level: CRITICAL, HIGH, MEDIUM, LOW |
| confidence | Score 0.0-1.0 per item; >=0.7 report, 0.3-0.7 flag, <0.3 discard |
| complexity | Cyclomatic (decision paths) or cognitive (human comprehension difficulty) |
| dead code | Functions, classes, or imports with no references in the codebase |
| staleness | Days since a dependency's current version was superseded |
| inconsistency | Same pattern implemented differently across files |
| remediation | Specific fix action with effort estimate and risk level |
| debt score | Aggregate metric: sum of (severity_weight x confidence) across all items |
| baseline | Previous scan stored at ~/.{gemini |
| heatmap | Visual density of debt items per file or directory |
| risk x effort | Prioritization matrix: impact vs. remediation cost |
| Term | Definition |
|---|---|
| debt item | 一个离散的技术债务发现项,包含类别、严重程度、置信度和证据 |
| category | 债务分类:设计、测试、文档、依赖、基础设施 |
| severity | 影响级别:CRITICAL、HIGH、MEDIUM、LOW |
| confidence | 每个项的得分(0.0-1.0);≥0.7则报告,0.3-0.7标记为待确认,<0.3则丢弃 |
| complexity | 圈复杂度(决策路径数)或认知复杂度(人类理解难度) |
| dead code | 代码库中无引用的函数、类或导入语句 |
| staleness | 依赖包当前版本被取代后的天数 |
| inconsistency | 同一模式在不同文件中的实现方式不一致 |
| remediation | 具体的修复操作,包含工作量估算和风险级别 |
| debt score | 聚合指标:所有项的(严重程度权重 × 置信度)之和 |
| baseline | 存储在`~/.{gemini |
| heatmap | 每个文件或目录中债务项的可视化密度图 |
| risk x effort | 优先级矩阵:影响程度 vs 修复成本 |
Dispatch
命令模式
| $ARGUMENTS | Mode |
|---|---|
| Full codebase debt inventory (or scoped to path) |
| Targeted deep analysis of specific file or directory |
| Rank all debt items by risk x effort matrix |
| Generate phased remediation plan |
| Render dashboard visualization |
| Compare current scan against previous baseline |
| Empty | Show mode menu with descriptions and examples |
| $ARGUMENTS | 模式 |
|---|---|
| 全代码库债务清单(或限定路径范围) |
| 针对特定文件或目录的深度分析 |
| 按风险×工作量矩阵对所有债务项排序 |
| 生成分阶段修复计划 |
| 渲染仪表盘可视化界面 |
| 对比当前扫描结果与历史基准 |
| Empty | 显示模式菜单及说明和示例 |
Mode: Scan
模式:扫描
Full codebase debt inventory. Run all 4 analysis scripts, aggregate results, assign categories and severities.
全代码库债务清单整理。运行全部4个分析脚本,汇总结果,分配类别和严重程度。
Scan Step 1: Project Profile
扫描步骤1:项目概况
Run to get complexity metrics.
Parse JSON output. Flag functions with cyclomatic_complexity > 10 as HIGH, > 5 as MEDIUM.
uv run python scripts/complexity-scanner.py <path>运行获取复杂度指标。
解析JSON输出。将圈复杂度>10的函数标记为HIGH,>5的标记为MEDIUM。
uv run python scripts/complexity-scanner.py <path>Scan Step 2: Dead Code Detection
扫描步骤2:死代码检测
Run to find unused code.
Parse JSON output. Each unused item becomes a debt item (category: design, severity by confidence).
uv run python scripts/dead-code-detector.py <path>运行查找未使用代码。
解析JSON输出。每个未使用项均成为债务项(类别:设计,严重程度由置信度决定)。
uv run python scripts/dead-code-detector.py <path>Scan Step 3: Dependency Staleness
扫描步骤3:依赖过期检查
Run to check outdated packages.
Parse JSON output. Deprecated packages are CRITICAL. Staleness > 365 days is HIGH.
uv run python scripts/dependency-staleness-checker.py <path>运行检查过时包。
解析JSON输出。已废弃的包标记为CRITICAL。过期超过365天的标记为HIGH。
uv run python scripts/dependency-staleness-checker.py <path>Scan Step 4: Pattern Consistency
扫描步骤4:模式一致性检测
Run to detect inconsistencies.
Parse JSON output. Each inconsistency becomes a debt item (category: design).
uv run python scripts/pattern-consistency-checker.py <path>运行检测不一致情况。
解析JSON输出。每个不一致项均成为债务项(类别:设计)。
uv run python scripts/pattern-consistency-checker.py <path>Scan Step 5: AI-Augmented Analysis
扫描步骤5:AI增强分析
After script-based detection, perform additional analysis:
- Documentation gaps — scan for undocumented public APIs, missing README sections, stale comments
- Test coverage gaps — Grep for untested modules, missing edge cases, test-to-code ratio
- Infrastructure debt — outdated CI configs, missing linting, inconsistent tooling
- Design smells — God classes, feature envy, shotgun surgery patterns
Assign confidence scores (0.0-1.0) per finding. Research-validate HIGH/CRITICAL items using Grep and codebase evidence.
基于脚本检测结果,执行额外分析:
- 文档缺失 — 扫描未文档化的公共API、缺失的README章节、过时注释
- 测试覆盖缺口 — 查找未测试模块、缺失的边缘用例、测试代码比
- 基础设施债务 — 过时的CI配置、缺失的代码检查、不一致的工具链
- 设计异味 — 上帝类、特性羡慕、霰弹式修改模式
为每个发现项分配置信度得分(0.0-1.0)。使用Grep和代码库证据对HIGH/CRITICAL级别的项进行验证。
Scan Step 6: Aggregate and Classify
扫描步骤6:汇总与分类
Merge all findings into a unified inventory:
- Deduplicate across script outputs
- Assign categories from debt taxonomy (references/debt-taxonomy.md)
- Calculate debt score: sum of (severity_weight x confidence)
- Store baseline at
~/.{gemini|copilot|codex|claude}/tech-debt/<project-slug>-<date>.json
Present findings grouped by category, sorted by severity within each group.
将所有发现项合并为统一清单:
- 去重脚本输出中的重复项
- 根据债务分类法(参考references/debt-taxonomy.md)分配类别
- 计算债务得分:所有项的(严重程度权重 × 置信度)之和
- 将基准结果存储至
~/.{gemini|copilot|codex|claude}/tech-debt/<project-slug>-<date>.json
按类别分组展示发现项,每组内按严重程度排序。
Mode: Analyze
模式:分析
Targeted deep analysis of a specific file or directory. Run all 4 scripts scoped to the target.
Apply the same 6-step scan process but with deeper per-function analysis.
Include: function-level complexity breakdown, inline dead code, local pattern violations.
针对特定文件或目录的深度分析。在目标范围内运行全部4个脚本。
应用相同的6步扫描流程,但增加函数级的深度分析。
包含:函数级复杂度细分、内嵌死代码、本地模式违规情况。
Mode: Prioritize
模式:优先级排序
Rank debt items using risk x effort matrix. Load .
references/prioritization-framework.md| Low Effort | Medium Effort | High Effort | |
|---|---|---|---|
| High Risk | P0: Fix immediately | P1: Schedule next sprint | P2: Plan for next quarter |
| Medium Risk | P1: Schedule next sprint | P2: Plan for next quarter | P3: Backlog |
| Low Risk | P2: Quick wins batch | P3: Backlog | P4: Accept or defer |
For each debt item, estimate:
- Risk: blast radius x severity x confidence
- Effort: LOC affected x complexity x dependency count
Output a ranked list with priority labels (P0-P4).
使用风险×工作量矩阵对债务项排序。加载。
references/prioritization-framework.md| 低工作量 | 中工作量 | 高工作量 | |
|---|---|---|---|
| 高风险 | P0:立即修复 | P1:安排至下一个迭代 | P2:规划至下一季度 |
| 中风险 | P1:安排至下一个迭代 | P2:规划至下一季度 | P3:放入待办清单 |
| 低风险 | P2:批量快速处理 | P3:放入待办清单 | P4:接受或延后处理 |
为每个债务项估算:
- 风险:影响范围 × 严重程度 × 置信度
- 工作量:受影响代码行数 × 复杂度 × 依赖数量
输出带优先级标签(P0-P4)的排序列表。
Mode: Roadmap
模式:路线图
Generate a phased remediation plan. Requires a prior scan (reads baseline from ).
~/.{gemini|copilot|codex|claude}/tech-debt/Phase structure:
- Quick Wins (P0 + low-effort P1): immediate fixes, minimal risk
- Structural (remaining P1 + high-risk P2): design improvements, refactoring
- Maintenance (P2 + P3): documentation, test coverage, dependency updates
- Strategic (P3 + P4): architecture changes, long-term improvements
Each phase includes: items, estimated effort, dependencies, success criteria.
生成分阶段修复计划。需要先完成扫描(从读取基准结果)。
~/.{gemini|copilot|codex|claude}/tech-debt/阶段结构:
- 快速处理(P0 + 低工作量P1):立即修复,风险极低
- 结构优化(剩余P1 + 高风险P2):设计改进、重构
- 维护完善(P2 + P3):文档补充、测试覆盖、依赖更新
- 战略升级(P3 + P4):架构调整、长期改进
每个阶段包含:处理项、估算工作量、依赖项、成功标准。
Mode: Report
模式:报告
Render dashboard visualization. Requires a prior scan.
- Read the most recent baseline from
~/.{gemini|copilot|codex|claude}/tech-debt/ - Copy to a temporary file
templates/dashboard.html - Inject findings JSON into the tag
<script id="data"> - Open in browser or report the path
Dashboard sections: category pie chart, complexity heatmap, trend chart (if multiple baselines), prioritized backlog table.
渲染仪表盘可视化界面。需要先完成扫描。
- 从读取最新基准结果
~/.{gemini|copilot|codex|claude}/tech-debt/ - 将复制到临时文件
templates/dashboard.html - 将发现项JSON注入标签
<script id="data"> - 在浏览器中打开或返回文件路径
仪表盘包含:类别饼图、复杂度热力图、趋势图(如有多个基准结果)、优先级待办清单表格。
Mode: Track
模式:跟踪
Compare current scan against previous baseline for longitudinal tracking.
- Run a fresh scan (Mode: Scan steps 1-6)
- Load previous baseline from (most recent)
~/.{gemini|copilot|codex|claude}/tech-debt/<project-slug>-*.json - Compute delta: new items, resolved items, changed severities, score trend
- Present comparison report with trend indicators
对比当前扫描结果与历史基准,实现纵向跟踪。
- 执行全新扫描(按「模式:扫描」步骤1-6)
- 从读取最新历史基准
~/.{gemini|copilot|codex|claude}/tech-debt/<project-slug>-*.json - 计算差值:新增项、已解决项、严重程度变更、得分趋势
- 展示带趋势指标的对比报告
State Management
状态管理
- State directory:
~/.{gemini|copilot|codex|claude}/tech-debt/ - Create directory on first use with
mkdir -p - Filename:
<project-slug>-<YYYY-MM-DD>.json - Project slug: sanitized basename of the project root directory
- Store after every scan; track mode reads historical baselines
- Schema:
{ "project": str, "date": str, "score": float, "items": [...], "summary": {...} }
- 状态目录:
~/.{gemini|copilot|codex|claude}/tech-debt/ - 首次使用时通过创建目录
mkdir -p - 文件名:
<project-slug>-<YYYY-MM-DD>.json - 项目标识:项目根目录的标准化名称
- 每次扫描后存储;跟踪模式读取历史基准
- Schema:
{ "project": str, "date": str, "score": float, "items": [...], "summary": {...} }
Reference Files
参考文件
Load ONE reference at a time. Do not preload all references into context.
| File | Content | Read When |
|---|---|---|
| 5 debt categories with subcategories and remediation templates | Scan Step 6, classifying findings |
| Cyclomatic and cognitive complexity definitions, thresholds, interpretation | Interpreting complexity-scanner output |
| Risk x effort matrix, scoring rubric, priority definitions | Prioritize mode |
| Fix patterns by issue type, effort estimates, risk ratings | Roadmap mode, generating fix plans |
| Script | When to Run |
|---|---|
| Scan Steps 1, Analyze mode |
| Scan Step 2, Analyze mode |
| Scan Step 3 |
| Scan Step 4, Analyze mode |
| Template | When to Render |
|---|---|
| Report mode — inject findings JSON into data tag |
每次仅加载一个参考文件。请勿预先加载所有参考文件至上下文。
| 文件 | 内容 | 加载时机 |
|---|---|---|
| 5种债务类别,包含子类别和修复模板 | 扫描步骤6,分类发现项时 |
| 圈复杂度与认知复杂度的定义、阈值、解读方式 | 解析complexity-scanner输出时 |
| 风险×工作量矩阵、评分规则、优先级定义 | 优先级排序模式时 |
| 按问题类型划分的修复模式、工作量估算、风险评级 | 路线图模式,生成修复计划时 |
| 脚本 | 运行时机 |
|---|---|
| 扫描步骤1、分析模式 |
| 扫描步骤2、分析模式 |
| 扫描步骤3 |
| 扫描步骤4、分析模式 |
| 模板 | 渲染时机 |
|---|---|
| 报告模式 — 将发现项JSON注入数据标签 |
Debt Item Structure
债务项结构
Every debt item follows this format:
- Location: or
[file:line]— exact source location[file:start-end] - Category: design | test | documentation | dependency | infrastructure
- Severity: CRITICAL | HIGH | MEDIUM | LOW
- Confidence: 0.0-1.0 score with evidence basis
- Description: What the debt is (1-2 sentences)
- Impact: Why it matters (blast radius, risk)
- Remediation: Recommended fix approach with effort estimate
每个债务项遵循以下格式:
- 位置:或
[file:line]— 精确的源码位置[file:start-end] - 类别:design | test | documentation | dependency | infrastructure
- 严重程度:CRITICAL | HIGH | MEDIUM | LOW
- 置信度:0.0-1.0的得分,附带证据依据
- 描述:债务内容(1-2句话)
- 影响:债务的重要性(影响范围、风险)
- 修复方案:推荐的修复方式,包含工作量估算
Critical Rules
核心规则
- Run all 4 analysis scripts before presenting findings — partial scans are labeled as such
- Every finding must have a confidence score backed by evidence (script output or codebase grep)
- Confidence < 0.3 = discard; 0.3-0.7 = flag as uncertain; >= 0.7 = report
- Never execute remediation — this skill inventories and plans, not fixes
- Store baseline after every full scan — longitudinal tracking depends on it
- Do not report style preferences as debt — only structural, behavioral, or maintainability issues
- Deduplicate across script outputs — same file:line should not appear twice
- Prioritize mode requires a prior scan — prompt user to run scan first if no baseline exists
- Always present the debt score (aggregate metric) in scan output
- Track mode must show delta (new/resolved/changed) — raw numbers without comparison are useless
- Dead code detection requires high confidence (>= 0.8) — false positives erode trust
- Load ONE reference file at a time — do not preload all references
- 展示发现项前必须运行全部4个分析脚本 — 部分扫描需明确标记
- 每个发现项必须有基于证据的置信度得分(脚本输出或代码库Grep结果)
- 置信度<0.3 = 丢弃;0.3-0.7 = 标记为不确定;≥0.7 = 报告
- 绝不执行修复操作 — 本工具仅用于清单整理和规划,不负责修复
- 每次全量扫描后必须存储基准结果 — 纵向跟踪依赖于此
- 不得将风格偏好列为债务 — 仅报告结构、行为或可维护性问题
- 去重脚本输出中的重复项 — 同一file:line不得重复出现
- 优先级排序模式需要先完成扫描 — 若无基准结果,提示用户先运行扫描
- 扫描输出中必须展示债务得分(聚合指标)
- 跟踪模式必须展示差值(新增/已解决/变更) — 无对比的原始数据无意义
- 死代码检测需要高置信度(≥0.8) — 误报会降低信任度
- 每次仅加载一个参考文件 — 请勿预先加载所有参考文件