mcpField
L
lessons

lessons

github.com/johnlindquistAgent 工作流2650 次安装45 周前更新
代码仓库

关于 lessons

Lessons 是一种记录经验并通过定期回顾加以复用的技能,适合希望积累调试、模式和工具知识的开发者。它提供结构化记录范例,并涵盖搜索、复盘及将重复经验转为自动化。

主要功能

  1. 01按背景、问题和解决方案记录经验
  2. 02分类整理缺陷、模式与工具经验
  3. 03按主题搜索并定期回顾
  4. 04将重复经验转为钩子、片段或清单
  5. 05用 AI 提取并关联经验

适用场景

  1. 01记录一次调试中的根因与预防方法
  2. 02开始任务前查找相关经验
  3. 03盘点重复问题并规划自动化
  4. 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 Hook
# 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"

最佳实践

  1. 立即记录 - 不要等待,你会忘记
  2. 具体明确 - 包含代码示例
  3. 记录代价 - 花费的时间会促使你记住
  4. 定期回顾 - 不回顾,经验会淡忘
  5. 自动化重复项 - 把经验转化为工具
  6. 标签一致 - 便于搜索
  7. 关联上下文 - 这条经验何时适用?

评论

支持 Markdown