memory-system

脚本路径: ~/.claude/skills/public/memory-system/scripts/memory.py

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "memory-system" with this command: npx skills add bahayonghang/my-claude-code-settings/bahayonghang-my-claude-code-settings-memory-system

Memory System

脚本路径: ~/.claude/skills/public/memory-system/scripts/memory.py

环境要求

首次使用前,请安装 Python 依赖:

pip3 install sentence-transformers numpy

  • 嵌入模型: all-MiniLM-L6-v2 (~80MB,首次运行自动下载)

  • Python: 3.10+

  • SQLite: 内置,FTS5 可选(增强全文搜索)

自动行为

当用户说"搜索记忆"或"在记忆中查找 X"

python3 ~/.claude/skills/public/memory-system/scripts/memory.py search "用户的查询"
--db ./memory/memory.sqlite --json --top 6

读取 JSON 结果后,用搜索到的上下文回答用户问题。如果数据库不存在,先执行索引。

当用户说"记住这个"或"添加到记忆"

将内容写入 memory/ 目录的 .md 文件:

python3 ~/.claude/skills/public/memory-system/scripts/memory.py add "内容"
--file 合适的文件名.md --dir ./memory --db ./memory/memory.sqlite

当用户说"索引记忆"或"更新记忆索引"

python3 ~/.claude/skills/public/memory-system/scripts/memory.py index
--dir ./memory --db ./memory/memory.sqlite

可选:通过 --memory-file 指定额外索引的文件:

python3 ~/.claude/skills/public/memory-system/scripts/memory.py index
--dir ./memory --db ./memory/memory.sqlite --memory-file ./MEMORY.md

当用户说"记忆状态"或"memory status"

python3 ~/.claude/skills/public/memory-system/scripts/memory.py status
--db ./memory/memory.sqlite -v

当用户说"清理记忆"

python3 ~/.claude/skills/public/memory-system/scripts/memory.py cleanup
--days 90 --dir ./memory --force

注意事项

  • ./memory/ 和 --db 路径相对于项目工作目录

  • 索引是增量的(SHA256 哈希比对),重复运行不会重新处理未变化的文件

  • 搜索使用混合策略:向量相似度(70%) + 全文匹配(30%)

  • --json 输出适合程序解析,不加则人类可读

  • 详细配置参考: references/config.md

常见问题

问题 解决方案

ModuleNotFoundError: sentence_transformers

运行 pip3 install sentence-transformers numpy

ModuleNotFoundError: numpy

运行 pip3 install numpy

搜索无结果 先运行 index 命令建立索引

FTS5 不可用 不影响使用,向量搜索仍可工作,仅全文搜索降级

索引后数据库损坏 删除 .sqlite 文件后重新索引

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

tech-design-doc

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

article-cover

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

tech-blog

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

excalidraw

No summary provided by upstream source.

Repository SourceNeeds Review