learn-rule

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Learn Rule

学习规则

Capture a lesson from the current session into permanent memory.
将当前会话中的经验总结存入永久记忆。

Trigger

触发条件

Use when the user says "remember this", "add to rules", "don't do that again", or after a mistake is identified.
当用户说出“记住这个”“添加到规则中”“别再犯了”,或在发现错误后使用。

Workflow

工作流程

  1. Identify the lesson — what mistake was made? What should happen instead?
  2. Format the rule with full context.
  3. Propose the addition and wait for user approval.
  4. After approval, persist to LEARNED section or project memory.
  1. 明确经验总结——犯了什么错误?正确的做法是什么?
  2. 为规则添加完整上下文并格式化。
  3. 提交规则添加申请,等待用户确认。
  4. 获得确认后,将规则持久化到“已学习”板块或项目记忆库中。

Format

格式

[LEARN] Category: One-line rule
Mistake: What went wrong
Correction: How it was fixed
[LEARN] Category: One-line rule
Mistake: What went wrong
Correction: How it was fixed

Categories

分类

CategoryExamples
NavigationFile paths, finding code, wrong file edited
EditingCode changes, patterns, wrong approach
TestingTest approaches, coverage gaps, flaky tests
GitCommits, branches, merge issues
QualityLint, types, style violations
ContextWhen to clarify, missing requirements
ArchitectureDesign decisions, wrong abstractions
PerformanceOptimization, O(n^2) loops, memory
分类示例
导航文件路径、查找代码、编辑了错误的文件
编辑代码修改、模式使用、错误的实现方式
测试测试方法、覆盖率缺口、不稳定测试
Git提交、分支、合并问题
质量代码检查(Lint)、类型、风格违规
上下文何时需要澄清、缺失的需求
架构设计决策、错误的抽象
性能优化、O(n²)循环、内存问题

Example

示例

Recent mistake: Edited wrong utils.ts file

[LEARN] Navigation: Confirm full path when multiple files share a name.

Add to LEARNED section? (y/n)
近期错误:编辑了错误的utils.ts文件

[LEARN] 导航:当多个文件重名时,确认完整路径。

是否添加到“已学习”板块?(y/n)

Guardrails

约束规则

  • Always wait for user approval before persisting.
  • Keep rules to one line — specific and actionable.
  • Bad: "Write good code". Good: "Always use snake_case for database columns".
  • Include the mistake context so the rule makes sense later.
  • 在持久化规则前必须等待用户确认。
  • 规则保持为一行——具体且可执行。
  • 反面示例:“写出好代码”。正面示例:“数据库列名始终使用snake_case”。
  • 包含错误上下文,确保规则在后续仍有意义。

Output

输出

  • The proposed
    [LEARN]
    rule with category
  • Confirmation after persisting
  • 带有分类的拟议
    [LEARN]
    规则
  • 持久化后的确认信息