npx skills add https://github.com/transiglobal/runesleo-systematic-debugging --skill 'Systematic Debugging'随机修复浪费时间并会引入新的错误。快速补丁掩盖了根本问题。
核心原则: 在尝试修复之前,必须找到根本原因。症状修复就是失败。
违反此流程的字面要求,就是违反调试的精神。
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
NO INVESTIGATION WITHOUT CONTEXT RECALL FIRST
如果你没有完成阶段 0,就不能进入阶段 1。如果你没有完成阶段 1,就不能提出修复方案。
适用于任何技术问题:
特别在以下情况使用:
不要跳过的情况:
你必须完成每个阶段,才能进入下一个阶段。
在进行任何其他操作之前:
* 错误类型是什么?(内存不足、超时、连接、类型错误...)
* 哪个组件?(服务器、浏览器、API、数据库...)
* 代码库的哪个区域?
2. 搜索先验知识
* 检查项目文档、MEMORY 文件或过去的对话记录
* 在代码库中搜索类似的错误模式:`grep -r "ErrorType" .`
* 检查 git 日志中相关的近期更改:`git log --oneline -20`
3. 审查结果
* 找到相关经验? -> **直接应用,跳到阶段 4**
* 找到部分匹配? -> 用作阶段 1 的起点
* 什么都没找到? -> 进入阶段 1,**记得之后记录解决方案**
4. 输出格式
上下文回顾:
- 查询:"xxx"
- 发现:[相关知识的描述]
- 行动:[应用经验 / 继续调查 / 无匹配项]
违规行为: 在没有输出上下文回顾的情况下进入阶段 1 = 流程失败。
在尝试任何修复之前:
* 不要跳过错误或警告
* 它们通常包含确切的解决方案
* 完整阅读堆栈跟踪
* 注意行号、文件路径、错误代码
2. 稳定复现
* 你能可靠地触发它吗?
* 确切的步骤是什么?
* 每次都发生吗?
* 如果无法复现 -> 收集更多数据,不要猜测
3. 检查近期变更
* 哪些变更可能导致此问题?
* Git diff,最近的提交
* 新的依赖项,配置更改
* 环境差异
4. 在多组件系统中收集证据
当系统有多个组件时(CI -> 构建 -> 签名,API -> 服务 -> 数据库):
在提出修复方案之前,添加诊断工具:
对于每个组件边界:
- 记录进入组件的数据
- 记录离开组件的数据
- 验证环境/配置传播
- 检查每一层的状态
运行一次以收集证据,显示它在**哪里**出错
然后分析证据以识别故障组件
然后调查那个特定的组件
5. 追踪数据流
* 错误值起源于哪里?
* 是什么用错误值调用了这个?
* 持续向上追踪,直到找到源头
* 在源头修复,而不是在症状处
在修复之前找到模式:
* 在同一代码库中找到类似的正常工作代码
* 什么能正常工作,与损坏的部分相似?
2. 与参考实现进行比较
* 如果正在实现某个模式,请**完整**阅读参考实现
* 不要略读——阅读每一行
* 在应用之前完全理解该模式
3. 识别差异
* 正常工作和损坏的部分之间有什么不同?
* 列出每一个差异,无论多小
* 不要假设"那不可能有关系"
4. 理解依赖关系
* 这需要哪些其他组件?
* 需要什么设置、配置、环境?
* 它做了哪些假设?
科学方法:
* 清晰陈述:"我认为 X 是根本原因,因为 Y"
* 把它写下来
* 要具体,不要模糊
2. 最小化测试
* 做出**最小**可能的更改来测试假设
* 一次只改变一个变量
* 不要一次修复多个问题
3. 在继续之前验证
* 有效吗?是 -> 进入阶段 4
* 没效?形成**新**假设
* **不要**在原有基础上添加更多修复
4. 当你不明白时
* 说"我不理解 X"
* 不要假装知道
* 请求帮助
* 进行更多研究
修复根本原因,而不是症状:
* 最简单的可能复现
* 如果可能,使用自动化测试
* 如果没有框架,使用一次性测试脚本
* **必须**在修复之前拥有
2. 实施单一修复
* 解决已识别的根本原因
* 一次**一个**更改
* 不要做"既然我在这里"的改进
* 不要捆绑重构
3. 验证修复
* 测试现在通过了吗?
* 没有破坏其他测试吗?
* 问题真的解决了吗?
4. 如果修复无效
* **停止**
* 计数:你尝试了多少次修复?
* 如果 < 3:返回阶段 1,用新信息重新分析
* **如果 >= 3:停止并质疑架构(见下面的步骤 5)**
* **不要**在没有架构讨论的情况下尝试第 4 次修复
5. 如果 3+ 次修复失败:质疑架构
表明存在架构问题的模式:
* 每次修复都会在不同地方揭示新的共享状态/耦合/问题
* 修复需要"大规模重构"才能实施
* 每次修复都会在其他地方产生新的症状
停止并质疑基本原则:
* 这个模式从根本上说是合理的吗?
* 我们是否"仅仅因为惯性而坚持它"?
* 我们应该重构架构,还是继续修复症状?
在尝试更多修复之前与用户讨论。
如果你发现自己有这些想法:
所有这些都意味着:停止。返回阶段 1。
如果 3+ 次修复失败: 质疑架构(见阶段 4.5)
| 借口 | 现实 |
|---|---|
| "问题很简单,不需要流程" | 简单的问题也有根本原因。流程对于简单的错误来说很快。 |
| "紧急情况,没时间走流程" | 系统化调试比猜测和检查的瞎忙活更快。 |
| "先试试这个,然后再调查" | 第一次修复就设定了模式。从一开始就做对。 |
| "确认修复有效后再写测试" | 未经测试的修复不牢固。先测试能证明它。 |
| "一次进行多个修复可以节省时间" | 无法隔离是什么起了作用。会导致新的错误。 |
| "参考太长了,我会调整这个模式" | 部分理解必然导致错误。完整阅读它。 |
| "我看到了问题,让我修复它" | 看到症状 != 理解根本原因。 |
| "再试一次修复"(在 2+ 次失败后) | 3+ 次失败 = 架构问题。质疑模式,不要再修复。 |
| 阶段 | 关键活动 | 成功标准 |
|---|---|---|
| 0. 上下文回顾 | 提取关键词,搜索先验知识 | 输出回顾摘要 |
| 1. 根本原因 | 阅读错误,复现,检查变更,收集证据 | 理解是什么和为什么 |
| 2. 模式 | 找到工作示例,进行比较 | 识别差异 |
| 3. 假设 | 形成理论,最小化测试 | 假设得到确认或形成新假设 |
| 4. 实施 | 创建测试,修复,验证 | 错误解决,测试通过 |
来自调试会话的数据:
每周安装次数
–
代码仓库
首次出现
–
安全审计
Random fixes waste time and create new bugs. Quick patches mask underlying issues.
Core principle: ALWAYS find root cause before attempting fixes. Symptom fixes are failure.
Violating the letter of this process is violating the spirit of debugging.
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
NO INVESTIGATION WITHOUT CONTEXT RECALL FIRST
If you haven't completed Phase 0, you cannot proceed to Phase 1. If you haven't completed Phase 1, you cannot propose fixes.
Use for ANY technical issue:
Use this ESPECIALLY when:
Don't skip when:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
You MUST complete each phase before proceeding to the next.
BEFORE doing ANYTHING else:
Extract Keywords from Error
Search for Prior Knowledge
grep -r "ErrorType" .git log --oneline -20Review Results
Output Format
Context Recall: - Query: "xxx" - Found: [description of related knowledge] - Action: [apply experience / continue investigation / no match]
VIOLATION: Proceeding to Phase 1 without Context Recall output = process failure.
BEFORE attempting ANY fix:
Read Error Messages Carefully
Reproduce Consistently
Check Recent Changes
Gather Evidence in Multi-Component Systems
WHEN system has multiple components (CI - > build -> signing, API -> service -> database):
BEFORE proposing fixes, add diagnostic instrumentation:
For EACH component boundary:
- Log what data enters component
- Log what data exits component
- Verify environment/config propagation
- Check state at each layer
Run once to gather evidence showing WHERE it breaks
THEN analyze evidence to identify failing component
THEN investigate that specific component
5. Trace Data Flow
* Where does bad value originate?
* What called this with bad value?
* Keep tracing up until you find the source
* Fix at source, not at symptom
Find the pattern before fixing:
Find Working Examples
Compare Against References
Identify Differences
Understand Dependencies
Scientific method:
Form Single Hypothesis
Test Minimally
Verify Before Continuing
When You Don't Know
Fix the root cause, not the symptom:
Create Failing Test Case
Implement Single Fix
Verify Fix
If Fix Doesn't Work
If 3+ Fixes Failed: Question Architecture
Pattern indicating architectural problem:
* Each fix reveals new shared state/coupling/problem in different place
* Fixes require "massive refactoring" to implement
* Each fix creates new symptoms elsewhere
STOP and question fundamentals:
* Is this pattern fundamentally sound?
* Are we "sticking with it through sheer inertia"?
* Should we refactor architecture vs. continue fixing symptoms?
Discuss with the user before attempting more fixes.
If you catch yourself thinking:
ALL of these mean: STOP. Return to Phase 1.
If 3+ fixes failed: Question the architecture (see Phase 4.5)
| Excuse | Reality |
|---|---|
| "Issue is simple, don't need process" | Simple issues have root causes too. Process is fast for simple bugs. |
| "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |
| "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |
| "I'll write test after confirming fix works" | Untested fixes don't stick. Test first proves it. |
| "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
| "Reference too long, I'll adapt the pattern" | Partial understanding guarantees bugs. Read it completely. |
| "I see the problem, let me fix it" | Seeing symptoms != understanding root cause. |
| "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Question pattern, don't fix again. |
| Phase | Key Activities | Success Criteria |
|---|---|---|
| 0. Context Recall | Extract keywords, search prior knowledge | Output recall summary |
| 1. Root Cause | Read errors, reproduce, check changes, gather evidence | Understand WHAT and WHY |
| 2. Pattern | Find working examples, compare | Identify differences |
| 3. Hypothesis | Form theory, test minimally | Confirmed or new hypothesis |
| 4. Implementation | Create test, fix, verify | Bug resolved, tests pass |
From debugging sessions:
Weekly Installs
–
Repository
First Seen
–
Security Audits
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
109,600 周安装