debug
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesedot-skills Debugging Best Practices
dot-skills 调试最佳实践
Comprehensive debugging methodology guide for software engineers, containing 54 rules across 10 categories prioritized by impact. Based on research from Andreas Zeller's "Why Programs Fail" and academic debugging curricula.
面向软件工程师的全面调试方法论指南,包含按影响优先级划分的10个类别共54条规则。基于Andreas Zeller的《Why Programs Fail》及学术调试课程研究而成。
When to Apply
适用场景
Reference these guidelines when:
- Investigating a bug or unexpected behavior
- Debugging code during development
- Code produces wrong results or crashes
- Performance issues need root cause analysis
- Triaging incoming bug reports and prioritizing fixes
- Conducting root cause analysis for incidents
- Reviewing debugging approaches or code for common bug patterns
在以下场景中可参考本指南:
- 排查bug或意外行为
- 开发过程中调试代码
- 代码输出错误结果或崩溃
- 需要对性能问题进行根因分析
- 分类处理收到的bug报告并确定修复优先级
- 针对事件开展根因分析
- 审查调试方法或代码中的常见bug模式
Rule Categories by Priority
按优先级划分的规则类别
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Problem Definition | CRITICAL | |
| 2 | Hypothesis-Driven Search | CRITICAL | |
| 3 | Observation Techniques | HIGH | |
| 4 | Root Cause Analysis | HIGH | |
| 5 | Tool Mastery | MEDIUM-HIGH | |
| 6 | Bug Triage and Classification | MEDIUM | |
| 7 | Common Bug Patterns | MEDIUM | |
| 8 | Fix Verification | MEDIUM | |
| 9 | Anti-Patterns | MEDIUM | |
| 10 | Prevention & Learning | LOW-MEDIUM | |
| 优先级 | 类别 | 影响级别 | 前缀 |
|---|---|---|---|
| 1 | 问题定义 | CRITICAL | |
| 2 | 基于假设的排查 | CRITICAL | |
| 3 | 观测技巧 | HIGH | |
| 4 | 根因分析 | HIGH | |
| 5 | 工具精通 | MEDIUM-HIGH | |
| 6 | Bug分类与优先级划分 | MEDIUM | |
| 7 | 常见Bug模式 | MEDIUM | |
| 8 | 修复验证 | MEDIUM | |
| 9 | 反模式 | MEDIUM | |
| 10 | 预防与学习 | LOW-MEDIUM | |
Quick Reference
快速参考
1. Problem Definition (CRITICAL)
1. 问题定义(CRITICAL)
- - Reproduce the bug before investigating
prob-reproduce-before-debug - - Create minimal reproduction cases
prob-minimal-reproduction - - Document symptoms precisely
prob-document-symptoms - - Separate symptoms from causes
prob-separate-symptoms-causes - - State expected vs actual behavior
prob-state-expected-actual - - Check recent changes first
prob-recent-changes
- - 先复现bug再开展排查
prob-reproduce-before-debug - - 创建最小化复现案例
prob-minimal-reproduction - - 精准记录症状
prob-document-symptoms - - 区分症状与原因
prob-separate-symptoms-causes - - 明确预期行为与实际行为的差异
prob-state-expected-actual - - 优先检查近期变更
prob-recent-changes
2. Hypothesis-Driven Search (CRITICAL)
2. 基于假设的排查(CRITICAL)
- - Apply the scientific method
hypo-scientific-method - - Use binary search to localize bugs
hypo-binary-search - - Test one hypothesis at a time
hypo-one-change-at-time - - Find WHERE before asking WHAT
hypo-where-not-what - - Rule out obvious causes first
hypo-rule-out-obvious - - Explain the problem aloud
hypo-rubber-duck
- - 应用科学方法
hypo-scientific-method - - 使用二分法定位bug
hypo-binary-search - - 每次仅测试一个假设
hypo-one-change-at-time - - 先确定位置再探究问题
hypo-where-not-what - - 先排除明显原因
hypo-rule-out-obvious - - 大声讲解问题
hypo-rubber-duck
3. Observation Techniques (HIGH)
3. 观测技巧(HIGH)
- - Use strategic logging
obs-strategic-logging - - Log function inputs and outputs
obs-log-inputs-outputs - - Use breakpoints strategically
obs-breakpoint-strategy - - Read stack traces bottom to top
obs-stack-trace-reading - - Use watch expressions for state
obs-watch-expressions - - Trace data flow through system
obs-trace-data-flow
- - 采用策略性日志
obs-strategic-logging - - 记录函数的输入与输出
obs-log-inputs-outputs - - 策略性使用断点
obs-breakpoint-strategy - - 从下往上阅读堆栈跟踪信息
obs-stack-trace-reading - - 使用监视表达式查看状态
obs-watch-expressions - - 跟踪系统中的数据流
obs-trace-data-flow
4. Root Cause Analysis (HIGH)
4. 根因分析(HIGH)
- - Use the 5 Whys technique
rca-five-whys - - Trace fault propagation chains
rca-fault-propagation - - Find the last known good state
rca-last-known-good - - Question your assumptions
rca-question-assumptions - - Examine system boundaries
rca-examine-boundaries
- - 使用5Why分析法
rca-five-whys - - 跟踪故障传播链
rca-fault-propagation - - 找到最后一个正常状态
rca-last-known-good - - 质疑既有假设
rca-question-assumptions - - 检查系统边界
rca-examine-boundaries
5. Tool Mastery (MEDIUM-HIGH)
5. 工具精通(MEDIUM-HIGH)
- - Use conditional breakpoints
tool-conditional-breakpoints - - Use logpoints instead of modifying code
tool-logpoints - - Master step over/into/out
tool-step-commands - - Navigate the call stack
tool-call-stack-navigation - - Inspect memory and object state
tool-memory-inspection - - Use exception breakpoints
tool-exception-breakpoints
- - 使用条件断点
tool-conditional-breakpoints - - 使用日志断点而非修改代码
tool-logpoints - - 精通单步跳过/单步进入/单步跳出命令
tool-step-commands - - 导航调用栈
tool-call-stack-navigation - - 检查内存与对象状态
tool-memory-inspection - - 使用异常断点
tool-exception-breakpoints
6. Bug Triage and Classification (MEDIUM)
6. Bug分类与优先级划分(MEDIUM)
- - Separate severity from priority
triage-severity-vs-priority - - Assess user impact before prioritizing
triage-user-impact-assessment - - Factor reproducibility into triage
triage-reproducibility-matters - - Identify and ship quick wins first
triage-quick-wins-first - - Detect and link duplicate bug reports
triage-duplicate-detection
- - 区分严重程度与优先级
triage-severity-vs-priority - - 先评估用户影响再确定优先级
triage-user-impact-assessment - - 将可复现性纳入分类考量
triage-reproducibility-matters - - 先识别并交付快速修复项
triage-quick-wins-first - - 检测并关联重复的bug报告
triage-duplicate-detection
7. Common Bug Patterns (MEDIUM)
7. 常见Bug模式(MEDIUM)
- - Recognize null pointer patterns
pattern-null-pointer - - Spot off-by-one errors
pattern-off-by-one - - Identify race condition symptoms
pattern-race-condition - - Detect memory leak patterns
pattern-memory-leak - - Watch for type coercion bugs
pattern-type-coercion - - Catch async/await error handling mistakes
pattern-async-await-errors - - Recognize timezone and date bugs
pattern-timezone-issues
- - 识别空指针模式
pattern-null-pointer - - 发现差一错误
pattern-off-by-one - - 识别竞态条件症状
pattern-race-condition - - 检测内存泄漏模式
pattern-memory-leak - - 注意类型转换bug
pattern-type-coercion - - 捕获async/await错误处理失误
pattern-async-await-errors - - 识别时区与日期bug
pattern-timezone-issues
8. Fix Verification (MEDIUM)
8. 修复验证(MEDIUM)
- - Verify with original reproduction
verify-reproduce-fix - - Check for regressions
verify-regression-check - - Understand why fix works
verify-understand-why-fix-works - - Add test to prevent recurrence
verify-add-test
- - 使用原始复现案例验证修复效果
verify-reproduce-fix - - 检查是否存在回归问题
verify-regression-check - - 理解修复生效的原因
verify-understand-why-fix-works - - 添加测试以防止问题复发
verify-add-test
9. Anti-Patterns (MEDIUM)
9. 反模式(MEDIUM)
- - Avoid shotgun debugging
anti-shotgun-debugging - - Avoid quick patches without understanding
anti-quick-patch - - Avoid tunnel vision on initial hypothesis
anti-tunnel-vision - - Recognize debugging fatigue
anti-debug-fatigue - - Don't blame the tool too quickly
anti-blame-tool
- - 避免盲目调试
anti-shotgun-debugging - - 避免未理解问题就仓促打补丁
anti-quick-patch - - 避免局限于初始假设
anti-tunnel-vision - - 警惕调试疲劳
anti-debug-fatigue - - 不要轻易归咎于工具
anti-blame-tool
10. Prevention & Learning (LOW-MEDIUM)
10. 预防与学习(LOW-MEDIUM)
- - Document bug solutions
prev-document-solution - - Conduct blameless postmortems
prev-postmortem - - Add defensive code at boundaries
prev-defensive-coding - - Improve error messages
prev-improve-error-messages
- - 记录bug解决方案
prev-document-solution - - 开展无责事后复盘
prev-postmortem - - 在系统边界添加防御性代码
prev-defensive-coding - - 优化错误提示信息
prev-improve-error-messages
How to Use
使用方法
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
- Example rules: prob-reproduce-before-debug, hypo-binary-search
阅读单独的参考文件获取详细说明及代码示例:
- 章节定义 - 类别结构与影响级别说明
- 规则模板 - 添加新规则的模板
- 示例规则:prob-reproduce-before-debug, hypo-binary-search
Full Compiled Document
完整编译文档
For the complete guide with all rules expanded: AGENTS.md
如需查看包含所有扩展规则的完整指南:AGENTS.md