Code Quality — Đánh giá sức khỏe codebase

Đo lường và phân tích chất lượng code: health score, technical debt, complexity metrics.

Cú pháp

/code-health                       # Đánh giá tổng thể codebase
/debt-analysis                     # Phân tích technical debt chi tiết

Bảng tham chiếu nhanh

LệnhMô tảOutput
/code-healthQuality metrics, test coverage, docs, maintainabilityHealth score 0-100
/debt-analysisTech debt identification, prioritization, refactoring roadmapDebt report + roadmap

/code-health — Codebase Health

1

Bước 1: Scan metrics

Đo: test coverage, lint errors, type safety, complexity, duplication.
2

Bước 2: Assess quality

So sánh với thresholds. Score từ 0-100.
3

Bước 3: Report

Tổng hợp: strong points, weak areas, recommendations.
Health Score Breakdown:
CategoryWeightMetrics
Test Coverage25%Line, branch, function coverage
Type Safety20%TypeScript strictness, any count
Code Complexity20%Cyclomatic complexity, nesting depth
Documentation15%README, API docs, inline comments
Dependencies10%Outdated, vulnerable, unused deps
Maintainability10%File size, duplication, coupling

/debt-analysis — Technical Debt

/debt-analysis                     # Full analysis
Output:
  • Debt inventory: categorized list (architecture, code, test, docs, infra)
  • Prioritization: impact × effort matrix
  • Refactoring roadmap: phased plan with estimates

Ví dụ thực tế

CODEBASE HEALTH: 72/100 (Good)
├── Test Coverage:    78% (target 80%) — WARN
├── Type Safety:      95% (2 `any` remaining) — GOOD
├── Complexity:       Low avg (3.2) — GOOD
├── Documentation:    45% — NEEDS WORK
├── Dependencies:     3 outdated, 1 vulnerable — WARN
└── Maintainability:  Good (low duplication)

TOP RECOMMENDATIONS:
1. Fix vulnerable dependency: lodash 4.17.20 → 4.17.21
2. Add API documentation (12 endpoints undocumented)
3. Increase test coverage: auth module only 45%

Khi nào dùng / không dùng

DùngKhông dùng
Đầu sprint — đánh giá code healthGiữa feature development
Plan refactoring sprintDebug specific bug (dùng /fix)
Báo cáo cho stakeholdersSecurity audit (dùng /ck-security)