codingbuddy-rules 4.3.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.
- package/.ai-rules/adapters/antigravity.md +648 -160
- package/.ai-rules/adapters/codex.md +500 -10
- package/.ai-rules/adapters/cursor.md +252 -8
- package/.ai-rules/adapters/kiro.md +551 -93
- package/.ai-rules/adapters/opencode-skills.md +179 -188
- package/.ai-rules/adapters/opencode.md +245 -44
- package/.ai-rules/skills/README.md +92 -24
- package/.ai-rules/skills/agent-design/SKILL.md +269 -0
- package/.ai-rules/skills/code-explanation/SKILL.md +259 -0
- package/.ai-rules/skills/context-management/SKILL.md +244 -0
- package/.ai-rules/skills/deployment-checklist/SKILL.md +233 -0
- package/.ai-rules/skills/documentation-generation/SKILL.md +293 -0
- package/.ai-rules/skills/error-analysis/SKILL.md +250 -0
- package/.ai-rules/skills/legacy-modernization/SKILL.md +292 -0
- package/.ai-rules/skills/mcp-builder/SKILL.md +356 -0
- package/.ai-rules/skills/prompt-engineering/SKILL.md +318 -0
- package/.ai-rules/skills/rule-authoring/SKILL.md +273 -0
- package/.ai-rules/skills/security-audit/SKILL.md +241 -0
- package/.ai-rules/skills/tech-debt/SKILL.md +224 -0
- package/package.json +1 -1
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-audit
|
|
3
|
+
description: Use when reviewing code for security vulnerabilities, before shipping features, or conducting security assessments. Covers OWASP Top 10, secrets exposure, authentication, and authorization flaws.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Security Audit
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Security vulnerabilities are invisible until exploited. This skill provides a systematic approach to finding them before attackers do.
|
|
11
|
+
|
|
12
|
+
**Core principle:** ASSUME BREACH. Review every input, every output, every boundary.
|
|
13
|
+
|
|
14
|
+
**Iron Law:**
|
|
15
|
+
```
|
|
16
|
+
NO SECURITY REVIEW WITHOUT THREAT MODELING FIRST
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## When to Use
|
|
20
|
+
|
|
21
|
+
- Before merging any authentication or authorization code
|
|
22
|
+
- Before shipping features that handle user data
|
|
23
|
+
- When adding third-party dependencies
|
|
24
|
+
- After environment variable / secrets changes
|
|
25
|
+
- Periodic security sweeps on production code
|
|
26
|
+
- Reviewing MCP server endpoints (especially SSE/HTTP transport)
|
|
27
|
+
|
|
28
|
+
## The Four Phases
|
|
29
|
+
|
|
30
|
+
### Phase 1: Threat Modeling
|
|
31
|
+
|
|
32
|
+
**Before reviewing any code:**
|
|
33
|
+
|
|
34
|
+
1. **Identify Assets** — What are we protecting? (user data, tokens, credentials, business logic)
|
|
35
|
+
2. **Identify Attack Surfaces** — HTTP endpoints, file uploads, environment vars, third-party integrations
|
|
36
|
+
3. **Identify Threat Actors** — External attackers, malicious insiders, compromised dependencies
|
|
37
|
+
4. **Map Data Flow** — Where does sensitive data enter, travel, and exit?
|
|
38
|
+
|
|
39
|
+
### Phase 2: OWASP Top 10 Checklist
|
|
40
|
+
|
|
41
|
+
Work through each category systematically:
|
|
42
|
+
|
|
43
|
+
#### A01: Broken Access Control
|
|
44
|
+
```
|
|
45
|
+
- [ ] Every endpoint checks authentication
|
|
46
|
+
- [ ] Authorization verified per-resource, not just per-route
|
|
47
|
+
- [ ] IDOR: Can user A access user B's data by changing ID?
|
|
48
|
+
- [ ] Admin routes protected from regular users
|
|
49
|
+
- [ ] CORS policy restricts allowed origins
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
#### A02: Cryptographic Failures
|
|
53
|
+
```
|
|
54
|
+
- [ ] No plaintext passwords stored
|
|
55
|
+
- [ ] Sensitive data encrypted at rest (PII, tokens, keys)
|
|
56
|
+
- [ ] TLS enforced for all connections
|
|
57
|
+
- [ ] Weak algorithms absent (MD5, SHA1 for passwords, DES)
|
|
58
|
+
- [ ] Secrets not in code, logs, or URLs
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
#### A03: Injection
|
|
62
|
+
```sql
|
|
63
|
+
-- ❌ SQL Injection vulnerable
|
|
64
|
+
db.query(`SELECT * FROM users WHERE id = ${userId}`);
|
|
65
|
+
|
|
66
|
+
-- ✅ Parameterized
|
|
67
|
+
db.query('SELECT * FROM users WHERE id = ?', [userId]);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
// ❌ Command Injection
|
|
72
|
+
exec(`ls ${userInput}`);
|
|
73
|
+
|
|
74
|
+
// ✅ Safe
|
|
75
|
+
execFile('ls', [userInput]);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
// ❌ XSS
|
|
80
|
+
element.innerHTML = userInput;
|
|
81
|
+
|
|
82
|
+
// ✅ Safe
|
|
83
|
+
element.textContent = userInput;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
#### A04: Insecure Design
|
|
87
|
+
```
|
|
88
|
+
- [ ] Rate limiting on sensitive endpoints (login, password reset)
|
|
89
|
+
- [ ] Account lockout after failed attempts
|
|
90
|
+
- [ ] Password reset tokens expire (< 15 minutes)
|
|
91
|
+
- [ ] Sensitive operations require re-authentication
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### A05: Security Misconfiguration
|
|
95
|
+
```
|
|
96
|
+
- [ ] Debug mode disabled in production
|
|
97
|
+
- [ ] Default credentials changed
|
|
98
|
+
- [ ] Unnecessary features/endpoints disabled
|
|
99
|
+
- [ ] Security headers present (CSP, HSTS, X-Frame-Options)
|
|
100
|
+
- [ ] Error messages don't expose stack traces to users
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### A06: Vulnerable Components
|
|
104
|
+
```bash
|
|
105
|
+
# Check for known CVEs
|
|
106
|
+
npm audit
|
|
107
|
+
yarn audit
|
|
108
|
+
|
|
109
|
+
# Check for outdated packages with vulnerabilities
|
|
110
|
+
npx audit-ci --moderate
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
#### A07: Authentication Failures
|
|
114
|
+
```
|
|
115
|
+
- [ ] Session IDs invalidated on logout
|
|
116
|
+
- [ ] JWT secrets sufficiently random (>= 256 bits)
|
|
117
|
+
- [ ] JWT expiry set appropriately (access: minutes, refresh: days)
|
|
118
|
+
- [ ] Brute force protection on login
|
|
119
|
+
- [ ] Multi-factor authentication available for sensitive actions
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### A08: Software Integrity Failures
|
|
123
|
+
```
|
|
124
|
+
- [ ] Dependencies pinned to exact versions
|
|
125
|
+
- [ ] Subresource integrity (SRI) for CDN assets
|
|
126
|
+
- [ ] CI/CD pipeline secured (no untrusted code execution)
|
|
127
|
+
- [ ] Package signatures verified where possible
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### A09: Logging Failures
|
|
131
|
+
```
|
|
132
|
+
- [ ] Authentication events logged (success + failure)
|
|
133
|
+
- [ ] Authorization failures logged
|
|
134
|
+
- [ ] No sensitive data (passwords, tokens, PII) in logs
|
|
135
|
+
- [ ] Log tampering prevented
|
|
136
|
+
- [ ] Alerts set for suspicious patterns
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### A10: Server-Side Request Forgery (SSRF)
|
|
140
|
+
```
|
|
141
|
+
- [ ] User-supplied URLs validated against allowlist
|
|
142
|
+
- [ ] Internal network addresses blocked from user input
|
|
143
|
+
- [ ] DNS rebinding protection
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Phase 3: Secrets & Credentials Scan
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Scan for hardcoded secrets
|
|
150
|
+
grep -rn "password\|secret\|token\|api_key\|apikey\|private_key" \
|
|
151
|
+
--include="*.ts" --include="*.js" --include="*.env*" \
|
|
152
|
+
--exclude-dir=node_modules .
|
|
153
|
+
|
|
154
|
+
# Check .gitignore covers sensitive files
|
|
155
|
+
cat .gitignore | grep -E "\.env|\.key|credentials"
|
|
156
|
+
|
|
157
|
+
# Verify no secrets in git history
|
|
158
|
+
git log --all --full-history -- "*.env" "*.key" "credentials*"
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Common secret patterns to find:**
|
|
162
|
+
```
|
|
163
|
+
❌ const API_KEY = "sk-abc123..."
|
|
164
|
+
❌ password: "admin123"
|
|
165
|
+
❌ Authorization: "Bearer eyJ..." (hardcoded)
|
|
166
|
+
❌ connectionString = "mongodb://user:pass@host"
|
|
167
|
+
|
|
168
|
+
✅ const API_KEY = process.env.API_KEY
|
|
169
|
+
✅ password: process.env.DB_PASSWORD
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Phase 4: MCP Server Specific (codingbuddy)
|
|
173
|
+
|
|
174
|
+
For MCP servers using SSE/HTTP transport:
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
// ❌ No authentication
|
|
178
|
+
app.use('/sse', sseHandler);
|
|
179
|
+
|
|
180
|
+
// ✅ Bearer token validation
|
|
181
|
+
app.use('/sse', (req, res, next) => {
|
|
182
|
+
const token = req.headers.authorization?.replace('Bearer ', '');
|
|
183
|
+
if (process.env.MCP_SSE_TOKEN && token !== process.env.MCP_SSE_TOKEN) {
|
|
184
|
+
return res.status(401).json({ error: 'Unauthorized' });
|
|
185
|
+
}
|
|
186
|
+
next();
|
|
187
|
+
});
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
- [ ] SSE endpoint authenticates when MCP_SSE_TOKEN is set
|
|
192
|
+
- [ ] CORS configured for trusted origins only
|
|
193
|
+
- [ ] Rate limiting on MCP tool calls
|
|
194
|
+
- [ ] Input validation on all tool parameters
|
|
195
|
+
- [ ] No sensitive data in MCP resource URIs
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Red Flags — STOP
|
|
199
|
+
|
|
200
|
+
| Thought | Reality |
|
|
201
|
+
|---------|---------|
|
|
202
|
+
| "We're not a target" | Every internet-facing system is a target |
|
|
203
|
+
| "This is internal only" | Insider threats are real; internal ≠ trusted |
|
|
204
|
+
| "The framework handles it" | Frameworks have defaults that must be configured |
|
|
205
|
+
| "We'll add security later" | Retrofitting security costs 10× more |
|
|
206
|
+
| "Tests don't cover security" | Security requires dedicated review, not just tests |
|
|
207
|
+
|
|
208
|
+
## Quick Reference
|
|
209
|
+
|
|
210
|
+
| Category | Check | Tool |
|
|
211
|
+
|----------|-------|------|
|
|
212
|
+
| Dependencies | CVE scan | `npm audit` |
|
|
213
|
+
| Secrets | Hardcoded creds | grep + git-secrets |
|
|
214
|
+
| Injection | SQL, XSS, Command | Manual + ESLint |
|
|
215
|
+
| Auth | JWT, sessions | Manual review |
|
|
216
|
+
| Headers | CSP, HSTS | securityheaders.com |
|
|
217
|
+
| OWASP | Top 10 | ZAP, Burp Suite |
|
|
218
|
+
|
|
219
|
+
## Output Format
|
|
220
|
+
|
|
221
|
+
Document findings as:
|
|
222
|
+
|
|
223
|
+
```markdown
|
|
224
|
+
## Security Audit Report — YYYY-MM-DD
|
|
225
|
+
|
|
226
|
+
### Critical (fix before deploy)
|
|
227
|
+
- [ ] SQL injection in /api/users endpoint (line 42, users.service.ts)
|
|
228
|
+
|
|
229
|
+
### High (fix within 24h)
|
|
230
|
+
- [ ] JWT secret too short (< 256 bits)
|
|
231
|
+
|
|
232
|
+
### Medium (fix this sprint)
|
|
233
|
+
- [ ] Missing rate limiting on /auth/login
|
|
234
|
+
|
|
235
|
+
### Low (backlog)
|
|
236
|
+
- [ ] Verbose error messages in development mode
|
|
237
|
+
|
|
238
|
+
### Passed Checks
|
|
239
|
+
- [x] No hardcoded secrets found
|
|
240
|
+
- [x] All endpoints require authentication
|
|
241
|
+
```
|
|
@@ -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 |
|