error-debugger

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Error Debugger

错误调试助手

Purpose

用途

Context-aware debugging that learns from past solutions. When an error occurs:
  1. Searches memory for similar past errors
  2. Analyzes error message and stack trace
  3. Provides immediate fix with code examples
  4. Creates regression test via testing-builder
  5. 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.
具备上下文感知能力的调试工具,可从过往解决方案中学习。发生错误时:
  1. 在记忆库中搜索类似的过往错误
  2. 分析错误信息和堆栈跟踪
  3. 提供附带代码示例的即时修复方案
  4. 通过testing-builder创建回归测试
  5. 将解决方案保存到记忆库中以备未来使用
针对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:
  1. Apply the fix
  2. Test manually
  3. 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响应前始终验证其结构。
后续步骤:
  1. 应用修复方案
  2. 手动测试
  3. 我将创建一个回归测试
undefined

5. Save Solution

5. 保存解决方案

After fix confirmed working:
bash
undefined
确认修复生效后:
bash
undefined

Save 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**:
```markdown
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 || []

**记忆库结构**:
```markdown

PROCEDURE: 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
undefined
error, typescript, array-operations, undefined-handling
undefined

6. 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 data

Tool 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
undefined

First 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**
```bash
search memories for error pattern

如果未找到过往解决方案 → 继续下一种方法

**2. GitHub Copilot CLI 搜索**
```bash

Second 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**
```bash
copilot "Search GitHub for solutions to: $ERROR_MESSAGE"

如果Copilot未找到好的结果 → 继续下一种方法

**3. 结合当前上下文的网络搜索**
```bash

Third 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:
  1. Try GitHub MCP → Auth error
  2. Try
    gh
    CLI → Check if authenticated
  3. Try direct GitHub API → Use personal token
  4. Then create manual instructions if all fail
Outcome: The
gh
CLI WAS authenticated and worked perfectly. We gave up too early.
事件经过: 尝试GitHub MCP → 遇到认证错误 → 立即放弃
正确的处理流程:
  1. 尝试GitHub MCP → 认证错误
  2. 尝试
    gh
    CLI → 检查是否已认证
  3. 尝试直接调用GitHub API → 使用个人令牌
  4. 如果所有方法都失败,再创建手动操作说明
结果:
gh
CLI实际上已认证且运行正常。我们放弃得太早了。

Applying 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:
  1. GitHub Copilot CLI → Search issues in your repos and similar projects
  2. Local memory → Past solutions you've saved
  3. Web search → Latest Stack Overflow/docs
For Solutions:
  1. Past solution from memory (fastest)
  2. Codegen-ai agent (if complex bug) → Automated PR
  3. Jules CLI async task (if time-consuming fix)
  4. Manual fix with code examples
当有可用集成工具时,按以下顺序使用:
错误搜索顺序:
  1. GitHub Copilot CLI → 在你的仓库和类似项目中搜索问题
  2. 本地记忆库 → 你已保存的过往解决方案
  3. 网络搜索 → 最新的Stack Overflow解决方案
解决方案获取顺序:
  1. 记忆库中的过往解决方案(最快)
  2. Codegen-ai agent(如果是复杂bug)→ 自动生成PR
  3. Jules CLI 异步任务(如果修复耗时较长)
  4. 附带代码示例的手动修复方案

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 procedures

Integration 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 fix

Context Manager

上下文管理器

Query for similar errors:
search memories for:
- PROCEDURE type
- Error tag
- Similar message
- Same file/component
Save 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 timestamp

Rapid 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 codebase

Additional 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

常见错误模式

ErrorQuick Fix
undefined.map
`data?.array
X is not a function
Check function exists
ECONNREFUSED
Check service running
CORS
Configure CORS headers
404
Verify route exists
500
Check server logs
Timeout
Increase timeout value
Cannot find module
Install dependency
Error快速修复
undefined.map
`data?.array
X is not a function
检查函数是否存在
ECONNREFUSED
检查服务是否运行
CORS
配置CORS头
404
验证路由是否存在
500
检查服务器日志
Timeout
增加超时值
Cannot find module
安装依赖

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:
    ~/.claude-memories/procedures/
    (Linux/macOS) or
    %USERPROFILE%\.claude-memories\procedures\
    (Windows)
  • Error patterns: Tagged with "error" in memory index
  • 过往解决方案:
    ~/.claude-memories/procedures/
    (Linux/macOS)或
    %USERPROFILE%\.claude-memories\procedures\
    (Windows)
  • 错误模式: 在记忆库索引中标记为“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秒) ✅ 自动召回过往解决方案 ✅ 所有修复方案均包含代码示例 ✅ 自动创建回归测试 ✅ 解决方案保存以供未来参考 ✅ 调试速度随时间推移不断加快