learn
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLearn from Conversation
从对话中学习
Analyze the conversation to extract lessons learned, then persist them to AI assistant configuration files.
分析对话内容以提取经验教训,然后将其保存到AI助手配置文件中。
Supported Assistants
支持的助手
| Assistant | Config File | Format |
|---|---|---|
| Claude Code | | Markdown |
| Gemini | | Markdown |
| AGENTS.md | | Markdown |
| Cursor | | Markdown/MDC |
| GitHub Copilot | | Markdown |
| Windsurf | | Markdown |
| Continue | | JSON |
See references/assistant-configs.md for format details.
| 助手 | 配置文件 | 格式 |
|---|---|---|
| Claude Code | | Markdown |
| Gemini | | Markdown |
| AGENTS.md | | Markdown |
| Cursor | | Markdown/MDC |
| GitHub Copilot | | Markdown |
| Windsurf | | Markdown |
| Continue | | JSON |
有关格式详情,请参阅 references/assistant-configs.md。
Process
处理流程
1. Detect and Assess Configurations
1. 检测并评估配置
Scan for config files and check their sizes:
bash
for f in CLAUDE.md GEMINI.md AGENTS.md .cursorrules .github/copilot-instructions.md \
.windsurf/rules/rules.md .continuerc.json; do
[ -f "$f" ] && wc -l "$f"
done
find .cursor/rules -name "*.mdc" -exec wc -l {} \; 2>/dev/nullBehavior based on detection:
| Scenario | Action |
|---|---|
| Single config found | Update it automatically |
| Multiple configs found | Prompt user to select which to update |
| No configs found | Display init commands from assistant-configs.md, then exit |
扫描配置文件并检查其大小:
bash
for f in CLAUDE.md GEMINI.md AGENTS.md .cursorrules .github/copilot-instructions.md \
.windsurf/rules/rules.md .continuerc.json; do
[ -f "$f" ] && wc -l "$f"
done
find .cursor/rules -name "*.mdc" -exec wc -l {} \; 2>/dev/null基于检测结果的行为:
| 场景 | 操作 |
|---|---|
| 找到单个配置 | 自动更新该配置 |
| 找到多个配置 | 提示用户选择要更新的配置 |
| 未找到配置 | 显示 assistant-configs.md 中的初始化命令,然后退出 |
Size Thresholds
大小阈值
| Lines | Status | Action |
|---|---|---|
| < 400 | Healthy | Add learnings directly |
| 400-500 | Warning | Add carefully, suggest cleanup |
| > 500 | Oversized | Refactor before adding new content |
| 行数 | 状态 | 操作 |
|---|---|---|
| < 400 | 健康 | 直接添加经验内容 |
| 400-500 | 警告 | 谨慎添加,建议清理 |
| > 500 | 过大 | 添加新内容前先重构 |
Discover Existing Skills
发现现有技能
List skills for routing decisions:
bash
find . -name "SKILL.md" -type f 2>/dev/null | grep -v node_modules | \
xargs grep -l "^name:" | while read -r f; do
grep -m1 "^name:" "$f" | sed 's/name: //'
done列出技能用于路由决策:
bash
find . -name "SKILL.md" -type f 2>/dev/null | grep -v node_modules | \
xargs grep -l "^name:" | while read -r f; do
grep -m1 "^name:" "$f" | sed 's/name: //'
done2. Analyze Conversation
2. 分析对话
Scan for:
- Corrections: Commands retried, assumptions proven wrong, missing prerequisites
- Discoveries: Undocumented patterns, integration quirks, environment requirements
- Improvements: Steps that should be automated or validated earlier
扫描以下内容:
- 修正内容:重试的命令、被证明错误的假设、缺失的前置条件
- 发现内容:未记录的模式、集成细节、环境要求
- 改进点:应提前自动化或验证的步骤
3. Categorize and Route Each Learning
3. 分类并路由每条经验
| Category | Primary Destination | Fallback When Oversized |
|---|---|---|
| Project facts | Config file | Extract to new skill |
| Prerequisites | Config file | Extract to |
| Environment | Config file | Extract to |
| Workflow pattern | Existing related skill | Create new skill |
| Automated workflow | New skill | New skill (always) |
| 类别 | 主要目标位置 | 过大时的备选方案 |
|---|---|---|
| 项目事实 | 配置文件 | 提取到新技能中 |
| 前置条件 | 配置文件 | 提取到 |
| 环境信息 | 配置文件 | 提取到 |
| 工作流模式 | 现有相关技能 | 创建新技能 |
| 自动化工作流 | 新技能 | 新技能(始终) |
Routing Decision Tree
路由决策树
For each learning, evaluate in order:
-
Is this a multi-step automated workflow (>5 steps)?
- YES → Create new skill (proceed to Step 5, Route C)
- NO → Continue
-
Does an existing skill cover this topic?
- YES → Update that skill
- NO → Continue
-
Is the target config file oversized (>500 lines)?
- YES → Create new skill OR offer refactoring (see Step 4)
- NO → Continue
-
Is this learning situation-specific (applies to narrow context)?
- YES → Create new skill with or context constraints
globs - NO → Add to config file
- YES → Create new skill with
对于每条经验,按以下顺序评估:
-
这是一个多步骤自动化工作流(超过5步)吗?
- 是 → 创建新技能(进入步骤5,路由C)
- 否 → 继续
-
现有技能是否涵盖该主题?
- 是 → 更新该技能
- 否 → 继续
-
目标配置文件是否过大(超过500行)?
- 是 → 创建新技能或提供重构选项(见步骤4)
- 否 → 继续
-
这条经验是否是特定场景的(仅适用于狭窄上下文)?
- 是 → 创建带有或上下文约束的新技能
globs - 否 → 添加到配置文件
- 是 → 创建带有
Size-Based Rules
基于大小的规则
| Learning Size | Preferred Destination |
|---|---|
| < 3 lines | Config file (even if near threshold) |
| 3-30 lines | Follow decision tree above |
| > 30 lines | Strongly prefer skill creation |
| 经验内容大小 | 首选目标位置 |
|---|---|
| < 3行 | 配置文件(即使接近阈值) |
| 3-30行 | 遵循上述决策树 |
| > 30行 | 强烈建议创建技能 |
Skill Relevance Matching
技能相关性匹配
Match learnings to existing skills using these criteria:
| Learning Topic | Matching Skill Indicators |
|---|---|
| Testing patterns | Skill name contains: test, spec, e2e, unit |
| Build/compile issues | Skill name contains: build, compile, bundle |
| Dependencies | Skill name contains: package, dependency, npm, yarn |
| API patterns | Skill name contains: api, http, fetch, request |
| Database | Skill name contains: db, database, migration, schema |
| Deployment | Skill name contains: deploy, release, ci, cd |
Also check skill field for keyword overlap with the learning topic.
description使用以下标准将经验与现有技能匹配:
| 经验主题 | 匹配技能的指标 |
|---|---|
| 测试模式 | 技能名称包含:test、spec、e2e、unit |
| 构建/编译问题 | 技能名称包含:build、compile、bundle |
| 依赖项 | 技能名称包含:package、dependency、npm、yarn |
| API模式 | 技能名称包含:api、http、fetch、request |
| 数据库 | 技能名称包含:db、database、migration、schema |
| 部署 | 技能名称包含:deploy、release、ci、cd |
同时检查技能的字段,看是否与经验主题存在关键词重叠。
description4. Present and Confirm
4. 展示并确认
For each learning, show:
**[Category]**: [Brief description]
- Source: [What happened in conversation]
- Proposed change: [Exact text or file to add]
- Destination: [Config file] ([current] → [projected] lines)对于每条经验,显示:
**[类别]**: [简要描述]
- 来源: [对话中发生的内容]
- 建议更改: [要添加的准确文本或文件]
- 目标位置: [配置文件] ([当前行数] → [预计行数])Handle Size Threshold
处理大小阈值
If adding the learning would push a config file over threshold:
Adding this learning would bring [filename] to [X] lines (threshold: [Y]).
Options:
1. Add learning anyway (not recommended)
2. [Refactor](references/refactoring.md) existing content to skills first, then add
3. Create a new skill for this learning instead
4. Skip this config fileAsk for confirmation before applying each change.
如果添加经验会导致配置文件超过阈值:
添加此经验会使[文件名]达到[X]行(阈值:[Y])。
选项:
1. 仍添加经验(不推荐)
2. 先将现有内容重构为技能,再添加
3. 为此经验创建新技能
4. 跳过此配置文件在应用每项更改前请求确认。
5. Apply Changes
5. 应用更改
Apply changes based on routing decision from Step 3:
根据步骤3的路由决策应用更改:
Route A: Add to Config File
路由A:添加到配置文件
Markdown configs (CLAUDE.md, GEMINI.md, AGENTS.md, Copilot, Windsurf):
- Find appropriate section, preserve existing structure
- Append to relevant section or create new section if needed
Cursor rules:
- Legacy : Treat like markdown, append content
.cursorrules - Modern : See references/format-cursor-mdc.md
.cursor/rules/*.mdc
Continue ():
.continuerc.json- Update field, preserving existing content
customInstructions - See references/format-continue.md
Markdown配置(CLAUDE.md、GEMINI.md、AGENTS.md、Copilot、Windsurf):
- 找到合适的章节,保留现有结构
- 追加到相关章节,或在需要时创建新章节
Cursor规则:
- 旧版: 视为Markdown处理,追加内容
.cursorrules - 新版: 参阅 references/format-cursor-mdc.md
.cursor/rules/*.mdc
Continue():
.continuerc.json- 更新字段,保留现有内容
customInstructions - 参阅 references/format-continue.md
Route B: Update Existing Skill
路由B:更新现有技能
When adding to an existing skill:
- Read the skill file:
skills/[name]/SKILL.md - Find appropriate section or create new one
- Append learning, maintaining the skill's existing structure
- If skill has references, consider adding to reference file instead
Skill update format:
markdown
undefined添加到现有技能时:
- 读取技能文件:
skills/[name]/SKILL.md - 找到合适的章节或创建新章节
- 追加经验内容,保持技能的现有结构
- 如果技能有参考文件,考虑添加到参考文件中
技能更新格式:
markdown
undefined[New Section or append to existing]
[新章节或追加到现有章节]
[Learning content formatted as guidance or workflow step]
undefined[经验内容格式化为指南或工作流步骤]
undefinedRoute C: Create New Skill
路由C:创建新技能
Create in with this template:
skills/[name]/SKILL.mdmarkdown
---
name: [learning-topic]
description: [What this handles and when to use it - triggers belong here, not in body]
---在中使用以下模板创建:
skills/[name]/SKILL.mdmarkdown
---
name: [learning-topic]
description: [What this handles and when to use it - triggers belong here, not in body]
---[Learning Topic]
[Learning Topic]
[Learning content structured as workflow]
[Learning content structured as workflow]
Process
Process
1. [First Step]
1. [First Step]
[Details]
undefined[Details]
undefined6. Verify Changes
6. 验证更改
After applying each change, confirm success by showing:
✓ Added to [file path]:
[Section name]
> [First 2-3 lines of added content...]If a write failed, report the error and offer to retry or skip.
应用每项更改后,通过以下方式确认成功:
✓ 添加到[文件路径]:
[章节名称]
> [添加内容的前2-3行...]如果写入失败,报告错误并提供重试或跳过选项。
7. Summarize
7. 总结
List:
- Config files modified (with full paths)
- Sections updated in each file
- Any skills created
列出:
- 修改的配置文件(含完整路径)
- 每个文件中更新的章节
- 创建的任何技能
Examples
示例
| Situation | Learning |
|---|---|
| "e2e tests failed because API wasn't running" | Add prerequisite to selected config(s) |
| "Parse SDK doesn't work with Vite out of the box" | Document workaround in selected config(s) |
| "Build failed because NODE_ENV wasn't set" | Add required env var to selected config(s) |
| "Every component needs tests, lint, build..." | Create |
| 场景 | 经验内容 |
|---|---|
| "e2e测试失败因为API未运行" | 向前选中的配置添加前置条件 |
| "Parse SDK无法直接与Vite配合使用" | 在选中的配置中记录解决方法 |
| "构建失败因为未设置NODE_ENV" | 向前选中的配置添加所需环境变量 |
| "每个组件都需要测试、Lint、构建..." | 创建 |
Edge Cases
边缘情况
| Scenario | Handling |
|---|---|
| No configs detected | Guide user to initialize one first, exit early |
| Multiple configs found | Prompt user to select which to update |
| Malformed config file | Warn and skip that file |
| Duplicate content exists | Check before adding, warn if similar learning exists |
| Config file already oversized | Offer refactoring before adding (Step 4) |
| Learning matches multiple skills | Present options, let user choose which skill to update |
| Skill file also oversized | Suggest creating sub-skills or reference files |
| Learning is very small (<3 lines) | Prefer config file even if near threshold |
| Learning is very large (>30 lines) | Strongly suggest skill creation |
| No existing skills found | Skip skill matching, proceed with config or new skill |
| 场景 | 处理方式 |
|---|---|
| 未检测到配置 | 引导用户先初始化配置,提前退出 |
| 找到多个配置 | 提示用户选择要更新的配置 |
| 配置文件格式错误 | 发出警告并跳过该文件 |
| 存在重复内容 | 添加前检查,若存在相似经验则发出警告 |
| 配置文件已过大 | 添加前提供重构选项(步骤4) |
| 经验匹配多个技能 | 提供选项,让用户选择要更新的技能 |
| 技能文件也过大 | 建议创建子技能或参考文件 |
| 经验内容非常短(<3行) | 即使接近阈值也优先选择配置文件 |
| 经验内容非常长(>30行) | 强烈建议创建技能 |
| 未找到现有技能 | 跳过技能匹配,继续使用配置文件或创建新技能 |
Guidelines
指南
See references/guidelines.md for learning quality principles.
有关经验质量原则,请参阅 references/guidelines.md。