Overview
Record the pitfalls encountered and their solutions, conduct a postmortem review, and avoid repeating mistakes. Consolidate lessons into documents and memory.
When to Use
- After solving a complex problem
- After hitting a pitfall
- After fixing a production incident
- When the user says "postmortem", "复盘", "总结问题"
Execution Steps
1. Gather Information
Guide the user to review:
- What was the problem?
- When was it discovered?
- Which solutions were attempted?
- How was it ultimately resolved?
- What was the root cause?
2. Reconstruct the Timeline
Organize the event timeline:
- `14:30` - 发现问题
- `14:35` - 尝试方案 A
- `14:50` - 发现方案 A 无效
- `15:10` - 找到根因
- `15:30` - 解决问题
3. Create the Postmortem Document
Create docs/postmortem/YYYY-MM-DD-简短描述.md:
# Postmortem: [标题]
**日期**: YYYY-MM-DD
**发现者**: [用户名]
**严重程度**: [低/中/高/严重]
## 问题描述
[发生了什么?]
## 时间线
- `[时间]` - [事件]
- `[时间]` - [事件]
## 根因分析
### 表面原因
[看起来是因为...]
### 真正原因
[实际上是因为...]
## 解决方案
[如何解决的?]
## 预防措施
[如何避免再次发生?]
## 教训总结
- [教训 1]
- [教训 2]
## 是否需要写入全局记忆?
- [ ] 是 - 写入 ~/.agents/memory/
- [ ] 否 - 仅项目级
4. Determine Whether to Write to Global Memory
If the problem is universal, recommend writing it to global memory:
- Similar problems may be encountered across projects
- Involves common tools or frameworks
- Is a common trap
Global memory location:~/.agents/memory/lessons-learned.md
5. Confirm the Postmortem Is Complete
Report to the user:
- Postmortem document has been created
- Whether it has been written to global memory
- Recommended follow-up actions
Notes
- Focus on learning and improvement, not blame
- Records should be objective and specific
- Root cause analysis should be in-depth, not superficial
- Preventive measures should be actionable
Success Criteria
- Created the postmortem document
- Recorded the complete timeline
- Analyzed the surface cause and the true cause
- Proposed solutions and preventive measures
- Determined whether to write to global memory