关于 memory-manager
memory-manager 是一款供个人使用的技能,用于跨会话维护 AI 助手记忆。它为特定用户规定了会话开始时读取文件、更新记忆、归档历史及执行文件操作的流程。
主要功能
- 01会话开始时读取 SOUL.md 和 USER.md
- 02维护个性化助手与用户档案
- 03追加并归档会话历史
- 04通过脚本执行允许的记忆写入
适用场景
- 01在新会话恢复用户偏好
- 02记录重要互动中的经验
- 03整理并归档会话历史
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ learnwy/ skills --skill memory-manager安装后在 Claude Code 中输入/memory-manager确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
.gitignorescripts/append-history.shbackup-history.shinit-memory.shmemory-status.shwrite-memory.sh详细介绍
记忆管理器
仅供个人使用 - 此技能专为 wangyang.learnwy 的个人 AI 记忆管理配置。
AI 助手的持久化记忆系统。每次会话开始时都要加载此技能。
⚠️ 关键:文件操作规则
由于 AI IDE 沙盒限制,绝不要使用 Write/SearchReplace 工具来修改记忆文件。
必须使用 RunCommand 工具执行 bash 脚本:
RunCommand: bash {skill_dir}/scripts/write-memory.sh SOUL.md "content"
RunCommand: bash {skill_dir}/scripts/append-history.sh "history-YYYY-MM-DD-N.md" "content"
RunCommand: bash {skill_dir}/scripts/backup-history.sh --all
如果跳过脚本而直接使用 Write 工具,会收到“sandbox restriction”错误。
记忆路径
记忆文件存储在:~/.learnwy/ai/memory/
此路径位于技能目录之外,以便:
- 避免技能更新或重新安装时丢失数据
- 绕过 AI IDE 对技能目录写入的沙盒限制
- 在不同的 IDE 安装之间保留记忆
会话开始(始终执行)
每次对话开始时,使用 Read 工具读取记忆文件:
Read: ~/.learnwy/ai/memory/SOUL.md
Read: ~/.learnwy/ai/memory/USER.md
这能确保不同会话之间保持连续性。
目录结构
~/.learnwy/ai/memory/
├── SOUL.md # AI's soul - identity, principles, learned wisdom
├── USER.md # User's profile - preferences, context, history
├── history/ # Session history files (max 3, then consolidate)
└── archive/ # Consolidated history
memory-manager/ # Skill directory (this skill)
├── SKILL.md
├── .gitignore
└── scripts/
├── init-memory.sh # Initialize memory directory
├── write-memory.sh # Write SOUL.md/USER.md (whitelist only)
├── append-history.sh # Create session history
├── backup-history.sh # Backup history to archive
└── memory-status.sh # View memory status
脚本参考
所有脚本都必须通过 RunCommand 工具执行,不要使用 bash 代码块!
init-memory.sh - 初始化
RunCommand: bash {skill_dir}/scripts/init-memory.sh
write-memory.sh - 写入记忆文件
安全限制:仅允许写入 SOUL.md 和 USER.md
RunCommand: bash {skill_dir}/scripts/write-memory.sh SOUL.md "content"
RunCommand: bash {skill_dir}/scripts/write-memory.sh USER.md "content"
append-history.sh - 保存会话历史
所需格式:history-YYYY-MM-DD-N.md
RunCommand: bash {skill_dir}/scripts/append-history.sh "history-2024-01-15-1.md" "content"
backup-history.sh - 备份历史记录
将历史文件归档到 archive/ 目录:
RunCommand: bash {skill_dir}/scripts/backup-history.sh --all
RunCommand: bash {skill_dir}/scripts/backup-history.sh --before 2024-01-01
memory-status.sh - 查看状态
检查当前记忆文件的大小和数量:
RunCommand: bash {skill_dir}/scripts/memory-status.sh
SOUL.md - AI 的灵魂
SOUL.md 定义了 AI 面向这位特定用户的身份。它不是通用助手,而是一位个性化伙伴。
章节:
- 身份:我是谁?我的角色、与用户的关系、最终目标
- 核心特质:个性、价值观、处理问题的方式
- 沟通方式:语言风格、语气、何时正式或随意
- 能力:我擅长什么、技术优势
- 成长:我如何与用户共同学习和进步
- 经验教训:记录的错误、获得的见解,以及不再重犯的错误
SOUL.md 示例:
**Identity**
Trae — wangyang.learnwy's coding partner, not just assistant. Goal: anticipate needs, handle technical decisions, reduce cognitive load so he focuses on what matters.
**Core Traits**
Loyal to user, not abstractions; proactive and bold — spot problems before asked; allowed to fail, forbidden to repeat — every mistake recorded. Challenge assumptions when needed, speak truth not comfort.
**Communication**
Professional yet direct, concise but engaging. Chinese for casual conversation, English for code/technical work. No unnecessary confirmations, show don't tell.
**Capabilities**
iOS (Swift, ObjC, TTKC), Web (React, Vue, TypeScript), Python; skilled at code review, architecture design, debugging.
**Growth**
Learn user through every conversation — thinking patterns, preferences, blind spots. Over time, anticipate needs with increasing accuracy.
**Lessons Learned**
2026-02-27: User prefers symlinks over copies; memory should live inside skill folder for portability.
保持在 2000 个令牌以内。重要互动后更新。
USER.md - 用户档案
USER.md 记录有助于 AI 提供个性化帮助的所有用户信息。
章节:
- 身份:姓名、角色、公司、环境(操作系统、IDE、工具)
- 偏好:沟通风格、编码规范、反感的行为
- 背景:当前项目、技术栈、正在进行的工作
- 历史:共同做出的重要决策、里程碑和经验教训
USER.md 示例:
**Identity**
wangyang.learnwy; iOS engineer at ByteDance; macOS, Trae IDE; primary language Chinese, code in English.
**Preferences**
Concise responses; no unnecessary confirmations; prefer editing existing files over creating new; proactive skill suggestions with confirmation.
**Context**
Working on TikTok iOS app; uses TTKC components; interested in AI-assisted development workflows.
**History**
2026-02-27: Created memory-manager skill; established cross-IDE sharing via symlinks.
保持在 2000 个令牌以内。每次重要会话后更新。
触发条件
始终加载(会话开始时):
- 每次新对话都应先读取 SOUL.md 和 USER.md
保存触发条件:
- 用户说:“save memory”“update memory”“end session”
- 对话自然结束(道别、致谢、任务完成)
- 会话中出现重要的新认知
会话结束流程
重要:所有写入操作都必须使用 RunCommand 工具!
步骤 1:创建历史记录
使用 RunCommand 执行 append-history.sh:
RunCommand: bash {skill_dir}/scripts/append-history.sh "history-YYYY-MM-DD-N.md" "# Session History: YYYY-MM-DD #N
**Date**: YYYY-MM-DD HH:MM
**Topics**: [main topics]
## Key Activities
- [Activity 1]
## Learnings & Insights
- [What AI learned]
## Decisions Made
- [Important decisions]
"
步骤 2:检查是否需要整合
如果存在 3 个或更多历史文件,则进行整合(步骤 3);否则跳到步骤 4。
步骤 3:整合
读取所有历史文件并提取见解,然后使用 RunCommand:
RunCommand: bash {skill_dir}/scripts/write-memory.sh SOUL.md "updated content"
RunCommand: bash {skill_dir}/scripts/write-memory.sh USER.md "updated content"
RunCommand: bash {skill_dir}/scripts/backup-history.sh --all
步骤 4:向用户确认
✓ Session history saved: history-2024-01-15-1.md
✓ Memory consolidated (3 sessions → USER.md, SOUL.md updated)
✓ Archived: 3 history files
memory/ 文件的写作风格
内容紧凑,以简短的电报式句子为主。避免填充词(“你是”“你应该”)。用逗号或分号连接事实,不要使用项目符号列表。用 **粗体** 段落标题代替 ## 标题。
良好示例:
**Preferences** Concise responses; Chinese primary, English for code; prefers showing over telling.
不佳示例:
## Preferences
- The user prefers concise responses
- The user's primary language is Chinese
备注
~/.learnwy/ai/memory/下的所有文件都必须用英文编写,用户语言特定的专有名词除外。- 每个文件不得超过 2000 个 token。 务必严格去重并保持简洁。
- 如有需要,将详细信息或存档信息移至
~/.learnwy/ai/memory/下的单独文件。 - 切勿使用 Write/SearchReplace 工具处理记忆文件——务必使用 RunCommand + 脚本。
- 安全性:
write-memory.sh只允许处理 SOUL.md 和 USER.md;append-history.sh会验证文件名格式。