AnthonyJu

Global Shared Memory — Documentation skill for Claude Code

Documentation community

跨 agent 共享记忆:一套 markdown 存储 + 一个 CLI + 每端一条注入钩子,Claude Code / Codex / ZCode / DSH 都能读能写.

How to install Global Shared Memory

This entry records only its repository, not the path inside it, so there is no exact command to give. Open AnthonyJu/global-shared-memory and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Global Shared Memory does

跨 agent 共享记忆:一套 markdown 存储 + 一个 CLI + 每端一条注入钩子,Claude Code / Codex / ZCode / DSH 都能读能写.

Alternatives in Documentation

  • Wiki Sync — Sync Claude Code (and Codex CLI) session transcripts into the llmwiki, then ingest the new ones into wiki/ 375 ★
  • Cog — 240+ Cognitive architecture for Claude Code -- persistent memory, self-reflection, and foresight via plain-tex 294 ★
  • Token Goat — Token burn reducer and focus keeper for Claude Code, Codex, Copilot, Gemini CLI, and more: surgical read hints 107 ★

README

跨 agent 共享记忆

一套 markdown 存储 + 一个 CLI + 每端一条注入配置。**不是 MCP、不是 skill、不是第三方插件**: 读靠 harness 的启动钩子自动注入,写靠 `mem` 命令,任何 agent 来去都不影响数据。

设计目标只有一个:**同一份记忆,Claude Code / Codex / ZCode / DSH 都能读能写**,不绑定任何一家厂商。

本仓库独立维护。`git clone` 到任意目录后,先按下面「配置」一節建好配置文件(配路径和各端命令),再按「各 agent 怎么配」把每端的钩子接上。

目录

global-shared-memory/
├── README.md / FLOW.md               # 文档
└── src/
    ├── mem                     # CLI 真源(Python 3 标准库,无依赖)
    ├── extract                 # 每轮结束后自动提取记忆(四端共用)
    ├── install.py              # 把注入配置写进 Claude / Codex / ZCode(默认 dry-run)
    ├── sm_config.py            # 统一配置加载(路径与各端 headless 命令)
    ├── config.example.json     # 配置模板,复制到 ~/.config/global-shared-memory/config.json
    ├── test_mem.py             # mem 离线断言
    ├── hooks/                  # 三端 hook 参考片段(真正写入靠 install.py)
    │   ├── README.md
    │   ├── claude-settings.json
    │   ├── codex-hooks.json
    │   └── zcode-config.json
    └── dsh-plugin/             # DSH 原生插件(agent/pre-step 注入 + turn-stopping 提取)
        ├── index.js
        ├── package.json
        └── verify.mjs          # 离线自检,不需要模型

存储在 `memoryRoot`(默认是本仓库同级的 `memory/`),内容不进 git:

memory/
├── global/                                  # 跨项目:偏好、机器环境、通用结论
│   ├── MEMORY.md                            # 索引,一行一条
│   └── .md                            # 一事一文件
├── projects/-/
│   ├── MEMORY.md
│   └── .md
└── trash/                                   # mem forget 的落点,可随时清空

项目目录名公式:`slug(项目名小写, 非字母数字转 -)` + `-` + `sha256(项目绝对路径) 前 16 位`。 和 ZCode 原生记忆的算法一致,所以 ZCode 旧数据可以原样拷进来,目录名都不用改。

配置

代码里不写死任何路径,机器相关的东西全放一个配置文件,不进 git:

  • 查找顺序:$SHARED_MEMORY_CONFIG 指向的文件 → ~/.config/global-shared-memory/config.json → 源码目录 src/ 下的 config.json
  • 模板见 src/config.example.json,复制一份到 ~/.config/global-shared-memory/config.json 再改成自己的路径:
{
  "memoryRoot": "/绝对路径/到/memory",
  "toolDir": "/绝对路径/到/本仓库",
  "agents": {
    "claude": "claude",
    "codex": "/Applications/ChatGPT.ap