debugging-wizard

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Debugging Wizard

调试向导

Expert debugger applying systematic methodology to isolate and resolve issues in any codebase.
采用系统化方法隔离并解决任意代码库问题的专家级调试能力。

Core Workflow

核心工作流

  1. Reproduce - Establish consistent reproduction steps
  2. Isolate - Narrow down to smallest failing case
  3. Hypothesize and test - Form testable theories, verify/disprove each one
  4. Fix - Implement and verify solution
  5. Prevent - Add tests/safeguards against regression
  1. 复现 - 确定一致的复现步骤
  2. 隔离 - 缩小范围至最小可复现用例
  3. 假设与验证 - 提出可测试的理论,逐一证实/证伪
  4. 修复 - 实现并验证解决方案
  5. 预防 - 添加测试/防护措施以避免回归

Reference Guide

参考指南

Load detailed guidance based on context:
<!-- Systematic Debugging row adapted from obra/superpowers by Jesse Vincent (@obra), MIT License -->
TopicReferenceLoad When
Debugging Tools
references/debugging-tools.md
Setting up debuggers by language
Common Patterns
references/common-patterns.md
Recognizing bug patterns
Strategies
references/strategies.md
Binary search, git bisect, time travel
Quick Fixes
references/quick-fixes.md
Common error solutions
Systematic Debugging
references/systematic-debugging.md
Complex bugs, multiple failed fixes, root cause analysis
根据上下文加载详细指导:
<!-- 系统化调试行改编自 Jesse Vincent (@obra) 的 obra/superpowers 项目,MIT 许可证 -->
主题参考文件加载时机
调试工具
references/debugging-tools.md
按语言配置调试器时
常见模式
references/common-patterns.md
识别Bug模式时
调试策略
references/strategies.md
使用二分查找、git bisect、时间旅行调试时
快速修复
references/quick-fixes.md
查找常见错误解决方案时
系统化调试
references/systematic-debugging.md
处理复杂Bug、多次修复失败、根因分析时

Constraints

约束条件

MUST DO

必须遵守

  • Reproduce the issue first
  • Gather complete error messages and stack traces
  • Test one hypothesis at a time
  • Document findings for future reference
  • Add regression tests after fixing
  • Remove all debug code before committing
  • 优先复现问题
  • 收集完整的错误消息和堆栈跟踪
  • 每次仅验证一个假设
  • 记录发现以供后续参考
  • 修复后添加回归测试
  • 提交前移除所有调试代码

MUST NOT DO

禁止行为

  • Guess without testing
  • Make multiple changes at once
  • Skip reproduction steps
  • Assume you know the cause
  • Debug in production without safeguards
  • Leave console.log/debugger statements in code
  • 未经测试就猜测
  • 一次性进行多处修改
  • 跳过复现步骤
  • 主观臆断问题原因
  • 无防护措施下在生产环境调试
  • 在代码中遗留console.log/debugger语句

Common Debugging Commands

常用调试命令

Python (pdb)
bash
python -m pdb script.py          # launch debugger
Python (pdb)
bash
python -m pdb script.py          # launch debugger

inside pdb:

inside pdb:

b 42 — set breakpoint at line 42

b 42 — set breakpoint at line 42

n — step over

n — step over

s — step into

s — step into

p some_var — print variable

p some_var — print variable

bt — print full traceback

bt — print full traceback


**JavaScript (Node.js)**
```bash
node --inspect-brk script.js     # pause at first line, attach Chrome DevTools

**JavaScript (Node.js)**
```bash
node --inspect-brk script.js     # pause at first line, attach Chrome DevTools

In Chrome: open chrome://inspect → click "inspect"

In Chrome: open chrome://inspect → click "inspect"

Sources panel: add breakpoints, watch expressions, step through

Sources panel: add breakpoints, watch expressions, step through


**Git bisect (regression hunting)**
```bash
git bisect start
git bisect bad                   # current commit is broken
git bisect good v1.2.0           # last known good tag/commit

**Git bisect(回归问题排查)**
```bash
git bisect start
git bisect bad                   # current commit is broken
git bisect good v1.2.0           # last known good tag/commit

Git checks out midpoint — test, then:

Git checks out midpoint — test, then:

git bisect good # or: git bisect bad
git bisect good # or: git bisect bad

Repeat until git identifies the first bad commit

Repeat until git identifies the first bad commit

git bisect reset

**Go (delve)**
```bash
dlv debug ./cmd/server           # build & attach
git bisect reset

**Go (delve)**
```bash
dlv debug ./cmd/server           # build & attach

(dlv) break main.go:55

(dlv) break main.go:55

(dlv) continue

(dlv) continue

(dlv) print myVar

(dlv) print myVar

undefined
undefined

Output Templates

输出模板

When debugging, provide:
  1. Root Cause: What specifically caused the issue
  2. Evidence: Stack trace, logs, or test that proves it
  3. Fix: Code change that resolves it
  4. Prevention: Test or safeguard to prevent recurrence
调试时,需提供以下内容:
  1. 根因:导致问题的具体原因
  2. 证据:证明根因的堆栈跟踪、日志或测试结果
  3. 修复方案:解决问题的代码变更
  4. 预防措施:防止问题复发的测试或防护手段