bug-detective
它能做什么
这项技能为你的 AI 提供一套循序渐进的方法,用来追查代码中的错误、异常和故障。适合代码出了问题、希望得到谨慎且基于证据修复的人。
适用场景
- ✓当你手里有需要排查的错误信息、异常或堆栈跟踪时。
- ✓当某个功能突然坏掉或停止工作时。
- ✓当你询问代码为何失败,而原因并不明显的时候。
技能链接
https://github.com/Galaxy-Dawn/claude-scholar/blob/main/skills/bug-detective/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的登录页面在上次部署后出现 500 错误,请帮我找出原因并修复。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会先收集错误细节,对错误类型进行分类,列出可能的原因,逐一验证,然后应用修复并确认结果。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Bug Detective
A systematic debugging workflow for investigating and resolving code errors, exceptions, and failures. Provides structured debugging methods and common error pattern recognition.
Core Philosophy
Debugging is a scientific problem-solving process that requires:
- Understand the problem - Clearly define symptoms and expected behavior
- Gather evidence - Collect error messages, logs, stack traces
- Form hypotheses - Infer possible causes based on evidence
- Verify hypotheses - Confirm or eliminate causes through experiments
- Resolve the issue - Apply fixes and verify
Debugging Workflow
Step 1: Understand the Problem
Before starting to debug, clarify the following information:
Required information to collect:
- Complete error message content
- Exact location of the error (filename and line number)
- Reproduction steps (how to trigger the error)
- Expected behavior vs actual behavior
- Environment info (OS, versions, dependencies)
Question template:
1. What is the exact error message?
2. Which file and line does the error occur at?
3. How can this issue be reproduced? Provide detailed steps.
4. What was the expected result? What actually happened?
5. What recent changes might have introduced this issue?
Step 2: Analyze Error Type
Choose a debugging strategy based on error type:
| Error Type | Characteristics | Debugging Method |
|---|---|---|
| Syntax Error | Code cannot be parsed | Check syntax, bracket matching, quotes |
| Import Error | ModuleNotFoundError | Check module installation, path config |
| Type Error | TypeError | Check data types, type conversions |
| Attribute Error | AttributeError | Check if object attribute exists |
| Key Error | KeyError | Check if dictionary key exists |
| Index Error | IndexError | Check list/array index range |
| Null Reference | NoneType/NullPointerException | Check if variable is None |
| Network Error | ConnectionError/Timeout | Check network connection, URL, timeout settings |
| Permission Error | PermissionError | Check file permissions, user permissions |
| Resource Error | FileNotFoundError | Check if file path exists |
Step 3: Locate the Problem Source
Use the following methods to locate the issue:
1. Binary Search Method
- Comment out half the code, check if the problem persists
- Progressively narrow the scope until the problematic code is found
2. Log Tracing
- Add print/logging statements at key locations
- Track variable value changes
- Confirm code execution path
3. Breakpoint Debugging
- Use debugger breakpoint functionality
- Step through code execution
- Inspect variable state
4. Stack Trace Analysis
- Find the call chain from the stack trace in the error message
- Determine the direct cause of the error
- Trace back to the root cause
Step 4: Form and Verify Hypotheses
Hypothesis framework:
Hypothesis: [problem description] causes [error phenomenon]
Verification steps:
1. [verification method 1]
2. [verification method 2]
Expected results:
- If hypothesis is correct: [expected phenomenon]
- If hypothesis is wrong: [expected phenomenon]
Step 5: Apply Fix
After fixing, verify:
- The original error is resolved
- No new errors have been introduced
- Related functionality still works correctly
- Tests added to prevent regression
Python Common Error Patterns
1. Indentation Errors
2. Mutable Default Arguments
3. Closure Issues in Loops
4. Modifying a List While Iterating
5. Using is for String Comparison
6. Forgetting to Call super().__init__()
JavaScript/TypeScript Common Error Patterns
1. this Binding Issues
2. Async Error Handling
3. Object Reference Comparison
Bash/Zsh Common Error Patterns
1. Spacing Issues
# ❌ No spaces allowed in assignment
name = "John" # Error: tries to run 'name' command
# ✅ Correct assignment
name="John"
# ❌ Missing spaces in conditional test
if[$name -eq 1]; then # Error
# ✅ Correct
if [ $name -eq 1 ]; then
2. Quoting Issues
# ❌ Variables not expanded inside single quotes
echo 'The value is $var' # Output: The value is $var
# ✅ Use double quotes
echo "The value is $var" # Output: The value is actual_value
# ❌ Using backticks for command substitution (confusing)
result=`command`
# ✅ Use $()
result=$(command)
3. Unquoted Variables
常见问题
需要提供哪些信息?
完整的错误信息;如果知道,提供文件和行号;复现问题的步骤;以及你原本期望发生的结果。
它会随意猜测修复方法吗?
不会。它会先列出可能的原因,逐一检查后才会修改代码。
它了解常见的错误模式吗?
了解。它内置了常见的错误模式,有助于更快地定位问题。
详情
作者的原始描述
This skill should be used when the user asks to "debug this", "fix this error", "investigate this bug", "troubleshoot this issue", "find the problem", "something is broken", "this isn't working", "why is this failing", or reports errors/exceptions/bugs. Provides systematic debugging workflow and common error patterns.
热度
- GitHub 星标
- 6.0k
- 排名
- #14480
- 许可证
- MIT
- 更新时间
- 2026/10/19
评论
- …
同一仓库的更多技能
agent-identifier
6.0k教你的智能体创建 Claude Code 智能体,正确编写其名称、触发描述、系统提示词和设置。
architecture-design
6.0k教你的智能体掌握机器学习项目代码的标准结构,在添加可注册组件时使用工厂和注册表模式。
citation-verification
6.0k教你的智能体对照可信的学术来源检查论文中的每条引用,找出虚假或错误的参考文献。
code-review-excellence
6.0k帮你的智能体审阅代码改动和拉取请求,给出清晰、友善、有重点的反馈,找出真正的错误并改进代码。