error-debugger
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseError Debugger
错误调试助手
Purpose
用途
Context-aware debugging that learns from past solutions. When an error occurs:
- Searches memory for similar past errors
- Analyzes error message and stack trace
- Provides immediate fix with code examples
- Creates regression test via testing-builder
- Saves solution to memory for future
For ADHD users: Eliminates debugging frustration - instant, actionable fixes.
For SDAM users: Recalls past solutions you've already found.
For all users: Gets smarter over time as it learns from your codebase.
具备上下文感知能力的调试工具,可从过往解决方案中学习。发生错误时:
- 在记忆库中搜索类似的过往错误
- 分析错误信息和堆栈跟踪
- 提供附带代码示例的即时修复方案
- 通过testing-builder创建回归测试
- 将解决方案保存到记忆库中以备未来使用
针对ADHD用户:消除调试挫败感——提供即时、可执行的修复方案。
针对SDAM用户:帮你回忆已经找到过的过往解决方案。
针对所有用户:随着它从你的代码库中不断学习,会变得越来越智能。
Activation Triggers
激活触发条件
- User says: "debug this", "fix this error", "why is this failing"
- Error messages containing: TypeError, ReferenceError, SyntaxError, ECONNREFUSED, CORS, 404, 500, etc.
- Stack traces pasted into conversation
- "Something's broken" or similar expressions
- 用户说出:"debug this", "fix this error", "why is this failing"
- 包含TypeError、ReferenceError、SyntaxError、ECONNREFUSED、CORS、404、500等的错误信息
- 粘贴到对话中的堆栈跟踪
- "Something's broken"或类似表述
Core Workflow
核心工作流程
1. Parse Error
1. 解析错误
Extract key information:
javascript
{
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"
}提取关键信息:
javascript
{
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. Search Past Solutions
2. 搜索过往解决方案
Query context-manager:
search memories for:
- error_type match
- similar message (fuzzy match)
- same file/component if available
- related tags (if previously tagged)If match found:
🔍 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...If no match:
🆕 New error - analyzing...
(Will save solution after fix)查询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. Analyze Error
3. 分析错误
See reference.md for comprehensive error pattern library.
Quick common patterns:
- TypeError: Cannot read property 'X' of undefined → Optional chaining + defaults
- ECONNREFUSED → Check service running, verify ports
- CORS errors → Configure CORS headers
- 404 Not Found → Verify route definition
- 500 Internal Server Error → Check server logs
查看reference.md获取完整的错误模式库。
常见快速模式:
- TypeError: Cannot read property 'X' of undefined → 可选链+默认值
- ECONNREFUSED → 检查服务是否运行,验证端口
- CORS errors → 配置CORS头
- 404 Not Found → 验证路由定义
- 500 Internal Server Error → 检查服务器日志
4. Provide Fix
4. 提供修复方案
Format:
🔧 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>);javascript
// ✅ Fixed code
const users = data?.users || [];
return users.map(user => <div>{user.name}</div>);Explanation: Added optional chaining and default empty array to handle case where data or data.users is undefined.
Prevention: Always validate API response structure before using.
Next steps:
- Apply the fix
- Test manually
- I'll create a regression test
undefined格式:
🔧 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>);javascript
// ✅ Fixed code
const users = data?.users || [];
return users.map(user => <div>{user.name}</div>);解释: 添加了可选链和默认空数组,以处理data或data.users为undefined的情况。
预防措施: 使用API响应前始终验证其结构。
后续步骤:
- 应用修复方案
- 手动测试
- 我将创建一个回归测试
undefined5. Save Solution
5. 保存解决方案
After fix confirmed working:
bash
undefined确认修复生效后:
bash
undefinedSave to context-manager as PROCEDURE
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 || []
**Memory structure**:
```markdownremember: 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 || []
**记忆库结构**:
```markdownPROCEDURE: Fix TypeError in map operations
PROCEDURE: Fix TypeError in map operations
Error Type: TypeError
Message Pattern: Cannot read property 'map' of undefined
Context: Array operations on potentially undefined data
Error Type: TypeError
Message Pattern: Cannot read property 'map' of undefined
Context: Array operations on potentially undefined data
Solution
Solution
Use optional chaining and default values:
javascript
// Before
const items = data.items;
return items.map(...)
// After
const items = data?.items || [];
return items.map(...)Use optional chaining and default values:
javascript
// Before
const items = data.items;
return items.map(...)
// After
const items = data?.items || [];
return items.map(...)When to Apply
When to Apply
- API responses that might be undefined
- Props that might not be passed
- Array operations on uncertain data
- API responses that might be undefined
- Props that might not be passed
- Array operations on uncertain data
Tested
Tested
✅ Fixed in UserList component (2025-10-17)
✅ Regression test: tests/components/UserList.test.jsx
✅ Fixed in UserList component (2025-10-17)
✅ Regression test: tests/components/UserList.test.jsx
Tags
Tags
error, typescript, array-operations, undefined-handling
undefinederror, typescript, array-operations, undefined-handling
undefined6. Create Regression Test
6. 创建回归测试
Automatically invoke testing-builder:
create regression test for this fix:
- Test that component handles undefined data
- Test that component handles empty array
- Test that component works with valid data自动调用testing-builder:
create regression test for this fix:
- Test that component handles undefined data
- Test that component handles empty array
- Test that component works with valid dataTool Persistence Pattern (Meta-Learning)
工具持久化模式(元学习)
Critical principle from self-analysis: Never give up on first obstacle. Try 3 approaches before abandoning a solution path.
自我分析得出的关键原则: 遇到第一个障碍时绝不放弃。在放弃某个解决方案路径前尝试3种方法。
Debugging Tools Hierarchy
调试工具层级
When debugging an error, try these tools in sequence:
1. Search Past Solutions (context-manager)
bash
undefined调试错误时,按以下顺序尝试这些工具:
1. 搜索过往解决方案(context-manager)
bash
undefinedFirst approach: Check memory
First approach: Check memory
search memories for error pattern
If no past solution found → Continue to next approach
**2. GitHub Copilot CLI Search**
```bashsearch memories for error pattern
如果未找到过往解决方案 → 继续下一种方法
**2. GitHub Copilot CLI 搜索**
```bashSecond approach: Search public issues
Second approach: Search public issues
copilot "Search GitHub for solutions to: $ERROR_MESSAGE"
If Copilot doesn't find good results → Continue to next approach
**3. Web Search with Current Context**
```bashcopilot "Search GitHub for solutions to: $ERROR_MESSAGE"
如果Copilot未找到好的结果 → 继续下一种方法
**3. 结合当前上下文的网络搜索**
```bashThird approach: Real-time web search
Third approach: Real-time web search
[Use web search for latest Stack Overflow solutions]
If web search fails → Then ask user for more context[Use web search for latest Stack Overflow solutions]
如果网络搜索失败 → 再向用户请求更多上下文Real Example from Meta-Analysis
元分析中的真实案例
What happened: Tried GitHub MCP → Got auth error → Immediately gave up
What should have happened:
- Try GitHub MCP → Auth error
- Try CLI → Check if authenticated
gh - Try direct GitHub API → Use personal token
- Then create manual instructions if all fail
Outcome: The CLI WAS authenticated and worked perfectly. We gave up too early.
gh事件经过: 尝试GitHub MCP → 遇到认证错误 → 立即放弃
正确的处理流程:
- 尝试GitHub MCP → 认证错误
- 尝试CLI → 检查是否已认证
gh - 尝试直接调用GitHub API → 使用个人令牌
- 如果所有方法都失败,再创建手动操作说明
结果: CLI实际上已认证且运行正常。我们放弃得太早了。
ghApplying This to Error Debugging
将此原则应用于错误调试
When fixing an error:
javascript
// 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);
}修复错误时:
javascript
// 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);
}Integration Tool Persistence
集成工具持久化
When integrations are available, use them in this order:
For Error Search:
- GitHub Copilot CLI → Search issues in your repos and similar projects
- Local memory → Past solutions you've saved
- Web search → Latest Stack Overflow/docs
For Solutions:
- Past solution from memory (fastest)
- Codegen-ai agent (if complex bug) → Automated PR
- Jules CLI async task (if time-consuming fix)
- Manual fix with code examples
当有可用集成工具时,按以下顺序使用:
错误搜索顺序:
- GitHub Copilot CLI → 在你的仓库和类似项目中搜索问题
- 本地记忆库 → 你已保存的过往解决方案
- 网络搜索 → 最新的Stack Overflow解决方案
解决方案获取顺序:
- 记忆库中的过往解决方案(最快)
- Codegen-ai agent(如果是复杂bug)→ 自动生成PR
- Jules CLI 异步任务(如果修复耗时较长)
- 附带代码示例的手动修复方案
Metrics
指标
Track debugging approach success:
json
{
"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"
}Key insight: Most "failed" approaches are actually "didn't try enough" approaches.
跟踪调试方法的成功率:
json
{
"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"
}关键洞察: 大多数“失败”的方法实际上是“尝试次数不够”的方法。
Context Integration
上下文集成
Query Past Solutions
查询过往解决方案
Before analyzing new error:
javascript
// 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
}分析新错误前:
javascript
// 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
}Learning Over Time
随时间学习
Track which solutions work:
javascript
{
solution_id: "uuid",
error_pattern: "TypeError.*map.*undefined",
times_applied: 5,
success_rate: 100%,
last_used: "2025-10-15",
avg_fix_time: "2 minutes"
}Sort solutions by success rate when multiple matches found.
跟踪哪些解决方案有效:
javascript
{
solution_id: "uuid",
error_pattern: "TypeError.*map.*undefined",
times_applied: 5,
success_rate: 100%,
last_used: "2025-10-15",
avg_fix_time: "2 minutes"
}当找到多个匹配项时,按成功率排序解决方案。
Project-Specific Patterns
项目特定模式
Some errors are project-specific:
javascript
// 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有些错误是项目特有的:
javascript
// 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 proceduresIntegration with Other Skills
与其他技能的集成
Testing Builder
测试构建工具
After providing fix:
Automatically invoke: testing-builder
Create regression test for: {error_scenario}
Ensure test fails without fix, passes with fix提供修复方案后:
Automatically invoke: testing-builder
Create regression test for: {error_scenario}
Ensure test fails without fix, passes with fixContext Manager
上下文管理器
Query for similar errors:
search memories for:
- PROCEDURE type
- Error tag
- Similar message
- Same file/componentSave new solutions:
Save as PROCEDURE:
- Error pattern
- Solution
- Code examples
- Tested timestamp查询类似错误:
search memories for:
- PROCEDURE type
- Error tag
- Similar message
- Same file/component保存新解决方案:
Save as PROCEDURE:
- Error pattern
- Solution
- Code examples
- Tested timestampRapid Prototyper
快速原型工具
For complex fixes:
If fix requires significant refactoring:
→ Invoke rapid-prototyper
→ Create isolated example showing fix
→ User validates before applying to codebase对于复杂修复:
If fix requires significant refactoring:
→ Invoke rapid-prototyper
→ Create isolated example showing fix
→ User validates before applying to codebaseAdditional Resources
其他资源
- Error Pattern Library - Comprehensive patterns for JavaScript, Network, Database, React errors
- Debugging Examples - Step-by-step debugging workflow examples
- 错误模式库 - 包含JavaScript、网络、数据库、React错误的全面模式
- 调试示例 - 分步调试工作流示例
Quick Reference
快速参考
Common Error Patterns
常见错误模式
| Error | Quick Fix |
|---|---|
| `data?.array |
| Check function exists |
| Check service running |
| Configure CORS headers |
| Verify route exists |
| Check server logs |
| Increase timeout value |
| Install dependency |
| Error | 快速修复 |
|---|---|
| `data?.array |
| 检查函数是否存在 |
| 检查服务是否运行 |
| 配置CORS头 |
| 验证路由是否存在 |
| 检查服务器日志 |
| 增加超时值 |
| 安装依赖 |
Trigger Phrases
触发短语
- "debug this"
- "fix this error"
- "why is this failing"
- "something's broken"
- [paste error message]
- [paste stack trace]
- "debug this"
- "fix this error"
- "why is this failing"
- "something's broken"
- [粘贴错误信息]
- [粘贴堆栈跟踪]
File Locations
文件位置
- Past solutions: (Linux/macOS) or
~/.claude-memories/procedures/(Windows)%USERPROFILE%\.claude-memories\procedures\ - Error patterns: Tagged with "error" in memory index
- 过往解决方案: (Linux/macOS)或
~/.claude-memories/procedures/(Windows)%USERPROFILE%\.claude-memories\procedures\ - 错误模式: 在记忆库索引中标记为“error”
Success Criteria
成功标准
✅ Common errors fixed instantly (<30 seconds)
✅ Past solutions automatically recalled
✅ All fixes include code examples
✅ Regression tests created automatically
✅ Solutions saved for future reference
✅ Debugging gets faster over time
✅ 常见错误即时修复(<30秒)
✅ 自动召回过往解决方案
✅ 所有修复方案均包含代码示例
✅ 自动创建回归测试
✅ 解决方案保存以供未来参考
✅ 调试速度随时间推移不断加快