lessons について
Lessonsは、経験を記録して再利用するためのスキルで、デバッグ、パターン、ツールに関する知見を蓄積したい開発者向けです。構造化した記録例に加え、検索や振り返り、繰り返す知見の自動化を扱います。
主な機能
- 01背景、問題、解決策を記録
- 02バグ・パターン・ツールの知見を分類
- 03トピック検索と定期的な振り返り
- 04繰り返す知見をフック、スニペット、チェックリストに変換
- 05AIによる知見の抽出と関連付け
活用シーン
- 01デバッグの根本原因と予防策を記録
- 02作業開始前に関連する知見を検索
- 03反復する問題を特定し自動化を計画
- 04コーディングセッションから再利用できる要点を抽出
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ johnlindquist/ claude --skill lessonsインストール後、Claude Code で/lessonsを入力して読み込まれたか確認します。
詳細
学んだこと
気づきを記録し、過去の経験から学びます。
パターンを記録する
すぐに学びを記録する
セッション中に価値のあることを学んだら:
# 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;
}
学び: TypeScript のジェネリクスでは、型を絞り込むために明示的な制約が必要です。
タグ: #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
学びを自動化に活用する
学びが何度も現れたら、自動化しましょう:
Git フックを作成する
# 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
AI を活用した学習
セッションから学びを抽出する
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"
ベストプラクティス
- すぐに記録する - 後回しにしないでください。忘れてしまいます
- 具体的にする - コード例を含めます
- かかったコストを記録する - 費やした時間を記録すると、覚えておく動機になります
- 定期的に振り返る - 振り返らないと、学びは薄れていきます
- 繰り返しを自動化する - 学びをツールに変えます
- 一貫したタグを付ける - 検索しやすくなります
- 状況と結び付ける - これはいつ役立ちますか?
コメント
Markdown 対応