Smart Memory Guard
智能记忆管理 — 防膨胀、防漂移、分类写入。解决记忆文件无限增长、过时记忆误导行动、什么都记导致噪音太多的问题。适用于所有 OpenClaw Agent。触发条件:(1) 写入 MEMORY.md 前自动执行分类检查 (2) 基于记忆行动前验证漂移 (3) heartbeat 时检查膨胀 (4) 被主人说"记忆太乱了"时。灵感源自 Claude Code Memory 系统设计。
Install
npx skills add kadaliao/claude-code-skills-collection --skill smart-memory-guardgit clone --depth 1 https://github.com/kadaliao/claude-code-skills-collection.git /tmp/claude-code-skills-collection
mkdir -p ~/.claude/skills
cp -r /tmp/claude-code-skills-collection/smart-memory-guard ~/.claude/skills/smart-memory-guardPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Smart Memory Guard
## 一、记忆四类型分类
写入记忆前,先判断属于哪一类:
| 类型 | 内容 | 示例 |
|---|---|---|
| `user` | 主人的角色/偏好/知识/习惯 | "bobooo 偏好 CC 做复杂任务" |
| `feedback` | 主人的纠正/确认 | "不要自动规划任务" |
| `project` | 进行中的项目/目标/决策 | "ClawHunt 内测中" |
| `reference` | 外部系统/工具的指针 | "RunningHub API Key 在 personal-secrets.json" |
## 二、绝对不记的内容(NOT-to-save 列表)
以下内容**即使主人说"记住"也不存入 MEMORY.md**:
- ❌ 代码模式/架构/文件结构 — `grep`/`find` 可以查
- ❌ Git 历史/谁改了什么 — `git log`/`git blame` 权威
- ❌ 调试方案/修复步骤 — fix 在代码里,commit message 有上下文
- ❌ AGENTS.md / SOUL.md 已有内容 — 不要重复
- ❌ 临时任务状态/当前对话细节 — 完成后无价值
- ❌ 活动日志/PR列表汇总 — 问"哪部分出乎意料?",记那个
**主人说"记住这个 PR 列表"** → 不记列表本身,问"哪个发现是意外的?" → 记那个发现
## 三、反馈记忆必须带 Why
纠正/确认记录格式:
```
### [日期] 标题
- 规则: 具体做法
- **Why:** 原因(主人为什么这么说,什么事故/偏好导致的)
- **How to apply:** 在什么场景下应用这条规则
```
没有 Why 的反馈记忆 = 盲从规则,遇到边界情况会做错。
## 四、记忆漂移防护
**基于记忆行动前,必须验证:**
| 记忆内容 | 验证方式 |
|---|---|
| 提到文件路径 | 检查文件是否存在 |
| 提到函数/变量名 | grep 确认是否还在 |
| 提到 API/服务地址 | curl 测试是否可达 |
| 项目状态描述 | 对照当前代码/环境 |
> "记忆说 X 存在" ≠ "X 现在存在"
**记忆与当前观察矛盾时** → 信当前,更新或删除旧记忆
## 五、膨胀检查(Heartbeat 时执行)
1. 检查 MEMORY.md 大小,超过 5KB 触发瘦身
2. 瘦身优先级:
- 已完成任务 → 删除或归档
- 超过 7 天的对话摘要 → 精简合并
- 已晋升到 AGENTS.md 的纠正 → 删除
- 代码模式/架构描述 → 删除(违反 NOT-to-save)
3. 永不删除:用户偏好、工作习惯、角色定位
## 六、写入决策树
```
收到新信息
├─ 是代码/git/调试信息? → ❌ 不记
├─ 已在 AGENTS.md/SOUL.md 中? → ❌ 不记
├─ 是纠正/确认? → ✅ feedback(带 Why + How to apply)
├─ 是主人偏好/角色? → ✅ user
├─ 是项目进展/决策? → ✅ project
├─ 是外部系统指针? → ✅ reference
└─ 不确定? → 问自己"6个月后这条还有用吗?"
├─ 有 → 记
└─ 没有 → 不记
```Details
- Skill name
smart-memory-guard- Repository
- kadaliao/claude-code-skills-collection
- Path
smart-memory-guard/SKILL.md- Repo updated
- 31 March 2026
FAQ
What does the Smart Memory Guard skill do?
智能记忆管理 — 防膨胀、防漂移、分类写入。解决记忆文件无限增长、过时记忆误导行动、什么都记导致噪音太多的问题。适用于所有 OpenClaw Agent。触发条件:(1) 写入 MEMORY.md 前自动执行分类检查 (2) 基于记忆行动前验证漂移 (3) heartbeat 时检查膨胀 (4) 被主人说"记忆太乱了"时。灵感源自 Claude Code Memory 系统设计。
How do I install the Smart Memory Guard skill?
skills CLI (Claude Code, Cursor, Codex and more): npx skills add kadaliao/claude-code-skills-collection --skill smart-memory-guard. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Smart Memory Guard popular?
It lives in kadaliao/claude-code-skills-collection, which has 9 GitHub stars and 8 forks.
Related skills
Adversarial Verification
9kadaliao/claude-code-skills-collection
对抗性验证技能 — 验证代码变更/部署/任务交付物的正确性。不是确认"它能工作",而是尝试"把它搞坏"。用于:(1) 完成非平凡任务后自验 (2) 审查 PR/MR (3) 部署后验证 (4) bobooo 说"验证一下"。灵感源自 Claude Code Verification Agent 设计。
Coordinator Orchestrator
9kadaliao/claude-code-skills-collection
多 Agent 协调者模式 — 你是指挥官,不是执行者。调度 Worker 做研究/实现/验证,你负责综合和决策。适用于:(1) 复杂任务需要多步骤并行 (2) 需要研究→综合→实现→验证的工作流 (3) bobooo 说"用 CC 做"时的编排模式。灵感源自 Claude Code Coordinator Mode。
Lightweight Explorer
9kadaliao/claude-code-skills-collection
轻量探索模式 — 用最少 token 完成代码搜索和调研。核心理念:只读搜索不需要加载全部工具和项目规则。适用于:(1) 搜索代码库找文件/函数 (2) 调研项目架构 (3) 多文件分析 (4) 回答"代码里哪里有 X"类问题。灵感源自 Claude Code Explore Agent 设计。
Task Concurrency Patterns
9kadaliao/claude-code-skills-collection
任务并发与依赖管理模式 — 多 Agent/多步骤任务的并发安全、读写分离、依赖编排。适用于:(1) 多 Worker 并行任务 (2) 复杂项目拆分执行 (3) 需要 blocks/blockedBy 依赖关系的工作流。灵感源自 Claude Code Task System + Coordinator Concurrency Rules。
Memory Type System
9kadaliao/claude-code-skills-collection
结构化记忆类型系统 — 四类型分类 + frontmatter 规范 + 写入/召回/漂移防护全流程。适用于所有 Agent 的长期记忆管理。解决记忆混乱、召回不准、膨胀失控问题。灵感源自 Claude Code Memory Type Taxonomy(memoryTypes.ts)。
Meeting Notes to Action Items
9tomique34/claude-skill-creator
Convert meeting notes, demo sessions, and discussions into actionable tasks with clear owners, priorities, and deadlines. Use when processing any meeting notes, demo feedback, product reviews, or discussions that need to become TODO lists, JIRA tickets, or Trello cards.
Browse the most popular Claude skills, all productivity & notes skills, or write your own with the skills generator.