learn

A command that reviews the current coding conversation and turns reusable lessons into project notes, rules, or documentation.

In plain words
What is it for?
Use it to extract patterns, conventions, preferences, and pitfalls from a session, view learned items and their confidence, or export and import shared learning.
Why use it?
It helps prevent the same discoveries and mistakes from being repeated. It can also check the quality of a lesson before saving it.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/xiaobei930/cc-best/learn
Clone the repo
git clone --depth 1 https://github.com/xiaobei930/cc-best
Per session 13 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,167 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00013 $0.02167
Opus 5 $0.00006 $0.01084
Sonnet 5 $0.00003 $0.00433
Haiku 4.5 $0.00001 $0.00217

Measured 2d ago against content hash 37328a9bf58e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

learn scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/learn.md · 239 lines

How it starts

The opening of the file, as written. The whole thing — 239 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/learn - 会话学习

从当前会话中提取可复用的知识,更新项目配置和文档。核心原则:从经验中学习,持续改进。

用法

/cc-best:learn                    # 从当前会话提取知识
/cc-best:learn --eval             # 仅评估知识质量,不保存
/cc-best:learn --status           # 查看已学习内容和置信度
/cc-best:learn --export           # 导出学习内容(用于分享)
/cc-best:learn --import <file>    # 导入他人的学习内容

角色定位

  • 身份: 知识萃取专家
  • 目标: 将会话中的经验转化为项目记忆
  • 原则: 只记录有价值的、可复用的知识

核心理念

📋 详细学习理念(学习什么/不学习什么)、知识分类矩阵、学习模板、常见场景参见预加载的 skills/learning/extraction-guide.md

工作流程

0. 观察数据预加载
   ├─ 读取 memory-bank/observations.jsonl(如存在)
   ├─ 按 pattern 分组:error_fix / repeated_search / multi_file_edit / test_after_edit / fix_retry
   ├─ 按 pattern_id 聚合统计(v0.8.2+),显示每个 pattern_id 的 occurrence 和置信度
   ├─ 筛选 confidence ≥ 0.3 且当前会话的观察
   ├─ 高置信度模式(confidence ≥ 0.7)标记为演化候选(可固化为规则)
   └─ 作为会话分析的补充输入(自动捕获 + 人工回顾 = 完整画面)

1. 会话分析
   ├─ 回顾当前会话的关键交互
   ├─ 结合 Step 0 的自动观察数据
   ├─ 识别有价值的知识点
   └─ 分类:模式/约定/偏好/陷阱

2. 知识萃取
   ├─ 提炼核心要点
   ├─ 确定适用范围
   └─ 编写简洁描述

2.5 质量评估(自动执行,--eval 模式到此为止)
    ├─ 具体性:   是否包含具体代码/命令/路径(非抽象原则)
    ├─ 可操作性: 步骤是否清晰可立即执行
    ├─ 范围适配: 是否与项目技术栈匹配
    ├─ 独特性:   是否与已有知识重复(检查 CLAUDE.md + rules/)
    └─ 覆盖度:   是否覆盖主要用例和边界

    评分: 每维 1-5 分,总分 ≥15 分通过
    未通过: 提示改进建议,不自动保存

3. 知识存储
   ├─ 更新 CLAUDE.md(核心规则)
   ├─ 更新 rules/(具体规范)
   ├─ 更新 memory-bank/(项目记忆)
   └─ 创建 hookify 规则(如需自动化)

4. 验证确认
   ├─ 检查不重复
   ├─ 检查不冲突
   └─ 确认位置正确

触发时机

自动触发建议

  • 会话结束前
  • 解决复杂问题后
  • 用户纠正错误后
  • 发现新的项目规范后

手动触发

  • 用户输入 /cc-best:learn
  • 用户说"记住这个"
  • 用户说"以后都这样做"

学习检查清单

提取知识前

  • 这个知识是项目特有的吗?
  • 这个知识是可复用的吗?
  • 这个知识足够重要吗?

存储知识前

  • 选择了正确的存储位置?
  • 描述是否清晰简洁?
  • 是否与现有知识冲突?
  • 是否已经存在类似记录?

存储知识后

  • 格式是否正确?
  • 是否需要创建 hookify 规则自动化检查?

置信度系统

📋 详细置信度等级定义和提升规则参见预加载的 skills/learning/extraction-guide.md

质量评估 | Quality Gate

知识保存前的 5 维质量评分,防止低质量知识进入知识库。

评分维度

维度 权重 满分条件 0 分条件
具体性 1-5 包含具体代码/命令/路径 仅抽象原则
可操作性 1-5 步骤清晰,可立即执行 模糊的"应该"建议
范围适配 1-5 与项目技术栈精确匹配 通用知识,无项目关联
独特性 1-5 与 CLAUDE.md / rules/ 无重叠 已有完全相同的记录
覆盖度 1-5 覆盖主要用例和边界 仅覆盖 happy path

Read the full file on GitHub · 239 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 239 lines · 13 tokens per session scan A 37328a9bf58e

Subscribe to this mod's changes

learn is a command published in the GitHub repository xiaobei930/cc-best (50 stars, last pushed 2mo ago), licensed MIT. It adds 13 tokens to every session and 2,167 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.