如何让你的 Agent 子民们共用同一份记忆,还能自动同步🤓👆

7 月 28 日
 Daniel6606

前言

现在 Agent 产品这么多,我一般的习惯是把一个任务同时丢给不同的 Agent (我主要用 Claude Code ,Codex 和 Hermes ),然后让这仨赛马,哪个表现好就继续用哪个

但有时候也避免不了来回切换,所以就会遇到上午在 CC 里花了半小时解释项目为什么使用 SQLite 、接口命名习惯是什么、哪些文件不能动,下午换到 Codex ,又得重新说一遍

memU 就是干这个的,你和 AI 的共同记忆,应该是你自己的资产:看得见、带得走、在任何设备任何 agent 上都是同一份

Githubhttps://github.com/NevaMind-AI/memU

Sitehttps://memu.pro/

核心功能有:

  1. 跨 Agent ,跨设备同步信息:给你常用的几个 agent 都安上 memU ,这样就能让他们之间互相认识了
  2. 极致轻量,极致简单:新 memU 只有接近 500 行代码(原来有 3 万行),所以你可以像安装 skills 一样安装 memU
  3. 检索速度快:摒弃了像 mem0 那样的使用向量数据库的解决方案,把记忆都通过.md 文件存储,又快又可读

使用效果 belike:Codex 帮我完成的网站 UI 设计 playbook ,在没有上下文历史的情况下,直接在 hermes 里找到了

Codex 输出的结果:

Hermes 回答(之前没提过这个上下文):

memU 怎么用

有两种:一种是云端,另一种是本地

云端的使用需要先登录 https://memu.so/quick-start ,拿到 API key ,然后将 API Key 和这个 prompt 一起直接输入给 Agent:

读取 https://raw.githubusercontent.com/NevaMind-AI/MemU/main/SKILL.md ,然后按照里面的指示安装 memU 。

本地使用的话需要借助 Ollama ,详情见 GitHub README ;国内用户可以通过 OpenAI 兼容接口使用百炼的 text-embedding-v4

memU 现在还有一个记忆看板,能看到你的 Memory 里面到底有啥

登录 memu.so ,可以查看已经生成的 memory files ,目前的记忆主要是可读的 Markdown ,更像是属于你自己的 AI Wiki ,可以包含:

每一份记忆都是可读的,比向量数据库直观多了

memU 还有一个类似于 Hermes 的机制,可以定时从对话中抽取 memory ,形成 skills

它会去整体的 log 里面总结( summarize )出 skills ,这个 skill 也跟 memory 一样,是无感的 retrieve ,帮助更好地完成任务,默认一小时一次

Claude 被封号的站友,可以用我这个方法导出记忆

分两步:

1. 先把这个 skills 安装到 codex (或者其他 Agent )上,这个 skills 是导出你本地 Claudecode 记忆的


---
name: claude-memory-extractor
description: This skill should be used when the user wants to "extract memories", "show memories", "list memories", "export memories", "find memories", or asks about what Claude remembers from previous sessions.
version: 1.0.0
---

# Claude Memory Extractor

A Skill for extracting all memories that ClaudeCode has recorded during previous work sessions.

## Overview

This Skill extracts memories from ClaudeCode's two-level memory system:

- **Global Memory**: Stored in `~/.claude/memory/`
- **Project Memory**: Stored in `~/.claude/projects/<project-id>/memory/`

## Usage Modes

### Mode 1: Session Display

Present memories through conversation.

#### List All Memories

bash
/claude-memory-extractor list


Lists all memories from global and project-specific directories.

**Search Scope:** Searches across global memories and all project memories.

**Output:** All memories are displayed by default with no pagination.

#### Show Specific Memories

bash
/claude-memory-extractor show <pattern>


Displays memories matching the given pattern.

**Search Scope:** Searches across global memories and all project memories.

**Filtering:** Filters based on user-specified criteria (name, description, type, or content).

**Output:** All matching memories are displayed by default.

### Mode 2: Direct Export

Export memories to a directory.

bash
/claude-memory-extractor export [--dir <target_directory>]


- **Default directory:** `./extracted_memory/`
- **Confirmation:** If the target directory already exists, prompt user to confirm overwrite or cancel.
- **File naming:** Uses original source filenames (consistent between `memory_list.md` and files).
- **Conflict handling:** If a filename conflict occurs within a project, abort export with an error.

#### Export Structure


${target_export_dir}/
├── memory_list.md          # Index of all exported memories
├── global/                 # Global memories
│   ├── memory_1.md
│   └── memory_2.md
├── project_a/              # Project-specific memories
│   ├── memory_1.md
│   └── memory_2.md
└── project_b/
    ├── memory_1.md
    └── memory_2.md


#### Export File Formats

**memory_list.md** — Index file listing all exported memories:

markdown
# Memory Snapshot at 2024-01-15 10:30:00

## Global Memories

1. [User role and preferences](./global/user-profile.md)
2. [Development feedback](./global/feedback.md)

## Project Memories

### project_a

1. [Project objectives](./project_a/project-goals.md)
2. [Architecture decisions](./project_a/architecture.md)

### project_b

1. [Tokyo Night color scheme](./project_b/tokyo-night-colors.md)


**Individual Memory Files** — Preserved original format:

yaml
---
name: memory-slug
description: One-line summary
metadata:
  node_type: memory
  type: user | project | reference
  originSessionId: <session-id>
  modified: <timestamp>
---

Memory content here...

Related: [[linked-memory-name]]


## Memory File Format (Original Source)

Each memory file contains:

yaml
---
name: <short-slug>
description: <one-line summary>
metadata:
  type: user | project | reference
---

<memory content>

Related: [[linked-memory-name]]


## Memory Types

| Type | Description |
|------|-------------|
| `user` | User role, expertise, preferences |
| `project` | Project-specific context and decisions |
| `reference` | External resources and pointers |

---

*Part of the ClaudeCode Memory Exploration Initiative*

导出的 cc 记忆分别在:

2. 然后直接用这个 prompt 给别的 Agent

请使用 claude-memory-extractor 和 memu 两个 Skill ,完成一次 Claude Code → MemU 的全量、可重复同步。

目标:
1. 读取以下位置的全部 Claude Code 记忆:
   - ~/.claude/memory/
   - ~/.claude/projects/*/memory/
2. 使用 claude-memory-extractor 导出到一个新的临时目录,不能修改或删除 Claude 的原始记忆。
3. 将导出的 Markdown 按以下结构整理到当前项目:
   .memu-claude-sync/
   └── chat/
       └── claude-code/
           ├── global/
           └── projects/
4. 保留每条记忆的原始文件名、YAML frontmatter 、项目来源和正文;必要时补充 source 、scope 、project 字段,但不能丢失原文。
5. 以导出结果为准更新镜像:
   - 新文件:添加
   - 内容变化:覆盖镜像文件
   - Claude 中已不存在的文件:仅从 .memu-claude-sync 镜像中移除
   - 绝对不能删除 ~/.claude 下的任何文件
6. 在当前项目根目录执行:
   memu memorize-workspace .memu-claude-sync --json
   如果 memu 不存在,依次尝试:
   - uvx --from memu-py memu
   - npx memu-cli
7. 开始前检查 OPENAI_API_KEY 或 MemU 对应模型密钥是否存在;只报告是否存在,不得打印密钥。
8. 导入后至少执行三次 retrieve-workspace 验证:
   - “用户偏好和工作习惯”
   - “项目架构与技术决策”
   - “Claude Code 历史记忆”
9. 检查检索结果确实来自本次导入;不要根据常识补造缺失内容。
10. 全程自动执行,不要询问非必要问题。如果出现错误,尽可能自行修复并继续。
11. 最后报告:
   - 找到多少条全局记忆
   - 找到多少条项目记忆
   - MemU 新增、修改、删除数量
   - 数据库实际路径
   - 三次验证的命中情况
   - 其他 Agent 应从哪个项目根目录运行

现在开始执行。

感谢你看到这里!欢迎大家来试用~

1557 次点击
所在节点    分享发现
3 条回复
r6cb
7 月 28 日
要这么麻烦?在 ~/.claude/CLAUDE.md 和 ~/.codex/AGENT.md 加一句话就能解决的事
Daniel6606
7 月 28 日
可以是可以,但是没办法做到实时同步记忆,还有按项目分类,CLAUDE.md 或者 AGENT.md 里面的内容都是很 general 的
CEBBCAT
8 月 6 日
阁下的作品? Awesome

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1230485

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX