// Capture and review lessons learned from coding sessions. Use to record insights, read past lessons, and improve over time.
| name | lessons |
| description | Capture and review lessons learned from coding sessions. Use to record insights, read past lessons, and improve over time. |
Capture insights and learn from past experiences.
When you learn something valuable during a session:
# Write to lessons file
cat >> ~/.claude/lessons.md << 'EOF'
## [Date] - [Topic]
**Context:** What were you doing?
**Lesson:** What did you learn?
**Application:** When to apply this?
EOF
## 2024-01-15 - TypeScript Generic Constraints
**Context:**
Building a type-safe form library, struggled with generic types.
**Problem:**
Generic function wasn't narrowing types correctly.
**Solution:**
Use `extends` constraints to narrow:
```typescript
function getValue<T extends { value: unknown }>(obj: T): T['value'] {
return obj.value;
}
Lesson: TypeScript generics need explicit constraints for type narrowing.
Tags: #typescript #generics #types
## Lesson Categories
### Bug Lessons
```markdown
## Bug: [Brief description]
**Symptom:** What happened
**Root Cause:** Why it happened
**Fix:** How to fix
**Prevention:** How to avoid in future
**Time Cost:** How long to debug (motivation to remember!)
## Pattern: [Name]
**When to use:** Situations where this applies
**How to implement:** Basic structure
**Gotchas:** Common mistakes
**Example:** Working code
## Tool: [Name]
**What it does:** Brief description
**Key commands:** Most useful commands
**Gotchas:** Things that trip people up
**Alternatives:** Other options
# Review recent lessons
tail -100 ~/.claude/lessons.md
# Search for topic
grep -A 10 "typescript" ~/.claude/lessons.md
gemini -m pro -o text -e "" "Review these lessons from the past week:
$(tail -500 ~/.claude/lessons.md)
1. What patterns emerge?
2. What mistakes keep recurring?
3. What should be turned into automation?
4. What needs deeper study?"
# Get relevant lessons
TOPIC="authentication"
grep -B 2 -A 10 -i "$TOPIC" ~/.claude/lessons.md
When a lesson appears multiple times, automate it:
# Lesson: Always run tests before commit
# โ Create pre-commit hook
cat > .git/hooks/pre-commit << 'EOF'
#!/bin/bash
npm test || exit 1
EOF
chmod +x .git/hooks/pre-commit
# Lesson: This pattern is useful
# โ Save as snippet
cat > ~/.claude/snippets/async-error-handling.ts << 'EOF'
async function safeAsync<T>(promise: Promise<T>): Promise<[T, null] | [null, Error]> {
try {
const result = await promise;
return [result, null];
} catch (error) {
return [null, error as Error];
}
}
EOF
# Lesson: Keep forgetting these steps
# โ Create checklist
cat > ~/.claude/checklists/pr-review.md << 'EOF'
# PR Review Checklist
- [ ] Tests pass
- [ ] No console.logs
- [ ] Types are explicit
- [ ] Error handling present
- [ ] Documentation updated
EOF
gemini -m pro -o text -e "" "Extract lessons learned from this coding session:
[Paste conversation or summary]
For each lesson:
1. What was learned
2. When it applies
3. How to remember it"
gemini -m pro -o text -e "" "Find connections between these lessons:
$(cat ~/.claude/lessons.md)
1. What themes emerge?
2. What knowledge gaps exist?
3. What should be studied next?"
gemini -m pro -o text -e "" "Create a quiz from these lessons:
$(tail -1000 ~/.claude/lessons.md)
Generate 5 questions that test understanding of key concepts."
# Single file
~/.claude/lessons.md
# By date
~/.claude/lessons/2024-01.md
# By topic
~/.claude/lessons/typescript.md
~/.claude/lessons/git.md
# Save to basic-memory
basic-memory tool write-note \
--title "Lesson: TypeScript Generics" \
--folder "lessons" \
--content "$(cat lesson.md)" \
--tags "lesson,typescript"