关于 error-debugger
面向开发者的上下文感知调试技能,会搜索以往错误解决方案、分析错误信息并给出带代码示例的修复建议。修复确认后,它还会创建回归测试并保存方案,以便后续参考。
主要功能
- 01搜索相似错误的历史方案
- 02分析错误信息与堆栈
- 03提供带代码示例的修复
- 04创建回归测试
- 05保存已验证的解决方案
- 06按成功率排序匹配方案
适用场景
- 01排查新出现的运行时错误
- 02复用项目中曾解决的问题
- 03修复后补充回归测试
- 04为常见故障积累可搜索记录
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ jackspace/ claudeskillz --skill error-debugger安装后在 Claude Code 中输入/error-debugger确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
examples.mdreference.mdSKILL.json详细介绍
错误调试器
用途
具备上下文感知能力的调试功能,可从过往解决方案中学习。发生错误时:
- 在记忆中搜索类似的过往错误
- 分析错误消息和堆栈跟踪
- 立即提供修复方案和代码示例
- 通过 testing-builder 创建回归测试
- 将解决方案保存到记忆中,供日后使用
适用于 ADHD 用户:消除调试带来的挫败感,立即提供可执行的修复方案。 适用于 SDAM 用户:回忆你已经找到的过往解决方案。 适用于所有用户:随着对代码库的学习,能力会不断提升。
激活触发条件
- 用户说:“调试这个”“修复这个错误”“为什么这个会失败”
- 错误消息包含:TypeError、ReferenceError、SyntaxError、ECONNREFUSED、CORS、404、500 等
- 对话中粘贴了堆栈跟踪
- “出问题了”或类似表达
核心工作流
1. 解析错误
提取关键信息:
{
error_type: "TypeError|ReferenceError|ECONNREFUSED|...",
message: "Cannot read property 'map' of undefined",
stack_trace: [...],
file: "src/components/UserList.jsx",
line: 42,
context: "Rendering user list"
}
2. 搜索过往解决方案
查询 context-manager:
search memories for:
- error_type match
- similar message (fuzzy match)
- same file/component if available
- related tags (if previously tagged)
如果找到匹配项:
🔍 Found similar past error!
📝 3 months ago: TypeError in UserList component
✅ Solution: Added null check before map
⏱️ Fixed in: 5 minutes
🔗 Memory: procedures/{uuid}.md
Applying the same solution...
如果没有匹配项:
🆕 New error - analyzing...
(Will save solution after fix)
3. 分析错误
有关全面的错误模式库,请参阅 reference.md。
常见模式速查:
- TypeError: Cannot read property 'X' of undefined → 使用可选链和默认值
- ECONNREFUSED → 检查服务是否正在运行,并确认端口
- CORS errors → 配置 CORS 标头
- 404 Not Found → 检查路由定义
- 500 Internal Server Error → 检查服务端日志
4. 提供修复方案
格式:
🔧 Error Analysis
**Type**: {error_type}
**Location**: {file}:{line}
**Cause**: {root_cause_explanation}
**Fix**:
```javascript
// ❌ Current code
const users = data.users;
return users.map(user => <div>{user.name}</div>);
// ✅ Fixed code
const users = data?.users || [];
return users.map(user => <div>{user.name}</div>);
说明:添加可选链和默认空数组,以处理 data 或 data.users 未定义的情况。
预防措施:使用前始终验证 API 响应结构。
后续步骤:
- 应用修复方案
- 手动测试
- 我会创建回归测试
### 5. Save Solution
After fix confirmed working:
```bash
# Save to context-manager as PROCEDURE
remember: Fix for TypeError in map operations
Type: PROCEDURE
Tags: error, typescript, array-operations
Content: When getting "Cannot read property 'map' of undefined",
add optional chaining and default empty array:
data?.users || []
记忆结构:
# PROCEDURE: Fix TypeError in map operations
**Error Type**: TypeError
**Message Pattern**: Cannot read property 'map' of undefined
**Context**: Array operations on potentially undefined data
## Solution
Use optional chaining and default values:
```javascript
// Before
const items = data.items;
return items.map(...)
// After
const items = data?.items || [];
return items.map(...)
适用场景
- 可能未定义的 API 响应
- 可能未传入的 Props
- 对不确定的数据执行数组操作
测试记录
✅ 已在 UserList 组件中修复(2025-10-17) ✅ 回归测试:tests/components/UserList.test.jsx
标签
错误、typescript、数组操作、未定义值处理
### 6. Create Regression Test
Automatically invoke testing-builder:
为此修复方案创建回归测试:
- 测试组件能否处理未定义的数据
- 测试组件能否处理空数组
- 测试组件能否使用有效数据正常运行
## Tool Persistence Pattern (Meta-Learning)
**Critical principle from self-analysis**: Never give up on first obstacle. Try 3 approaches before abandoning a solution path.
### Debugging Tools Hierarchy
When debugging an error, try these tools in sequence:
**1. Search Past Solutions (context-manager)**
```bash
# First approach: Check memory
search memories for error pattern
如果没有找到过往解决方案 → 继续尝试下一种方法
2. GitHub Copilot CLI 搜索
# Second approach: Search public issues
copilot "Search GitHub for solutions to: $ERROR_MESSAGE"
如果 Copilot 没有找到合适的结果 → 继续尝试下一种方法
3. 使用当前上下文进行网络搜索
# Third approach: Real-time web search
[Use web search for latest Stack Overflow solutions]
如果网络搜索失败 → 再向用户询问更多上下文
元分析中的真实示例
发生了什么:尝试 GitHub MCP → 遇到身份验证错误 → 立即放弃
本应采取的做法:
- 尝试 GitHub MCP → 遇到身份验证错误
- 尝试
ghCLI → 检查是否已通过身份验证 - 尝试直接调用 GitHub API → 使用个人令牌
- 如果都失败,再创建手动操作说明
结果:gh CLI 已通过身份验证,而且运行正常。我们放弃得太早了。
将此方法用于错误调试
修复错误时:
// Pattern: Try 3 fix approaches
async function debugError(error) {
// Approach 1: Past solution
const pastFix = await searchMemories(error);
if (pastFix?.success_rate > 80%) {
return applyPastFix(pastFix);
}
// Approach 2: Pattern matching
const commonFix = matchErrorPattern(error);
if (commonFix) {
return applyCommonFix(commonFix);
}
// Approach 3: External search (Copilot/Web)
const externalSolution = await searchExternalSolutions(error);
if (externalSolution) {
return applyExternalSolution(externalSolution);
}
// Only NOW ask for more context
return askUserForMoreContext(error);
}
集成工具的持续使用
有可用的集成时,按以下顺序使用:
搜索错误:
- GitHub Copilot CLI → 在你的代码库和类似项目中搜索问题
- 本地记忆 → 你保存的过往解决方案
- 网络搜索 → 最新的 Stack Overflow 和文档
查找解决方案:
- 记忆中的过往解决方案(最快)
- Codegen-ai Agent(适用于复杂 Bug)→ 自动创建 PR
- Jules CLI 异步任务(适用于耗时的修复)
- 使用代码示例手动修复
指标
跟踪调试方法的成功情况:
{
"error_id": "uuid",
"approaches_tried": [
{"type": "memory_search", "result": "no_match"},
{"type": "copilot_search", "result": "success", "time": "5s"},
{"type": "applied_fix", "verified": true}
],
"total_time": "30s",
"lesson": "Copilot found solution on second try"
}
关键见解:大多数“失败”的方法,实际上只是“尝试得还不够”。
上下文集成
查询过往解决方案
分析新错误之前:
// Search context-manager
const pastSolutions = searchMemories({
type: 'PROCEDURE',
tags: [errorType, language, framework],
content: errorMessage,
fuzzyMatch: true
});
if (pastSolutions.length > 0) {
// Show user the past solution
// Ask if they want to apply it
// If yes, apply and test
// If no, analyze fresh
}
持续学习
跟踪哪些解决方案有效:
{
solution_id: "uuid",
error_pattern: "TypeError.*map.*undefined",
times_applied: 5,
success_rate: 100%,
last_used: "2025-10-15",
avg_fix_time: "2 minutes"
}
找到多个匹配项时,按成功率对解决方案排序。
项目特定模式
有些错误与特定项目有关:
// BOOSTBOX-specific
Error: "Boost ID not found"
→ Solution: Check boost exists before processing
// Tool Hub-specific
Error: "Tool not installed"
→ Solution: Run tool installer first
// Save these as PROJECT-specific procedures
与其他技能集成
测试构建器
提供修复后:
Automatically invoke: testing-builder
Create regression test for: {error_scenario}
Ensure test fails without fix, passes with fix
上下文管理器
查询类似错误:
search memories for:
- PROCEDURE type
- Error tag
- Similar message
- Same file/component
保存新解决方案:
Save as PROCEDURE:
- Error pattern
- Solution
- Code examples
- Tested timestamp
快速原型设计师
对于复杂修复:
If fix requires significant refactoring:
→ Invoke rapid-prototyper
→ Create isolated example showing fix
→ User validates before applying to codebase
其他资源
快速参考
常见错误模式
| 错误 | 快速修复 |
|---|---|
undefined.map | `data?.array |
X is not a function | 检查函数是否存在 |
ECONNREFUSED | 检查服务是否正在运行 |
CORS | 配置 CORS 标头 |
404 | 确认路由存在 |
500 | 检查服务器日志 |
Timeout | 增加超时值 |
Cannot find module | 安装依赖项 |
触发短语
- “调试这个”
- “修复这个错误”
- “为什么会失败”
- “出问题了”
- [粘贴错误消息]
- [粘贴堆栈跟踪]
文件位置
- 过往解决方案:
~/.claude-memories/procedures/(Linux/macOS)或%USERPROFILE%\.claude-memories\procedures\(Windows) - 错误模式:在记忆索引中标记为“error”
成功标准
✅ 常见错误即时修复(<30 秒) ✅ 自动回忆过往解决方案 ✅ 所有修复均包含代码示例 ✅ 自动创建回归测试 ✅ 保存解决方案以供将来参考 ✅ 调试效率随时间提升