Skill files2 files

references/

SKILL.md266 lines
1
---
2
name: debugging-strategies
3
description: Master systematic debugging techniques, profiling tools, and root cause analysis to efficiently track down bugs across any codebase or technology stack. Use when investigating bugs, performance issues, or unexpected behavior.
4
---
5
6
# Debugging Strategies
7
8
Transform debugging from frustrating guesswork into systematic problem-solving with proven strategies, powerful tools, and methodical approaches.
9
10
## When to Use This Skill
11
12
- Tracking down elusive bugs
13
- Investigating performance issues
14
- Understanding unfamiliar codebases
15
- Debugging production issues
16
- Analyzing crash dumps and stack traces
17
- Profiling application performance
18
- Investigating memory leaks
19
- Debugging distributed systems
20
21
## Core Principles
22
23
### 1. The Scientific Method
24
25
**1. Observe**: What's the actual behavior?
26
**2. Hypothesize**: What could be causing it?
27
**3. Experiment**: Test your hypothesis
28
**4. Analyze**: Did it prove/disprove your theory?
29
**5. Repeat**: Until you find the root cause
30
31
### 2. Debugging Mindset
32
33
**Don't Assume:**
34
35
- "It can't be X" - Yes it can
36
- "I didn't change Y" - Check anyway
37
- "It works on my machine" - Find out why
38
39
**Do:**
40
41
- Reproduce consistently
42
- Isolate the problem
43
- Keep detailed notes
44
- Question everything
45
- Take breaks when stuck
46
47
### 3. Rubber Duck Debugging
48
49
Explain your code and problem out loud (to a rubber duck, colleague, or yourself). Often reveals the issue.
50
51
## Systematic Debugging Process
52
53
### Phase 1: Reproduce
54
55
```markdown
56
## Reproduction Checklist
57
58
1. **Can you reproduce it?**
59
- Always? Sometimes? Randomly?
60
- Specific conditions needed?
61
- Can others reproduce it?
62
63
2. **Create minimal reproduction**
64
- Simplify to smallest example
65
- Remove unrelated code
66
- Isolate the problem
67
68
3. **Document steps**
69
- Write down exact steps
70
- Note environment details
71
- Capture error messages
72
```
73
74
### Phase 2: Gather Information
75
76
```markdown
77
## Information Collection
78
79
1. **Error Messages**
80
- Full stack trace
81
- Error codes
82
- Console/log output
83
84
2. **Environment**
85
- OS version
86
- Language/runtime version
87
- Dependencies versions
88
- Environment variables
89
90
3. **Recent Changes**
91
- Git history
92
- Deployment timeline
93
- Configuration changes
94
95
4. **Scope**
96
- Affects all users or specific ones?
97
- All browsers or specific ones?
98
- Production only or also dev?
99
```
100
101
### Phase 3: Form Hypothesis
102
103
```markdown
104
## Hypothesis Formation
105
106
Based on gathered info, ask:
107
108
1. **What changed?**
109
- Recent code changes
110
- Dependency updates
111
- Infrastructure changes
112
113
2. **What's different?**
114
- Working vs broken environment
115
- Working vs broken user
116
- Before vs after
117
118
3. **Where could this fail?**
119
- Input validation
120
- Business logic
121
- Data layer
122
- External services
123
```
124
125
### Phase 4: Test & Verify
126
127
```markdown
128
## Testing Strategies
129
130
1. **Binary Search**
131
- Comment out half the code
132
- Narrow down problematic section
133
- Repeat until found
134
135
2. **Add Logging**
136
- Strategic console.log/print
137
- Track variable values
138
- Trace execution flow
139
140
3. **Isolate Components**
141
- Test each piece separately
142
- Mock dependencies
143
- Remove complexity
144
145
4. **Compare Working vs Broken**
146
- Diff configurations
147
- Diff environments
148
- Diff data
149
```
150
151
Before selecting debugging tools or performing bisect, differential, trace, or memory analysis, read `references/tools-and-techniques.md`.
152
153
## Debugging Patterns by Issue Type
154
155
### Pattern 1: Intermittent Bugs
156
157
```markdown
158
## Strategies for Flaky Bugs
159
160
1. **Add extensive logging**
161
- Log timing information
162
- Log all state transitions
163
- Log external interactions
164
165
2. **Look for race conditions**
166
- Concurrent access to shared state
167
- Async operations completing out of order
168
- Missing synchronization
169
170
3. **Check timing dependencies**
171
- setTimeout/setInterval
172
- Promise resolution order
173
- Animation frame timing
174
175
4. **Stress test**
176
- Run many times
177
- Vary timing
178
- Simulate load
179
```
180
181
### Pattern 2: Performance Issues
182
183
```markdown
184
## Performance Debugging
185
186
1. **Profile first**
187
- Don't optimize blindly
188
- Measure before and after
189
- Find bottlenecks
190
191
2. **Common culprits**
192
- N+1 queries
193
- Unnecessary re-renders
194
- Large data processing
195
- Synchronous I/O
196
197
3. **Tools**
198
- Browser DevTools Performance tab
199
- Lighthouse
200
- Python: cProfile, line_profiler
201
- Node: clinic.js, 0x
202
```
203
204
### Pattern 3: Production Bugs
205
206
```markdown
207
## Production Debugging
208
209
1. **Gather evidence**
210
- Error tracking (Sentry, Bugsnag)
211
- Application logs
212
- User reports
213
- Metrics/monitoring
214
215
2. **Reproduce locally**
216
- Use production data (anonymized)
217
- Match environment
218
- Follow exact steps
219
220
3. **Safe investigation**
221
- Don't change production
222
- Use feature flags
223
- Add monitoring/logging
224
- Test fixes in staging
225
```
226
227
## Best Practices
228
229
1. **Reproduce First**: Can't fix what you can't reproduce
230
2. **Isolate the Problem**: Remove complexity until minimal case
231
3. **Read Error Messages**: They're usually helpful
232
4. **Check Recent Changes**: Most bugs are recent
233
5. **Use Version Control**: Git bisect, blame, history
234
6. **Take Breaks**: Fresh eyes see better
235
7. **Document Findings**: Help future you
236
8. **Fix Root Cause**: Not just symptoms
237
238
## Common Debugging Mistakes
239
240
- **Making Multiple Changes**: Change one thing at a time
241
- **Not Reading Error Messages**: Read the full stack trace
242
- **Assuming It's Complex**: Often it's simple
243
- **Debug Logging in Prod**: Remove before shipping
244
- **Not Using Debugger**: console.log isn't always best
245
- **Giving Up Too Soon**: Persistence pays off
246
- **Not Testing the Fix**: Verify it actually works
247
248
## Quick Debugging Checklist
249
250
```markdown
251
## When Stuck, Check:
252
253
- [ ] Spelling errors (typos in variable names)
254
- [ ] Case sensitivity (fileName vs filename)
255
- [ ] Null/undefined values
256
- [ ] Array index off-by-one
257
- [ ] Async timing (race conditions)
258
- [ ] Scope issues (closure, hoisting)
259
- [ ] Type mismatches
260
- [ ] Missing dependencies
261
- [ ] Environment variables
262
- [ ] File paths (absolute vs relative)
263
- [ ] Cache issues (clear cache)
264
- [ ] Stale data (refresh database)
265
```
266

© Seth Hobson · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 11,967 prompts

More by @OpenSourceBuffGuy

See all
Acid Lime 3D Streetwear Type Poster Style prompt image

Acid Lime 3D Streetwear Type Poster Style

Defines a JSON style for glossy 3D streetwear campaign posters with black block type, acid-lime marker strokes, stickers and fashion props, with fill-in variables.

image-prompt, json-prompt, template, placeholders, 3d-render, fashion, toys, poster, vibrant-colors, studio-lighting, low-angle, sticker, typography, text-rendering, structured-output, style-reference, negative-prompt, for-designers, for-marketers, long-form, advanced

Azure Static Web Apps prompt image

Azure Static Web Apps

Helps an agent create, configure and deploy Azure Static Web Apps with the SWA CLI, including local emulation, Functions APIs and CI/CD.

agent-skill, azure, deployment, github-actions, ci-cd, serverless, command-line, frontend, step-by-step-guide, for-developers, best-practices, authentication, web-development, scaffolding, cloud, api, nodejs

Workflow Automation Specialist prompt image

Workflow Automation Specialist

Finds repetitive tasks to automate, estimates time savings and ROI, and designs no-code workflows with Zapier, Make or native tools within your budget.

system-prompt, expert-advice, workflow-automation, no-code, productivity, zapier, make-com, for-non-coders, for-small-business-owners, beginner-friendly, xml-tags, estimation, planner, guardrails, structured-output, process-improvement, step-by-step-guide, consulting, time-management, office-administration

Reviews

Loading reviews…

Discussion

Loading comments…