关于 learn
learn 是一套工作流技能,用于将不易察觉的发现整理为可复用技能,适合需要跨会话保留解决方案的 Agent。它先评估发现是否值得记录,再检查重复并指导创建和审核。
主要功能
- 01评估发现是否适合复用
- 02搜索相关的现有技能
- 03在 .claude/skills/ 中创建技能
- 04检查具体性、验证情况与敏感信息
适用场景
- 01记录经过排查得出的调试修复
- 02整理未文档化的集成变通方案
- 03保存可重复的多步骤工作流
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ pedrohcgs/ claude-code-my-workflow --skill learn安装后在 Claude Code 中输入/learn确认已加载。
详细介绍
/learn — 技能提取工作流
将不易察觉的发现提取为可复用的技能,使其能在不同会话中持续发挥作用。
何时使用此技能
遇到以下情况时调用 /learn:
- 不易察觉的调试问题 — 调查花费了大量精力,且文档中没有相关说明
- 误导性错误 — 错误消息有误,后来找到了真正原因
- 变通方案 — 发现某项限制,并通过巧妙的方法解决
- 工具集成 — 未记录的 API 用法或配置
- 反复试错 — 多次尝试后才成功
- 可复用的工作流 — 以后还会重复执行的多步骤任务
- 面向用户的自动化 — 用户会要求的报告、检查或流程
工作流阶段
阶段 1:评估(自我评估)
创建技能前,回答以下问题:
- “我刚刚学到了什么之前并不明显的知识?”
- “记录下来对未来的我有帮助吗?”
- “仅凭文档无法轻易找到解决方案吗?”
- “这是我会重复执行的多步骤工作流吗?”
至少有一个问题的答案为是,才继续。
阶段 2:检查现有技能
搜索相关技能,避免重复:
# Check project skills
ls .claude/skills/ 2>/dev/null
# Search for keywords
grep -r -i "KEYWORD" .claude/skills/ 2>/dev/null
结果:
- 没有相关内容 → 创建新技能(继续阶段 3)
- 触发条件和修复方案相同 → 更新现有技能(提升版本号)
- 部分重叠 → 更新技能并加入新变体
阶段 3:创建技能
在 .claude/skills/[skill-name]/SKILL.md 创建技能文件:
---
name: descriptive-kebab-case-name
description: |
[What the skill does, then the situations it applies to — the key use first.
Include an exact error string only when that string is the trigger.]
- What the skill does
- Trigger conditions (symptoms; an exact error message when that is the trigger)
- When to use it (contexts, scenarios)
metadata:
author: [you]
version: "1.0"
argument-hint: "[expected arguments]" # Optional
---
# Skill Name
## Problem
[Clear problem description — what situation triggers this skill]
## Context / Trigger Conditions
[When to use — exact error messages, symptoms, scenarios]
[Be specific enough that you'd recognize it again]
## Solution
[Step-by-step solution]
[Include commands, code snippets, or workflows]
## Verification
[How to verify it worked]
[Expected output or state]
## Example
[Concrete example of the skill in action]
## References
[Documentation links, related files, or prior discussions]
阶段 4:质量检查
完成前,确认:
- 描述包含具体的触发条件(而非含糊的描述)
- 解决方案已验证有效(经过测试)
- 内容足够具体,可据此采取行动
- 内容足够通用,可重复使用
- 不包含敏感信息(凭据、个人数据)
- 技能名称清晰,并采用 kebab-case 格式
输出
创建技能后,报告:
✓ Skill created: .claude/skills/[name]/SKILL.md
Trigger: [when to use]
Problem: [what it solves]
示例:创建技能
用户发现某个 R 包会静默丢弃观测值:
---
name: fixest-missing-covariate-handling
description: |
Handle silent observation dropping in fixest when covariates have missing values.
Use when: estimates seem wrong, sample size unexpectedly small, or comparing
results between packages.
metadata:
author: [you]
version: "1.0"
---
# fixest Missing Covariate Handling
## Problem
The fixest package silently drops observations when covariates have NA values,
which can produce unexpected results when comparing to other packages.
## Context / Trigger Conditions
- Sample size in fixest is smaller than expected
- Results differ from Stata or other R packages
- Model has covariates with potential missing values
## Solution
1. Check for NA patterns before regression:
```r
summary(complete.cases(data[, covariates]))
- 显式处理 NA 值,或使用
na.action参数 - 在注释中记录预期样本量
验证
比较 nobs(model) 与 nrow(data) — 差值表示有观测值被丢弃。
参考资料
- fixest 关于缺失值的文档
- MEMORY.md 中的 [LEARN:r-code] 条目
评论
支持 Markdown