memory-bank

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Memory Bank Skill

Memory Bank 技能

Overview

概述

Memory Bank is a cross-session context continuity system for AI coding agents. It maintains a
memory-bank/
directory in the project root with structured markdown files that capture project knowledge, architecture decisions, progress, and active context. Every AI agent reads these files at session start, ensuring continuity across sessions and across different agents working on the same project.
This skill handles four intents: SETUP, UPDATE, STATUS, and READ. It detects user intent from natural language in any language.
Memory Bank是为AI编码Agent打造的跨会话上下文连续性系统。它会在项目根目录维护一个
memory-bank/
文件夹,其中包含结构化的markdown文件,用于记录项目知识、架构决策、开发进度和活跃上下文。所有AI Agent都会在会话启动时读取这些文件,确保同个项目下不同会话、不同Agent之间的工作连续性。
本技能支持四种意图处理:SETUP(搭建)UPDATE(更新)STATUS(状态)READ(读取),支持从任意语言的自然语言中识别用户意图。

Intent Detection

意图识别

Detect the user's intent from their message. The user may write in any language — use natural language understanding to map to the correct intent.
IntentTrigger Words (examples, not exhaustive)
SETUPsetup, install, initialize, init, create, bootstrap, kur, kurulum, başlat, einrichten, configurar, installer, configurer, 설치, セットアップ
UPDATEupdate, refresh, sync, güncelle, yenile, aktualisieren, actualizar, mettre à jour, 업데이트, 更新
STATUSstatus, check, durumu, durum, kontrol, estado, statut, 상태, ステータス
READread, show, review, display, present, oku, göster, lesen, anzeigen, lire, leer, mostrar, 읽기, 読む
Route to the matching flow below. If the intent is ambiguous, ask the user which action they want.

从用户消息中识别其意图,用户可能使用任意语言表述,通过自然语言理解映射到正确的意图。
意图触发词(示例,非全部)
SETUPsetup, install, initialize, init, create, bootstrap, kur, kurulum, başlat, einrichten, configurar, installer, configurer, 설치, セットアップ
UPDATEupdate, refresh, sync, güncelle, yenile, aktualisieren, actualizar, mettre à jour, 업데이트, 更新
STATUSstatus, check, durumu, durum, kontrol, estado, statut, 상태, ステータス
READread, show, review, display, present, oku, göster, lesen, anzeigen, lire, leer, mostrar, 읽기, 読む
请路由到下方匹配的流程。如果意图不明确,询问用户想要执行的操作。

SETUP Flow

SETUP 搭建流程

Follow these steps in order. Get user confirmation at each major step.
按顺序执行以下步骤,每个主要步骤都需要获取用户确认。

Step 1: Language & Profile Preference

步骤1:语言与配置偏好选择

1a. Language:
Ask the user which language the memory bank files should be written in:
  • TR (Turkish)
  • EN (English)
Store this choice — all file headings, labels, and descriptions will be in this language. Templates in
templates/
are in English; translate headings and labels to the chosen language when filling them.
1b. Profile:
Ask the user which profile they want:
  • Basic (7 files) — Suitable for small/medium projects. Includes the core files for project context, architecture, tech stack, active context, and progress tracking.
  • Extended (7 core + optional extra files) — Suitable for enterprise/production projects. Includes the core files plus specialized files for business logic, data models, security, observability, and more.
If the user selects Extended, present the list of optional extended files and let them pick which ones they need:
Extended FilePurpose
businessLogic.md
Domain rules, business workflows, validation logic
dataModel.md
Database schema, entity relationships, data flow
dependencies.md
Detailed dependency map, version constraints, upgrade notes
events.md
Event-driven architecture, pub/sub topics, event schemas
externalIntegrations.md
3rd party APIs, webhooks, service contracts
featureToggles.md
Feature flags, A/B tests, gradual rollout rules
observability.md
Logging, monitoring, tracing, alerting setup
security.md
Auth flows, security policies, vulnerability tracking
technicalDebt.md
Known debt items, refactoring priorities, cleanup plans
contextCoverage.md
Memory bank completeness tracking, coverage gaps
The user can select all, some, or none. Store the selection for Steps 4 and 5.
1a. 语言:
询问用户希望Memory Bank文件使用哪种语言编写:
  • TR(土耳其语)
  • EN(英语)
存储该选择,所有文件标题、标签和描述都将使用该语言生成。
templates/
中的模板为英文版本,填充内容时需要将标题和标签翻译为用户选择的语言。
1b. 配置版本:
询问用户想要使用哪种版本:
  • 基础版(7个文件)—— 适合中小型项目,包含项目上下文、架构、技术栈、活跃上下文和进度追踪的核心文件。
  • 扩展版(7个核心文件 + 可选扩展文件)—— 适合企业级/生产级项目,除核心文件外还包含业务逻辑、数据模型、安全、可观测性等专项文件。
如果用户选择扩展版,展示可选扩展文件列表,让用户选择需要的文件:
扩展文件用途
businessLogic.md
领域规则、业务工作流、校验逻辑
dataModel.md
数据库 schema、实体关系、数据流
dependencies.md
详细依赖映射、版本约束、升级说明
events.md
事件驱动架构、发布/订阅主题、事件 schema
externalIntegrations.md
第三方API、webhook、服务契约
featureToggles.md
功能开关、A/B测试、灰度发布规则
observability.md
日志、监控、链路追踪、告警配置
security.md
鉴权流程、安全策略、漏洞追踪
technicalDebt.md
已知技术债项、重构优先级、清理计划
contextCoverage.md
Memory Bank完整性追踪、覆盖缺口
用户可以选择全部、部分或不选任何扩展文件,存储选择结果用于步骤4和步骤5。

Step 2: Ask User Which Agent(s) They Use

步骤2:询问用户使用的Agent

CRITICAL: This skill can run inside any agent (Claude Code, Cursor, Windsurf, Cline, etc.). The agent running this skill is NOT necessarily the agent the user wants to configure. You MUST always ask the user which agent(s) they use for this project. NEVER assume the running agent is the target. NEVER skip this question. NEVER auto-create a rules file based on which agent you are.
2a. Ask the user:
Ask: "Which AI coding agent(s) do you use for this project?" and present these options:
  • Claude Code →
    CLAUDE.md
    or
    .claude/rules/*.md
  • Cursor →
    .cursor/rules/*.mdc
    (legacy:
    .cursorrules
    )
  • Windsurf →
    .windsurf/rules/*.md
    (legacy:
    .windsurfrules
    )
  • Cline →
    .clinerules/
    directory or
    .clinerules
    file
  • GitHub Copilot →
    .github/copilot-instructions.md
  • Roo Code →
    .roo/rules/*.md
    (legacy:
    .roorules
    )
  • Aider →
    CONVENTIONS.md
    +
    .aider.conf.yml
  • Antigravity →
    .gemini/GEMINI.md
  • OpenAI Codex →
    AGENTS.md
  • Other → ask for the rules file name/path
The user may select multiple agents. Store the selection for Step 3.
2b. Scan for existing rules files:
Read
reference.md
for the full agent-to-rules-file mapping table.
IMPORTANT: Rules files are NOT always in the project root. Search the ENTIRE project tree to find them. Use glob/find patterns to locate all known rules files regardless of their location.
Search for the rules files of the agent(s) the user selected:
AgentFile Names to Search
Claude Code
CLAUDE.md
,
.claude/CLAUDE.md
,
.claude/rules/*.md
Cursor
.cursor/rules/*.mdc
,
.cursorrules
(legacy)
Windsurf
.windsurf/rules/*.md
,
.windsurfrules
(legacy)
Cline
.clinerules/
(directory),
.clinerules
(file)
GitHub Copilot
.github/copilot-instructions.md
,
.github/instructions/*.instructions.md
Roo Code
.roo/rules/*.md
,
.roorules
(legacy)
Aider
CONVENTIONS.md
,
.aider.conf.yml
Antigravity
.gemini/GEMINI.md
OpenAI Codex
AGENTS.md
Search strategy:
  1. Use glob patterns like
    **/.cursor/rules/*.mdc
    ,
    **/.windsurf/rules/*.md
    ,
    **/CLAUDE.md
    ,
    **/.claude/rules/*.md
    ,
    **/.clinerules
    ,
    **/.github/copilot-instructions.md
    ,
    **/.roo/rules/*.md
    ,
    **/.aider.conf.yml
    ,
    **/CONVENTIONS.md
    ,
    **/AGENTS.md
    ,
    **/.gemini/GEMINI.md
  2. Also search for legacy files:
    **/.cursorrules
    ,
    **/.windsurfrules
    ,
    **/.roorules
  3. Exclude
    node_modules/
    ,
    .git/
    ,
    dist/
    ,
    build/
    ,
    .next/
    ,
    vendor/
    directories from search
  4. For ambiguous names (like
    CONVENTIONS.md
    ), verify by checking parent directory context
2c. Report results and handle unrecognized agents:
  • If the rules file for the user's selected agent(s) already exists, report the path(s) and proceed to inject the protocol
  • If the rules file does not exist, create it at the standard location for that agent
  • If the user selected multiple agents, handle each one
  • If the user's agent is NOT in the supported list above, or the agent cannot be matched to a known rules file format:
    1. Create
      AGENTS.md
      in the project root as a generic fallback
    2. Inject the Memory Bank protocol into
      AGENTS.md
    3. Display a clear warning to the user:
      ⚠️  Your agent ([agent name]) is not in our supported list.
      The Memory Bank protocol has been written to AGENTS.md in the project root.
      
      For Memory Bank to work correctly, you MUST manually add or copy
      the contents of AGENTS.md into your agent's own rules file.
      
      Please check your agent's documentation for the correct rules file
      location and format, then ensure the Memory Bank protocol is included.
    4. This ensures the protocol content is available even if automatic injection isn't possible
重要提示: 本技能可以在任意Agent(Claude Code、Cursor、Windsurf、Cline等)中运行,运行本技能的Agent不一定是用户想要配置的目标Agent。你必须始终询问用户在本项目中使用哪些Agent,永远不要假设当前运行的Agent就是目标,永远不要跳过该问题,永远不要根据当前运行的Agent自动创建规则文件。
2a. 询问用户:
提问:“你在本项目中使用哪些AI编码Agent?”并展示以下选项:
  • Claude Code →
    CLAUDE.md
    .claude/rules/*.md
  • Cursor →
    .cursor/rules/*.mdc
    (旧版本:
    .cursorrules
  • Windsurf →
    .windsurf/rules/*.md
    (旧版本:
    .windsurfrules
  • Cline →
    .clinerules/
    目录 或
    .clinerules
    文件
  • GitHub Copilot →
    .github/copilot-instructions.md
  • Roo Code →
    .roo/rules/*.md
    (旧版本:
    .roorules
  • Aider →
    CONVENTIONS.md
    +
    .aider.conf.yml
  • Antigravity →
    .gemini/GEMINI.md
  • OpenAI Codex →
    AGENTS.md
  • 其他 → 询问规则文件的名称/路径
用户可以选择多个Agent,存储选择结果用于步骤3。
2b. 扫描现有规则文件:
完整的Agent与规则文件映射表请查看
reference.md
重要提示: 规则文件不一定都存放在项目根目录,需要搜索整个项目目录树来查找。使用glob/find模式定位所有已知规则文件,不限制存储位置。
搜索用户选择的Agent对应的规则文件:
Agent待搜索文件名
Claude Code
CLAUDE.md
,
.claude/CLAUDE.md
,
.claude/rules/*.md
Cursor
.cursor/rules/*.mdc
,
.cursorrules
(旧版本)
Windsurf
.windsurf/rules/*.md
,
.windsurfrules
(旧版本)
Cline
.clinerules/
(目录),
.clinerules
(文件)
GitHub Copilot
.github/copilot-instructions.md
,
.github/instructions/*.instructions.md
Roo Code
.roo/rules/*.md
,
.roorules
(旧版本)
Aider
CONVENTIONS.md
,
.aider.conf.yml
Antigravity
.gemini/GEMINI.md
OpenAI Codex
AGENTS.md
搜索策略:
  1. 使用glob模式,例如
    **/.cursor/rules/*.mdc
    **/.windsurf/rules/*.md
    **/CLAUDE.md
    **/.claude/rules/*.md
    **/.clinerules
    **/.github/copilot-instructions.md
    **/.roo/rules/*.md
    **/.aider.conf.yml
    **/CONVENTIONS.md
    **/AGENTS.md
    **/.gemini/GEMINI.md
  2. 同时搜索旧版本文件:
    **/.cursorrules
    **/.windsurfrules
    **/.roorules
  3. 搜索时排除
    node_modules/
    .git/
    dist/
    build/
    .next/
    vendor/
    目录
  4. 对于命名有歧义的文件(例如
    CONVENTIONS.md
    ),通过父目录上下文验证归属
2c. 反馈结果并处理未识别的Agent:
  • 如果用户选择的Agent对应的规则文件已存在,反馈文件路径后继续注入协议
  • 如果规则文件不存在,在该Agent的标准路径下创建对应文件
  • 如果用户选择了多个Agent,逐个处理
  • 如果用户的Agent不在上述支持列表中,或者无法匹配到已知的规则文件格式:
    1. 在项目根目录创建
      AGENTS.md
      作为通用兜底文件
    2. 将Memory Bank协议注入到
      AGENTS.md
    3. 向用户展示明确的警告:
      ⚠️  你使用的Agent([agent名称])不在我们的支持列表中。
      Memory Bank协议已写入项目根目录的AGENTS.md文件。
      
      为了保证Memory Bank正常工作,你必须手动将AGENTS.md的内容
      添加或复制到你的Agent对应的规则文件中。
      
      请查看你的Agent文档确认规则文件的正确路径和格式,
      确保Memory Bank协议已被包含在内。
    4. 该操作可以保证即使无法自动注入,协议内容也可被获取

Step 3: Inject Protocol into Rules Files

步骤3:向规则文件注入协议

For each selected rules file:
  1. Read the file
  2. Check if it already contains "Memory Bank Protocol" — if yes, skip it
  3. Read
    templates/rules-protocol.md
    for the protocol block
  4. Prepend the protocol block to the top of the file (before existing content)
  5. Show the user the change and get confirmation before writing
对每个选中的规则文件:
  1. 读取文件内容
  2. 检查是否已包含“Memory Bank Protocol”内容,如果已包含则跳过
  3. templates/rules-protocol.md
    读取协议块内容
  4. 将协议块添加到文件的最顶部(现有内容之前)
  5. 向用户展示修改内容,获取确认后再写入

Step 4: Create memory-bank/ Directory

步骤4:创建memory-bank/目录

Check if
memory-bank/
exists in the project root:
  • If it exists, check which files are present and only create missing ones
  • If it doesn't exist, create it
Core files (always created — 7 total):
  1. RULES.md
  2. projectbrief.md
  3. productContext.md
  4. systemPatterns.md
  5. techContext.md
  6. activeContext.md
  7. progress.md
Extended files (only if user selected Extended profile — based on their selection): 8.
businessLogic.md
9.
dataModel.md
10.
dependencies.md
11.
events.md
12.
externalIntegrations.md
13.
featureToggles.md
14.
observability.md
15.
security.md
16.
technicalDebt.md
17.
contextCoverage.md
检查项目根目录下是否存在
memory-bank/
  • 如果已存在,检查现有文件,仅创建缺失的文件
  • 如果不存在,创建该目录
核心文件(始终创建,共7个):
  1. RULES.md
  2. projectbrief.md
  3. productContext.md
  4. systemPatterns.md
  5. techContext.md
  6. activeContext.md
  7. progress.md
扩展文件(仅当用户选择扩展版时,根据用户选择创建): 8.
businessLogic.md
9.
dataModel.md
10.
dependencies.md
11.
events.md
12.
externalIntegrations.md
13.
featureToggles.md
14.
observability.md
15.
security.md
16.
technicalDebt.md
17.
contextCoverage.md

Step 5: Fill Templates with Project Data

步骤5:使用项目数据填充模板

For each missing file:
  1. Read the corresponding template from
    templates/
  2. Scan the project for real data to fill the template:
    • package.json
      — project name, dependencies, scripts
    • README.md
      — project description, vision
    • tsconfig.json
      /
      jsconfig.json
      — import aliases, compiler options
    • Folder structure — architecture patterns
    • Git log (last 10-20 commits) — recent changes, active work
    • Existing rules files — conventions, preferences
  3. Fill placeholders with discovered project data
  4. Translate headings/labels to the user's chosen language
  5. Show the filled content to the user
  6. Get approval before writing each file
Important:
RULES.md
is created from
templates/RULES.md
and is immutable after creation — the skill must never modify it in subsequent runs.
对每个缺失的文件:
  1. templates/
    读取对应的模板
  2. 扫描项目获取真实数据填充模板:
    • package.json
      —— 项目名称、依赖、脚本
    • README.md
      —— 项目描述、愿景
    • tsconfig.json
      /
      jsconfig.json
      —— 导入别名、编译器选项
    • 文件夹结构 —— 架构模式
    • Git日志(最近10-20次提交)—— 近期变更、活跃工作内容
    • 现有规则文件 —— 约定、偏好
  3. 用扫描到的项目数据填充占位符
  4. 将标题/标签翻译为用户选择的语言
  5. 向用户展示填充后的内容
  6. 每个文件写入前都需要获取用户批准
重要提示:
RULES.md
templates/RULES.md
生成,创建后是不可修改的,本技能在后续运行中永远不得修改该文件。

Step 6: .gitignore Check

步骤6:.gitignore检查

Verify that
memory-bank/
is NOT listed in
.gitignore
. Memory bank files should be committed to git so all team members and agents can access them.
If
memory-bank/
is found in
.gitignore
, warn the user and offer to remove it.
确认
memory-bank/
没有被列入
.gitignore
中。Memory Bank文件应该提交到git,以便所有团队成员和Agent都可以访问。
如果发现
.gitignore
中包含
memory-bank/
,警告用户并提供移除该配置的选项。

Step 7: Validation Checklist

步骤7:校验清单

Run the validation checklist and display results:
[✓/✗] Rules file found and Memory Bank protocol injected
[✓/✗] memory-bank/ directory exists

Core files:
[✓/✗] RULES.md exists
[✓/✗] projectbrief.md exists
[✓/✗] productContext.md exists
[✓/✗] systemPatterns.md exists
[✓/✗] techContext.md exists
[✓/✗] activeContext.md exists
[✓/✗] progress.md exists
If Extended profile was selected, also validate the selected extended files:
Extended files:
[✓/✗] businessLogic.md exists
[✓/✗] dataModel.md exists
[✓/✗] dependencies.md exists
... (only show files the user selected)
If all pass, show completion message:
Memory Bank setup complete!
Profile: [Basic/Extended]
Agent: [agent name]
Rules file: [file path]
Memory Bank: memory-bank/ ([N] files)

From now on, memory-bank/ files will be read at every session start.
Try: "memory bank status" or "memory bank read"
If any fail, explain the issue and offer to fix it.

运行校验清单并展示结果:
[✓/✗] 已找到规则文件并注入Memory Bank协议
[✓/✗] memory-bank/目录已存在

核心文件:
[✓/✗] RULES.md已存在
[✓/✗] projectbrief.md已存在
[✓/✗] productContext.md已存在
[✓/✗] systemPatterns.md已存在
[✓/✗] techContext.md已存在
[✓/✗] activeContext.md已存在
[✓/✗] progress.md已存在
如果用户选择了扩展版,同时校验选中的扩展文件:
扩展文件:
[✓/✗] businessLogic.md已存在
[✓/✗] dataModel.md已存在
[✓/✗] dependencies.md已存在
...(仅展示用户选择的文件)
如果所有校验通过,展示完成消息:
Memory Bank搭建完成!
版本:[基础版/扩展版]
Agent:[agent名称]
规则文件:[文件路径]
Memory Bank:memory-bank/(共[N]个文件)

从现在开始,每次会话启动时都会读取memory-bank/下的文件。
你可以尝试:“memory bank status”或“memory bank read”
如果有校验不通过,说明问题并提供修复选项。

UPDATE Flow

UPDATE 更新流程

Step 1: Read Current Memory Bank

步骤1:读取当前Memory Bank内容

Read all 7 files from
memory-bank/
(skip
RULES.md
— it is immutable).
读取
memory-bank/
下的所有7个文件(跳过
RULES.md
,该文件不可修改)。

Step 2: Scan Current Project State

步骤2:扫描当前项目状态

Gather current project information:
  • Git status, recent commits, current branch
  • Package.json changes (new dependencies, scripts)
  • Folder structure changes
  • Any new/modified rules files
收集当前项目信息:
  • Git状态、近期提交、当前分支
  • Package.json变更(新增依赖、脚本)
  • 文件夹结构变更
  • 任何新增/修改的规则文件

Step 3: Detect Changes & Propose Updates

步骤3:检测变更并提出更新建议

Compare current project state with memory bank contents. For each file that needs updates:
  1. Show what changed (diff-style or summary)
  2. Show proposed new content
  3. Get user approval before writing
对比当前项目状态和Memory Bank内容。对每个需要更新的文件:
  1. 展示变更内容(diff格式或摘要形式)
  2. 展示更新后的内容建议
  3. 获取用户批准后再写入

Step 4: Write Approved Updates

步骤4:写入已批准的更新

Write only the approved changes. Add date stamps
[YYYY-MM-DD]
to entries.
仅写入用户批准的变更,为条目添加日期戳
[YYYY-MM-DD]

Step 5: Summary

步骤5:更新总结

Show a summary of what was updated and what was left unchanged.

展示更新内容和未变更内容的总结。

STATUS Flow

STATUS 状态流程

  1. Read
    memory-bank/activeContext.md
  2. Read
    memory-bank/progress.md
  3. Present a concise summary:
    • Current focus / active work
    • Recent changes
    • What's completed
    • What's in progress
    • Known issues
    • Next steps
Respond in the same language as the existing memory bank files (auto-detect from headings).

  1. 读取
    memory-bank/activeContext.md
  2. 读取
    memory-bank/progress.md
  3. 展示简洁的状态总结:
    • 当前聚焦/活跃工作
    • 近期变更
    • 已完成内容
    • 进行中内容
    • 已知问题
    • 下一步计划
使用与现有Memory Bank文件相同的语言回复(从标题自动检测)。

READ Flow

READ 读取流程

  1. Read ALL files in
    memory-bank/
  2. Present the full context in an organized format:
    • Start with project overview (from
      projectbrief.md
      )
    • Then product context (from
      productContext.md
      )
    • Then technical details (from
      techContext.md
      +
      systemPatterns.md
      )
    • Then current state (from
      activeContext.md
      +
      progress.md
      )
  3. Highlight any areas that appear outdated or incomplete
Respond in the same language as the existing memory bank files (auto-detect from headings).

  1. 读取
    memory-bank/
    下的所有文件
  2. 以结构化格式展示完整上下文:
    • projectbrief.md
      提取项目概览作为开头
    • 之后展示
      productContext.md
      中的产品上下文
    • 然后展示
      techContext.md
      +
      systemPatterns.md
      中的技术细节
    • 最后展示
      activeContext.md
      +
      progress.md
      中的当前状态
  3. 高亮显示任何看起来过时或不完整的部分
使用与现有Memory Bank文件相同的语言回复(从标题自动检测)。

Important Rules

重要规则

  • NEVER modify
    memory-bank/RULES.md
    after initial creation
  • NEVER write secrets (API keys, tokens, passwords) to memory bank files
  • NEVER skip user confirmation for file writes during setup
  • Keep each file under 500 lines
  • Use date stamps
    [YYYY-MM-DD]
    for temporal entries
  • Don't duplicate information across files
  • When updating, preserve existing content and append/modify — don't overwrite entire files unless the user approves
For detailed rules, agent mapping, and update triggers, see
reference.md
.
  • 初始创建后永远不要修改
    memory-bank/RULES.md
  • 永远不要向Memory Bank文件写入密钥(API密钥、token、密码)
  • 搭建过程中写入文件前永远不要跳过用户确认
  • 每个文件的内容保持在500行以内
  • 时间相关的条目使用日期戳
    [YYYY-MM-DD]
  • 不要在不同文件中重复存储相同信息
  • 更新时保留现有内容,仅追加/修改内容,除非用户批准,否则不要覆盖整个文件
详细规则、Agent映射和更新触发条件请查看
reference.md