start-vibing 2.0.11 → 2.0.13
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/README.md +177 -177
- package/dist/cli.js +19 -2
- package/package.json +42 -42
- package/template/.claude/CLAUDE.md +174 -174
- package/template/.claude/agents/01-orchestration/agent-selector.md +130 -130
- package/template/.claude/agents/01-orchestration/checkpoint-manager.md +142 -142
- package/template/.claude/agents/01-orchestration/context-manager.md +138 -138
- package/template/.claude/agents/01-orchestration/error-recovery.md +182 -182
- package/template/.claude/agents/01-orchestration/orchestrator.md +114 -114
- package/template/.claude/agents/01-orchestration/parallel-coordinator.md +141 -141
- package/template/.claude/agents/01-orchestration/task-decomposer.md +121 -121
- package/template/.claude/agents/01-orchestration/workflow-router.md +114 -114
- package/template/.claude/agents/02-typescript/bun-runtime-expert.md +197 -197
- package/template/.claude/agents/02-typescript/esm-resolver.md +193 -193
- package/template/.claude/agents/02-typescript/import-alias-enforcer.md +158 -158
- package/template/.claude/agents/02-typescript/ts-generics-helper.md +183 -183
- package/template/.claude/agents/02-typescript/ts-migration-helper.md +238 -238
- package/template/.claude/agents/02-typescript/ts-strict-checker.md +180 -180
- package/template/.claude/agents/02-typescript/ts-types-analyzer.md +199 -199
- package/template/.claude/agents/02-typescript/type-definition-writer.md +187 -187
- package/template/.claude/agents/02-typescript/zod-schema-designer.md +212 -212
- package/template/.claude/agents/02-typescript/zod-validator.md +158 -158
- package/template/.claude/agents/03-testing/playwright-assertions.md +265 -265
- package/template/.claude/agents/03-testing/playwright-e2e.md +247 -247
- package/template/.claude/agents/03-testing/playwright-fixtures.md +234 -234
- package/template/.claude/agents/03-testing/playwright-multi-viewport.md +256 -256
- package/template/.claude/agents/03-testing/playwright-page-objects.md +247 -247
- package/template/.claude/agents/03-testing/test-cleanup-manager.md +248 -248
- package/template/.claude/agents/03-testing/test-data-generator.md +254 -254
- package/template/.claude/agents/03-testing/tester-integration.md +278 -278
- package/template/.claude/agents/03-testing/tester-unit.md +207 -207
- package/template/.claude/agents/03-testing/vitest-config.md +287 -287
- package/template/.claude/agents/04-docker/container-health.md +255 -255
- package/template/.claude/agents/04-docker/deployment-validator.md +225 -225
- package/template/.claude/agents/04-docker/docker-compose-designer.md +281 -281
- package/template/.claude/agents/04-docker/docker-env-manager.md +235 -235
- package/template/.claude/agents/04-docker/docker-multi-stage.md +241 -241
- package/template/.claude/agents/04-docker/dockerfile-optimizer.md +208 -208
- package/template/.claude/agents/05-database/database-seeder.md +273 -273
- package/template/.claude/agents/05-database/mongodb-query-optimizer.md +230 -230
- package/template/.claude/agents/05-database/mongoose-aggregation.md +306 -306
- package/template/.claude/agents/05-database/mongoose-index-optimizer.md +182 -182
- package/template/.claude/agents/05-database/mongoose-schema-designer.md +267 -267
- package/template/.claude/agents/06-security/auth-session-validator.md +68 -68
- package/template/.claude/agents/06-security/input-sanitizer.md +80 -80
- package/template/.claude/agents/06-security/owasp-checker.md +97 -97
- package/template/.claude/agents/06-security/permission-auditor.md +100 -100
- package/template/.claude/agents/06-security/security-auditor.md +84 -84
- package/template/.claude/agents/06-security/sensitive-data-scanner.md +83 -83
- package/template/.claude/agents/07-documentation/api-documenter.md +136 -136
- package/template/.claude/agents/07-documentation/changelog-manager.md +105 -105
- package/template/.claude/agents/07-documentation/documenter.md +76 -76
- package/template/.claude/agents/07-documentation/domain-updater.md +81 -81
- package/template/.claude/agents/07-documentation/jsdoc-generator.md +114 -114
- package/template/.claude/agents/07-documentation/readme-generator.md +135 -135
- package/template/.claude/agents/08-git/branch-manager.md +58 -58
- package/template/.claude/agents/08-git/commit-manager.md +63 -63
- package/template/.claude/agents/08-git/pr-creator.md +76 -76
- package/template/.claude/agents/09-quality/code-reviewer.md +71 -71
- package/template/.claude/agents/09-quality/quality-checker.md +67 -67
- package/template/.claude/agents/10-research/best-practices-finder.md +89 -89
- package/template/.claude/agents/10-research/competitor-analyzer.md +106 -106
- package/template/.claude/agents/10-research/pattern-researcher.md +93 -93
- package/template/.claude/agents/10-research/research-cache-manager.md +76 -76
- package/template/.claude/agents/10-research/research-web.md +98 -98
- package/template/.claude/agents/10-research/tech-evaluator.md +101 -101
- package/template/.claude/agents/11-ui-ux/accessibility-auditor.md +136 -136
- package/template/.claude/agents/11-ui-ux/design-system-enforcer.md +125 -125
- package/template/.claude/agents/11-ui-ux/skeleton-generator.md +118 -118
- package/template/.claude/agents/11-ui-ux/ui-desktop.md +132 -132
- package/template/.claude/agents/11-ui-ux/ui-mobile.md +98 -98
- package/template/.claude/agents/11-ui-ux/ui-tablet.md +110 -110
- package/template/.claude/agents/12-performance/api-latency-analyzer.md +156 -156
- package/template/.claude/agents/12-performance/bundle-analyzer.md +113 -113
- package/template/.claude/agents/12-performance/memory-leak-detector.md +137 -137
- package/template/.claude/agents/12-performance/performance-profiler.md +115 -115
- package/template/.claude/agents/12-performance/query-optimizer.md +124 -124
- package/template/.claude/agents/12-performance/render-optimizer.md +154 -154
- package/template/.claude/agents/13-debugging/build-error-fixer.md +207 -207
- package/template/.claude/agents/13-debugging/debugger.md +149 -149
- package/template/.claude/agents/13-debugging/error-stack-analyzer.md +141 -141
- package/template/.claude/agents/13-debugging/network-debugger.md +208 -208
- package/template/.claude/agents/13-debugging/runtime-error-fixer.md +181 -181
- package/template/.claude/agents/13-debugging/type-error-resolver.md +185 -185
- package/template/.claude/agents/14-validation/final-validator.md +93 -93
- package/template/.claude/agents/_backup/analyzer.md +134 -134
- package/template/.claude/agents/_backup/code-reviewer.md +279 -279
- package/template/.claude/agents/_backup/commit-manager.md +219 -219
- package/template/.claude/agents/_backup/debugger.md +280 -280
- package/template/.claude/agents/_backup/documenter.md +237 -237
- package/template/.claude/agents/_backup/domain-updater.md +197 -197
- package/template/.claude/agents/_backup/final-validator.md +169 -169
- package/template/.claude/agents/_backup/orchestrator.md +149 -149
- package/template/.claude/agents/_backup/performance.md +232 -232
- package/template/.claude/agents/_backup/quality-checker.md +240 -240
- package/template/.claude/agents/_backup/research.md +315 -315
- package/template/.claude/agents/_backup/security-auditor.md +192 -192
- package/template/.claude/agents/_backup/tester.md +566 -566
- package/template/.claude/agents/_backup/ui-ux-reviewer.md +247 -247
- package/template/.claude/config/README.md +30 -30
- package/template/.claude/config/mcp-config.json +344 -344
- package/template/.claude/config/project-config.json +53 -53
- package/template/.claude/config/quality-gates.json +46 -46
- package/template/.claude/config/security-rules.json +45 -45
- package/template/.claude/config/testing-config.json +164 -164
- package/template/.claude/hooks/SETUP.md +126 -126
- package/template/.claude/hooks/run-hook.ts +176 -176
- package/template/.claude/hooks/stop-validator.ts +914 -824
- package/template/.claude/hooks/user-prompt-submit.ts +886 -886
- package/template/.claude/scripts/mcp-quick-install.ts +151 -151
- package/template/.claude/scripts/setup-mcps.ts +651 -651
- package/template/.claude/settings.json +275 -275
- package/template/.claude/skills/bun-runtime/SKILL.md +430 -430
- package/template/.claude/skills/codebase-knowledge/domains/claude-system.md +431 -431
- package/template/.claude/skills/codebase-knowledge/domains/mcp-integration.md +295 -295
- package/template/.claude/skills/debugging-patterns/SKILL.md +485 -485
- package/template/.claude/skills/docker-patterns/SKILL.md +555 -555
- package/template/.claude/skills/git-workflow/SKILL.md +454 -454
- package/template/.claude/skills/mongoose-patterns/SKILL.md +499 -499
- package/template/.claude/skills/nextjs-app-router/SKILL.md +327 -327
- package/template/.claude/skills/performance-patterns/SKILL.md +547 -547
- package/template/.claude/skills/playwright-automation/SKILL.md +438 -438
- package/template/.claude/skills/react-patterns/SKILL.md +389 -389
- package/template/.claude/skills/research-cache/SKILL.md +222 -222
- package/template/.claude/skills/shadcn-ui/SKILL.md +511 -511
- package/template/.claude/skills/tailwind-patterns/SKILL.md +465 -465
- package/template/.claude/skills/test-coverage/SKILL.md +467 -467
- package/template/.claude/skills/trpc-api/SKILL.md +434 -434
- package/template/.claude/skills/typescript-strict/SKILL.md +367 -367
- package/template/.claude/skills/zod-validation/SKILL.md +403 -403
- package/template/CLAUDE.md +117 -117
|
@@ -1,485 +1,485 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: debugging-patterns
|
|
3
|
-
description: Debugging strategies and error resolution patterns. Stack trace analysis, runtime errors, build errors, network issues. Use when debugging any type of error.
|
|
4
|
-
allowed-tools: Read, Write, Edit, Bash, Grep, Glob
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Debugging Patterns - Error Resolution Best Practices
|
|
8
|
-
|
|
9
|
-
## Purpose
|
|
10
|
-
|
|
11
|
-
Expert guidance for debugging:
|
|
12
|
-
|
|
13
|
-
- **Error Analysis** - Stack traces, error messages
|
|
14
|
-
- **Runtime Issues** - Type errors, null references
|
|
15
|
-
- **Build Errors** - Compilation, bundling
|
|
16
|
-
- **Network Issues** - API, CORS, HTTP errors
|
|
17
|
-
- **Performance Bugs** - Slow operations, memory leaks
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Debug Process
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
1. UNDERSTAND - What should happen vs what happens
|
|
25
|
-
↓
|
|
26
|
-
2. REPRODUCE - Consistent steps to trigger bug
|
|
27
|
-
↓
|
|
28
|
-
3. ISOLATE - Narrow down to specific code
|
|
29
|
-
↓
|
|
30
|
-
4. IDENTIFY - Find root cause
|
|
31
|
-
↓
|
|
32
|
-
5. FIX - Implement solution
|
|
33
|
-
↓
|
|
34
|
-
6. VERIFY - Confirm fix works + no regressions
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## Stack Trace Analysis
|
|
40
|
-
|
|
41
|
-
### Reading Error Stack
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
TypeError: Cannot read properties of undefined (reading 'name')
|
|
45
|
-
at getUserName (src/utils/user.ts:45:23)
|
|
46
|
-
at ProfileCard (src/components/ProfileCard.tsx:12:18)
|
|
47
|
-
at renderWithHooks (node_modules/react-dom/...)
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
**Key Information:**
|
|
51
|
-
|
|
52
|
-
- **Error Type**: `TypeError`
|
|
53
|
-
- **Message**: `Cannot read properties of undefined`
|
|
54
|
-
- **Property**: `name`
|
|
55
|
-
- **Location**: `src/utils/user.ts:45:23` (file:line:column)
|
|
56
|
-
- **Call Stack**: Shows how we got here
|
|
57
|
-
|
|
58
|
-
### Fix Pattern
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
// Error at line 45
|
|
62
|
-
function getUserName(user: User) {
|
|
63
|
-
return user.name; // ERROR: user is undefined
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Fix: Add null check
|
|
67
|
-
function getUserName(user: User | undefined): string {
|
|
68
|
-
return user?.name ?? 'Unknown';
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Or use assertion with clear error
|
|
72
|
-
function getUserName(user: User | undefined): string {
|
|
73
|
-
if (!user) {
|
|
74
|
-
throw new Error('User is required for getUserName');
|
|
75
|
-
}
|
|
76
|
-
return user.name;
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
## Common Error Patterns
|
|
83
|
-
|
|
84
|
-
### TypeError: Cannot read properties of undefined
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
// Pattern: Accessing property on undefined
|
|
88
|
-
const name = user.profile.name;
|
|
89
|
-
|
|
90
|
-
// Fix 1: Optional chaining
|
|
91
|
-
const name = user?.profile?.name ?? 'Unknown';
|
|
92
|
-
|
|
93
|
-
// Fix 2: Early return
|
|
94
|
-
if (!user?.profile) return null;
|
|
95
|
-
const name = user.profile.name;
|
|
96
|
-
|
|
97
|
-
// Fix 3: Default value
|
|
98
|
-
const profile = user?.profile ?? { name: 'Unknown' };
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### TypeError: X is not a function
|
|
102
|
-
|
|
103
|
-
```typescript
|
|
104
|
-
// Pattern: Calling non-function
|
|
105
|
-
onClick(); // onClick is undefined
|
|
106
|
-
|
|
107
|
-
// Fix 1: Check before calling
|
|
108
|
-
onClick?.();
|
|
109
|
-
|
|
110
|
-
// Fix 2: Provide default
|
|
111
|
-
const handleClick = onClick ?? (() => {});
|
|
112
|
-
handleClick();
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### ReferenceError: X is not defined
|
|
116
|
-
|
|
117
|
-
```typescript
|
|
118
|
-
// Pattern: Using undefined variable
|
|
119
|
-
console.log(userData); // userData not imported/declared
|
|
120
|
-
|
|
121
|
-
// Fix: Import or declare
|
|
122
|
-
import { userData } from './data';
|
|
123
|
-
// or
|
|
124
|
-
const userData = await fetchUserData();
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### SyntaxError: Unexpected token
|
|
128
|
-
|
|
129
|
-
```typescript
|
|
130
|
-
// Pattern: Invalid JSON
|
|
131
|
-
const data = JSON.parse(response);
|
|
132
|
-
// SyntaxError: Unexpected token '<'
|
|
133
|
-
|
|
134
|
-
// Fix: Check response before parsing
|
|
135
|
-
if (!response.ok) {
|
|
136
|
-
throw new Error(`HTTP ${response.status}`);
|
|
137
|
-
}
|
|
138
|
-
const text = await response.text();
|
|
139
|
-
try {
|
|
140
|
-
return JSON.parse(text);
|
|
141
|
-
} catch {
|
|
142
|
-
throw new Error(`Invalid JSON: ${text.slice(0, 100)}`);
|
|
143
|
-
}
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
---
|
|
147
|
-
|
|
148
|
-
## TypeScript Errors
|
|
149
|
-
|
|
150
|
-
### TS2339: Property does not exist
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
// Error
|
|
154
|
-
const env = process.env.NODE_ENV;
|
|
155
|
-
// Property 'NODE_ENV' does not exist on type 'ProcessEnv'
|
|
156
|
-
|
|
157
|
-
// Fix: Use bracket notation
|
|
158
|
-
const env = process.env['NODE_ENV'];
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### TS2532: Object is possibly undefined
|
|
162
|
-
|
|
163
|
-
```typescript
|
|
164
|
-
// Error
|
|
165
|
-
const items = array.map((x) => x.value);
|
|
166
|
-
// Object is possibly 'undefined'
|
|
167
|
-
|
|
168
|
-
// Fix 1: Non-null assertion (if certain)
|
|
169
|
-
const items = array!.map((x) => x.value);
|
|
170
|
-
|
|
171
|
-
// Fix 2: Default value
|
|
172
|
-
const items = (array ?? []).map((x) => x.value);
|
|
173
|
-
|
|
174
|
-
// Fix 3: Conditional
|
|
175
|
-
const items = array ? array.map((x) => x.value) : [];
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### TS2345: Argument type mismatch
|
|
179
|
-
|
|
180
|
-
```typescript
|
|
181
|
-
// Error
|
|
182
|
-
function greet(name: string) {}
|
|
183
|
-
greet(user.name); // Argument of type 'string | undefined'
|
|
184
|
-
|
|
185
|
-
// Fix 1: Provide default
|
|
186
|
-
greet(user.name ?? 'Guest');
|
|
187
|
-
|
|
188
|
-
// Fix 2: Assert
|
|
189
|
-
greet(user.name!);
|
|
190
|
-
|
|
191
|
-
// Fix 3: Guard
|
|
192
|
-
if (user.name) greet(user.name);
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### TS7053: Index signature
|
|
196
|
-
|
|
197
|
-
```typescript
|
|
198
|
-
// Error
|
|
199
|
-
const value = obj[key];
|
|
200
|
-
// Element implicitly has 'any' type
|
|
201
|
-
|
|
202
|
-
// Fix: Type the index
|
|
203
|
-
const value = (obj as Record<string, unknown>)[key];
|
|
204
|
-
|
|
205
|
-
// Or define proper type
|
|
206
|
-
interface MyObj {
|
|
207
|
-
[key: string]: string | undefined;
|
|
208
|
-
}
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
---
|
|
212
|
-
|
|
213
|
-
## Build Errors
|
|
214
|
-
|
|
215
|
-
### Module Not Found
|
|
216
|
-
|
|
217
|
-
```bash
|
|
218
|
-
# Error
|
|
219
|
-
Cannot find module './utils' or its corresponding type declarations
|
|
220
|
-
|
|
221
|
-
# Check 1: File exists?
|
|
222
|
-
ls src/utils.ts
|
|
223
|
-
|
|
224
|
-
# Check 2: Extension needed?
|
|
225
|
-
import { helper } from './utils.js'; # ESM requires extension
|
|
226
|
-
|
|
227
|
-
# Check 3: Path alias configured?
|
|
228
|
-
# Check tsconfig.json paths
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
### Duplicate Identifier
|
|
232
|
-
|
|
233
|
-
```bash
|
|
234
|
-
# Error
|
|
235
|
-
Duplicate identifier 'User'
|
|
236
|
-
|
|
237
|
-
# Fix: Check imports for conflicts
|
|
238
|
-
# May have both named and default import
|
|
239
|
-
import User from './User';
|
|
240
|
-
import { User } from './types'; # Conflict!
|
|
241
|
-
|
|
242
|
-
# Solution: Rename one
|
|
243
|
-
import { User as UserType } from './types';
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
### ESM/CJS Compatibility
|
|
247
|
-
|
|
248
|
-
```typescript
|
|
249
|
-
// Error: require is not defined in ES module
|
|
250
|
-
const fs = require('fs');
|
|
251
|
-
|
|
252
|
-
// Fix: Use ESM import
|
|
253
|
-
import fs from 'fs';
|
|
254
|
-
import { readFileSync } from 'fs';
|
|
255
|
-
|
|
256
|
-
// If must use require in ESM
|
|
257
|
-
import { createRequire } from 'module';
|
|
258
|
-
const require = createRequire(import.meta.url);
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
---
|
|
262
|
-
|
|
263
|
-
## Network & API Errors
|
|
264
|
-
|
|
265
|
-
### CORS Errors
|
|
266
|
-
|
|
267
|
-
```
|
|
268
|
-
Access to fetch at 'https://api.example.com' has been blocked by CORS policy
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
```typescript
|
|
272
|
-
// Server-side fix (add headers)
|
|
273
|
-
res.setHeader('Access-Control-Allow-Origin', 'https://yoursite.com');
|
|
274
|
-
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
|
|
275
|
-
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
|
276
|
-
|
|
277
|
-
// Client-side workaround (proxy in dev)
|
|
278
|
-
// vite.config.ts
|
|
279
|
-
export default {
|
|
280
|
-
server: {
|
|
281
|
-
proxy: {
|
|
282
|
-
'/api': {
|
|
283
|
-
target: 'https://api.example.com',
|
|
284
|
-
changeOrigin: true,
|
|
285
|
-
},
|
|
286
|
-
},
|
|
287
|
-
},
|
|
288
|
-
};
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
### HTTP Error Handling
|
|
292
|
-
|
|
293
|
-
```typescript
|
|
294
|
-
async function fetchWithErrorHandling<T>(url: string): Promise<T> {
|
|
295
|
-
const response = await fetch(url);
|
|
296
|
-
|
|
297
|
-
if (!response.ok) {
|
|
298
|
-
// Get error details
|
|
299
|
-
let message: string;
|
|
300
|
-
try {
|
|
301
|
-
const error = await response.json();
|
|
302
|
-
message = error.message || response.statusText;
|
|
303
|
-
} catch {
|
|
304
|
-
message = response.statusText;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
throw new Error(`${response.status} ${message}`);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
return response.json();
|
|
311
|
-
}
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
### Network Timeout
|
|
315
|
-
|
|
316
|
-
```typescript
|
|
317
|
-
async function fetchWithTimeout(url: string, timeout = 5000) {
|
|
318
|
-
const controller = new AbortController();
|
|
319
|
-
const id = setTimeout(() => controller.abort(), timeout);
|
|
320
|
-
|
|
321
|
-
try {
|
|
322
|
-
const response = await fetch(url, { signal: controller.signal });
|
|
323
|
-
clearTimeout(id);
|
|
324
|
-
return response;
|
|
325
|
-
} catch (error) {
|
|
326
|
-
clearTimeout(id);
|
|
327
|
-
if (error instanceof Error && error.name === 'AbortError') {
|
|
328
|
-
throw new Error(`Request timeout after ${timeout}ms`);
|
|
329
|
-
}
|
|
330
|
-
throw error;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
---
|
|
336
|
-
|
|
337
|
-
## React Debugging
|
|
338
|
-
|
|
339
|
-
### "Cannot update a component while rendering"
|
|
340
|
-
|
|
341
|
-
```typescript
|
|
342
|
-
// Error: State update during render
|
|
343
|
-
function Component({ value }) {
|
|
344
|
-
const [state, setState] = useState(0);
|
|
345
|
-
setState(value); // ERROR!
|
|
346
|
-
|
|
347
|
-
// Fix: Use useEffect
|
|
348
|
-
useEffect(() => {
|
|
349
|
-
setState(value);
|
|
350
|
-
}, [value]);
|
|
351
|
-
}
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
### "Too many re-renders"
|
|
355
|
-
|
|
356
|
-
```typescript
|
|
357
|
-
// Error: Infinite loop
|
|
358
|
-
function Component() {
|
|
359
|
-
const [count, setCount] = useState(0);
|
|
360
|
-
setCount(count + 1); // Causes re-render, which sets count...
|
|
361
|
-
|
|
362
|
-
// Fix: Add condition or use effect
|
|
363
|
-
useEffect(() => {
|
|
364
|
-
if (count < 10) {
|
|
365
|
-
setCount((c) => c + 1);
|
|
366
|
-
}
|
|
367
|
-
}, [count]);
|
|
368
|
-
}
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
### "Invalid hook call"
|
|
372
|
-
|
|
373
|
-
```typescript
|
|
374
|
-
// Error: Hook outside component or conditional
|
|
375
|
-
function Component() {
|
|
376
|
-
if (condition) {
|
|
377
|
-
const [state] = useState(0); // ERROR!
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// Fix: Hooks must be at top level
|
|
382
|
-
function Component() {
|
|
383
|
-
const [state] = useState(0); // OK
|
|
384
|
-
if (condition) {
|
|
385
|
-
// use state here
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
---
|
|
391
|
-
|
|
392
|
-
## Debug Commands
|
|
393
|
-
|
|
394
|
-
### Git - Find Breaking Commit
|
|
395
|
-
|
|
396
|
-
```bash
|
|
397
|
-
# Start bisect
|
|
398
|
-
git bisect start
|
|
399
|
-
git bisect bad HEAD
|
|
400
|
-
git bisect good abc123 # Last known good commit
|
|
401
|
-
|
|
402
|
-
# Test and mark each commit
|
|
403
|
-
git bisect good # or bad
|
|
404
|
-
|
|
405
|
-
# End bisect
|
|
406
|
-
git bisect reset
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
### Find Error in Code
|
|
410
|
-
|
|
411
|
-
```bash
|
|
412
|
-
# Search for error message
|
|
413
|
-
grep -rn "specific error text" src/
|
|
414
|
-
|
|
415
|
-
# Search for pattern
|
|
416
|
-
grep -rn "throw new Error" src/ --include="*.ts"
|
|
417
|
-
|
|
418
|
-
# Find file with symbol
|
|
419
|
-
grep -rn "functionName" src/ --include="*.ts" -l
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
### Bun Debugging
|
|
423
|
-
|
|
424
|
-
```bash
|
|
425
|
-
# Debug mode
|
|
426
|
-
bun --inspect src/index.ts
|
|
427
|
-
|
|
428
|
-
# With breakpoint on start
|
|
429
|
-
bun --inspect-brk src/index.ts
|
|
430
|
-
|
|
431
|
-
# Low memory mode (for memory issues)
|
|
432
|
-
bun --smol src/index.ts
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
---
|
|
436
|
-
|
|
437
|
-
## Debugging Checklist
|
|
438
|
-
|
|
439
|
-
### Before You Start
|
|
440
|
-
|
|
441
|
-
- [ ] Can you reproduce the bug?
|
|
442
|
-
- [ ] Do you have the exact error message?
|
|
443
|
-
- [ ] What changed recently? (`git log`, `git diff`)
|
|
444
|
-
|
|
445
|
-
### Investigation
|
|
446
|
-
|
|
447
|
-
- [ ] Read the full error message and stack trace
|
|
448
|
-
- [ ] Check the line number mentioned in error
|
|
449
|
-
- [ ] Add console.log at key points
|
|
450
|
-
- [ ] Check network tab for API errors
|
|
451
|
-
|
|
452
|
-
### After Fix
|
|
453
|
-
|
|
454
|
-
- [ ] Does the fix work for all cases?
|
|
455
|
-
- [ ] Did you add tests to prevent regression?
|
|
456
|
-
- [ ] Did you handle edge cases?
|
|
457
|
-
|
|
458
|
-
---
|
|
459
|
-
|
|
460
|
-
## Agent Integration
|
|
461
|
-
|
|
462
|
-
This skill is used by:
|
|
463
|
-
|
|
464
|
-
- **debugger** agent
|
|
465
|
-
- **error-stack-analyzer** agent
|
|
466
|
-
- **type-error-resolver** agent
|
|
467
|
-
- **runtime-error-fixer** agent
|
|
468
|
-
- **network-debugger** agent
|
|
469
|
-
- **build-error-fixer** agent
|
|
470
|
-
|
|
471
|
-
---
|
|
472
|
-
|
|
473
|
-
## FORBIDDEN
|
|
474
|
-
|
|
475
|
-
1. **Swallowing errors silently** - Always log or handle
|
|
476
|
-
2. **Using `any` to hide errors** - Fix the actual type issue
|
|
477
|
-
3. **`@ts-ignore` without comment** - Use `@ts-expect-error` with explanation
|
|
478
|
-
4. **Empty catch blocks** - At minimum, log the error
|
|
479
|
-
5. **Fixing symptoms not causes** - Find and fix root cause
|
|
480
|
-
|
|
481
|
-
---
|
|
482
|
-
|
|
483
|
-
## Version
|
|
484
|
-
|
|
485
|
-
- **v1.0.0** - Initial implementation based on 2024-2025 debugging patterns
|
|
1
|
+
---
|
|
2
|
+
name: debugging-patterns
|
|
3
|
+
description: Debugging strategies and error resolution patterns. Stack trace analysis, runtime errors, build errors, network issues. Use when debugging any type of error.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Bash, Grep, Glob
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Debugging Patterns - Error Resolution Best Practices
|
|
8
|
+
|
|
9
|
+
## Purpose
|
|
10
|
+
|
|
11
|
+
Expert guidance for debugging:
|
|
12
|
+
|
|
13
|
+
- **Error Analysis** - Stack traces, error messages
|
|
14
|
+
- **Runtime Issues** - Type errors, null references
|
|
15
|
+
- **Build Errors** - Compilation, bundling
|
|
16
|
+
- **Network Issues** - API, CORS, HTTP errors
|
|
17
|
+
- **Performance Bugs** - Slow operations, memory leaks
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Debug Process
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
1. UNDERSTAND - What should happen vs what happens
|
|
25
|
+
↓
|
|
26
|
+
2. REPRODUCE - Consistent steps to trigger bug
|
|
27
|
+
↓
|
|
28
|
+
3. ISOLATE - Narrow down to specific code
|
|
29
|
+
↓
|
|
30
|
+
4. IDENTIFY - Find root cause
|
|
31
|
+
↓
|
|
32
|
+
5. FIX - Implement solution
|
|
33
|
+
↓
|
|
34
|
+
6. VERIFY - Confirm fix works + no regressions
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Stack Trace Analysis
|
|
40
|
+
|
|
41
|
+
### Reading Error Stack
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
TypeError: Cannot read properties of undefined (reading 'name')
|
|
45
|
+
at getUserName (src/utils/user.ts:45:23)
|
|
46
|
+
at ProfileCard (src/components/ProfileCard.tsx:12:18)
|
|
47
|
+
at renderWithHooks (node_modules/react-dom/...)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Key Information:**
|
|
51
|
+
|
|
52
|
+
- **Error Type**: `TypeError`
|
|
53
|
+
- **Message**: `Cannot read properties of undefined`
|
|
54
|
+
- **Property**: `name`
|
|
55
|
+
- **Location**: `src/utils/user.ts:45:23` (file:line:column)
|
|
56
|
+
- **Call Stack**: Shows how we got here
|
|
57
|
+
|
|
58
|
+
### Fix Pattern
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
// Error at line 45
|
|
62
|
+
function getUserName(user: User) {
|
|
63
|
+
return user.name; // ERROR: user is undefined
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Fix: Add null check
|
|
67
|
+
function getUserName(user: User | undefined): string {
|
|
68
|
+
return user?.name ?? 'Unknown';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Or use assertion with clear error
|
|
72
|
+
function getUserName(user: User | undefined): string {
|
|
73
|
+
if (!user) {
|
|
74
|
+
throw new Error('User is required for getUserName');
|
|
75
|
+
}
|
|
76
|
+
return user.name;
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Common Error Patterns
|
|
83
|
+
|
|
84
|
+
### TypeError: Cannot read properties of undefined
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
// Pattern: Accessing property on undefined
|
|
88
|
+
const name = user.profile.name;
|
|
89
|
+
|
|
90
|
+
// Fix 1: Optional chaining
|
|
91
|
+
const name = user?.profile?.name ?? 'Unknown';
|
|
92
|
+
|
|
93
|
+
// Fix 2: Early return
|
|
94
|
+
if (!user?.profile) return null;
|
|
95
|
+
const name = user.profile.name;
|
|
96
|
+
|
|
97
|
+
// Fix 3: Default value
|
|
98
|
+
const profile = user?.profile ?? { name: 'Unknown' };
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### TypeError: X is not a function
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
// Pattern: Calling non-function
|
|
105
|
+
onClick(); // onClick is undefined
|
|
106
|
+
|
|
107
|
+
// Fix 1: Check before calling
|
|
108
|
+
onClick?.();
|
|
109
|
+
|
|
110
|
+
// Fix 2: Provide default
|
|
111
|
+
const handleClick = onClick ?? (() => {});
|
|
112
|
+
handleClick();
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### ReferenceError: X is not defined
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
// Pattern: Using undefined variable
|
|
119
|
+
console.log(userData); // userData not imported/declared
|
|
120
|
+
|
|
121
|
+
// Fix: Import or declare
|
|
122
|
+
import { userData } from './data';
|
|
123
|
+
// or
|
|
124
|
+
const userData = await fetchUserData();
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### SyntaxError: Unexpected token
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
// Pattern: Invalid JSON
|
|
131
|
+
const data = JSON.parse(response);
|
|
132
|
+
// SyntaxError: Unexpected token '<'
|
|
133
|
+
|
|
134
|
+
// Fix: Check response before parsing
|
|
135
|
+
if (!response.ok) {
|
|
136
|
+
throw new Error(`HTTP ${response.status}`);
|
|
137
|
+
}
|
|
138
|
+
const text = await response.text();
|
|
139
|
+
try {
|
|
140
|
+
return JSON.parse(text);
|
|
141
|
+
} catch {
|
|
142
|
+
throw new Error(`Invalid JSON: ${text.slice(0, 100)}`);
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## TypeScript Errors
|
|
149
|
+
|
|
150
|
+
### TS2339: Property does not exist
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
// Error
|
|
154
|
+
const env = process.env.NODE_ENV;
|
|
155
|
+
// Property 'NODE_ENV' does not exist on type 'ProcessEnv'
|
|
156
|
+
|
|
157
|
+
// Fix: Use bracket notation
|
|
158
|
+
const env = process.env['NODE_ENV'];
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### TS2532: Object is possibly undefined
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
// Error
|
|
165
|
+
const items = array.map((x) => x.value);
|
|
166
|
+
// Object is possibly 'undefined'
|
|
167
|
+
|
|
168
|
+
// Fix 1: Non-null assertion (if certain)
|
|
169
|
+
const items = array!.map((x) => x.value);
|
|
170
|
+
|
|
171
|
+
// Fix 2: Default value
|
|
172
|
+
const items = (array ?? []).map((x) => x.value);
|
|
173
|
+
|
|
174
|
+
// Fix 3: Conditional
|
|
175
|
+
const items = array ? array.map((x) => x.value) : [];
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### TS2345: Argument type mismatch
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
// Error
|
|
182
|
+
function greet(name: string) {}
|
|
183
|
+
greet(user.name); // Argument of type 'string | undefined'
|
|
184
|
+
|
|
185
|
+
// Fix 1: Provide default
|
|
186
|
+
greet(user.name ?? 'Guest');
|
|
187
|
+
|
|
188
|
+
// Fix 2: Assert
|
|
189
|
+
greet(user.name!);
|
|
190
|
+
|
|
191
|
+
// Fix 3: Guard
|
|
192
|
+
if (user.name) greet(user.name);
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### TS7053: Index signature
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
// Error
|
|
199
|
+
const value = obj[key];
|
|
200
|
+
// Element implicitly has 'any' type
|
|
201
|
+
|
|
202
|
+
// Fix: Type the index
|
|
203
|
+
const value = (obj as Record<string, unknown>)[key];
|
|
204
|
+
|
|
205
|
+
// Or define proper type
|
|
206
|
+
interface MyObj {
|
|
207
|
+
[key: string]: string | undefined;
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Build Errors
|
|
214
|
+
|
|
215
|
+
### Module Not Found
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# Error
|
|
219
|
+
Cannot find module './utils' or its corresponding type declarations
|
|
220
|
+
|
|
221
|
+
# Check 1: File exists?
|
|
222
|
+
ls src/utils.ts
|
|
223
|
+
|
|
224
|
+
# Check 2: Extension needed?
|
|
225
|
+
import { helper } from './utils.js'; # ESM requires extension
|
|
226
|
+
|
|
227
|
+
# Check 3: Path alias configured?
|
|
228
|
+
# Check tsconfig.json paths
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Duplicate Identifier
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
# Error
|
|
235
|
+
Duplicate identifier 'User'
|
|
236
|
+
|
|
237
|
+
# Fix: Check imports for conflicts
|
|
238
|
+
# May have both named and default import
|
|
239
|
+
import User from './User';
|
|
240
|
+
import { User } from './types'; # Conflict!
|
|
241
|
+
|
|
242
|
+
# Solution: Rename one
|
|
243
|
+
import { User as UserType } from './types';
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### ESM/CJS Compatibility
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
// Error: require is not defined in ES module
|
|
250
|
+
const fs = require('fs');
|
|
251
|
+
|
|
252
|
+
// Fix: Use ESM import
|
|
253
|
+
import fs from 'fs';
|
|
254
|
+
import { readFileSync } from 'fs';
|
|
255
|
+
|
|
256
|
+
// If must use require in ESM
|
|
257
|
+
import { createRequire } from 'module';
|
|
258
|
+
const require = createRequire(import.meta.url);
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Network & API Errors
|
|
264
|
+
|
|
265
|
+
### CORS Errors
|
|
266
|
+
|
|
267
|
+
```
|
|
268
|
+
Access to fetch at 'https://api.example.com' has been blocked by CORS policy
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
// Server-side fix (add headers)
|
|
273
|
+
res.setHeader('Access-Control-Allow-Origin', 'https://yoursite.com');
|
|
274
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
|
|
275
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
|
276
|
+
|
|
277
|
+
// Client-side workaround (proxy in dev)
|
|
278
|
+
// vite.config.ts
|
|
279
|
+
export default {
|
|
280
|
+
server: {
|
|
281
|
+
proxy: {
|
|
282
|
+
'/api': {
|
|
283
|
+
target: 'https://api.example.com',
|
|
284
|
+
changeOrigin: true,
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
};
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### HTTP Error Handling
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
async function fetchWithErrorHandling<T>(url: string): Promise<T> {
|
|
295
|
+
const response = await fetch(url);
|
|
296
|
+
|
|
297
|
+
if (!response.ok) {
|
|
298
|
+
// Get error details
|
|
299
|
+
let message: string;
|
|
300
|
+
try {
|
|
301
|
+
const error = await response.json();
|
|
302
|
+
message = error.message || response.statusText;
|
|
303
|
+
} catch {
|
|
304
|
+
message = response.statusText;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
throw new Error(`${response.status} ${message}`);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return response.json();
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Network Timeout
|
|
315
|
+
|
|
316
|
+
```typescript
|
|
317
|
+
async function fetchWithTimeout(url: string, timeout = 5000) {
|
|
318
|
+
const controller = new AbortController();
|
|
319
|
+
const id = setTimeout(() => controller.abort(), timeout);
|
|
320
|
+
|
|
321
|
+
try {
|
|
322
|
+
const response = await fetch(url, { signal: controller.signal });
|
|
323
|
+
clearTimeout(id);
|
|
324
|
+
return response;
|
|
325
|
+
} catch (error) {
|
|
326
|
+
clearTimeout(id);
|
|
327
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
328
|
+
throw new Error(`Request timeout after ${timeout}ms`);
|
|
329
|
+
}
|
|
330
|
+
throw error;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## React Debugging
|
|
338
|
+
|
|
339
|
+
### "Cannot update a component while rendering"
|
|
340
|
+
|
|
341
|
+
```typescript
|
|
342
|
+
// Error: State update during render
|
|
343
|
+
function Component({ value }) {
|
|
344
|
+
const [state, setState] = useState(0);
|
|
345
|
+
setState(value); // ERROR!
|
|
346
|
+
|
|
347
|
+
// Fix: Use useEffect
|
|
348
|
+
useEffect(() => {
|
|
349
|
+
setState(value);
|
|
350
|
+
}, [value]);
|
|
351
|
+
}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### "Too many re-renders"
|
|
355
|
+
|
|
356
|
+
```typescript
|
|
357
|
+
// Error: Infinite loop
|
|
358
|
+
function Component() {
|
|
359
|
+
const [count, setCount] = useState(0);
|
|
360
|
+
setCount(count + 1); // Causes re-render, which sets count...
|
|
361
|
+
|
|
362
|
+
// Fix: Add condition or use effect
|
|
363
|
+
useEffect(() => {
|
|
364
|
+
if (count < 10) {
|
|
365
|
+
setCount((c) => c + 1);
|
|
366
|
+
}
|
|
367
|
+
}, [count]);
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### "Invalid hook call"
|
|
372
|
+
|
|
373
|
+
```typescript
|
|
374
|
+
// Error: Hook outside component or conditional
|
|
375
|
+
function Component() {
|
|
376
|
+
if (condition) {
|
|
377
|
+
const [state] = useState(0); // ERROR!
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// Fix: Hooks must be at top level
|
|
382
|
+
function Component() {
|
|
383
|
+
const [state] = useState(0); // OK
|
|
384
|
+
if (condition) {
|
|
385
|
+
// use state here
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## Debug Commands
|
|
393
|
+
|
|
394
|
+
### Git - Find Breaking Commit
|
|
395
|
+
|
|
396
|
+
```bash
|
|
397
|
+
# Start bisect
|
|
398
|
+
git bisect start
|
|
399
|
+
git bisect bad HEAD
|
|
400
|
+
git bisect good abc123 # Last known good commit
|
|
401
|
+
|
|
402
|
+
# Test and mark each commit
|
|
403
|
+
git bisect good # or bad
|
|
404
|
+
|
|
405
|
+
# End bisect
|
|
406
|
+
git bisect reset
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### Find Error in Code
|
|
410
|
+
|
|
411
|
+
```bash
|
|
412
|
+
# Search for error message
|
|
413
|
+
grep -rn "specific error text" src/
|
|
414
|
+
|
|
415
|
+
# Search for pattern
|
|
416
|
+
grep -rn "throw new Error" src/ --include="*.ts"
|
|
417
|
+
|
|
418
|
+
# Find file with symbol
|
|
419
|
+
grep -rn "functionName" src/ --include="*.ts" -l
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### Bun Debugging
|
|
423
|
+
|
|
424
|
+
```bash
|
|
425
|
+
# Debug mode
|
|
426
|
+
bun --inspect src/index.ts
|
|
427
|
+
|
|
428
|
+
# With breakpoint on start
|
|
429
|
+
bun --inspect-brk src/index.ts
|
|
430
|
+
|
|
431
|
+
# Low memory mode (for memory issues)
|
|
432
|
+
bun --smol src/index.ts
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
---
|
|
436
|
+
|
|
437
|
+
## Debugging Checklist
|
|
438
|
+
|
|
439
|
+
### Before You Start
|
|
440
|
+
|
|
441
|
+
- [ ] Can you reproduce the bug?
|
|
442
|
+
- [ ] Do you have the exact error message?
|
|
443
|
+
- [ ] What changed recently? (`git log`, `git diff`)
|
|
444
|
+
|
|
445
|
+
### Investigation
|
|
446
|
+
|
|
447
|
+
- [ ] Read the full error message and stack trace
|
|
448
|
+
- [ ] Check the line number mentioned in error
|
|
449
|
+
- [ ] Add console.log at key points
|
|
450
|
+
- [ ] Check network tab for API errors
|
|
451
|
+
|
|
452
|
+
### After Fix
|
|
453
|
+
|
|
454
|
+
- [ ] Does the fix work for all cases?
|
|
455
|
+
- [ ] Did you add tests to prevent regression?
|
|
456
|
+
- [ ] Did you handle edge cases?
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
## Agent Integration
|
|
461
|
+
|
|
462
|
+
This skill is used by:
|
|
463
|
+
|
|
464
|
+
- **debugger** agent
|
|
465
|
+
- **error-stack-analyzer** agent
|
|
466
|
+
- **type-error-resolver** agent
|
|
467
|
+
- **runtime-error-fixer** agent
|
|
468
|
+
- **network-debugger** agent
|
|
469
|
+
- **build-error-fixer** agent
|
|
470
|
+
|
|
471
|
+
---
|
|
472
|
+
|
|
473
|
+
## FORBIDDEN
|
|
474
|
+
|
|
475
|
+
1. **Swallowing errors silently** - Always log or handle
|
|
476
|
+
2. **Using `any` to hide errors** - Fix the actual type issue
|
|
477
|
+
3. **`@ts-ignore` without comment** - Use `@ts-expect-error` with explanation
|
|
478
|
+
4. **Empty catch blocks** - At minimum, log the error
|
|
479
|
+
5. **Fixing symptoms not causes** - Find and fix root cause
|
|
480
|
+
|
|
481
|
+
---
|
|
482
|
+
|
|
483
|
+
## Version
|
|
484
|
+
|
|
485
|
+
- **v1.0.0** - Initial implementation based on 2024-2025 debugging patterns
|