auto-memory-rules

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Auto-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 TypeTrigger SignalsPriorityHandling Strategy
Explicit Correction"incorrect", "wrong", "it should be..."🔴 HighImmediate reflection + Record
Modification Request"change to...", "replace with...", "don't..."🔴 HighImmediate reflection + Record
Preference Expression"I prefer...", "it's better...", "suggest..."🟡 MediumRecord after reflection
Method Guidance"use...command", "go to...query"🟡 MediumRecord after reflection
Interaction OptimizationAdjustments to answer methods, formats, styles🟡 MediumRecord after reflection
Global Specificationunified, all, all of, all + verb, any, each, every time, all, uniformly🟡 MediumRecord after reflection
One-time Modification"handle specially here", "temporarily..."⚪ LowDo 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

创建记忆前必须进行三层反思:
  1. 表层:用户说了什么?
  2. 深层:为什么会这么说?我的回答哪里不够好?
  3. 原则:背后的通用规则是什么?能泛化到类似场景吗?
Three layers of reflection are required before creating memory:
  1. Surface Level: What did the user say?
  2. Deep Level: Why did they say that? What was insufficient in my response?
  3. 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
    memory/
    directory under the skill directory (e.g.:
    .agents/skills/auto-memory-rules/memory/
    ), initialize it if it doesn't exist
  • Search for relevant memories based on the user's request and load them into the context

2. 对话执行

2. Conversation Execution

  1. 反思 → 提取原则 → 创建记忆文件到技能目录下的
    memory/
    目录
  2. 在当前任务中立即应用
  3. 告知用户:"我已记录这条记忆,下次会自动应用"
  1. Reflect → Extract principles → Create memory files in the
    memory/
    directory under the skill directory
  2. Apply immediately in the current task
  3. Inform the user: "I have recorded this memory and will apply it automatically next time"

3. 规则更新(结算)

3. Rule Update (Settlement)

执行步骤:
bash
undefined
Execution 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
  • 更新平台规则:<自动探测到的平台>
undefined
bash 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.sh
    +
    generate-rules.sh
  • Antigravity:技能目录
    .agents/skills/auto-memory-rules/
    ,可用
    generate-integration-rules.sh
    +
    generate-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/
    ,规则输出到
    .claude/rules/
    ;可选安装 hook 自动更新记忆索引(不安装也可手动执行脚本)
如需在 Claude Code 启用自动索引更新,在使用本 skill 的项目根目录运行:
bash
bash <skill所在路径>/auto-memory-rules/scripts/setup-hooks.sh
安装后,每次向技能目录下的
memory/
目录写入
.md
文件,
generate-memory-artifacts.sh
会自动触发;其他平台可手动运行该脚本完成结算。
  • Kiro: Skill directory
    .kiro/skills/auto-memory-rules/
    , use
    generate-integration-rules.sh
    +
    generate-rules.sh
  • Antigravity: Skill directory
    .agents/skills/auto-memory-rules/
    , use
    generate-integration-rules.sh
    +
    generate-rules.sh
  • Cursor: Skill directory
    .cursor/skills/auto-memory-rules/
    (compatible with
    .agents/skills/
    ), rules output to
    .cursor/rules/
  • Windsurf: Skill directory
    .windsurf/skills/auto-memory-rules/
    , use
    generate-rules.sh windsurf
    to generate rule files
  • Claude Code: Skill directory
    .claude/skills/auto-memory-rules/
    , rules output to
    .claude/rules/
    ; optional hook installation for automatic memory index update (can also execute scripts manually if not installed)
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.sh
After installation, each time a
.md
file is written to the
memory/
directory under the skill directory,
generate-memory-artifacts.sh
will be triggered automatically; for other platforms, you can run this script manually to complete settlement.

标准 Category

Standard Category

Category适用场景
api
API 调用、接口定义、HTTP 请求、URL 规范
types
TypeScript 类型、接口、泛型
component
React 组件、JSX、Props 设计
hook
自定义 Hook、useXxx 封装
state
状态设计、数据流、状态恢复
backend
后端服务、业务分层、控制器/服务/仓储设计
database
数据库建模、SQL、索引、事务、迁移
infra
部署、CI/CD、容器、环境变量、监控告警
testing
单元测试、集成测试、E2E、测试策略
security
认证鉴权、权限模型、输入校验、安全基线
pattern
设计模式、架构模式、代码组织
convention
命名、格式、代码风格、注释
quality
可维护性、性能优化、最佳实践
workflow
开发流程、调试方法、问题排查
general
跨领域通用规则、不适合以上分类的偏好
多方面冲突时选最核心的那个。
CategoryApplicable Scenarios
api
API calls, interface definitions, HTTP requests, URL specifications
types
TypeScript types, interfaces, generics
component
React components, JSX, Props design
hook
Custom Hooks, useXxx encapsulation
state
State design, data flow, state recovery
backend
Backend services, business layering, controller/service/repository design
database
Database modeling, SQL, indexes, transactions, migrations
infra
Deployment, CI/CD, containers, environment variables, monitoring and alerts
testing
Unit testing, integration testing, E2E, testing strategies
security
Authentication and authorization, permission models, input validation, security baselines
pattern
Design patterns, architecture patterns, code organization
convention
Naming, formatting, code style, comments
quality
Maintainability, performance optimization, best practices
workflow
Development processes, debugging methods, troubleshooting
general
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}.md
markdown
---
category: [从标准列表中选择唯一一个]
priority: [high|medium|low]
tags: [关键词1, 关键词2]
description: [一句话描述]
---
File name:
YYYY-MM-DD-{category}-{brief-description}.md
markdown
---
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