Technical Debt Manager
Analyze current repo for technical debt by exploring codebase and researching version-specific best practices. Produces a single GitHub issue with prioritized checklist of findings rated across 4 axes (impact, effort, contagion, business alignment) with concrete, actionable fix descriptions and measurement recommendations.
Arguments
Parse from $ARGUMENTS:
- --focus: Optional — Narrow analysis to specific area (e.g.,
error-handling, tests, dependencies, architecture). Default: full scan.
- --label: Optional — GitHub issue label. Default:
tech-debt
Workflow
Phase 1: Repo Discovery
1a. Detect language & framework:
- Read project config files to identify stack:
package.json, tsconfig.json → TypeScript/JavaScript + framework (React, Next.js, Express, etc.)
go.mod → Go
pyproject.toml, setup.py, requirements.txt → Python + framework
Cargo.toml → Rust
Gemfile → Ruby
pom.xml, build.gradle → Java/Kotlin
mise.toml, .tool-versions → Additional tool hints
- Identify test framework, linter, formatter from config
- Note monorepo structure if applicable
1b. Codebase overview:
Glob for directory structure (top 2 levels)
- Count files per language
- Identify entry points, main modules
- Check for CI/CD config (
.github/workflows/, Makefile, etc.)
1c. Check existing debt tracking:
- Search for existing
tech-debt labeled issues: gh issue list --label tech-debt --state open
- Read CLAUDE.md, README, CONTRIBUTING for known debt/conventions
- Note any existing TODO/FIXME/HACK conventions
Phase 2: Research Modern Practices
2a. Detect specific versions:
- Extract language VERSION from config (e.g.,
"engines": {"node": ">=20"}, go 1.22 in go.mod, python_requires in pyproject.toml)
- Extract framework VERSION (e.g.,
"react": "^18.2", "next": "14.1")
- Note: version-specific best practices differ significantly (e.g., Go 1.22 vs 1.18, React 18 vs 17)
2b. Monorepo handling:
- If monorepo detected (multiple
package.json, workspace config, apps/ + packages/), research separately per app/package
- Note shared dependencies and cross-package patterns
2c. Use WebSearch to find current best practices for detected language/framework.
Search queries (adapt to detected stack — include detected version):
"{language} {version} best practices {year}" maintainable code
"{framework} {version} common anti-patterns {year}"
"{language} {version} migration guide" breaking changes (if version is behind latest)
"{language} code architecture patterns {year}"
"{language} technical debt indicators checklist"
"{language} dependency management best practices {year}"
Extract from research:
- Current idiomatic patterns for the specific language version in use
- Common anti-patterns specific to the framework version
- Version-specific deprecations (are they using deprecated APIs for their version?)
- Recommended project structure
- Error handling conventions
- Testing best practices
- Dependency management guidelines
- Performance pitfalls
Save research summary internally for Phase 3 comparison.
Phase 3: Codebase Analysis
Run analysis across these categories. For each finding, record: file:line, description, why it matters, fix approach.
3a. Code Quality (SATD & Complexity)
- Search for
TODO, FIXME, HACK, XXX, WORKAROUND comments with Grep
- Extract 3 lines context around each match
- Classify severity:
TODO (low) → FIXME (medium) → HACK (high) → XXX (critical)
- Check age via
git blame on flagged lines — older = higher priority
- Group by theme clusters (e.g., "error handling TODOs", "performance FIXMEs")
- Identify dead code: unused exports, unreachable branches, commented-out code blocks
- Find overly complex functions (deeply nested, very long)
- Detect code duplication patterns
- Check error handling: bare catches, swallowed errors, missing error propagation
- Compare patterns found against Phase 2 research findings
Pattern Heuristics (Grep-able):
- Bare exception handlers:
except:, catch {}, catch(Exception, catch (...)
- Swallowed errors: empty catch blocks (catch + next line is
})
- God objects: files >1000 lines with many public methods/exports
- Commented-out code:
// followed by valid syntax patterns across 3+ consecutive lines
- Deep nesting: 4+ levels of indentation in control flow
3b. Architecture
- Check for circular dependencies or tightly coupled modules
- Identify inconsistent patterns (e.g., mixed async styles, inconsistent naming)
- Look for missing abstractions (repeated boilerplate across files)
- Verify separation of concerns (business logic vs infrastructure)
- Compare project structure against language-specific recommendations from Phase 2
Pattern Heuristics (Grep-able):
- Mixed async:
Promise + callback in same module, .then() + async/await mixed
- Circular imports: mutual import chains (A→B→A)
- Feature envy: functions accessing another module's internals more than their own
- Barrel file bloat: re-export files >50 entries
3c. Dependencies
- Check for outdated dependencies:
gh api repos/{owner}/{repo}/dependabot/alerts or manual check
- Look for unused dependencies (imported but not used in code)
- Identify pinning issues (too loose or too strict version ranges)
- Check for deprecated packages
- Compare against Phase 2 dependency management recommendations
Pattern Heuristics (Grep-able):
- Version pin extremes:
"*", "latest", or exact pins without range ("1.2.3" vs "^1.2.3")
- Duplicate dependency: same lib in multiple package managers or lock files
- Vendored copies: lib source copied into
vendor/ or lib/ that's also in deps
3d. Testing
- Identify untested modules (no corresponding test file)
- Check test quality: look for tests without assertions, overly mocked tests
- Find flaky test indicators (sleep, timing-dependent, order-dependent)
- Check for missing edge case coverage (error paths, boundary conditions)
- Compare test patterns against Phase 2 testing best practices
Pattern Heuristics (Grep-able):
- Tests without assertions:
test( or it( blocks without assert/expect/should
- Sleep-based tests:
time.Sleep, setTimeout, sleep( in test files
- Overly mocked: test files where mock count > assertion count
3e. DevOps & Tooling
- Linter/formatter configured and matching language standards?
- CI pipeline running all quality gates?
- Pre-commit hooks in place?
- Security scanning configured?
Pattern Heuristics (Grep-able):
- Missing lint step: CI config without
lint, check, or fmt step
- No lockfile:
package.json without package-lock.json/yarn.lock/pnpm-lock.yaml
- Hardcoded CI versions: pinned action versions without Dependabot/Renovate for updates
3f. Documentation Debt
- Compare doc comments vs actual function signatures — outdated params, return types
- Find stub docs:
@param x - x parameter, @returns the result, auto-generated placeholders
- Check for missing error documentation (thrown exceptions, error return values)
- Identify public API surface without usage examples
- README accuracy: does it match current setup steps, config, and features?
Pattern Heuristics (Grep-able):
- Stub
@param: @param \w+ - \w+ parameter or @param \w+ - the \w+
- Stub
@returns: @returns the result, @returns {void}
- Missing doc on exports:
export (function|class|const) without preceding /**
- Stale README commands:
npm start / go run in README that don't match package.json scripts or Makefile
3g. Security Debt
- Bare exception handlers that swallow security-relevant errors
- Hardcoded secrets patterns: API keys, tokens, passwords in source
- Unvalidated inputs at system boundaries (HTTP handlers, CLI args, file reads)
- Known CVE patterns in dependencies (cross-reference with
gh api repos/{owner}/{repo}/dependabot/alerts)
- Missing rate limiting, auth checks, or CORS configuration
Pattern Heuristics (Grep-able):
- Hardcoded secrets:
password\s*=\s*", api_key\s*=\s*", token\s*=\s*", secret\s*=\s*"
- SQL injection: string concatenation in queries (
"SELECT.*" \+, f-strings with SQL)
- Insecure random:
Math.random() in security context, rand.Intn without crypto/rand
- Disabled TLS verification:
InsecureSkipVerify, verify=False, NODE_TLS_REJECT_UNAUTHORIZED
If --focus specified: Only run the matching sub-phase (3a-3g).
Phase 4: Prioritize Findings
Rate each finding on 4 axes:
| Rating |
Impact |
Effort |
Contagion |
Business Alignment |
| High |
Causes bugs, security risk, blocks features |
>1 day, architectural change |
Foundational — touches architecture, affects many modules |
Blocks product goals, compliance, or release velocity |
| Medium |
Degrades DX, slows development, tech debt compounds |
Hours, localized change |
Spreads — affects 2-5 modules or shared patterns |
Slows feature delivery but doesn't block |
| Low |
Style, minor inconsistency, nice-to-have |
Minutes, simple fix |
Isolated — contained to 1 module |
No direct business impact |
Contagion (from Riot Games tech debt taxonomy): How far does this debt spread? Isolated debt in a single module is less urgent than foundational debt baked into architecture that every new feature inherits.
Business Alignment: Does fixing this unblock product goals, compliance requirements, or improve release velocity? Debt aligned with business priorities gets promoted.
Priority matrix:
- 🔴 Critical Path Block: High impact + High contagion → Do first even if high effort (architectural rot spreads)
- 🔴 Quick Wins: High impact + Low effort + Low contagion → Do immediately
- 🟠 Strategic: High impact + High effort → Plan & schedule, consider business alignment for ordering
- 🟡 Velocity Improvers: Medium impact + Low effort + reduces dev friction → Batch together
- ⚪ Backlog: Low impact or high contagion with unresolved upstream deps → Track, do opportunistically
Phase 5: Create GitHub Issue
5a. Verify repo has GitHub remote:
gh repo view --json nameWithOwner -q .nameWithOwner
- If no remote, save as local markdown file instead:
./findings/tech-debt/debt-report-{date}.md
5b. Check for existing label:
gh label list --search tech-debt
- If missing:
gh label create tech-debt --description "Technical debt items" --color "D93F0B"
5c. Create issue with this structure:
Title: Tech Debt Audit: {repo-name} ({date})
Body:
## 📊 Tech Debt Audit
**Repo:** {repo-name}
**Stack:** {language} / {framework}
**Date:** {date}
**Scope:** {full | focused area}
## 🔬 Research Context
Key best practices for {language}/{framework} ({year}):
- {Practice 1 — compared against codebase}
- {Practice 2 — compared against codebase}
- {Practice 3 — compared against codebase}
Sources: {URLs from Phase 2}
## 🔴 Critical Path Blocks (High Impact, High Contagion)
- [ ] **{Finding title}** — `file:line` or module-level
Impact: {why this matters}
Contagion: {how far it spreads}
Fix: {concrete approach with specific code reference}
Effort: {what's involved}
## 🔴 Quick Wins (High Impact, Low Effort, Low Contagion)
- [ ] **{Finding title}** — `file:line`
Impact: {why this matters}
Fix: {concrete approach — see actionability examples below}
Ref: {link to best practice if applicable}
## 🟠 Strategic (High Impact, High Effort)
- [ ] **{Finding title}** — `file:line` or module-level
Impact: {why this matters}
Business Alignment: {blocks what goal?}
Fix: {approach + considerations}
Effort: {what's involved}
## 🟡 Velocity Improvers (Medium Impact, Low Effort)
- [ ] **{Finding title}** — `file:line`
Fix: {concrete approach}
DX Gain: {what dev friction it removes}
## ⚪ Backlog
- [ ] **{Finding title}** — {brief description}
## 📈 Summary
| Category | Items | Critical | Quick Wins | Strategic | Velocity | Backlog |
|----------|-------|----------|------------|-----------|----------|---------|
| Code Quality | N | N | N | N | N | N |
| Architecture | N | N | N | N | N | N |
| Dependencies | N | N | N | N | N | N |
| Testing | N | N | N | N | N | N |
| DevOps | N | N | N | N | N | N |
| Documentation | N | N | N | N | N | N |
| Security | N | N | N | N | N | N |
**Recommended next action:** {Single most impactful thing to do first}
5d. Create the issue:
gh issue create --title "Tech Debt Audit: {repo} ({date})" --label tech-debt --body "..."
Phase 6: Measurement Recommendations
Include the following "Measurement" section in the issue body (after the Summary table):
## 📏 Measurement & Tracking
### Baseline Metrics (from this audit)
- Total findings: {count}
- Critical/Quick Win ratio: {critical+quick_wins}/{total}
- Categories with most debt: {top 2-3 categories}
- Estimated total effort: {rough sum}
### Re-audit Cadence
- **Quarterly:** Full re-audit recommended (run this skill again)
- **Monthly:** Spot-check top 3 priority items
- **Per-sprint:** Address at least 1 quick win
### KPIs to Track
- **Complexity trend:** Average cyclomatic complexity per module (should decrease)
- **Bug density:** Bugs per KLOC in debt-heavy modules vs clean modules
- **Release frequency:** Time between deployments (debt reduction should improve)
- **SATD count:** Total TODO/FIXME/HACK comments (should decrease quarterly)
- **Dependency freshness:** % of deps within 1 major version of latest
Phase 7: Summary
Display in chat:
✅ Tech debt audit complete
Issue: {issue-url}
Findings: {total-count}
🔴 Critical + Quick wins: {count}
🟠 Strategic: {count}
🟡 Velocity improvers: {count}
⚪ Backlog: {count}
Top recommendation: {single most impactful action}
Error Handling
- No GitHub remote: Save report as
./findings/tech-debt/debt-report-{date}.md instead
- No findings: Create issue noting clean audit, mention practices verified
- Rate limited on web search: Proceed with codebase analysis only, note limited research in issue
- Very large repo: Focus on src/lib/app directories, skip vendor/generated/node_modules
--focus area not applicable: Inform user, suggest valid areas for this repo
Actionability Standard
Every finding's "Fix" field must be specific enough for a developer to implement without guessing.
Bad examples:
- ❌ "Improve error handling"
- ❌ "Refactor this module"
- ❌ "Add better tests"
- ❌ "Consider using a different approach"
Good examples:
- ✅ "Replace bare
except: at src/api.py:42 with except ValueError as e: logger.error(f'Invalid input: {e}')"
- ✅ "Extract
parseConfig() from main.go:120-185 into pkg/config/parser.go — currently 65 lines with 4 nested ifs"
- ✅ "Add missing
t.Parallel() to TestUserCreate at user_test.go:28 — currently runs sequentially, blocking CI"
- ✅ "Pin
lodash from * to ^4.17.21 in package.json:15 — wildcard allows breaking changes"
Litmus test: Can a developer implement the fix within 2 days without architectural redesign? If no, break into smaller items.
Quality Checklist
Before creating issue:
1---2name: technical-debt-manager3description: Analyze repo for technical debt, research language-specific best practices, create prioritized GitHub issue4---5
6# Technical Debt Manager
7
8Analyze current repo for technical debt by exploring codebase and researching version-specific best practices. Produces a single GitHub issue with prioritized checklist of findings rated across 4 axes (impact, effort, contagion, business alignment) with concrete, actionable fix descriptions and measurement recommendations.
9
10## Arguments
11
12Parse from `$ARGUMENTS`:
13
14- **--focus:** Optional — Narrow analysis to specific area (e.g., `error-handling`, `tests`, `dependencies`, `architecture`). Default: full scan.
15- **--label:** Optional — GitHub issue label. Default: `tech-debt`
16
17---
18
19## Workflow
20
21### Phase 1: Repo Discovery
22
23**1a. Detect language & framework:**
24
25- Read project config files to identify stack:
26 - `package.json`, `tsconfig.json` → TypeScript/JavaScript + framework (React, Next.js, Express, etc.)
27 - `go.mod` → Go
28 - `pyproject.toml`, `setup.py`, `requirements.txt` → Python + framework
29 - `Cargo.toml` → Rust
30 - `Gemfile` → Ruby
31 - `pom.xml`, `build.gradle` → Java/Kotlin
32 - `mise.toml`, `.tool-versions` → Additional tool hints
33- Identify test framework, linter, formatter from config
34- Note monorepo structure if applicable
35
36**1b. Codebase overview:**
37
38- `Glob` for directory structure (top 2 levels)
39- Count files per language
40- Identify entry points, main modules
41- Check for CI/CD config (`.github/workflows/`, `Makefile`, etc.)
42
43**1c. Check existing debt tracking:**
44
45- Search for existing `tech-debt` labeled issues: `gh issue list --label tech-debt --state open`
46- Read CLAUDE.md, README, CONTRIBUTING for known debt/conventions
47- Note any existing TODO/FIXME/HACK conventions
48
49### Phase 2: Research Modern Practices
50
51**2a. Detect specific versions:**
52
53- Extract language VERSION from config (e.g., `"engines": {"node": ">=20"}`, `go 1.22` in go.mod, `python_requires` in pyproject.toml)
54- Extract framework VERSION (e.g., `"react": "^18.2"`, `"next": "14.1"`)
55- Note: version-specific best practices differ significantly (e.g., Go 1.22 vs 1.18, React 18 vs 17)
56
57**2b. Monorepo handling:**
58
59- If monorepo detected (multiple `package.json`, workspace config, `apps/` + `packages/`), research separately per app/package
60- Note shared dependencies and cross-package patterns
61
62**2c. Use WebSearch to find current best practices for detected language/framework.**
63
64Search queries (adapt to detected stack — include detected version):
65
66- `"{language} {version} best practices {year}" maintainable code`
67- `"{framework} {version} common anti-patterns {year}"`
68- `"{language} {version} migration guide" breaking changes` (if version is behind latest)
69- `"{language} code architecture patterns {year}"`
70- `"{language} technical debt indicators checklist"`
71- `"{language} dependency management best practices {year}"`
72
73**Extract from research:**
74
75- Current idiomatic patterns for the **specific language version** in use
76- Common anti-patterns specific to the **framework version**
77- Version-specific deprecations (are they using deprecated APIs for their version?)
78- Recommended project structure
79- Error handling conventions
80- Testing best practices
81- Dependency management guidelines
82- Performance pitfalls
83
84**Save research summary internally for Phase 3 comparison.**
85
86### Phase 3: Codebase Analysis
87
88Run analysis across these categories. For each finding, record: file:line, description, why it matters, fix approach.
89
90**3a. Code Quality (SATD & Complexity)**
91
92- Search for `TODO`, `FIXME`, `HACK`, `XXX`, `WORKAROUND` comments with `Grep`
93 - Extract 3 lines context around each match
94 - Classify severity: `TODO` (low) → `FIXME` (medium) → `HACK` (high) → `XXX` (critical)
95 - Check age via `git blame` on flagged lines — older = higher priority
96 - Group by theme clusters (e.g., "error handling TODOs", "performance FIXMEs")
97- Identify dead code: unused exports, unreachable branches, commented-out code blocks
98- Find overly complex functions (deeply nested, very long)
99- Detect code duplication patterns
100- Check error handling: bare catches, swallowed errors, missing error propagation
101- Compare patterns found against Phase 2 research findings
102
103> **Pattern Heuristics (Grep-able):**
104>
105> - Bare exception handlers: `except:`, `catch {}`, `catch(Exception`, `catch (...)`
106> - Swallowed errors: empty catch blocks (catch + next line is `}`)
107> - God objects: files >1000 lines with many public methods/exports
108> - Commented-out code: `// ` followed by valid syntax patterns across 3+ consecutive lines
109> - Deep nesting: 4+ levels of indentation in control flow
110
111**3b. Architecture**
112
113- Check for circular dependencies or tightly coupled modules
114- Identify inconsistent patterns (e.g., mixed async styles, inconsistent naming)
115- Look for missing abstractions (repeated boilerplate across files)
116- Verify separation of concerns (business logic vs infrastructure)
117- Compare project structure against language-specific recommendations from Phase 2
118
119> **Pattern Heuristics (Grep-able):**
120>
121> - Mixed async: `Promise` + `callback` in same module, `.then()` + `async/await` mixed
122> - Circular imports: mutual import chains (A→B→A)
123> - Feature envy: functions accessing another module's internals more than their own
124> - Barrel file bloat: re-export files >50 entries
125
126**3c. Dependencies**
127
128- Check for outdated dependencies: `gh api repos/{owner}/{repo}/dependabot/alerts` or manual check
129- Look for unused dependencies (imported but not used in code)
130- Identify pinning issues (too loose or too strict version ranges)
131- Check for deprecated packages
132- Compare against Phase 2 dependency management recommendations
133
134> **Pattern Heuristics (Grep-able):**
135>
136> - Version pin extremes: `"*"`, `"latest"`, or exact pins without range (`"1.2.3"` vs `"^1.2.3"`)
137> - Duplicate dependency: same lib in multiple package managers or lock files
138> - Vendored copies: lib source copied into `vendor/` or `lib/` that's also in deps
139
140**3d. Testing**
141
142- Identify untested modules (no corresponding test file)
143- Check test quality: look for tests without assertions, overly mocked tests
144- Find flaky test indicators (sleep, timing-dependent, order-dependent)
145- Check for missing edge case coverage (error paths, boundary conditions)
146- Compare test patterns against Phase 2 testing best practices
147
148> **Pattern Heuristics (Grep-able):**
149>
150> - Tests without assertions: `test(` or `it(` blocks without `assert`/`expect`/`should`
151> - Sleep-based tests: `time.Sleep`, `setTimeout`, `sleep(` in test files
152> - Overly mocked: test files where mock count > assertion count
153
154**3e. DevOps & Tooling**
155
156- Linter/formatter configured and matching language standards?
157- CI pipeline running all quality gates?
158- Pre-commit hooks in place?
159- Security scanning configured?
160
161> **Pattern Heuristics (Grep-able):**
162>
163> - Missing lint step: CI config without `lint`, `check`, or `fmt` step
164> - No lockfile: `package.json` without `package-lock.json`/`yarn.lock`/`pnpm-lock.yaml`
165> - Hardcoded CI versions: pinned action versions without Dependabot/Renovate for updates
166
167**3f. Documentation Debt**
168
169- Compare doc comments vs actual function signatures — outdated params, return types
170- Find stub docs: `@param x - x parameter`, `@returns the result`, auto-generated placeholders
171- Check for missing error documentation (thrown exceptions, error return values)
172- Identify public API surface without usage examples
173- README accuracy: does it match current setup steps, config, and features?
174
175> **Pattern Heuristics (Grep-able):**
176>
177> - Stub `@param`: `@param \w+ - \w+ parameter` or `@param \w+ - the \w+`
178> - Stub `@returns`: `@returns the result`, `@returns {void}`
179> - Missing doc on exports: `export (function|class|const)` without preceding `/**`
180> - Stale README commands: `npm start` / `go run` in README that don't match `package.json` scripts or `Makefile`
181
182**3g. Security Debt**
183
184- Bare exception handlers that swallow security-relevant errors
185- Hardcoded secrets patterns: API keys, tokens, passwords in source
186- Unvalidated inputs at system boundaries (HTTP handlers, CLI args, file reads)
187- Known CVE patterns in dependencies (cross-reference with `gh api repos/{owner}/{repo}/dependabot/alerts`)
188- Missing rate limiting, auth checks, or CORS configuration
189
190> **Pattern Heuristics (Grep-able):**
191>
192> - Hardcoded secrets: `password\s*=\s*"`, `api_key\s*=\s*"`, `token\s*=\s*"`, `secret\s*=\s*"`
193> - SQL injection: string concatenation in queries (`"SELECT.*" \+`, f-strings with SQL)
194> - Insecure random: `Math.random()` in security context, `rand.Intn` without crypto/rand
195> - Disabled TLS verification: `InsecureSkipVerify`, `verify=False`, `NODE_TLS_REJECT_UNAUTHORIZED`
196
197**If `--focus` specified:** Only run the matching sub-phase (3a-3g).
198
199### Phase 4: Prioritize Findings
200
201Rate each finding on 4 axes:
202
203| Rating | Impact | Effort | Contagion | Business Alignment |
204|--------|--------|--------|-----------|-------------------|
205| **High** | Causes bugs, security risk, blocks features | >1 day, architectural change | Foundational — touches architecture, affects many modules | Blocks product goals, compliance, or release velocity |
206| **Medium** | Degrades DX, slows development, tech debt compounds | Hours, localized change | Spreads — affects 2-5 modules or shared patterns | Slows feature delivery but doesn't block |
207| **Low** | Style, minor inconsistency, nice-to-have | Minutes, simple fix | Isolated — contained to 1 module | No direct business impact |
208
209> **Contagion** (from Riot Games tech debt taxonomy): How far does this debt spread? Isolated debt in a single module is less urgent than foundational debt baked into architecture that every new feature inherits.
210>
211> **Business Alignment**: Does fixing this unblock product goals, compliance requirements, or improve release velocity? Debt aligned with business priorities gets promoted.
212
213**Priority matrix:**
214
215- 🔴 **Critical Path Block:** High impact + High contagion → Do first even if high effort (architectural rot spreads)
216- 🔴 **Quick Wins:** High impact + Low effort + Low contagion → Do immediately
217- 🟠 **Strategic:** High impact + High effort → Plan & schedule, consider business alignment for ordering
218- 🟡 **Velocity Improvers:** Medium impact + Low effort + reduces dev friction → Batch together
219- ⚪ **Backlog:** Low impact or high contagion with unresolved upstream deps → Track, do opportunistically
220
221### Phase 5: Create GitHub Issue
222
223**5a. Verify repo has GitHub remote:**
224
225- `gh repo view --json nameWithOwner -q .nameWithOwner`
226- If no remote, save as local markdown file instead: `./findings/tech-debt/debt-report-{date}.md`
227
228**5b. Check for existing label:**
229
230- `gh label list --search tech-debt`
231- If missing: `gh label create tech-debt --description "Technical debt items" --color "D93F0B"`
232
233**5c. Create issue with this structure:**
234
235```markdown
236Title: Tech Debt Audit: {repo-name} ({date})
237
238Body:
239## 📊 Tech Debt Audit
240
241**Repo:** {repo-name}
242**Stack:** {language} / {framework}
243**Date:** {date}
244**Scope:** {full | focused area}
245
246## 🔬 Research Context
247
248Key best practices for {language}/{framework} ({year}):
249- {Practice 1 — compared against codebase}
250- {Practice 2 — compared against codebase}
251- {Practice 3 — compared against codebase}
252
253Sources: {URLs from Phase 2}
254
255## 🔴 Critical Path Blocks (High Impact, High Contagion)
256
257- [ ] **{Finding title}** — `file:line` or module-level
258 Impact: {why this matters}
259 Contagion: {how far it spreads}
260 Fix: {concrete approach with specific code reference}
261 Effort: {what's involved}
262
263## 🔴 Quick Wins (High Impact, Low Effort, Low Contagion)
264
265- [ ] **{Finding title}** — `file:line`
266 Impact: {why this matters}
267 Fix: {concrete approach — see actionability examples below}
268 Ref: {link to best practice if applicable}
269
270## 🟠 Strategic (High Impact, High Effort)
271
272- [ ] **{Finding title}** — `file:line` or module-level
273 Impact: {why this matters}
274 Business Alignment: {blocks what goal?}
275 Fix: {approach + considerations}
276 Effort: {what's involved}
277
278## 🟡 Velocity Improvers (Medium Impact, Low Effort)
279
280- [ ] **{Finding title}** — `file:line`
281 Fix: {concrete approach}
282 DX Gain: {what dev friction it removes}
283
284## ⚪ Backlog
285
286- [ ] **{Finding title}** — {brief description}
287
288## 📈 Summary
289
290| Category | Items | Critical | Quick Wins | Strategic | Velocity | Backlog |
291|----------|-------|----------|------------|-----------|----------|---------|
292| Code Quality | N | N | N | N | N | N |
293| Architecture | N | N | N | N | N | N |
294| Dependencies | N | N | N | N | N | N |
295| Testing | N | N | N | N | N | N |
296| DevOps | N | N | N | N | N | N |
297| Documentation | N | N | N | N | N | N |
298| Security | N | N | N | N | N | N |
299
300**Recommended next action:** {Single most impactful thing to do first}
301```
302
303**5d. Create the issue:**
304
305```bash
306gh issue create --title "Tech Debt Audit: {repo} ({date})" --label tech-debt --body "..."
307```
308
309### Phase 6: Measurement Recommendations
310
311Include the following "Measurement" section in the issue body (after the Summary table):
312
313```markdown
314## 📏 Measurement & Tracking
315
316### Baseline Metrics (from this audit)
317- Total findings: {count}
318- Critical/Quick Win ratio: {critical+quick_wins}/{total}
319- Categories with most debt: {top 2-3 categories}
320- Estimated total effort: {rough sum}
321
322### Re-audit Cadence
323- **Quarterly:** Full re-audit recommended (run this skill again)
324- **Monthly:** Spot-check top 3 priority items
325- **Per-sprint:** Address at least 1 quick win
326
327### KPIs to Track
328- **Complexity trend:** Average cyclomatic complexity per module (should decrease)
329- **Bug density:** Bugs per KLOC in debt-heavy modules vs clean modules
330- **Release frequency:** Time between deployments (debt reduction should improve)
331- **SATD count:** Total TODO/FIXME/HACK comments (should decrease quarterly)
332- **Dependency freshness:** % of deps within 1 major version of latest
333```
334
335### Phase 7: Summary
336
337Display in chat:
338
339```
340✅ Tech debt audit complete
341
342Issue: {issue-url}
343Findings: {total-count}
344 🔴 Critical + Quick wins: {count}
345 🟠 Strategic: {count}
346 🟡 Velocity improvers: {count}
347 ⚪ Backlog: {count}
348
349Top recommendation: {single most impactful action}
350```
351
352---
353
354## Error Handling
355
356- **No GitHub remote:** Save report as `./findings/tech-debt/debt-report-{date}.md` instead
357- **No findings:** Create issue noting clean audit, mention practices verified
358- **Rate limited on web search:** Proceed with codebase analysis only, note limited research in issue
359- **Very large repo:** Focus on src/lib/app directories, skip vendor/generated/node_modules
360- **`--focus` area not applicable:** Inform user, suggest valid areas for this repo
361
362## Actionability Standard
363
364Every finding's "Fix" field must be specific enough for a developer to implement without guessing.
365
366**Bad examples:**
367
368- ❌ "Improve error handling"
369- ❌ "Refactor this module"
370- ❌ "Add better tests"
371- ❌ "Consider using a different approach"
372
373**Good examples:**
374
375- ✅ "Replace bare `except:` at `src/api.py:42` with `except ValueError as e: logger.error(f'Invalid input: {e}')`"
376- ✅ "Extract `parseConfig()` from `main.go:120-185` into `pkg/config/parser.go` — currently 65 lines with 4 nested ifs"
377- ✅ "Add missing `t.Parallel()` to `TestUserCreate` at `user_test.go:28` — currently runs sequentially, blocking CI"
378- ✅ "Pin `lodash` from `*` to `^4.17.21` in `package.json:15` — wildcard allows breaking changes"
379
380**Litmus test:** Can a developer implement the fix within 2 days without architectural redesign? If no, break into smaller items.
381
382## Quality Checklist
383
384Before creating issue:
385
386- [ ] Language and framework correctly identified (including version)
387- [ ] Web research completed with current-year sources
388- [ ] Every finding has file:line reference (or module-level for architecture)
389- [ ] Every finding has concrete fix approach (passes actionability standard above)
390- [ ] All 4 priority axes rated (Impact, Effort, Contagion, Business Alignment)
391- [ ] Findings grouped by priority matrix
392- [ ] Summary table counts are accurate
393- [ ] No duplicate findings
394- [ ] Research context section links findings to best practices
395- [ ] Each fix is implementable within 2 days (or broken into sub-items)
396- [ ] Security findings prioritized regardless of effort