克劳德错误收集器
MCP服务器 克劳德代码 从你的纠正中学习。当你告诉克劳德“那是错的”或“不,这样做”时,它通常会在你的 CLAUDE.md -所以同样的错误不会发生两次。
运作原理
- 你在编码会话中纠正了Claude
- 克劳德承认了这一更正,并称
record_error工具 - 服务器导出规则并将其写入相应的
CLAUDE.md - 克劳德在以后的会议上阅读了这条规则,并避免重蹈覆辙
服务器会自动检测您是否在项目目录中(写入项目 CLAUDE.md)或您的主目录(写入 ~/.claude/CLAUDE.md).
工具
record_error
记录更正并将其保存为带有元数据(日期、类别)的学习规则。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
error_description | string | 是 | 怎么了 |
correction | string | 是 | 什么是正确的 |
rule | string | yes | 派生准则,例如“始终使用X而不是Y” |
category | string | no | 规则类别(例如“n8n”、“bash”、“谷歌工作区”)。如果省略,则自动检测。 |
project_dir | string | no | 当前工作目录(用于查找项目CLAUDE.md) |
list_errors
列出从相关领域学到的所有规则 CLAUDE.md.支持过滤和分组。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
category | string | 否 | 按类别筛选规则 |
grouped | boolean | 否 | 按类别和标题对规则进行分组 |
project_dir | string | no | 当前工作目录 |
delete_rule
通过索引或子字符串匹配删除学习到的规则。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
index | number | no\* | 1要删除的规则的索引 |
match | string | no\* | 要匹配的子字符串(必须恰好匹配一个规则) |
project_dir | string | no | 当前工作目录 |
\*正是其中之一 index 或 match 必须提供。
update_rule
更新现有规则的文本、日期和可选类别。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
index | number | no\* | 1要更新的规则的索引 |
match | string | no\* | 要匹配的子字符串(必须恰好匹配一个规则) |
new_rule | string | yes | 新规则文本 |
category | string | no | 新类别(如果省略,则保持现有) |
project_dir | string | no | 当前工作目录 |
\*正是其中之一 index 或 match 必须提供。
review_rules
审查所有规则及其使用年限,以进行生命周期管理。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
older_than_days | number | no | 考虑“旧”的阈值(默认值:30) |
project_dir | string | no | 当前工作目录 |
输出格式
规则存储在 ## Learned Rules 你的部分 CLAUDE.md 元数据作为HTML注释:
## Learned Rules
- Legacy rule without metadata (still supported)
### N8n
- Bei n8n IMMER nodeId verwenden
### Bash
- NEVER embed large JSON inline in Bash commands 元数据字段:
@date:YYYY-MM-DD--规则创建/更新时@category:name--分组规则类别
没有元数据(传统格式)的规则仍然得到完全支持,并显示在该部分的顶部,没有类别标题。
安装
git clone https://github.com/henningziech/claude-error-collector-mcp.git
cd claude-error-collector-mcp
npm install && npm run build
claude mcp add error-collector -s user -- node "$PWD/dist/index.js"安装后重新启动Claude Code。无手册 CLAUDE.md 需要编辑——服务器通过MCP服务器元数据向Claude提供自己的指令。
CLAUDE.md决议
服务器找到正确的 CLAUDE.md 使用此逻辑:
- 如果
project_dir提供:在目录树中查找CLAUDE.md - 如果找到并且不在主目录中:使用它(项目级规则)
- 退路:
~/.claude/CLAUDE.md(全球规则)
重复检测
重复检测在两个层面上工作:
- 服务器端:在编写规则之前,服务器使用不区分大小写的子字符串匹配检查现有规则。如果新规则已经被现有规则覆盖(反之亦然),它将跳过写入。
- 语义(通过指令):服务器指示Claude检查现有的学习规则,以确定语义等价性 *之前* 召唤
record_error--即使措辞不同。克劳德将:
- 悄悄跳过 如果规则显然已经存在 - 记录下来 如果规则明显是新的 - 询问用户 如果存在类似的规则,但不完全清楚它是否是重复的,则提供添加、合并或跳过的选项
许可证
麻省理工学院
