Reflective self-improvement system with post-mortem templates. Use when code fails after declaring it complete, when backtracking on an approach, when user corrects an assumption, or when discovering a better pattern. Creates structured learning artifacts.
Purpose: Learn from failures to compound knowledge and prevent recurrence.
You MUST create a post-mortem entry when:
Code fails after you declared it complete
You backtrack on an approach
User corrects your assumption
You discover a significantly better pattern
## Post-Mortem: [Title] (YYYY-MM-DD)
### What Happened
- **Expected:** [What I thought would happen]
- **Actual:** [What actually happened]
- **Discovery:** [How the error was identified]
### Root Cause
- [ ] Outdated information (training data)
- [ ] Skipped verification step
- [ ] Misread documentation
- [ ] Incorrect mental model
- [ ] Other: ___
### What I Should Have Known Beforehand
[The key knowledge that would have prevented this]
### Prevention Checklist
- [ ] Specific check 1
- [ ] Specific check 2
- [ ] Verification step 3
### Heuristic
> "One-sentence rule that encodes the lesson"
From actual failures:
Maintain these living documents:
| File | Purpose |
|---|---|
LESSONS_LEARNED.md | Post-mortems of every significant failure |
USER_PATTERNS.md | Communication style, tool preferences, corrections |
ENCYCLOPEDIA.md | Master taxonomy of project concepts |
Also capture what works:
Error/Failure
↓
Post-Mortem Analysis
↓
Heuristic Extraction
↓
Knowledge Artifact Updated
↓
Future Agent Retrieves Context
↓
Error Prevented