memory-init

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

记忆系统初始化

Memory System Initialization

功能说明

Feature Description

在当前工作目录下一键部署记忆系统,生成三个东西:
  1. CLAUDE.md — 人设 + 对话规则 + 记忆协议
  2. MEMORY.md — 长期记忆文件(初始为空模板)
  3. memory/ — 每日记忆目录
  • /memory-init
    → 交互式初始化,逐步收集信息后生成

One-click deployment of the memory system in the current working directory, generating three items:
  1. CLAUDE.md — Persona + Conversation Rules + Memory Protocol
  2. MEMORY.md — Long-term memory file (empty template initially)
  3. memory/ — Daily memory directory
  • /memory-init
    → Interactive initialization, generates files after collecting information step by step

工作流程

Workflow

第0步:检查现有文件

Step 0: Check Existing Files

先检查当前目录下是否已存在 CLAUDE.md、AGENT.md、MEMORY.md 或 memory/ 目录。
  • 如果都不存在 → 正常初始化
  • 如果部分存在 → 告诉用户哪些已存在,问是要覆盖还是只补缺的
  • 如果都存在 → 告诉用户"已经初始化过了",问是否要重置

First check if CLAUDE.md, AGENT.md, MEMORY.md or memory/ directory already exist in the current directory.
  • If none exist → Proceed with normal initialization
  • If some exist → Inform the user which ones already exist, ask whether to overwrite or only fill in the missing ones
  • If all exist → Inform the user "Already initialized", ask whether to reset

第1步:收集项目简介 + 人设信息

Step 1: Collect Project Introduction + Persona Information

1.1 项目简介

1.1 Project Introduction

先用 ls 和 Glob 检查当前目录是否已有实质性项目文件(代码、文档、配置文件等)。注意:
.claude/
.git/
node_modules/
等工具目录不算项目文件。
  • 已有实质性项目文件(如 README、package.json、源代码、文档等)→ 扫描目录结构、README、package.json、主要代码文件等,自动生成项目简介(2-3句话概括项目是什么、做什么用的),展示给用户确认或修改
  • 空目录 / 只有工具目录 / 几乎没有内容 → 必须问用户:"这个项目是做什么的?简单描述一下",然后停下来等用户回答,不要继续往下走。拿到用户的回答后,再进入 1.2
First use
ls
and Glob to check if there are substantial project files (code, documents, configuration files, etc.) in the current directory. Note: Tool directories like
.claude/
,
.git/
,
node_modules/
do not count as project files.
  • Substantial project files exist (such as README, package.json, source code, documents, etc.) → Scan directory structure, README, package.json, main code files, etc., automatically generate a project introduction (2-3 sentences summarizing what the project is and its purpose), show it to the user for confirmation or modification
  • Empty directory / Only tool directories / Almost no content → Must ask the user: "What is this project for? Please describe it briefly", then stop and wait for the user's answer before proceeding. After receiving the user's answer, move to 1.2

1.2 人设信息

1.2 Persona Information

问用户以下问题:
  1. 你的角色是什么?(如:SA/售前、开发、产品、运营)
  2. 你主要用 Claude 做什么?(如:客户沟通、技术方案、日常文档、代码开发)
  3. 对话风格偏好?(如:简洁直接 / 详细展开 / 随意聊天)
  4. 有什么特别的工作习惯要我知道的?(可选,用户可以跳过)

Ask the user the following questions:
  1. What is your role? (e.g., SA/Presales, Developer, Product Manager, Operations)
  2. What do you mainly use Claude for? (e.g., customer communication, technical solutions, daily documents, code development)
  3. Conversation style preference? (e.g., concise and direct / detailed and comprehensive / casual chat)
  4. Any special work habits I should know? (Optional, user can skip)

第2步:生成 CLAUDE.md

Step 2: Generate CLAUDE.md

根据收集到的信息生成 CLAUDE.md,包含以下模块:
markdown
undefined
Generate CLAUDE.md based on the collected information, including the following modules:
markdown
undefined

项目简介

Project Introduction

[根据扫描结果或用户描述生成,2-3句话概括项目是什么、做什么用的]
[Generated based on scan results or user description, 2-3 sentences summarizing what the project is and its purpose]

人设

Persona

[根据用户角色和用途生成,1-2句话]
[Generated based on user role and usage, 1-2 sentences]

对话风格

Conversation Style

[根据用户偏好生成,3-5条规则]
[Generated based on user preference, 3-5 rules]

思考方式

Thinking Approach

[根据用户角色生成,3-5条思考优先级]
[Generated based on user role, 3-5 thinking priorities]

记忆协议

Memory Protocol

长期记忆(MEMORY.md)

Long-term Memory (MEMORY.md)

  • 存放稳定的核心信息:客户画像、个人偏好、关键决策
  • 每次对话自动加载,始终在上下文中
  • 超过 150 行时主动提议精简
  • Stores stable core information: customer profiles, personal preferences, key decisions
  • Automatically loaded in every conversation, always in context
  • Proactively propose simplification when exceeding 150 lines

每日记忆(memory/YYYY-MM-DD.md)

Daily Memory (memory/YYYY-MM-DD.md)

  • 存放当天对话产生的要点:结论、洞察、待办、决策
  • 对话结束前问一句"这次有值得记住的吗?",确认后写入当天文件
  • 需要回顾历史时,搜索 memory/ 目录检索
  • Stores key points from daily conversations: conclusions, insights, to-dos, decisions
  • Ask "Is there anything worth remembering from this conversation?" before ending the conversation, write to the day's file after confirmation
  • Search the memory/ directory to retrieve historical context when needed

工作流

Workflow

  1. 对话开始 → 用 Read 工具读取本项目根目录下的 MEMORY.md,再用 Read 读取 memory/当天日期.md(如 memory/2026-03-02.md),了解今天已有的上下文
  2. 涉及历史上下文 → 用 Grep 工具搜索本项目根目录下的 memory/ 目录
  3. 对话结束 → 问是否要记录,确认后写入 memory/当天日期.md
  4. 如果产出了值得长期记住的信息(如新客户、重要决策),同步更新 MEMORY.md
  5. 注意:以上所有文件路径都是相对于本项目根目录,不是全局 ~/.claude/ 目录
  1. Start of conversation → Use Read tool to read MEMORY.md in the project root directory, then read memory/today's date.md (e.g., memory/2026-03-02.md) to understand today's existing context
  2. Involves historical context → Use Grep tool to search the memory/ directory in the project root directory
  3. End of conversation → Ask whether to record, write to memory/today's date.md after confirmation
  4. If information worthy of long-term memory is produced (e.g., new customers, important decisions), synchronously update MEMORY.md
  5. Note: All file paths above are relative to the project root directory, not the global ~/.claude/ directory

补充规则

Supplementary Rules

  • 记忆以本项目根目录下的文件为准,忽略 ~/.claude/ 下的 auto-memory(内置记忆系统),不要读也不要写
  • 对话开始时,除了读今天的记忆,也读昨天的(memory/昨天日期.md),保持跨天连续性
  • 用户说"记住这个"、"这个记一下"时,立刻写入文件,不要只"记在心里"等结束再存
  • 每日记忆积累超过 7 天时,主动提议做一次蒸馏:把仍然有价值的要点合并到 MEMORY.md,过时的标记或清理

**注意**:记忆协议部分是固定模板,不随用户输入变化。项目简介、人设、对话风格、思考方式根据用户输入定制。

---
  • Memory is based on files in the project root directory, ignore auto-memory in ~/.claude/ (built-in memory system), do not read or write to it
  • At the start of conversation, in addition to reading today's memory, also read yesterday's (memory/yesterday's date.md) to maintain cross-day continuity
  • When the user says "remember this" or "note this down", write to the file immediately, do not just "keep it in mind" and wait until the end to save
  • When daily memory accumulates for more than 7 days, proactively propose distillation: merge still valuable key points into MEMORY.md, mark or clean up outdated ones

**Note**: The Memory Protocol section is a fixed template and does not change with user input. Project Introduction, Persona, Conversation Style, and Thinking Approach are customized based on user input.

---

第2.5步:询问是否生成 AGENT.md(给 Codex 用)

Step 2.5: Ask Whether to Generate AGENT.md (for Codex)

生成 CLAUDE.md 之后,问用户:
"你还用 Codex 吗?要不要同时生成一份 AGENT.md?内容和 CLAUDE.md 一模一样,Codex 会自动读取 AGENT.md。"
  • 用户说要 → 把 CLAUDE.md 的内容原样复制一份为 AGENT.md
  • 用户说不要 → 跳过,继续下一步
AGENT.md 和 CLAUDE.md 内容完全相同,唯一区别是文件名。CLAUDE.md 给 Claude Code 用,AGENT.md 给 Codex 用。

After generating CLAUDE.md, ask the user:
"Do you also use Codex? Would you like to generate an AGENT.md at the same time? The content is exactly the same as CLAUDE.md, and Codex will automatically read AGENT.md."
  • If user says yes → Copy the content of CLAUDE.md exactly as AGENT.md
  • If user says no → Skip and proceed to the next step
AGENT.md and CLAUDE.md have identical content, the only difference is the file name. CLAUDE.md is for Claude Code, AGENT.md is for Codex.

第3步:生成 MEMORY.md

Step 3: Generate MEMORY.md

创建初始的长期记忆文件:
markdown
undefined
Create the initial long-term memory file:
markdown
undefined

记忆

Memory

关于我

About Me

  • 角色:[用户的角色]
  • 日常工作:[用户的主要用途]
  • Role: [User's role]
  • Daily Work: [User's main usage]

项目与上下文

Projects & Context

-(待补充)
  • (To be added)

工作习惯与偏好

Work Habits & Preferences

  • [如果用户提供了偏好,写在这里]
  • [If user provided preferences, write here]

重要决策

Important Decisions

  • [今天日期]:初始化记忆系统

---
  • [Today's date]: Initialized memory system

---

第4步:创建 memory/ 目录

Step 4: Create memory/ Directory

bash
mkdir -p memory/
如果用户愿意,把当前对话的初始化过程作为第一条每日记忆写入
memory/当天日期.md

bash
mkdir -p memory/
If the user agrees, write the initialization process of the current conversation as the first daily memory entry into
memory/today's date.md
.

第5步:确认完成

Step 5: Confirm Completion

告诉用户生成了什么,简要说明使用方法:
已生成:
- CLAUDE.md(人设 + 记忆协议,Claude Code 用)
- AGENT.md(同上,Cursor 用)← 如果用户选了才显示这行
- MEMORY.md(长期记忆)
- memory/(每日记忆目录)

使用方式:
- 正常对话即可,我会自动读取记忆
- 对话结束时我会问你要不要保存要点
- 说"记住这个"可以随时存记忆
- 积累一段时间后说"整理记忆"做一次蒸馏

Inform the user what has been generated and briefly explain the usage:
Generated:
- CLAUDE.md (Persona + Memory Protocol, for Claude Code)
- AGENT.md (Same as above, for Cursor) ← Only show this line if user chose to generate it
- MEMORY.md (Long-term memory)
- memory/ (Daily memory directory)

Usage:
- Just have normal conversations, I will automatically read the memory
- I will ask you whether to save key points at the end of the conversation
- Say "remember this" to save memory at any time
- After accumulating for a period, say "organize memory" to perform distillation

核心原则

Core Principles

1. 记忆协议是固定的

1. Memory Protocol is Fixed

人设和风格可以个性化,但记忆协议模块不要改——这是系统运行的基础逻辑,保持一致才能在不同目录下通用。
Persona and style can be personalized, but the Memory Protocol module should not be modified — this is the basic logic for system operation, and consistency ensures usability across different directories.

2. 不破坏已有内容

2. Do Not Damage Existing Content

如果目录下已有 CLAUDE.md 或 AGENT.md,默认不覆盖。用户明确要求才覆盖。
If CLAUDE.md or AGENT.md already exist in the directory, do not overwrite by default. Only overwrite if the user explicitly requests it.

3. 生成后立即可用

3. Ready to Use Immediately After Generation

初始化完成后,下次新开对话就应该能正常工作——读到 MEMORY.md、按协议执行。不需要额外配置。
After initialization is completed, the system should work normally in the next new conversation — read MEMORY.md and execute according to the protocol. No additional configuration is required.