learn-rule
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLearn 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
工作流程
- Identify the lesson — what mistake was made? What should happen instead?
- Format the rule with full context.
- Propose the addition and wait for user approval.
- After approval, persist to LEARNED section or project memory.
- 明确经验总结——犯了什么错误?正确的做法是什么?
- 为规则添加完整上下文并格式化。
- 提交规则添加申请,等待用户确认。
- 获得确认后,将规则持久化到“已学习”板块或项目记忆库中。
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 fixedCategories
分类
| Category | Examples |
|---|---|
| Navigation | File paths, finding code, wrong file edited |
| Editing | Code changes, patterns, wrong approach |
| Testing | Test approaches, coverage gaps, flaky tests |
| Git | Commits, branches, merge issues |
| Quality | Lint, types, style violations |
| Context | When to clarify, missing requirements |
| Architecture | Design decisions, wrong abstractions |
| Performance | Optimization, 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 rule with category
[LEARN] - Confirmation after persisting
- 带有分类的拟议规则
[LEARN] - 持久化后的确认信息