Technical debt analysis and remediation. Scans codebase for code smells, duplication, complexity, testing gaps, and architecture issues. Generates prioritized reports with ROI estimates. Use /tech-debt to run full analysis or /tech-debt [area] for targeted scan.
Technical debt analysis and remediation. Scans codebase for code smells, duplication, complexity, testing gaps, and architecture issues. Generates prioritized reports with ROI estimates. Use /tech-debt to run full analysis or /tech-debt [area] for targeted scan.
argument-hint
[area] e.g. challenges, goals, all
Technical Debt Analysis and Remediation
Analyze the HeadsUp codebase to identify, quantify, and prioritize technical debt. Generate actionable remediation plans with clear ROI.
Target: $ARGUMENTS
Workflow
Phase 1: Scan & Inventory
Conduct a thorough scan based on the target area. If no area specified, scan the full codebase.
Impact = Frequency_of_change x Severity x Blast_radius
Where:
Frequency: How often this code is touched (1-5)
Severity: How bad the debt is (1-5)
Blast_radius: How much code is affected (1-5)
Phase 3: Generate Report
Create the report at project/tech-debt/TD-[DATE]-[area].md
# Technical Debt Report: [Area]**Date:** YYYY-MM-DD
**Scope:** [what was scanned]
**Overall Score:** X/100 (lower = more debt)
## Executive Summary- Total debt items: X
- Critical: X | High: X | Medium: X | Low: X
- Estimated remediation effort: X hours
- Top 3 priorities: [list]
## Debt Inventory### Critical Items
| # | Category | File | Description | Impact | Effort |
|---|----------|------|-------------|--------|--------|
| 1 | [type] | path | description | score | hours |
### High Priority Items
[same table format]
### Medium Priority Items
[same table format]
### Low Priority Items
[same table format]
## Metrics### Code Quality- Average function length: X lines
- Functions >50 lines: X
- Modules >500 lines: X
- Duplicated patterns: X locations
### Test Coverage- Context functions tested: X%
- LiveView events tested: X%
- Files without tests: X
### Schema Health- Missing indexes: X
- Missing validations: X
- Inconsistent patterns: X
## Quick Wins (< 4 hours each)1. [item] - Effort: Xh, Savings: Xh/month
2. [item] - Effort: Xh, Savings: Xh/month
## Remediation Roadmap### Week 1-2: Quick Wins- [ ] [task]
- [ ] [task]
### Month 1: High Priority- [ ] [task]
- [ ] [task]
### Month 2-3: Medium Priority- [ ] [task]
- [ ] [task]
## Prevention Recommendations1. [recommendation]
2. [recommendation]
Phase 4: Create Tasks
For each Quick Win and High Priority item, create a task file:
# BAD: Repo call in LiveView
def handle_event("save", params, socket) do
Repo.insert(changeset) # Should be in context
end
# GOOD: Context function
def handle_event("save", params, socket) do
Goals.create_goal(params)
end
LiveView Anti-patterns
# BAD: Business logic in template
<%= if length(user.goals) >= 2 do %> # Magic number, logic in template
# GOOD: Helper or context function
<%= if Goals.at_limit?(@current_user) do %>
Schema Checks
# Check for: missing validates, missing indexes, missing on_delete
schema "goals" do
belongs_to :user, User # Should have on_delete
field :status, Ecto.Enum # Should validate in changeset
end