systematic-debugging
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSystematic Debugging
系统化调试
Source: obra/superpowers
Source: obra/superpowers
Overview
概述
This skill provides a structured approach to debugging that prevents random guessing and ensures problems are properly understood before solving.
本技能提供一种结构化的调试方法,可避免随机猜测,确保在解决问题前充分理解问题。
4-Phase Debugging Process
四阶段调试流程
Phase 1: Reproduce
阶段1:复现
Before fixing, reliably reproduce the issue.
markdown
undefined在修复之前,需稳定复现问题。
markdown
undefinedReproduction Steps
复现步骤
- [Exact step to reproduce]
- [Next step]
- [Expected vs actual result]
- [具体复现步骤]
- [下一步操作]
- [预期结果 vs 实际结果]
Reproduction Rate
复现概率
- Always (100%)
- Often (50-90%)
- Sometimes (10-50%)
- Rare (<10%)
undefined- 总是(100%)
- 经常(50-90%)
- 有时(10-50%)
- 很少(<10%)
undefinedPhase 2: Isolate
阶段2:定位
Narrow down the source.
markdown
undefined缩小问题来源范围。
markdown
undefinedIsolation Questions
定位问题的疑问点
- When did this start happening?
- What changed recently?
- Does it happen in all environments?
- Can we reproduce with minimal code?
- What's the smallest change that triggers it?
undefined- 这个问题从何时开始出现?
- 最近有哪些变更?
- 是否在所有环境中都会出现?
- 能否用最简代码复现问题?
- 触发问题的最小变更是什么?
undefinedPhase 3: Understand
阶段3:分析
Find the root cause, not just symptoms.
markdown
undefined找到根本原因,而非仅处理表面症状。
markdown
undefinedRoot Cause Analysis
根本原因分析
The 5 Whys
5个为什么分析法
- Why: [First observation]
- Why: [Deeper reason]
- Why: [Still deeper]
- Why: [Getting closer]
- Why: [Root cause]
undefined- 为什么:[首次观察到的现象]
- 为什么:[更深层原因]
- 为什么:[更核心的原因]
- 为什么:[接近根源的原因]
- 为什么:[根本原因]
undefinedPhase 4: Fix & Verify
阶段4:修复与验证
Fix and verify it's truly fixed.
markdown
undefined修复问题并验证是否彻底解决。
markdown
undefinedFix Verification
修复验证
- Bug no longer reproduces
- Related functionality still works
- No new issues introduced
- Test added to prevent regression
undefined- Bug不再复现
- 相关功能仍正常运行
- 未引入新问题
- 添加测试以防止回归
undefinedDebugging Checklist
调试检查清单
markdown
undefinedmarkdown
undefinedBefore Starting
开始调试前
- Can reproduce consistently
- Have minimal reproduction case
- Understand expected behavior
- 能够稳定复现问题
- 拥有最简复现案例
- 理解预期行为
During Investigation
调查过程中
- Check recent changes (git log)
- Check logs for errors
- Add logging if needed
- Use debugger/breakpoints
- 查看最近的变更记录(git log)
- 检查日志中的错误信息
- 如有需要添加日志
- 使用调试器/断点
After Fix
修复完成后
- Root cause documented
- Fix verified
- Regression test added
- Similar code checked
undefined- 记录根本原因
- 验证修复效果
- 添加回归测试
- 检查相似代码
undefinedCommon Debugging Commands
常用调试命令
bash
undefinedbash
undefinedRecent changes
最近的变更
git log --oneline -20
git diff HEAD~5
git log --oneline -20
git diff HEAD~5
Search for pattern
搜索指定模式
grep -r "errorPattern" --include="*.ts"
grep -r "errorPattern" --include="*.ts"
Check logs
查看日志
pm2 logs app-name --err --lines 100
undefinedpm2 logs app-name --err --lines 100
undefinedAnti-Patterns
反模式
❌ Random changes - "Maybe if I change this..."
❌ Ignoring evidence - "That can't be the cause"
❌ Assuming - "It must be X" without proof
❌ Not reproducing first - Fixing blindly
❌ Stopping at symptoms - Not finding root cause
❌ 随机修改 - “或许我改一下这个试试...”
❌ 忽略证据 - “那不可能是原因”
❌ 主观假设 - “肯定是X的问题”却没有证据
❌ 未复现就修复 - 盲目尝试修复
❌ 仅处理表面症状 - 未找到根本原因