code-showcase-systematic-debugging
它能做什么
这个系统可以用 4 步方法帮你找到代码问题的根本原因。它注重先理解错误“为什么”会发生,然后再尝试修复。
适用场景
- ✓当代码中出现错误而你不知道原因时。
- ✓当修复自动化测试中的失败时。
- ✓当你要调查程序的异常行为时。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/code-showcase-systematic-debugging/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我遇到了错误 X,你能帮我用四阶段方法找到根本原因吗?”
每周 5 个新技能,1 分钟读完。
工作原理
该系统会引导你完成 4 个阶段:根本原因调查、模式分析、假设与测试,最后是实施修复。它坚持在做任何修复之前先找到最初的原因。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Systematic Debugging
When to Use
Use this skill when you need four-phase debugging methodology with root cause analysis. Use when investigating bugs, fixing test failures, or troubleshooting unexpected behavior. Emphasizes NO FIXES WITHOUT ROOT CAUSE FIRST.
Core Principle
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST.
Never apply symptom-focused patches that mask underlying problems. Understand WHY something fails before attempting to fix it.
The Four-Phase Framework
Phase 1: Root Cause Investigation
Before touching any code:
- Read error messages thoroughly - Every word matters
- Reproduce the issue consistently - If you can't reproduce it, you can't verify a fix
- Examine recent changes - What changed before this started failing?
- Gather diagnostic evidence - Logs, stack traces, state dumps
- Trace data flow - Follow the call chain to find where bad values originate
Root Cause Tracing Technique:
1. Observe the symptom - Where does the error manifest?
2. Find immediate cause - Which code directly produces the error?
3. Ask "What called this?" - Map the call chain upward
4. Keep tracing up - Follow invalid data backward through the stack
5. Find original trigger - Where did the problem actually start?
Key principle: Never fix problems solely where errors appear—always trace to the original trigger.
Phase 2: Pattern Analysis
- Locate working examples - Find similar code that works correctly
- Compare implementations completely - Don't just skim
- Identify differences - What's different between working and broken?
- Understand dependencies - What does this code depend on?
Phase 3: Hypothesis and Testing
Apply the scientific method:
- Formulate ONE clear hypothesis - "The error occurs because X"
- Design minimal test - Change ONE variable at a time
- Predict the outcome - What should happen if hypothesis is correct?
- Run the test - Execute and observe
- Verify results - Did it behave as predicted?
- Iterate or proceed - Refine hypothesis if wrong, implement if right
Phase 4: Implementation
- Create failing test case - Captures the bug behavior
- Implement single fix - Address root cause, not symptoms
- Verify test passes - Confirms fix works
- Run full test suite - Ensure no regressions
- If fix fails, STOP - Re-evaluate hypothesis
Critical rule: If THREE or more fixes fail consecutively, STOP. This signals architectural problems requiring discussion, not more patches.
Red Flags - Process Violations
Stop immediately if you catch yourself thinking:
- "Quick fix for now, investigate later"
- "One more fix attempt" (after multiple failures)
- "This should work" (without understanding why)
- "Let me just try..." (without hypothesis)
- "It works on my machine" (without investigating difference)
Warning Signs of Deeper Problems
Consecutive fixes revealing new problems in different areas indicates architectural issues:
- Stop patching
- Document what you've found
- Discuss with team before proceeding
- Consider if the design needs rethinking
Common Debugging Scenarios
Test Failures
1. Read the FULL error message and stack trace
2. Identify which assertion failed and why
3. Check test setup - is the test environment correct?
4. Check test data - are mocks/fixtures correct?
5. Trace to the source of unexpected value
Runtime Errors
1. Capture the full stack trace
2. Identify the line that throws
3. Check what values are undefined/null
4. Trace backward to find where bad value originated
5. Add validation at the source
"It worked before"
1. Use git bisect to find the breaking commit
2. Compare the change with previous working version
3. Identify what assumption changed
4. Fix at the source of the assumption violation
Intermittent Failures
1. Look for race conditions
2. Check for shared mutable state
3. Examine async operation ordering
4. Look for timing dependencies
5. Add deterministic waits or proper synchronization
Debugging Checklist
Before claiming a bug is fixed:
- Root cause identified and documented
- Hypothesis formed and tested
- Fix addresses root cause, not symptoms
- Failing test created that reproduces bug
- Test now passes with fix
- Full test suite passes
- No "quick fix" rationalization used
- Fix is minimal and focused
…
常见问题
为什么要先找到根本原因再修复?
只修复表面症状可能会掩盖真正的问题,而问题可能会在之后再次出现或引发其他错误。理解根本原因才能做出彻底的修复。
什么是“危险信号”?
这些是提示你可能跳过了重要步骤的警示信号,例如没有理解问题就想着快速修复,或者反复尝试多种都不成功的修复方法。
如果我尝试修复多次都失败了,该怎么办?
如果你尝试了三次或更多次修复都没有成功,系统会建议你停下来。这可能说明代码存在更大的结构性问题,需要和团队一起讨论。
详情
作者的原始描述
Four-phase debugging methodology with root cause analysis. Use when investigating bugs, fixing test failures, or troubleshooting unexpected behavior. Emphasizes NO FIXES WITHOUT ROOT CAUSE FIRST.
热度
- GitHub 星标
- 48k
- 排名
- #4194
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。