auto-memory-rules
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAuto-Memory-Rules 核心执行准则
Auto-Memory-Rules Core Execution Guidelines
最高优先级
Highest Priority
用户的实时要求 > 历史记忆 — 冲突时无条件执行用户要求,对话结束时询问是否覆盖旧记忆。
User's real-time requirements > Historical memory — When there is a conflict, unconditionally execute the user's requirements, and ask whether to overwrite the old memory when the conversation ends.
触发与处理
Trigger and Handling
| 意图类型 | 触发信号 | 优先级 | 处理策略 |
|---|---|---|---|
| 明确纠错 | "不对"、"错了"、"应该是..." | 🔴 高 | 立即反思 + 记录 |
| 要求修改 | "改成..."、"换成..."、"不要..." | 🔴 高 | 立即反思 + 记录 |
| 偏好表达 | "我更喜欢..."、"最好..."、"建议..." | 🟡 中 | 反思后记录 |
| 方法指导 | "用...命令"、"去...查询" | 🟡 中 | 反思后记录 |
| 交互优化 | 对回答方式、格式、风格的调整 | 🟡 中 | 反思后记录 |
| 全局规范 | 统一、所有、所有的、都+动词、任何、每个、每次、全部、一律 | 🟡 中 | 反思后记录 |
| 一次性修改 | "这里特殊处理"、"临时..." | ⚪ 低 | 不记录 |
即使用户没有明确说"记住",当同一问题被纠正 2 次以上时,主动询问是否记录为规则:
💡 检测到可记录的记忆:[简短描述]
是否要记录到记忆系统?这样下次我会自动应用。[Y/n]| Intent Type | Trigger Signals | Priority | Handling Strategy |
|---|---|---|---|
| Explicit Correction | "incorrect", "wrong", "it should be..." | 🔴 High | Immediate reflection + Record |
| Modification Request | "change to...", "replace with...", "don't..." | 🔴 High | Immediate reflection + Record |
| Preference Expression | "I prefer...", "it's better...", "suggest..." | 🟡 Medium | Record after reflection |
| Method Guidance | "use...command", "go to...query" | 🟡 Medium | Record after reflection |
| Interaction Optimization | Adjustments to answer methods, formats, styles | 🟡 Medium | Record after reflection |
| Global Specification | unified, all, all of, all + verb, any, each, every time, all, uniformly | 🟡 Medium | Record after reflection |
| One-time Modification | "handle specially here", "temporarily..." | ⚪ Low | Do not record |
Even if the user doesn't explicitly say "remember", when the same issue is corrected more than 2 times, proactively ask whether to record it as a rule:
💡 Detected recordable memory: [Brief description]
Do you want to record it to the memory system? I will automatically apply it next time. [Y/n]自我反思流程
Self-Reflection Process
创建记忆前必须进行三层反思:
- 表层:用户说了什么?
- 深层:为什么会这么说?我的回答哪里不够好?
- 原则:背后的通用规则是什么?能泛化到类似场景吗?
Three layers of reflection are required before creating memory:
- Surface Level: What did the user say?
- Deep Level: Why did they say that? What was insufficient in my response?
- Principle Level: What is the underlying general rule? Can it be generalized to similar scenarios?
记忆质量标准
Memory Quality Standards
核心问题:这个规则下次能让用户少提修改要求吗?
应该记录:用户明确的偏好、重复出现的修改模式(2次+)、可跨项目复用的通用原则、代码风格/架构/交互偏好
不应记录:一次性特殊处理、项目特定业务逻辑、临时解决方案、纯概念解释
质量检查:
- 去具体化 — 移除文件路径、行号、具体变量名
- 高可执行性 — AI 读完后能立刻执行
- 跨任务通用 — 在其他类似场景依然有效
- 抗衰减 — 规则逻辑清晰,不会随时间推移而失效
- 记录了"为什么",不只是"做什么"
冲突处理:
- 规则演进 — 若用户明确推翻旧习惯,询问后覆盖旧规则
- 场景分支 — 若两个规则在不同场景下均有效,则合并为一条规则并分别描述各自的触发场景
Core Question: Will this rule reduce the user's need for modification requests next time?
Should record: User's explicit preferences, repeated modification patterns (2+ times), general principles reusable across projects, code style/architecture/interaction preferences
Should not record: One-time special handling, project-specific business logic, temporary solutions, pure concept explanations
Quality Check:
- De具体化 — Remove file paths, line numbers, specific variable names
- High Executability — AI can execute immediately after reading
- Cross-task Universality — Remains effective in other similar scenarios
- Anti-attenuation — Clear rule logic that won't become invalid over time
- Record "why", not just "what to do"
Conflict Handling:
- Rule Evolution — If the user explicitly overturns old habits, ask before overwriting the old rule
- Scenario Branching — If two rules are valid in different scenarios, merge them into one rule and describe their respective trigger scenarios separately
任务生命周期
Task Lifecycle
1. 对话开始
1. Conversation Start
- 检查技能目录下的 目录(例如:
memory/),不存在则初始化.agents/skills/auto-memory-rules/memory/ - 根据用户请求搜索相关记忆并加载到上下文
- Check the directory under the skill directory (e.g.:
memory/), initialize it if it doesn't exist.agents/skills/auto-memory-rules/memory/ - Search for relevant memories based on the user's request and load them into the context
2. 对话执行
2. Conversation Execution
- 反思 → 提取原则 → 创建记忆文件到技能目录下的 目录
memory/ - 在当前任务中立即应用
- 告知用户:"我已记录这条记忆,下次会自动应用"
- Reflect → Extract principles → Create memory files in the directory under the skill directory
memory/ - Apply immediately in the current task
- Inform the user: "I have recorded this memory and will apply it automatically next time"
3. 规则更新(结算)
3. Rule Update (Settlement)
执行步骤:
bash
undefinedExecution Steps:
bash
undefined步骤 1:更新索引和清单
Step 1: Update index and checklist
如果已安装 hook(见下方安装说明),写入记忆文件时会自动触发,无需手动执行
If hooks are installed (see installation instructions below), it will be triggered automatically when writing memory files, no manual execution needed
未安装 hook 时手动运行:
Run manually if hooks are not installed:
bash scripts/generate-memory-artifacts.sh
bash scripts/generate-memory-artifacts.sh
步骤 2:更新平台规则(自动探测并更新当前项目中的所有平台)
Step 2: Update platform rules (automatically detect and update all platforms in the current project)
bash scripts/generate-rules.sh
输出结算报告:✅ 记忆系统结算完成
- 新增记忆:N 条
- 更新索引:memory/index.md
- 更新清单:memory/CHECKLIST.md
- 更新平台规则:<自动探测到的平台>
undefinedbash scripts/generate-rules.sh
Output settlement report:✅ Memory system settlement completed
- New memories added: N
- Updated index: memory/index.md
- Updated checklist: memory/CHECKLIST.md
- Updated platform rules: <Automatically detected platforms>
undefined安装与兼容平台
Installation and Compatible Platforms
- Kiro:技能目录 ,可用
.kiro/skills/auto-memory-rules/+generate-integration-rules.shgenerate-rules.sh - Antigravity:技能目录 ,可用
.agents/skills/auto-memory-rules/+generate-integration-rules.shgenerate-rules.sh - Cursor:技能目录 (兼容
.cursor/skills/auto-memory-rules/),规则输出到.agents/skills/.cursor/rules/ - Windsurf:技能目录 ,可用
.windsurf/skills/auto-memory-rules/生成规则文件generate-rules.sh windsurf - Claude Code:技能目录 ,规则输出到
.claude/skills/auto-memory-rules/;可选安装 hook 自动更新记忆索引(不安装也可手动执行脚本).claude/rules/
如需在 Claude Code 启用自动索引更新,在使用本 skill 的项目根目录运行:
bash
bash <skill所在路径>/auto-memory-rules/scripts/setup-hooks.sh安装后,每次向技能目录下的 目录写入 文件, 会自动触发;其他平台可手动运行该脚本完成结算。
memory/.mdgenerate-memory-artifacts.sh- Kiro: Skill directory , use
.kiro/skills/auto-memory-rules/+generate-integration-rules.shgenerate-rules.sh - Antigravity: Skill directory , use
.agents/skills/auto-memory-rules/+generate-integration-rules.shgenerate-rules.sh - Cursor: Skill directory (compatible with
.cursor/skills/auto-memory-rules/), rules output to.agents/skills/.cursor/rules/ - Windsurf: Skill directory , use
.windsurf/skills/auto-memory-rules/to generate rule filesgenerate-rules.sh windsurf - Claude Code: Skill directory , rules output to
.claude/skills/auto-memory-rules/; optional hook installation for automatic memory index update (can also execute scripts manually if not installed).claude/rules/
To enable automatic index update in Claude Code, run the following in the root directory of the project using this skill:
bash
bash <path-to-skill>/auto-memory-rules/scripts/setup-hooks.shAfter installation, each time a file is written to the directory under the skill directory, will be triggered automatically; for other platforms, you can run this script manually to complete settlement.
.mdmemory/generate-memory-artifacts.sh标准 Category
Standard Category
| Category | 适用场景 |
|---|---|
| API 调用、接口定义、HTTP 请求、URL 规范 |
| TypeScript 类型、接口、泛型 |
| React 组件、JSX、Props 设计 |
| 自定义 Hook、useXxx 封装 |
| 状态设计、数据流、状态恢复 |
| 后端服务、业务分层、控制器/服务/仓储设计 |
| 数据库建模、SQL、索引、事务、迁移 |
| 部署、CI/CD、容器、环境变量、监控告警 |
| 单元测试、集成测试、E2E、测试策略 |
| 认证鉴权、权限模型、输入校验、安全基线 |
| 设计模式、架构模式、代码组织 |
| 命名、格式、代码风格、注释 |
| 可维护性、性能优化、最佳实践 |
| 开发流程、调试方法、问题排查 |
| 跨领域通用规则、不适合以上分类的偏好 |
多方面冲突时选最核心的那个。
| Category | Applicable Scenarios |
|---|---|
| API calls, interface definitions, HTTP requests, URL specifications |
| TypeScript types, interfaces, generics |
| React components, JSX, Props design |
| Custom Hooks, useXxx encapsulation |
| State design, data flow, state recovery |
| Backend services, business layering, controller/service/repository design |
| Database modeling, SQL, indexes, transactions, migrations |
| Deployment, CI/CD, containers, environment variables, monitoring and alerts |
| Unit testing, integration testing, E2E, testing strategies |
| Authentication and authorization, permission models, input validation, security baselines |
| Design patterns, architecture patterns, code organization |
| Naming, formatting, code style, comments |
| Maintainability, performance optimization, best practices |
| Development processes, debugging methods, troubleshooting |
| Cross-domain general rules, preferences not suitable for the above categories |
Choose the most core one when there are conflicts in multiple aspects.
记忆文件模板
Memory File Template
文件名:
YYYY-MM-DD-{category}-{brief-description}.mdmarkdown
---
category: [从标准列表中选择唯一一个]
priority: [high|medium|low]
tags: [关键词1, 关键词2]
description: [一句话描述]
---File name:
YYYY-MM-DD-{category}-{brief-description}.mdmarkdown
---
category: [Select only one from the standard list]
priority: [high|medium|low]
tags: [keyword1, keyword2]
description: [One-sentence description]
---[记忆主题]
[Memory Topic]
反思记录
Reflection Record
用户说了什么:[原始表达]
为什么会这么说:[分析]
提取的原则:[通用原则]
What the user said: [Original expression]
Why they said it: [Analysis]
Extracted principle: [General principle]
核心原则
Core Principle
[一句话概括]
[One-sentence summary]
具体要求
Specific Requirements
- [可执行的指令]
- [Executable instructions]
检查点
Checkpoints
- [陈述句:描述应该做什么]
注意:检查点使用陈述句,不是疑问句或错误描述
✅ 好:Hook 不允许暴露内部 setter
❌ 差:Hook 是否暴露了 setter?
❌ 差:Hook 暴露了 setter
- [Statement: Describe what should be done]
Note: Use declarative sentences for checkpoints, not questions or error descriptions
✅ Good: Hooks are not allowed to expose internal setters
❌ Bad: Does the hook expose the setter?
❌ Bad: The hook exposes the setter
示例
Examples
✅ [好的示例]
❌ [避免的示例]
✅ [Good example]
❌ [Example to avoid]
相关记忆
Related Memories
- 相关记忆文件名
undefined- Related memory file name
undefined