debugging-wizard
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDebugging Wizard
调试向导
Expert debugger applying systematic methodology to isolate and resolve issues in any codebase.
采用系统化方法隔离并解决任意代码库问题的专家级调试能力。
Core Workflow
核心工作流
- Reproduce - Establish consistent reproduction steps
- Isolate - Narrow down to smallest failing case
- Hypothesize and test - Form testable theories, verify/disprove each one
- Fix - Implement and verify solution
- Prevent - Add tests/safeguards against regression
- 复现 - 确定一致的复现步骤
- 隔离 - 缩小范围至最小可复现用例
- 假设与验证 - 提出可测试的理论,逐一证实/证伪
- 修复 - 实现并验证解决方案
- 预防 - 添加测试/防护措施以避免回归
Reference Guide
参考指南
Load detailed guidance based on context:
<!-- Systematic Debugging row adapted from obra/superpowers by Jesse Vincent (@obra), MIT License -->
| Topic | Reference | Load When |
|---|---|---|
| Debugging Tools | | Setting up debuggers by language |
| Common Patterns | | Recognizing bug patterns |
| Strategies | | Binary search, git bisect, time travel |
| Quick Fixes | | Common error solutions |
| Systematic Debugging | | Complex bugs, multiple failed fixes, root cause analysis |
根据上下文加载详细指导:
<!-- 系统化调试行改编自 Jesse Vincent (@obra) 的 obra/superpowers 项目,MIT 许可证 -->
| 主题 | 参考文件 | 加载时机 |
|---|---|---|
| 调试工具 | | 按语言配置调试器时 |
| 常见模式 | | 识别Bug模式时 |
| 调试策略 | | 使用二分查找、git bisect、时间旅行调试时 |
| 快速修复 | | 查找常见错误解决方案时 |
| 系统化调试 | | 处理复杂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 debuggerPython (pdb)
bash
python -m pdb script.py # launch debuggerinside 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 DevToolsIn 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/commitGit 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 & attachgit 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
undefinedundefinedOutput Templates
输出模板
When debugging, provide:
- Root Cause: What specifically caused the issue
- Evidence: Stack trace, logs, or test that proves it
- Fix: Code change that resolves it
- Prevention: Test or safeguard to prevent recurrence
调试时,需提供以下内容:
- 根因:导致问题的具体原因
- 证据:证明根因的堆栈跟踪、日志或测试结果
- 修复方案:解决问题的代码变更
- 预防措施:防止问题复发的测试或防护手段