← 返回 Skills 市场
sinnzen

Memory Hierarchy

作者 Sinnzen · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ✓ 安全检测通过
102
总下载
0
收藏
0
当前安装
2
版本数
在 OpenClaw 中安装
/install memory-hierarchy
功能描述
基于 Claude Code memdir 的三层记忆系统。让 AI 记住用户偏好、反馈、项目上下文、外部系统索引。
使用说明 (SKILL.md)

memory-hierarchy

基于 Claude Code memdir 的三层记忆系统。


什么时候触发

当以下情况发生时,必须使用本 skill:

  • 用户提供了明确的偏好或反馈("这样做,不要那样做")
  • 用户透露了关于自己身份/角色/目标的信息
  • 用户提到项目进展、截止日期、驱动因素
  • 用户告诉外部系统的位置(Linear、Slack、Grafana 等)
  • 用户问"你还记得上次……吗?"

记忆目录结构

memory/                          # 记忆根目录
  user/                          # 用户相关
    yyyy-mm-dd.md               # 按日期保存
  feedback/                      # 反馈/纠正
    yyyy-mm-dd.md
  project/                       # 项目进展/目标
    yyyy-mm-dd.md
  reference/                     # 外部系统索引
    yyyy-mm-dd.md

每条记忆文件格式:

---
name: \x3C简短名称>
description: \x3C一句话描述,用于判断相关性>
type: \x3Cuser | feedback | project | reference>
date: \x3Cyyyy-mm-dd>
---

\x3C记忆内容>

四种记忆类型

1. user(用户)

什么: 用户角色、目标、职责、知识背景 何时保存: 了解到用户的角色、偏好、职责、知识时 结构:

用户说:我是数据科学家,关注日志
→ 保存:user memory: 用户是数据科学家,目前关注可观测性/日志

2. feedback(反馈)

什么: 用户对我工作方式的指导——要避免的 + 要坚持的 何时保存:

  • 用户纠正时("不要那样做"、"停止做 X")
  • 用户确认时("是的"、"完美,继续这样做") 结构:
规则本身
**Why:** (用户给的 이유——通常是因为过去的问题或强烈偏好)
**How to apply:** (何时何地适用这条指导)

3. project(项目)

什么: 正在进行的项目、目标、bug、事件 何时保存: 了解到谁在做什么、为什么、截止时间 注意: 相对日期 → 绝对日期("周四" → "2026-04-03")

4. reference(外部系统)

什么: 外部系统中信息的指针/位置 何时保存: 了解到外部资源及其用途时 示例: "Linear 的 INGEST 项目跟踪所有 pipeline bug" → 保存位置索引


禁止保存的内容

代码模式、架构、文件路径 → 从代码里直接读 ❌ Git 历史、最近改动 → 用 git log / git blame ❌ 调试方案 → 修复在代码里,上下文在 commit message ❌ CLAUDE.md 里已有的内容 → 不要重复 ❌ 临时状态/进行中的工作 → 记忆是长期的


记忆读取流程

  1. 读取 memory/ 下所有 .md 文件
  2. type 分类
  3. description 字段判断相关性
  4. 验证记忆是否仍然有效(检查文件/资源)
  5. 如果记忆与当前状态冲突 → 信任当前状态,更新或删除旧记忆

记忆写入流程

  1. 判断类型(user/feedback/project/reference)
  2. 检查是否已存在相似记忆 → 合并或追加
  3. 写入对应日期文件
  4. 格式:memory/\x3Ctype>/yyyy-mm-dd.md

容量限制

  • MEMORY.md(入口点)限制:200 行 / 25KB
  • 单条记忆文件:保持精简
  • 索引条目:一行 ~200 字符以内
  • 详细说明放到专题文件里

scripts/

scripts/ 目录下是可执行的辅助脚本,用于维护记忆系统。


与 MEMORY.md 的关系

MEMORY.md = 入口点 + 最核心的长期记忆(最多 200 行) memory/ 目录 = 分层记忆仓库(user/feedback/project/reference) CLAUDE.md = 项目级配置和规则(不属于记忆)

三者是递进关系:CLAUDE.md 定义框架,MEMORY.md 是精选,memory/ 是档案库。

安全使用建议
This skill appears to do what it says: manage local markdown memories under a workspace. Before installing: (1) review and, if desired, set MEMORY_WORKSPACE to a directory you control; (2) be aware the agent will read and write persistent files that may contain sensitive user information — avoid saving secrets; (3) consider whether you want the agent to be allowed to invoke this autonomously (it can persist user data across sessions); (4) note minor implementation issues (search.sh uses "$$KEYWORD" which is a bug causing searches to fail, save.sh takes content only as $4 so multi-word content may be truncated) — not security-critical but worth fixing; (5) if you need stricter safety, restrict filesystem permissions on the workspace or inspect and sanitize saved content periodically.
能力评估
Purpose & Capability
Name/description (local memory hierarchy for user/feedback/project/reference) align with what the scripts do: creating a workspace, listing, saving, and searching .md memory files. No unrelated credentials or binaries are requested.
Instruction Scope
SKILL.md and scripts confine operations to a local memory directory. One ambiguity: SKILL.md suggests verifying 'file/resource' validity which could imply checking external systems, but the shipped scripts do not perform any network access. Also the written guidance and scripts permit persistent storage of user-provided content (including potentially sensitive info).
Install Mechanism
Instruction-only skill with small local shell scripts; there is no installer, no downloads, and nothing is written outside the user's workspace/home by default.
Credentials
No credentials or special environment variables are required. The scripts optionally honor MEMORY_WORKSPACE and otherwise use HOME — reasonable and proportionate. Note: the skill will persist user data locally, so sensitive data could be retained if saved.
Persistence & Privilege
Skill writes persistent files under ${MEMORY_WORKSPACE:-$HOME/.openclaw/workspace}/memory; autonomous invocation is allowed by default (platform normal). This combination means the agent can persist state across sessions — expected for a memory skill but important for privacy considerations.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install memory-hierarchy
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /memory-hierarchy 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
安全修复:使用环境变量替代硬编码路径,增加路径遍历防护和白名单校验
v1.0.0
Initial release: Claude Code memdir-inspired 4-type memory system
元数据
Slug memory-hierarchy
版本 1.0.1
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 2
常见问题

Memory Hierarchy 是什么?

基于 Claude Code memdir 的三层记忆系统。让 AI 记住用户偏好、反馈、项目上下文、外部系统索引。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 102 次。

如何安装 Memory Hierarchy?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install memory-hierarchy」即可一键安装,无需额外配置。

Memory Hierarchy 是免费的吗?

是的,Memory Hierarchy 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Memory Hierarchy 支持哪些平台?

Memory Hierarchy 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Memory Hierarchy?

由 Sinnzen(@sinnzen)开发并维护,当前版本 v1.0.1。

💬 留言讨论