Failure Memory
Record failures. Learn from them. Never repeat them.
Core Concept
Every failure has three parts:
- 1. What happened (error message, symptom)
- Why it happened (root cause)
- How to fix/avoid it (resolution)
This skill stores them in a searchable markdown file and provides a recall mechanism before starting similar tasks.
File Structure
CODEBLOCK0
Recording a Failure
When an error occurs during work, append to memory/failures.md:
CODEBLOCK1
When to Record
Record AUTOMATICALLY when:
- - A shell command exits non-zero and you identify why
- An API call fails and you find the cause
- A config/setup step fails and you resolve it
- You catch yourself repeating a previously-solved mistake
- A sub-agent reports an error with resolution
Do NOT record:
- - Transient network timeouts (unless pattern emerges)
- Intentional test failures
- User-cancelled operations
Pre-Task Recall
Before starting any significant task, search failures for relevant history:
CODEBLOCK2
Or use memory_search if vector search is available:
CODEBLOCK3
If matches found, mention them briefly:
⚠️ Known pitfall: [title] — [prevention tip]
Failure Report
When asked for a failure report or review, generate a summary:
- 1. Read INLINECODE2
- Group by category
- Identify repeat patterns (same root cause appearing multiple times)
- Suggest systemic fixes for patterns
Report Format
CODEBLOCK4
Initialization
Run scripts/init.sh to set up the failures file:
CODEBLOCK5
Default memory_dir: INLINECODE4
Best Practices
- 1. Be specific — "EACCES on /var/run/docker.sock" beats "permission error"
- Include the exact error — Future grep depends on it
- Tag generously — More tags = better recall
- Review monthly — Patterns reveal systemic issues
- Link to fixes — Reference commits, PRs, or config changes when possible
失败记忆
记录失败。从中学习。永不重蹈覆辙。
核心概念
每个失败包含三个部分:
- 1. 发生了什么(错误信息、症状)
- 为什么会发生(根本原因)
- 如何修复/避免(解决方案)
该技能将失败记录存储在可搜索的Markdown文件中,并在开始类似任务前提供回忆机制。
文件结构
memory/
└── failures.md # 所有失败记录(仅追加日志)
记录失败
当工作中出现错误时,追加到 memory/failures.md:
markdown
[YYYY-MM-DD HH:mm] <简短标题>
- - 类别: <构建|部署|配置|API|权限|数据|逻辑|网络|依赖>
- 上下文: <你当时尝试做的事情>
- 错误: <确切的错误信息或症状>
- 根本原因: <为什么会发生>
- 解决方案: <修复方法>
- 预防措施: <下次如何避免>
- 标签: <用于搜索的逗号分隔关键词>
何时记录
在以下情况自动记录:
- - Shell命令退出码非零且你已查明原因
- API调用失败且你找到原因
- 配置/设置步骤失败且你已解决
- 你发现自己重复犯之前已解决的错误
- 子代理报告错误并附带解决方案
不要记录:
- - 临时性网络超时(除非出现规律性模式)
- 有意的测试失败
- 用户取消的操作
任务前回忆
在开始任何重要任务前,搜索失败记录中的相关历史:
bash
grep -i <关键词> memory/failures.md
如果支持向量搜索,可使用 memory_search:
memory_search query=<任务描述> 失败 错误
如果找到匹配项,简要提及:
⚠️ 已知陷阱:[标题] — [预防提示]
失败报告
当要求提供失败报告或回顾时,生成摘要:
- 1. 读取 memory/failures.md
- 按类别分组
- 识别重复模式(相同根本原因多次出现)
- 针对模式提出系统性修复建议
报告格式
markdown
失败报告 — YYYY-MM-DD
统计
- - 总计:记录N次失败
- 最多类别:<类别>(出现N次)
- 重复问题:N个模式出现2次以上
重复模式
<模式名称>
- - 出现次数:N次
- 根本原因:<共同原因>
- 系统性修复:<建议>
近期失败(最近7天)
初始化
运行 scripts/init.sh 来设置失败记录文件:
bash
bash scripts/init.sh [memory_dir]
默认 memory_dir:./memory
最佳实践
- 1. 具体明确 — EACCES on /var/run/docker.sock 优于 权限错误
- 包含确切错误信息 — 未来的grep搜索依赖于此
- 慷慨添加标签 — 更多标签 = 更好的回忆效果
- 每月回顾 — 模式揭示系统性问题
- 链接到修复方案 — 尽可能引用提交、PR或配置变更