codingbuddy-rules 4.2.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,224 @@
1
+ ---
2
+ name: tech-debt
3
+ description: Use when identifying, prioritizing, and planning resolution of technical debt. Provides structured assessment, ROI-based prioritization, and incremental paydown strategies.
4
+ ---
5
+
6
+ # Tech Debt
7
+
8
+ ## Overview
9
+
10
+ Technical debt is borrowed time — the gap between the code you have and the code you need. Left unmanaged, it compounds interest: every new feature costs more, every bug takes longer to fix.
11
+
12
+ **Core principle:** Not all debt is equal. Pay down debt that blocks you, not debt that merely annoys you.
13
+
14
+ **Iron Law:**
15
+ ```
16
+ MEASURE DEBT BEFORE PAYING IT. PRIORITIZE BY IMPACT, NOT BY DISCOMFORT.
17
+ ```
18
+
19
+ ## When to Use
20
+
21
+ - Sprint planning (decide which debt to pay down)
22
+ - Before major feature work (assess what debt will slow you down)
23
+ - After incidents (identify debt that contributed)
24
+ - Quarterly tech health reviews
25
+ - Before refactoring (use the refactoring skill after this one)
26
+
27
+ ## Types of Technical Debt
28
+
29
+ | Type | Example | Urgency |
30
+ |------|---------|---------|
31
+ | **Critical** | Security vulnerability, data loss risk | Fix now |
32
+ | **Architectural** | God class, circular dependencies | Fix before next major feature |
33
+ | **Code quality** | Duplicated logic, magic numbers | Fix this quarter |
34
+ | **Test debt** | Missing tests, brittle tests | Fix this sprint |
35
+ | **Documentation debt** | Outdated docs, missing docs | Fix when touching code |
36
+ | **Dependency debt** | Outdated packages, EOL dependencies | Fix on cadence |
37
+ | **Performance debt** | N+1 queries, memory leaks | Fix when it hurts |
38
+
39
+ ## The Assessment Process
40
+
41
+ ### Phase 1: Discover
42
+
43
+ **Automated discovery:**
44
+ ```bash
45
+ # Code complexity
46
+ npx ts-complexity src/ --threshold 10
47
+
48
+ # Duplicate code
49
+ npx jscpd src/ --min-lines 5 --reporters console
50
+
51
+ # Test coverage gaps
52
+ npx jest --coverage
53
+
54
+ # Dependency age and CVEs
55
+ npm outdated
56
+ npm audit
57
+
58
+ # TODO/FIXME/HACK markers
59
+ grep -rn "TODO\|FIXME\|HACK\|XXX\|TEMP\|WORKAROUND" \
60
+ --include="*.ts" --include="*.js" src/ | wc -l
61
+ ```
62
+
63
+ **Manual discovery checklist:**
64
+ ```
65
+ Architecture smells:
66
+ - [ ] Classes > 300 lines (God class)
67
+ - [ ] Functions > 30 lines (God function)
68
+ - [ ] Files with > 10 imports (high coupling)
69
+ - [ ] Circular dependencies
70
+ - [ ] Global mutable state
71
+
72
+ Code quality smells:
73
+ - [ ] Duplicate code blocks (> 5 lines, 2+ occurrences)
74
+ - [ ] Magic numbers/strings without constants
75
+ - [ ] Deep nesting (> 3 levels)
76
+ - [ ] Long parameter lists (> 4 params)
77
+ - [ ] Boolean traps (function(true, false, false))
78
+
79
+ Test smells:
80
+ - [ ] Test coverage < 80%
81
+ - [ ] Tests that always pass (no assertions)
82
+ - [ ] Tests that mock everything
83
+ - [ ] No integration tests
84
+ - [ ] Flaky tests
85
+ ```
86
+
87
+ ### Phase 2: Catalog
88
+
89
+ Create a tech debt register:
90
+
91
+ ```markdown
92
+ ## Tech Debt Register — [Date]
93
+
94
+ | ID | Type | Description | File | Discovered | Owner |
95
+ |----|------|-------------|------|------------|-------|
96
+ | TD-001 | Architecture | McpService is a God class (450 lines) | mcp.service.ts | 2024-01-15 | — |
97
+ | TD-002 | Test | RulesService has 45% coverage | rules.service.ts | 2024-01-15 | — |
98
+ | TD-003 | Dependency | NestJS 9 → 10 migration pending | package.json | 2024-01-15 | — |
99
+ | TD-004 | Code quality | searchRules logic duplicated 3 times | *.service.ts | 2024-01-15 | — |
100
+ ```
101
+
102
+ ### Phase 3: Prioritize
103
+
104
+ **Priority formula:**
105
+ ```
106
+ Priority Score = (Velocity Impact × Bug Risk) / Effort
107
+
108
+ Scale: 1-5 for each factor
109
+ - Velocity Impact: How much does this slow down development?
110
+ - Bug Risk: How likely is this to cause bugs?
111
+ - Effort: How hard is this to fix?
112
+ ```
113
+
114
+ **Prioritization matrix:**
115
+ ```markdown
116
+ | ID | Description | Velocity | Bug Risk | Effort | Score |
117
+ |----|-------------|----------|----------|--------|-------|
118
+ | TD-001 | God class McpService | 4 | 3 | 4 | (4×3)/4 = 3.0 |
119
+ | TD-002 | Low test coverage | 3 | 5 | 2 | (3×5)/2 = 7.5 ← Fix first |
120
+ | TD-003 | NestJS upgrade | 2 | 3 | 3 | (2×3)/3 = 2.0 |
121
+ | TD-004 | Duplicate logic | 3 | 3 | 1 | (3×3)/1 = 9.0 ← Fix first |
122
+ ```
123
+
124
+ **Priority tiers:**
125
+ - **Score ≥ 7**: Fix this sprint (blocks progress)
126
+ - **Score 4-7**: Fix this quarter (accumulating interest)
127
+ - **Score < 4**: Backlog (low ROI)
128
+
129
+ ### Phase 4: Plan Resolution
130
+
131
+ For each high-priority item, create a paydown plan:
132
+
133
+ ```markdown
134
+ ## Paydown Plan: TD-004 (Duplicate searchRules logic)
135
+
136
+ **Goal:** Extract shared search logic into reusable utility
137
+
138
+ **Approach:** Refactoring skill (not a rewrite)
139
+
140
+ **Steps:**
141
+ 1. Write tests covering all three duplicate sites (2h)
142
+ 2. Extract to `src/shared/search.utils.ts` (1h)
143
+ 3. Replace all three call sites (1h)
144
+ 4. Verify tests pass (30m)
145
+
146
+ **Risk:** Low — covered by tests before and after
147
+ **Estimate:** 4.5h
148
+ **Assigned to:** —
149
+
150
+ **Definition of Done:**
151
+ - [ ] Tests cover all search scenarios
152
+ - [ ] Single implementation in search.utils.ts
153
+ - [ ] All three call sites use shared utility
154
+ - [ ] Coverage increased to > 90% for search logic
155
+ ```
156
+
157
+ ### Phase 5: Track Progress
158
+
159
+ Update the debt register as items are resolved:
160
+
161
+ ```markdown
162
+ | ID | Status | Resolution | Date |
163
+ |----|--------|------------|------|
164
+ | TD-004 | ✅ Done | Extracted to search.utils.ts | 2024-01-20 |
165
+ | TD-002 | 🔄 In Progress | Coverage at 78%, target 90% | — |
166
+ | TD-001 | 📋 Planned | Sprint 5 | — |
167
+ | TD-003 | 🚫 Deferred | Low score, Q2 | — |
168
+ ```
169
+
170
+ ## Debt Prevention
171
+
172
+ Good practices that prevent debt accumulation:
173
+
174
+ ```
175
+ Definition of Done (add these):
176
+ - [ ] New code has > 80% test coverage
177
+ - [ ] No functions > 30 lines
178
+ - [ ] No TODO/FIXME left in merged code
179
+ - [ ] Dependencies not introducing CVEs
180
+ - [ ] Architecture review for files > 200 lines
181
+ ```
182
+
183
+ **The Boy Scout Rule:** Leave code cleaner than you found it.
184
+ - Fix ONE small thing whenever you touch a file
185
+ - 10 minutes per PR on adjacent debt
186
+ - Over time: debt decreases without dedicated sprints
187
+
188
+ ## Talking About Debt
189
+
190
+ **With product managers:**
191
+ ```
192
+ ❌ "We need a refactoring sprint"
193
+ ✅ "The authentication module is slowing every login feature
194
+ by 3x. A 2-day investment now saves 6 days in the next
195
+ quarter. Here's the ROI breakdown."
196
+ ```
197
+
198
+ **In sprint planning:**
199
+ ```
200
+ Rule of thumb:
201
+ - 20% capacity on debt paydown (sustainable)
202
+ - 0% = debt accumulates, velocity declines
203
+ - 50%+ = not enough new value
204
+ ```
205
+
206
+ ## Quick Reference
207
+
208
+ | Signal | Likely Debt Type | Action |
209
+ |--------|-----------------|--------|
210
+ | New features take 2× longer | Architectural debt | God class audit |
211
+ | Same bug keeps appearing | Test debt | Coverage analysis |
212
+ | Security alert | Dependency debt | `npm audit fix` |
213
+ | "Nobody touches that file" | Code quality debt | Complexity analysis |
214
+ | Onboarding takes weeks | Documentation debt | Codebase guide |
215
+
216
+ ## Red Flags — STOP
217
+
218
+ | Thought | Reality |
219
+ |---------|---------|
220
+ | "We'll pay it back later" | Without a plan, later = never |
221
+ | "All debt is bad" | Debt taken consciously is a tool |
222
+ | "We need a big rewrite" | Incremental refactoring is safer |
223
+ | "Let's fix it all this sprint" | Context switches kill velocity |
224
+ | "The score is wrong for this item" | Trust the formula; bias skews perception |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codingbuddy-rules",
3
- "version": "4.2.0",
3
+ "version": "4.4.0",
4
4
  "description": "AI coding rules for consistent practices across AI assistants",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",