系统化调试流程
systematic-debugging
针对复杂问题的四阶段调试流程(观察 Observe、假设 Hypothesize、测试 Test、修复 Fix)。适用于调试失败、排查不稳定的测试(flaky tests)、追踪根本原因,或遇到难以解释的 bug。不适用于:编写新测试(使用 test-driven-development)、React 组件测试模式(使用 ui-testing),或 E2E 测试搭建(使用 webapp-testing)。
- License 许可
- MIT
- 最近更新
- 2026-08-16
- Stars
- ★ 3
- Forks
- 0
01 前言 Front Matter
- name
- systematic-debugging
- description
- 4-phase debugging process (Observe, Hypothesize, Test, Fix) for complex issues. Use when debugging fails, investigating flaky tests, tracking root causes, or facing mysterious bugs. DO NOT USE FOR: writing new tests (use test-driven-development), React component test patterns (use ui-testing), or E2E test setup (use webapp-testing).
02 资源文件 1
- 参考文档debugging-phases.md5.4 KB
03 SKILL.md 正文
Systematic Debugging
Evidence-based debugging methodology using a structured 4-phase approach.
When to Use
- Initial debugging attempts failed
- Bug is intermittent or hard to reproduce
- Multiple potential root causes
- High-stakes fix (production, security)
- Teaching debugging skills
The 4-Phase Process
┌─────────────┐ ┌──────────────┐ ┌─────────────┐ ┌─────────────┐
│ 1. OBSERVE │ -> │ 2. HYPOTHESIZE│ -> │ 3. TEST │ -> │ 4. FIX │
│ │ │ │ │ │ │ │
│ Gather data │ │ Form theories│ │ Validate │ │ Implement & │
│ Don't assume│ │ Rank by │ │ One at a │ │ Verify │
│ │ │ likelihood │ │ time │ │ │
└─────────────┘ └──────────────┘ └─────────────┘ └─────────────┘
↑ │
└──────────────────────────────────────┘
(if hypothesis fails)
Phase 1: OBSERVE
Goal: Gather facts without assumptions.
Actions
- [ ] Document exact symptoms (error messages, behavior)
- [ ] Identify when it started (commit, deployment, date)
- [ ] Determine reproduction steps (or note if intermittent)
- [ ] Check logs, metrics, and monitoring
- [ ] Note what IS working (bounds the problem)
Questions to Answer
- What exactly is happening vs. expected?
- When did this start? What changed?
- Who/what is affected? (all users, some, specific conditions)
- Can I reproduce it? How reliably?
- What have I already tried?
Observation Log Template
## Bug: [Brief description]
### Symptoms
- [Exact error message or behavior]
### Timeline
- First reported: [date/time]
- Last known working: [date/time]
- Related changes: [commits, deploys]
### Reproduction
- Steps: [1, 2, 3...]
- Reliability: [always/sometimes/rarely]
- Environment: [local/staging/prod]
### What Works
- [Related functionality that IS working]
Phase 2: HYPOTHESIZE
Goal: Generate ranked theories based on evidence.
Generate Hypotheses
Based on observations, list possible causes:
- Most likely (evidence strongly supports)
- Possible (evidence partially supports)
- Unlikely but testable (low probability, easy to rule out)
Ranking Criteria
- Evidence fit: Does it explain ALL symptoms?
- Recency: Recent changes more likely than old code
- Complexity: Simpler explanations first (Occam's Razor)
- Testability: Can we prove/disprove it quickly?
Hypothesis Template
### Hypothesis: [Theory]
Evidence for:
- [Supporting observation]
Evidence against:
- [Contradicting observation]
How to test:
- [Specific test that proves/disproves]
Likelihood: [High/Medium/Low]
See debugging-phases.md for detailed phase guidance.
Phase 3: TEST
Goal: Validate one hypothesis at a time with evidence.
Testing Rules
- One variable at a time: Change only what tests the hypothesis
- Record everything: Document what you tried and results
- Preserve ability to undo: Don't make permanent changes while testing
- Set time limits: Timebox each hypothesis test
Test Log Template
### Testing: [Hypothesis]
Test approach:
- [What I'm changing/checking]
Result:
- [What happened]
Conclusion:
- [ ] Confirmed (proceed to Fix)
- [ ] Disproved (next hypothesis)
- [ ] Inconclusive (need different test)
Phase 4: FIX
Goal: Implement verified fix with confidence.
Fix Checklist
- [ ] Fix addresses confirmed root cause (not just symptoms)
- [ ] Fix is minimal (no unrelated changes)
- [ ] Added test that would catch regression
- [ ] Verified fix in same environment where bug occurred
- [ ] Documented what the bug was and how it was fixed
Post-Fix Verification
- [ ] Original reproduction steps no longer fail
- [ ] Related functionality still works
- [ ] No new errors in logs
- [ ] Performance not degraded
Quick Debugging Toolkit
Information Gathering
[CUSTOMIZE] Add your project's debugging commands:
- Log tailing: [command]
- Database queries: [tool/access]
- Metrics dashboard: [URL]
- Error tracking: [tool/URL]
Common Root Causes Checklist
- [ ] Recent deployment? Check release notes
- [ ] Environment difference? Compare configs
- [ ] Data issue? Check for bad/missing data
- [ ] Dependency update? Check lock files
- [ ] Race condition? Check async code
- [ ] Resource exhaustion? Check memory/connections
- [ ] Permission change? Check access controls
Gotchas
| Trigger | Gotcha | Fix |
|---|---|---|
| Making multiple simultaneous changes to isolate the bug | Root cause becomes impossible to identify — can't know which change fixed it | Revert to baseline; apply one targeted change; verify; then proceed |
| Closing the bug without adding a regression test | Bug recurs under similar conditions undetected | Add a test that reproduces the original failure; confirm it is GREEN after the fix |
| Forming a hypothesis before completing Phase 1 observations | Leads investigation down the wrong path; root cause stays unexamined | Complete Phase 1 (Observe) fully before proposing any hypothesis |
| Applying changes directly in the production environment | Risk of cascading failure or data corruption | Reproduce locally first; use staging environments or feature flags |
| Ending the session without updating the observation log | Investigation must restart from scratch next session | Log dated observations before ending the session; commit the log |
| Making permanent code changes while testing hypotheses | Progressive state contamination — hard to reason about current baseline | Preserve ability to undo each test step; use feature flags or branches |
| Fixing the symptom without root cause analysis | Bug recurs under different conditions | Follow the 4-phase protocol fully; document root cause before applying fix |
04 同仓库更多 Skills
Playwright 端到端测试
webapp-testing
面向 Web 应用的 Playwright 端到端测试指南,包含实用模式和设置步骤。在创建或改进基于浏览器的 E2E 覆盖率、测试稳定性和 CI 执行时使用。不要用于:React 组件测试(使用 ui-testing)、Canvas 游戏交互(使用 browser-canvas-testing)、TDD 工作流(使用 test-driven-development)、失败调试(使用 systematic-debugging)或随机化属性测试(使用 property-based-testing)。
任务完成前验证
verification-before-completion
在将工作标记为完成前使用的基于证据的验证清单。适用于提交 PR、发布、将工单标记为完成,或任何「我已完成」的声明之前;也适用于为差异测试套件的主张指定基线提交、设计变异测试活动或红灯运行证据、做出「不存在」的主张、普遍性主张,或将一次性演示作为长期保证提供时、归因某项测量结果或声称某次扫描或验证循环已完成时,以及陈述某项检查或 CI 套件将如何处理某个变更时。不要用于:合并后清理或归档(使用 post-pr-review),或处理 GitHub 审查意见(使用 code-review-intake)。
验证与审查方法论
validation-methodology
用于分阶段验证、故障分诊和追查深度设置的可复用验证与审查方法论。在运行验证阶梯、对失败进行分诊或执行对抗性审查时使用。不要用于:CE Gate 编排、专家派发的职责归属或步骤执行流程(这些保留在 Code-Conductor 中)。
上游智能体接手协议
upstream-onboarding
供上游智能体(Experience-Owner、Solution-Designer、Issue-Planner)与 Code-Conductor 在针对现有 GitHub issue 被调用时使用的共享开场阶段协议。它会生成适配规模的上下文简报,并在每个阶段边界对承接的工作执行标准检查。当用户可调用的智能体收到引用现有 GitHub issue 的请求、且必须在开场阶段加载 solution-authoring 与 upstream-onboarding 时使用。不要用于:子智能体派发(其已在经评估的会话上下文中运行)、合并后审查(使用 post-pr-review)、研究类或非树形子智能体。
React 组件测试策略
ui-testing
以用户行为为核心的弹性 React 组件测试策略。适用于编写或审阅组件级 React 测试、修复不稳定的组件测试,或建立 React 测试模式。不适用于:Playwright E2E 测试(使用 webapp-testing)、canvas 游戏交互(使用 browser-canvas-testing)、TDD 工作流(使用 test-driven-development)、失败调试(使用 systematic-debugging)、UI 组件设计(使用 frontend-design),或随机属性测试(使用 property-based-testing)。
UI 界面视觉迭代优化
ui-iteration
可复用的截图驱动 UI 打磨工作流,用于迭代式视觉优化。适用于通过反复审阅与调整来改进布局、层级、间距、反馈或基于 Tailwind 的呈现效果。不适用于:功能性 Bug 修复、仅针对无障碍的审计,或重大重设计策略工作(使用 Code-Smith 或 frontend-design)。