npx skills add https://github.com/realalexandreai/personal-skills-marketplace --skill 'Error Resolver'一种基于第一性原理的方法,用于诊断和解决所有语言和框架中的错误。
五步错误解决流程:
1. 分类 -> 2. 解析 -> 3. 匹配 -> 4. 分析 -> 5. 解决
| | | | |
什么类型? 提取关键 已知模式? 根本原因 修复 +
信息 分析 预防
当你遇到错误时:
| 类别 | 指示符 | 常见原因 |
|---|---|---|
| 语法 | 解析错误,意外的标记 | 拼写错误,缺少括号,无效语法 |
| 类型 | TypeError,类型不匹配 | 错误的数据类型,访问 null/undefined |
| 引用 | ReferenceError,NameError | 未定义的变量,作用域问题 |
| 运行时 | RuntimeError,Exception | 逻辑错误,无效操作 |
| 网络 | ECONNREFUSED,超时,4xx/5xx | 连接问题,错误的 URL,服务器宕机 |
| 权限 | EACCES,PermissionError | 文件/目录访问权限,需要 sudo |
| 依赖项 | ModuleNotFound,找不到模块 | 缺少包,版本不匹配 |
| 配置 | 配置错误,缺少环境变量 | 错误的设置,缺少环境变量 |
通过检查以下内容识别错误类别:
ENOENT,TypeError)提取关键信息:
- 错误代码:[如果有特定的代码]
- 文件路径:[错误起源的位置]
- 行号:[如果可用,精确的行号]
- 函数/方法:[错误的上下文]
- 变量/值:[涉及的内容]
- 堆栈跟踪深度:[调用栈的深度]
对照已知的错误模式进行检查:
patterns/ 目录中特定语言的模式应用 5 Whys 技术:
错误:无法读取 undefined 的属性 'name'
为什么 1? -> user 对象是 undefined
为什么 2? -> API 调用返回了 null
为什么 3? -> 数据库中不存在该用户 ID
为什么 4? -> ID 来自过时的缓存
为什么 5? -> 未实现缓存失效逻辑
根本原因:缺少缓存失效逻辑
生成可操作的解决方案:
解决错误时,提供:
## 错误诊断
**分类**:[类别] / [严重性] / [范围]
**错误特征**:
- 代码:[错误代码]
- 类型:[错误类型]
- 位置:[文件:行号]
## 根本原因
[解释为什么发生此错误]
**促成因素**:
1. [因素 1]
2. [因素 2]
## 解决方案
### 立即修复
[快速解决步骤]
### 代码更改
[要添加/修改的具体代码]
### 验证
[如何验证修复有效]
## 预防
[未来如何预防此错误]
## 重放标签
[此解决方案的唯一标识符 - 供将来参考]
重放系统记录成功的解决方案以供将来参考。
解决错误后,记录它:
# 在项目中创建解决方案记录
mkdir -p .claude/error-solutions
# 解决方案文件格式:[错误类型]-[哈希].yaml
# .claude/error-solutions/[错误特征].yaml
id: "nodejs-module-not-found-express"
created: "2024-01-15T10:30:00Z"
updated: "2024-01-20T14:22:00Z"
error:
type: "dependency"
category: "ModuleNotFound"
language: "nodejs"
pattern: "Cannot find module 'express'"
context: "npm 项目,缺少依赖项"
diagnosis:
root_cause: "包未安装或 node_modules 损坏"
factors:
- "git clone 后未运行 npm install"
- "node_modules 目录损坏"
- "package.json 中未包含该包"
solution:
immediate:
- "运行:npm install express"
proper:
- "检查 package.json 是否列出了 express"
- "运行:rm -rf node_modules && npm install"
code_change: null
verification:
- "再次运行应用程序"
- "检查 express 是否在 node_modules 中"
prevention:
- "将 npm install 添加到项目设置文档中"
- "在 CI/CD 流水线中使用 npm ci"
metadata:
occurrences: 5
last_resolved: "2024-01-20T14:22:00Z"
success_rate: 1.0
tags: ["nodejs", "npm", "dependency"]
遇到错误时:
.claude/error-solutions/ 中搜索匹配的模式signature = hash(
error_type +
error_code +
normalized_message + # 移除特定值
language +
framework
)
示例转换:
Cannot find module 'express' -> Cannot find module '{module}'TypeError: Cannot read property 'name' of undefined -> TypeError: Cannot read property '{prop}' of undefined调试期间有用的命令:
# 详细错误输出
NODE_DEBUG=* node app.js
# 内存调试
node --inspect app.js
# 检查已安装的包
npm ls [package-name]
# 验证 package.json
npm ls --depth=0
# 调试模式
python -m pdb script.py
# 检查已安装的包
pip show [package-name]
pip list
# 检查文件权限
ls -la [file]
# 检查端口使用情况
lsof -i :[port]
netstat -an | grep [port]
# 检查环境变量
env | grep [VAR_NAME]
printenv [VAR_NAME]
# 检查磁盘空间
df -h
# 检查内存
free -m # Linux
vm_stat # macOS
当错误位置不明确时:
创建能复现错误的最小代码:
大声解释问题(或向 Claude 解释):
查找引入错误的提交:
git bisect start
git bisect bad # 当前提交是坏的
git bisect good [最后已知的好提交]
# Git 将为你检出提交以供测试
git bisect good/bad # 将每个标记为好或坏
git bisect reset # 完成后
patterns/ - 特定语言的错误模式
nodejs.md - Node.js 常见错误python.md - Python 常见错误react.md - React/Next.js 错误database.md - 数据库错误docker.md - Docker/容器错误git.md - Git 错误network.md - 网络/API 错误analysis/ - 分析方法论
stack-trace.md - 堆栈跟踪解析指南每周安装次数
–
仓库
首次出现时间
–
安全审计
A first-principle approach to diagnosing and resolving errors across all languages and frameworks.
The 5-step Error Resolution Process:
1. CLASSIFY -> 2. PARSE -> 3. MATCH -> 4. ANALYZE -> 5. RESOLVE
| | | | |
What type? Extract key Known Root cause Fix +
information pattern? analysis Prevent
When you encounter an error:
| Category | Indicators | Common Causes |
|---|---|---|
| Syntax | Parse error, Unexpected token | Typos, missing brackets, invalid syntax |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 数据库 | 连接被拒绝,查询错误 | 数据库宕机,错误的凭据,错误的查询 |
| 内存 | 内存不足,堆内存耗尽 | 内存泄漏,大数据处理 |
root-cause.mdreplay/ - 重放系统
solution-template.yaml - 记录解决方案的模板| Type | TypeError, type mismatch | Wrong data type, null/undefined access |
| Reference | ReferenceError, NameError | Undefined variable, scope issues |
| Runtime | RuntimeError, Exception | Logic errors, invalid operations |
| Network | ECONNREFUSED, timeout, 4xx/5xx | Connection issues, wrong URL, server down |
| Permission | EACCES, PermissionError | File/directory access, sudo needed |
| Dependency | ModuleNotFound, Cannot find module | Missing package, version mismatch |
| Configuration | Config error, env missing | Wrong settings, missing env vars |
| Database | Connection refused, query error | DB down, wrong credentials, bad query |
| Memory | OOM, heap out of memory | Memory leak, large data processing |
Identify the error category by examining:
ENOENT, TypeError)Extract key information:
- Error code: [specific code if any]
- File path: [where the error originated]
- Line number: [exact line if available]
- Function/method: [context of the error]
- Variable/value: [what was involved]
- Stack trace depth: [how deep is the call stack]
Check against known error patterns:
patterns/ directory for language-specific patternsApply the 5 Whys technique:
Error: Cannot read property 'name' of undefined
Why 1? -> user object is undefined
Why 2? -> API call returned null
Why 3? -> User ID doesn't exist in database
Why 4? -> ID was from stale cache
Why 5? -> Cache invalidation not implemented
Root Cause: Missing cache invalidation logic
Generate actionable solution:
When resolving an error, provide:
## Error Diagnosis
**Classification**: [Category] / [Severity] / [Scope]
**Error Signature**:
- Code: [error code]
- Type: [error type]
- Location: [file:line]
## Root Cause
[Explanation of why this error occurred]
**Contributing Factors**:
1. [Factor 1]
2. [Factor 2]
## Solution
### Immediate Fix
[Quick steps to resolve]
### Code Change
[Specific code to add/modify]
### Verification
[How to verify the fix works]
## Prevention
[How to prevent this error in the future]
## Replay Tag
[Unique identifier for this solution - for future reference]
The replay system records successful solutions for future reference.
After resolving an error, record it:
# Create solution record in project
mkdir -p .claude/error-solutions
# Solution file format: [error-type]-[hash].yaml
# .claude/error-solutions/[error-signature].yaml
id: "nodejs-module-not-found-express"
created: "2024-01-15T10:30:00Z"
updated: "2024-01-20T14:22:00Z"
error:
type: "dependency"
category: "ModuleNotFound"
language: "nodejs"
pattern: "Cannot find module 'express'"
context: "npm project, missing dependency"
diagnosis:
root_cause: "Package not installed or node_modules corrupted"
factors:
- "Missing npm install after git clone"
- "Corrupted node_modules directory"
- "Package not in package.json"
solution:
immediate:
- "Run: npm install express"
proper:
- "Check package.json has express listed"
- "Run: rm -rf node_modules && npm install"
code_change: null
verification:
- "Run the application again"
- "Check express is in node_modules"
prevention:
- "Add npm install to project setup docs"
- "Use npm ci in CI/CD pipelines"
metadata:
occurrences: 5
last_resolved: "2024-01-20T14:22:00Z"
success_rate: 1.0
tags: ["nodejs", "npm", "dependency"]
When encountering an error:
.claude/error-solutions/ for matching patternssignature = hash(
error_type +
error_code +
normalized_message + # remove specific values
language +
framework
)
Example transformations:
Cannot find module 'express' -> Cannot find module '{module}'TypeError: Cannot read property 'name' of undefined -> TypeError: Cannot read property '{prop}' of undefinedUseful commands during debugging:
# Verbose error output
NODE_DEBUG=* node app.js
# Memory debugging
node --inspect app.js
# Check installed packages
npm ls [package-name]
# Verify package.json
npm ls --depth=0
# Debug mode
python -m pdb script.py
# Check installed packages
pip show [package-name]
pip list
# Check file permissions
ls -la [file]
# Check port usage
lsof -i :[port]
netstat -an | grep [port]
# Check environment variables
env | grep [VAR_NAME]
printenv [VAR_NAME]
# Check disk space
df -h
# Check memory
free -m # Linux
vm_stat # macOS
When the error location is unclear:
Create the smallest code that reproduces the error:
Explain the problem out loud (or to Claude):
Find which commit introduced the bug:
git bisect start
git bisect bad # current commit is bad
git bisect good [last-known-good-commit]
# Git will checkout commits for you to test
git bisect good/bad # mark each as good or bad
git bisect reset # when done
patterns/ - Language-specific error patterns
nodejs.md - Node.js common errorspython.md - Python common errorsreact.md - React/Next.js errorsdatabase.md - Database errorsdocker.md - Docker/container errorsgit.md - Git errorsnetwork.md - Network/API errorsanalysis/ - Analysis methodologies
stack-trace.md - Stack trace parsing guideroot-cause.md - Root cause analysis techniquesreplay/ - Replay system
solution-template.yaml - Template for recording solutionsWeekly Installs
–
Repository
First Seen
–
Security Audits
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
109,600 周安装