learn-add

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

learn-add

learn-add

Route feedback to the appropriate LEARN.md file.
将反馈路由至对应的LEARN.md文件。

Context Files

上下文文件

  • $JAAN_LEARN_DIR/*.learn.md
    - Skill lessons
  • $JAAN_CONTEXT_DIR/*.md
    - Context files and lessons
  • ${CLAUDE_PLUGIN_ROOT}/docs/extending/language-protocol.md
    - Language resolution protocol
  • $JAAN_LEARN_DIR/*.learn.md
    - 技能经验总结文件
  • $JAAN_CONTEXT_DIR/*.md
    - 上下文文件与经验总结
  • ${CLAUDE_PLUGIN_ROOT}/docs/extending/language-protocol.md
    - 语言解析协议

Input

输入

Arguments: $ARGUMENTS
Expected format:
"target" "lesson"
  • Target: skill name,
    $JAAN_TEMPLATES_DIR/name
    , or
    $JAAN_CONTEXT_DIR/name
  • Lesson: the feedback to add
Examples:
  • /jaan-to:learn-add "pm-prd-write" "Always ask about rollback strategy"
  • /jaan-to:learn-add "$JAAN_CONTEXT_DIR/tech" "All new tables need soft delete"
If no input provided, ask for target and lesson.

参数: $ARGUMENTS
预期格式:
"target" "lesson"
  • Target: 技能名称、
    $JAAN_TEMPLATES_DIR/name
    $JAAN_CONTEXT_DIR/name
  • Lesson: 要添加的反馈内容
示例:
  • /jaan-to:learn-add "pm-prd-write" "始终询问回滚策略"
  • /jaan-to:learn-add "$JAAN_CONTEXT_DIR/tech" "所有新表需要软删除"
若未提供输入,请询问目标和经验内容。

Pre-Execution Protocol

执行前协议

Language Settings

语言设置

Read and apply language protocol:
${CLAUDE_PLUGIN_ROOT}/docs/extending/language-protocol.md
Override field for this skill:
language_learn-add

读取并应用语言协议:
${CLAUDE_PLUGIN_ROOT}/docs/extending/language-protocol.md
本技能的覆盖字段:
language_learn-add

PHASE 1: Analysis (Read-Only)

阶段1: 分析(只读)

Step 1: Parse Input

步骤1: 解析输入

Extract target and lesson from arguments.
If format is unclear:
  1. "Which skill/context should this lesson apply to?"
  2. "What is the lesson to add?"
从参数中提取目标和经验内容。
若格式不清晰:
  1. "这条经验应该应用于哪个技能/上下文?"
  2. "要添加的经验内容是什么?"

Step 2: Determine Target File

步骤2: 确定目标文件

Route based on target:
Target PatternLEARN.md Location
Skill name (e.g.,
pm-prd-write
)
$JAAN_LEARN_DIR/jaan-to-{skill}.learn.md
System skill (e.g.,
skill-create
)
$JAAN_LEARN_DIR/jaan-to-{skill}.learn.md
$JAAN_TEMPLATES_DIR/{name}
$JAAN_TEMPLATES_DIR/LEARN.md
$JAAN_CONTEXT_DIR/{name}
$JAAN_CONTEXT_DIR/LEARN.md
$JAAN_CONTEXT_DIR/tech
$JAAN_CONTEXT_DIR/tech.md
(constraints section)
$JAAN_CONTEXT_DIR/team
$JAAN_CONTEXT_DIR/team.md
(norms section)
根据目标进行路由:
目标模式LEARN.md 路径
技能名称(例如:
pm-prd-write
$JAAN_LEARN_DIR/jaan-to-{skill}.learn.md
系统技能(例如:
skill-create
$JAAN_LEARN_DIR/jaan-to-{skill}.learn.md
$JAAN_TEMPLATES_DIR/{name}
$JAAN_TEMPLATES_DIR/LEARN.md
$JAAN_CONTEXT_DIR/{name}
$JAAN_CONTEXT_DIR/LEARN.md
$JAAN_CONTEXT_DIR/tech
$JAAN_CONTEXT_DIR/tech.md
(约束章节)
$JAAN_CONTEXT_DIR/team
$JAAN_CONTEXT_DIR/team.md
(规范章节)

Step 3: Auto-Categorize Lesson

步骤3: 自动分类经验

Detect category from lesson keywords:
CategoryTrigger Keywords
Better Questionsask, question, clarify, confirm, "should ask"
Edge Casesedge, special, case, handle, check, "need to handle"
Workflowworkflow, process, step, order, "before/after"
Common Mistakesavoid, mistake, wrong, don't, never, "should not"
If unclear, ask: "Which category? [questions/edge-cases/workflow/mistakes]"
根据经验内容中的关键词检测分类:
分类触发关键词
更佳提问询问、问题、澄清、确认、"应当询问"
边缘场景边缘、特殊、场景、处理、检查、"需要处理"
工作流工作流、流程、步骤、顺序、"之前/之后"
常见错误避免、错误、不正确、不要、绝不、"不应当"
若分类不明确,询问: "请选择分类?[questions/edge-cases/workflow/mistakes]"

Step 4: Read Current LEARN.md

步骤4: 读取当前LEARN.md文件

Read the target LEARN.md file if it exists at
$JAAN_LEARN_DIR/jaan-to-{name}.learn.md
. If not found, check legacy path
$JAAN_LEARN_DIR/jaan-to:{name}.learn.md
— if legacy found, rename it to the dash-prefixed path first. If neither exists, prepare to create with template.

如果目标LEARN.md文件存在于
$JAAN_LEARN_DIR/jaan-to-{name}.learn.md
,则读取该文件。 若未找到,检查旧路径
$JAAN_LEARN_DIR/jaan-to:{name}.learn.md
—— 若找到旧文件,先将其重命名为短横线连接的路径。 若两者都不存在,则准备使用模板创建。

HARD STOP - Human Review Check

强制暂停 - 人工审核检查

Show preview:
markdown
Ready to Add Lesson

**File:** {file path}
**Category:** {category}
**Lesson:** {lesson text}

Preview:
显示预览:
markdown
准备添加经验总结

**文件:** {文件路径}
**分类:** {分类名称}
**经验内容:** {经验文本}

预览:

{Category}

{分类名称}

  • {existing lessons...}
  • {new lesson} <-- NEW
Confirm? [y/n/edit]

**Do NOT proceed without explicit approval.**

---
  • {现有经验内容...}
  • {新经验内容} <-- 新增
确认执行?[是/否/编辑]

**未获得明确批准前,请勿继续执行。**

---

PHASE 2: Write

阶段2: 写入

Step 5: Update LEARN.md

步骤5: 更新LEARN.md文件

If file exists:
  1. Read current content
  2. Find the category section (e.g.,
    ## Better Questions
    )
  3. Append new lesson as bullet point
  4. Update "Last updated" date
  5. Write file
If file doesn't exist:
  1. Check if plugin has seed data:
    ${CLAUDE_PLUGIN_ROOT}/skills/{skill-name}/LEARN.md
  2. If seed exists and has meaningful content (contains
    - 
    bullet points), use it as starting point
  3. If no seed exists, create from the template below
  4. Add the new lesson to the appropriate category
  5. Write file to:
    $JAAN_LEARN_DIR/jaan-to-{skill-name}.learn.md
若文件已存在:
  1. 读取当前内容
  2. 找到对应分类章节(例如:
    ## 更佳提问
  3. 将新经验作为项目符号追加
  4. 更新“最后更新”日期
  5. 写入文件
若文件不存在:
  1. 检查插件是否有种子数据:
    ${CLAUDE_PLUGIN_ROOT}/skills/{skill-name}/LEARN.md
  2. 若种子文件存在且包含有效内容(包含
    - 
    项目符号),则以此为基础
  3. 若没有种子文件,使用下方模板创建
  4. 将新经验添加至对应分类
  5. 将文件写入至:
    $JAAN_LEARN_DIR/jaan-to-{skill-name}.learn.md

LEARN.md Template

LEARN.md模板

markdown
undefined
markdown
undefined

Lessons: {skill-name}

经验总结: {skill-name}

Last updated: {date}
最后更新: {日期}

Better Questions

更佳提问

  • {lesson if category matches}
  • {匹配该分类的经验内容}

Edge Cases

边缘场景

  • {lesson if category matches}
  • {匹配该分类的经验内容}

Workflow

工作流

  • {lesson if category matches}
  • {匹配该分类的经验内容}

Common Mistakes

常见错误

  • {lesson if category matches}
undefined
  • {匹配该分类的经验内容}
undefined

Step 6: Confirm Write

步骤6: 确认写入

markdown
Lesson Added

**File:** {path}
**Category:** {category}
**Lesson:** {lesson}
markdown
经验总结已添加

**文件:** {路径}
**分类:** {分类名称}
**经验内容:** {经验文本}

Step 7: Offer to Commit

步骤7: 询问是否提交

Ask user:
Commit this lesson? [y/n]
If confirmed:
  1. Stage:
    git add {file_path}
  2. Commit:
    git commit -m "learn({skill}): {short lesson summary}"
  3. Show: "Lesson committed:
    {commit hash}
    "
If declined:
  • Skip commit, lesson is saved locally
  • Show: "Lesson saved (not committed)"

询问用户:
是否提交这条经验总结?[是/否]
若确认:
  1. 暂存:
    git add {file_path}
  2. 提交:
    git commit -m "learn({skill}): {经验内容简短总结}"
  3. 显示: "经验总结已提交:
    {提交哈希值}
    "
若拒绝:
  • 跳过提交,经验总结已保存至本地
  • 显示: "经验总结已保存(未提交)"

Error Handling

错误处理

No Target

未指定目标

"No target specified. Which skill or context should this lesson apply to?"
"未指定目标。这条经验应该应用于哪个技能或上下文?"

Target Not Found

目标未找到

"Skill '{target}' not found. Available skills: {list}"
"未找到技能'{target}'。可用技能: {列表}"

Empty Lesson

经验内容为空

"No lesson provided. What feedback should be remembered?"
"未提供经验内容。需要记录什么反馈?"

LEARN.md Create Fail

LEARN.md创建失败

"Could not create LEARN.md. Check file permissions."

"无法创建LEARN.md文件。请检查文件权限。"

Trust Rules

信任规则

  1. NEVER modify without user confirmation
  2. ALWAYS show preview before writing
  3. PRESERVE existing lessons
  4. ASK when category is unclear
  1. 绝不在未获得用户确认的情况下修改内容
  2. 始终在写入前显示预览
  3. 保留现有经验内容
  4. 询问当分类不明确时

Skill Alignment

技能一致性

  • Two-phase workflow with HARD STOP for human approval
  • Single source of truth (no duplication)
  • Plugin-internal automation
  • Maintains human control over changes
  • 包含强制人工审核暂停的两阶段工作流
  • 单一事实来源(无重复)
  • 插件内部自动化
  • 保持人类对变更的控制权

Definition of Done

完成标准

  • Target skill/context identified and validated
  • Lesson categorized (questions/edge-cases/workflow/mistakes)
  • Preview shown and user approved
  • LEARN.md file updated with new lesson
  • Commit offered to user
  • 已识别并验证目标技能/上下文
  • 经验内容已分类(questions/edge-cases/workflow/mistakes)
  • 已显示预览并获得用户批准
  • LEARN.md文件已添加新经验内容
  • 已向用户询问是否提交