chore: persist memories and excerpts under knowledge/ instead of .claude/

Move documented and skill paths to knowledge/memories and knowledge/files
(project root, mappable to @knowledge) to reduce sandbox issues on .claude/.
Update CLAUDE.md memory protocol, update-mykb-* skills, and settings.local.json
bootstrap check for core.json.

Made-with: Cursor
This commit is contained in:
Zhengshou Lai
2026-04-09 10:36:00 +08:00
parent d63ce56e3f
commit 1bead9a6d8
5 changed files with 25 additions and 23 deletions
+9 -9
View File
@@ -1,7 +1,7 @@
---
name: update-mykb-memories
description: |
Cross-session personal memory: write short, verifiable facts, preferences, and project conventions to .claude/memories (CLAUDE.md protocol); long excerpts go to .claude/files via update-mykb-files. Tone: concise, deduped, no secrets/credentials—matches 简洁直接. Evolves with corrections ("纠正偏好", "以后别…").
Cross-session personal memory: write short, verifiable facts, preferences, and project conventions to knowledge/memories at project root (CLAUDE.md; Cursor @knowledge). Long excerpts go to knowledge/files via update-mykb-files. Avoid .claude/ for writes (sandbox). Tone: concise, deduped, no secrets—matches 简洁直接.
Triggers: update-mykb-memories; 记住/记下来/默认/偏好/沉淀/跨会话; remember this, save preference, persist this, update how you work with me.
---
@@ -10,17 +10,17 @@ description: |
## 目标
- 让 Agent 在**不依赖超长上下文**的情况下,在后续会话中仍能利用已确认有用的信息。
- **短而稳**:一句话事实、用户偏好、命令别名、项目内约定 → `.claude/memories/`
- **长而可搜**:段落、摘录、整理稿 → `.claude/files/`(见 **update-mykb-files**),不要用 `core.json` 塞长文。
- **短而稳**:一句话事实、用户偏好、命令别名、项目内约定 → `knowledge/memories/`
- **长而可搜**:段落、摘录、整理稿 → `knowledge/files/`(见 **update-mykb-files**),不要用 `core.json` 塞长文。
- **随使用收敛**:用户纠正或补充时更新既有条目,避免堆叠矛盾记录,使行为逐渐贴近固定偏好与做事方式。
## 写哪里
| 类型 | 位置 | 说明 |
|------|------|------|
| 核心记忆、偏好、稳定事实 | `.claude/memories/core.json` | 若文件不存在,可创建;必须保持合法 JSON |
| 当前模式等状态 | `.claude/memories/current_mode.json` | 仅在与模式切换相关时更新 |
| 单主题若干句补充 | `.claude/memories/notes/<slug>.md` | 避免把 `core.json` 撑得过大;`slug` 用小写连字符 |
| 核心记忆、偏好、稳定事实 | `knowledge/memories/core.json` | 若文件不存在,可创建;必须保持合法 JSON |
| 当前模式等状态 | `knowledge/memories/current_mode.json` | 仅在与模式切换相关时更新 |
| 单主题若干句补充 | `knowledge/memories/notes/<slug>.md` | 避免把 `core.json` 撑得过大;`slug` 用小写连字符 |
## 何时写入
@@ -35,12 +35,12 @@ description: |
- 顶层对象含 `facts`(字符串数组)与 `preferences`(字符串键值对),或沿用已有键名,**不要**破坏已有字段含义。
2. 合并新条目:去重(同一事实不重复追加);必要时更新而非复制多条矛盾记录。
3. 写回前校验 JSON(引号、逗号、尾随逗号);写回后用 Read 抽查。
4. 若当前仓库将 `.claude/memories` 排除在版本控制外,仍按同样路径写入,便于本机 Agent 加载
4. `knowledge/` 常被 gitignore;仍向上述路径写入,便于本机 Agent 加载。若有旧数据在 `.claude/memories/`,可手工迁移到 `knowledge/memories/`
## 与 update-mykb-files 配合
- 从 PDF/Excel/长文档抽出的**大段原文或详细笔记**:写入 `.claude/files/` 并在 `core.json``notes` 里只保留**一行指针**(文件名 + 用途)。
- 检索时:先 Grep/Read `.claude/files`,短事实读 `core.json` / `notes/`
- 从 PDF/Excel/长文档抽出的**大段原文或详细笔记**:写入 `knowledge/files/` 并在 `core.json``notes` 里只保留**一行指针**(文件名 + 用途)。
- 检索时:先 Grep/Read `knowledge/files`,短事实读 `core.json` / `notes/`
## 回答风格