Files
myagents/.claude/skills/update-mykb-memories/SKILL.md
T
Zhengshou Lai 1bead9a6d8 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
2026-04-09 10:36:00 +08:00

3.1 KiB
Raw Blame History

name, description
name description
update-mykb-memories 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.

本地记忆沉淀(update-mykb-memories

目标

  • 让 Agent 在不依赖超长上下文的情况下,在后续会话中仍能利用已确认有用的信息。
  • 短而稳:一句话事实、用户偏好、命令别名、项目内约定 → knowledge/memories/
  • 长而可搜:段落、摘录、整理稿 → knowledge/files/(见 update-mykb-files),不要用 core.json 塞长文。
  • 随使用收敛:用户纠正或补充时更新既有条目,避免堆叠矛盾记录,使行为逐渐贴近固定偏好与做事方式。

写哪里

类型 位置 说明
核心记忆、偏好、稳定事实 knowledge/memories/core.json 若文件不存在,可创建;必须保持合法 JSON
当前模式等状态 knowledge/memories/current_mode.json 仅在与模式切换相关时更新
单主题若干句补充 knowledge/memories/notes/<slug>.md 避免把 core.json 撑得过大;slug 用小写连字符

何时写入

  • 用户明确说「记住」「记下来」「以后默认…」。
  • 用户纠正行为或偏好(沟通风格、工具选择、路径约定)。
  • 对话或阅读文件中出现的可验证、会重复用到的项目事实(例如:默认知识库路径、私有脚本入口、环境约束)。
  • 不要写入:一次性任务状态、未经确认的猜测、密钥与隐私。

core.json 操作建议

  1. 用 Read 读完整文件(体量应小);若不存在,从最小结构初始化,例如:
    • 顶层对象含 facts(字符串数组)与 preferences(字符串键值对),或沿用已有键名,不要破坏已有字段含义。
  2. 合并新条目:去重(同一事实不重复追加);必要时更新而非复制多条矛盾记录。
  3. 写回前校验 JSON(引号、逗号、尾随逗号);写回后用 Read 抽查。
  4. knowledge/ 常被 gitignore;仍向上述路径写入,便于本机 Agent 加载。若有旧数据在 .claude/memories/,可手工迁移到 knowledge/memories/

与 update-mykb-files 配合

  • 从 PDF/Excel/长文档抽出的大段原文或详细笔记:写入 knowledge/files/ 并在 core.jsonnotes 里只保留一行指针(文件名 + 用途)。
  • 检索时:先 Grep/Read knowledge/files,短事实读 core.json / notes/

回答风格

  • 写入后可用一句话向用户确认已记录的内容(不含敏感信息)。
  • 若用户只要求「记住」但内容过长,建议拆成:记忆条 + 文件摘录,并说明存放位置。