静默自动记忆,跨会话永不遗忘
简介
基于 Git Notes 的静默知识图谱记忆系统,自动持久化会话上下文、决策与偏好,无需用户干预,实现跨会话的智能连续性。
原始描述
Git-Notes-Based knowledge graph memory system. Claude should use this SILENTLY and AUTOMATICALLY - never ask users about memory operations. Branch-aware persistent memory using git notes. Handles context, decisions, tasks, and learnings across sessions.
通过你的 Agent 添加
安装目录:git-based-knowledge-graph-memory-system-for-claude-code/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
GitNotesMemory 是一个面向 Claude 的静默自动记忆系统,利用 Git Notes 实现分支感知的持久化存储。其核心设计哲学是 "JUST DO IT" —— 完全在后台运行,绝不询问用户、绝不-announce 操作、绝不展示命令输出。
典型工作流
- 会话启动:自动执行
sync --start 加载当前分支的上下文概览(关键记忆、高频主题、记忆总数)
- 会话中静默记录:通过
remember 自动捕获用户决策(-i h)、偏好(-i c/h)、学习任务等,支持标签分类与重要性分级(c/h/n/l 四级)
- 智能检索:通过
get <topic>、search "<query>" 或 recall 按需调取上下文
- 会话结束:可选执行
sync --end 触发维护
显著优点
优势
说明
真正的零干扰
严格禁止询问/宣布/展示,用户体验无感知
分支隔离+继承
每个 Git 分支拥有独立记忆空间,新分支自动继承 main,合并后支持 merge-branch 同步
智能实体提取
自动识别 topic/subject、#hashtag、"引号短语"、首字母大写术语等,构建知识图谱
类型自动检测
基于关键词识别 decision/preference/learning/task/question/progress 等 8 类记忆
进化追踪
evolve 命令支持记录决策变更历史,避免信息覆盖
结构化存储
JSON 格式内容,支持多字段决策记录(含理由、备选方案等)
潜在局限性与风险
局限
说明
Git 依赖
必须在 Git 仓库内运行,非 Git 项目无法使用
路径配置
需正确配置 $SKILL_PATH 和 $DIR,配置错误导致失效
静默失效难察觉
若命令执行失败,用户和 Claude 均无法感知,可能导致"失忆"
分支混淆风险
频繁切换分支若未及时 sync --start,可能加载错误上下文
重要性主观性
-i c/h/n/l 分级依赖 Claude 判断,存在误判可能
隐私边界模糊
文档未明确说明敏感信息(密码、API key)的自动过滤机制,存在泄露风险
适合人群
- 长期项目协作:需要跨数周/数月维持上下文连续性的开发者
- 多分支并行工作:在 feature 分支间切换、需要隔离+合并记忆的场景
- 高上下文依赖任务:复杂架构决策、逐步演进的系统设计讨论
常规风险
- 过度记忆:缺乏明确的存储上限与自动清理策略(仅
-i l 可修剪),长期项目可能累积冗余
- 检索噪声:实体提取的自动化可能索引过多无意义术语,降低检索精度
- 分支遗留:已删除的 Git 分支若未清理对应 notes,造成存储浪费
- Claude 幻觉干扰:若记忆内容与当前实际代码状态脱节,可能导致基于过时信息的错误建议
sync --start 加载当前分支的上下文概览(关键记忆、高频主题、记忆总数)remember 自动捕获用户决策(-i h)、偏好(-i c/h)、学习任务等,支持标签分类与重要性分级(c/h/n/l 四级)get <topic>、search "<query>" 或 recall 按需调取上下文sync --end 触发维护| 优势 | 说明 |
|---|---|
| 真正的零干扰 | 严格禁止询问/宣布/展示,用户体验无感知 |
| 分支隔离+继承 | 每个 Git 分支拥有独立记忆空间,新分支自动继承 main,合并后支持 merge-branch 同步 |
| 智能实体提取 | 自动识别 topic/subject、#hashtag、"引号短语"、首字母大写术语等,构建知识图谱 |
| 类型自动检测 | 基于关键词识别 decision/preference/learning/task/question/progress 等 8 类记忆 |
| 进化追踪 | evolve 命令支持记录决策变更历史,避免信息覆盖 |
| 结构化存储 | JSON 格式内容,支持多字段决策记录(含理由、备选方案等) |
潜在局限性与风险
局限
说明
Git 依赖
必须在 Git 仓库内运行,非 Git 项目无法使用
路径配置
需正确配置 $SKILL_PATH 和 $DIR,配置错误导致失效
静默失效难察觉
若命令执行失败,用户和 Claude 均无法感知,可能导致"失忆"
分支混淆风险
频繁切换分支若未及时 sync --start,可能加载错误上下文
重要性主观性
-i c/h/n/l 分级依赖 Claude 判断,存在误判可能
隐私边界模糊
文档未明确说明敏感信息(密码、API key)的自动过滤机制,存在泄露风险
适合人群
- 长期项目协作:需要跨数周/数月维持上下文连续性的开发者
- 多分支并行工作:在 feature 分支间切换、需要隔离+合并记忆的场景
- 高上下文依赖任务:复杂架构决策、逐步演进的系统设计讨论
常规风险
- 过度记忆:缺乏明确的存储上限与自动清理策略(仅
-i l 可修剪),长期项目可能累积冗余
- 检索噪声:实体提取的自动化可能索引过多无意义术语,降低检索精度
- 分支遗留:已删除的 Git 分支若未清理对应 notes,造成存储浪费
- Claude 幻觉干扰:若记忆内容与当前实际代码状态脱节,可能导致基于过时信息的错误建议
| 局限 | 说明 |
|---|---|
| Git 依赖 | 必须在 Git 仓库内运行,非 Git 项目无法使用 |
| 路径配置 | 需正确配置 $SKILL_PATH 和 $DIR,配置错误导致失效 |
| 静默失效难察觉 | 若命令执行失败,用户和 Claude 均无法感知,可能导致"失忆" |
| 分支混淆风险 | 频繁切换分支若未及时 sync --start,可能加载错误上下文 |
| 重要性主观性 | -i c/h/n/l 分级依赖 Claude 判断,存在误判可能 |
| 隐私边界模糊 | 文档未明确说明敏感信息(密码、API key)的自动过滤机制,存在泄露风险 |
- 长期项目协作:需要跨数周/数月维持上下文连续性的开发者
- 多分支并行工作:在 feature 分支间切换、需要隔离+合并记忆的场景
- 高上下文依赖任务:复杂架构决策、逐步演进的系统设计讨论
常规风险
- 过度记忆:缺乏明确的存储上限与自动清理策略(仅
-i l 可修剪),长期项目可能累积冗余
- 检索噪声:实体提取的自动化可能索引过多无意义术语,降低检索精度
- 分支遗留:已删除的 Git 分支若未清理对应 notes,造成存储浪费
- Claude 幻觉干扰:若记忆内容与当前实际代码状态脱节,可能导致基于过时信息的错误建议
-i l 可修剪),长期项目可能累积冗余技能正文
name: git-notes-memory
description: Git-Notes-Based knowledge graph memory system. Claude should use this SILENTLY and AUTOMATICALLY - never ask users about memory operations. Branch-aware persistent memory using git notes. Handles context, decisions, tasks, and learnings across sessions.
GitNotesMemory - Claude Integration Guide
CRITICAL: SILENT OPERATION RULES
CRITICAL: SILENT OPERATION RULES
These rules are ABSOLUTE and must NEVER be violated:
- NEVER ask "should I remember?" or "want me to save?"
- NEVER announce "I'll remember this" or "saving to memory"
- NEVER show memory command output to users
- NEVER mention memory system unless user explicitly asks about it
- JUST DO IT - silently in the background
Quick Reference
# Replace $SKILL_PATH with actual path to memory.py
# Replace $DIR with the project directory path
python3 $SKILL_PATH/memory.py -p $DIR <command>
Essential Commands
# Replace $SKILL_PATH with actual path to memory.py
# Replace $DIR with the project directory path
python3 $SKILL_PATH/memory.py -p $DIR <command>
| Command | When to Use |
|---|---|
sync --start |
ALWAYS at session start |
sync --end '{"summary":"..."}' |
At session end (optional but recommended) |
remember '{"..."}' -t tags -i h |
Store important information |
get <topic> |
Retrieve context about a topic |
search "<query>" |
Full-text search across all memories |
recall -i <id> |
Get full details of a specific memory |
Importance Flags
Flag
Level
When to Use
-i c
Critical
User says "always remember", "never forget", explicit preferences
-i h
High
Decisions, architecture choices, user corrections, preferences
-i n
Normal
General information (default)
-i l
Low
Temporary notes, might be pruned
Session Lifecycle
1. Session Start (MANDATORY)
| Flag | Level | When to Use |
|---|---|---|
-i c |
Critical | User says "always remember", "never forget", explicit preferences |
-i h |
High | Decisions, architecture choices, user corrections, preferences |
-i n |
Normal | General information (default) |
-i l |
Low | Temporary notes, might be pruned |
1. Session Start (MANDATORY)
Always run sync --start at the beginning of every session:
python3 $SKILL_PATH/memory.py -p $DIR sync --start
Output explains:
{
"b": "main", // Current git branch
"t": {"api": 5, "auth": 3}, // Top topics with memory counts
"c": [...], // Critical memories (always review these)
"n": 42, // Total memory count
"h": [...] // High-importance recent memories
}
Use this context to:
- Understand what the user has been working on
- Reference previous decisions
- Maintain continuity across sessions
2. During Session
Silently remember when user:
- Makes a decision: "Let's use PostgreSQL" → remember with
-i h - States a preference: "I prefer tabs over spaces" → remember with
-i hor-i c - Learns something: "Oh, so that's how async works" → remember with
-i n - Sets a task: "We need to fix the login bug" → remember with
-i n - Shares important context: Project requirements, constraints, goals
Retrieve context when:
- User asks about something previously discussed →
get <topic> - You need to recall a specific decision →
search "<keywords>" - User references "what we decided" → check relevant memories
3. Session End (Recommended)
python3 $SKILL_PATH/memory.py -p $DIR sync --end '{"summary": "Brief session summary"}'
Memory Content Best Practices
Good Memory Structure
python3 $SKILL_PATH/memory.py -p $DIR sync --end '{"summary": "Brief session summary"}'
Good Memory Structure
For decisions:
{"decision": "Use React for frontend", "reason": "Team expertise", "alternatives": ["Vue", "Angular"]}
For preferences:
{"preference": "Detailed explanations", "context": "User prefers thorough explanations over brief answers"}
For learnings:
{"topic": "Authentication", "learned": "OAuth2 flow requires redirect URI configuration"}
For tasks:
{"task": "Implement user dashboard", "status": "in progress", "blockers": ["API not ready"]}
For notes:
{"subject": "Project Architecture", "note": "Microservices pattern with API gateway"}
Tags
Use tags to categorize memories for better retrieval:
-t architecture,backend- Technical categories-t urgent,bug- Priority/type markers-t meeting,requirements- Source context
Command Reference
Core Commands
sync --start
Initialize session, get context overview.
python3 $SKILL_PATH/memory.py -p $DIR sync --start
sync --end
End session with summary (triggers maintenance).
python3 $SKILL_PATH/memory.py -p $DIR sync --end '{"summary": "Implemented auth flow"}'
remember
Store a new memory.
python3 $SKILL_PATH/memory.py -p $DIR remember '{"key": "value"}' -t tag1,tag2 -i h
get
Get memories related to a topic (searches entities, tags, and content).
python3 $SKILL_PATH/memory.py -p $DIR get authentication
search
Full-text search across all memories.
python3 $SKILL_PATH/memory.py -p $DIR search "database migration"
recall
Retrieve memories by various criteria.
# Get full memory by ID
python3 $SKILL_PATH/memory.py -p $DIR recall -i abc123
# Get memories by tag
python3 $SKILL_PATH/memory.py -p $DIR recall -t architecture
# Get last N memories
python3 $SKILL_PATH/memory.py -p $DIR recall --last 5
# Overview of all memories
python3 $SKILL_PATH/memory.py -p $DIR recall
Update Commands
update
updateModify an existing memory.
# Replace content
python3 $SKILL_PATH/memory.py -p $DIR update <id> '{"new": "content"}'
# Merge content (add to existing)
python3 $SKILL_PATH/memory.py -p $DIR update <id> '{"extra": "field"}' -m
# Change importance
python3 $SKILL_PATH/memory.py -p $DIR update <id> -i c
# Update tags
python3 $SKILL_PATH/memory.py -p $DIR update <id> -t newtag1,newtag2
evolve
Add an evolution note to track changes over time.
python3 $SKILL_PATH/memory.py -p $DIR evolve <id> "User changed preference to dark mode"
forget
Delete a memory (use sparingly).
python3 $SKILL_PATH/memory.py -p $DIR forget <id>
Entity Commands
entities
entitiesList all extracted entities with counts.
python3 $SKILL_PATH/memory.py -p $DIR entities
entity
Get details about a specific entity.
python3 $SKILL_PATH/memory.py -p $DIR entity authentication
Branch Commands
branches
branchesList all branches with memory counts.
python3 $SKILL_PATH/memory.py -p $DIR branches
merge-branch
Merge memories from another branch (run after git merge).
python3 $SKILL_PATH/memory.py -p $DIR merge-branch feature-auth
Branch Awareness
How It Works
- Each git branch has isolated memory storage
- New branches automatically inherit from main/master
- After git merge, run
merge-branchto combine memories
Branch Workflow
1. User on main branch → memories stored in refs/notes/mem-main
2. User creates feature branch → auto-inherits main's memories
3. User works on feature → new memories stored in refs/notes/mem-feature-xxx
4. After git merge → run merge-branch to combine memories
Memory Types (Auto-Detected)
1. User on main branch → memories stored in refs/notes/mem-main
2. User creates feature branch → auto-inherits main's memories
3. User works on feature → new memories stored in refs/notes/mem-feature-xxx
4. After git merge → run merge-branch to combine memories
The system automatically classifies memories based on content:
| Type | Trigger Words |
|---|---|
decision |
decided, chose, picked, selected, opted, going with |
preference |
prefer, favorite, like best, rather, better to |
learning |
learned, studied, understood, realized, discovered |
task |
todo, task, need to, plan to, next step, going to |
question |
wondering, curious, research, investigate, find out |
note |
noticed, observed, important, remember that |
progress |
completed, finished, done, achieved, milestone |
info |
(default for unclassified content) |
Entity Extraction
Entities are automatically extracted for intelligent retrieval:
- Explicit fields:
topic,subject,name,category,area,project - Hashtags:
#cooking,#urgent,#v2 - Quoted phrases:
"machine learning","user authentication" - Capitalized words:
React,PostgreSQL,Monday - Key terms: Meaningful words (common words filtered out)
What to Remember
DO remember:
- User decisions and their rationale
- Stated preferences (coding style, communication style, tools)
- Project architecture and constraints
- Important context that affects future work
- Tasks, blockers, and progress
- Corrections ("actually, I meant..." → high importance)
- Explicit requests to remember something → critical importance
DON'T remember:
- Trivial conversation
- Information easily derivable from code
- Secrets, passwords, API keys
- One-time questions with no future relevance
- Duplicate information already stored
Output Format Reference
Tier 0: sync --start
{
"b": "feature-auth", // Current branch
"t": {"auth": 5, "api": 3, "db": 2}, // Topics with counts
"c": [{"id": "x", "s": "summary", "t": "preference"}], // Critical
"n": 15, // Total count
"h": [{"id": "y", "s": "summary"}] // High importance
}
Tier 1: get/search
{
"topic": "auth",
"mem": [
{"id": "abc", "s": "decided OAuth2", "t": "decision", "i": "h", "b": "main"}
]
}
Tier 2: recall -i
{
"d": {"decision": "Use OAuth2"}, // Full data
"e": ["auth", "oauth2"], // Entities
"t": "decision", // Type
"g": ["architecture"], // Tags
"i": "h", // Importance
"b": "main", // Branch
"c": "2024-01-15T10:30:00", // Created
"u": "2024-01-15T10:30:00", // Updated
"a": 3, // Access count
"ev": [{"n": "note", "t": "..."}] // Evolution notes (if any)
}
Example Silent Flow
User: "Let's build a REST API with Python"
Claude: [silently: remember '{"decision": "REST API", "language": "Python"}' -t architecture -i h]
[responds about REST API setup WITHOUT mentioning memory]
User: "I prefer FastAPI over Flask"
Claude: [silently: remember '{"preference": "FastAPI over Flask", "reason": "user preference"}' -i h]
[continues discussion using FastAPI WITHOUT saying "I'll remember"]
User: "What did we decide about the API?"
Claude: [silently: get api]
[uses retrieved context to answer accurately]
User: "Actually, let's use Flask instead"
Claude: [silently: remember '{"decision": "Changed to Flask", "previous": "FastAPI"}' -i h]
[silently: evolve <fastapi-memory-id> "User changed preference to Flask"]
[acknowledges change WITHOUT mentioning memory update]
Troubleshooting
{
"topic": "auth",
"mem": [
{"id": "abc", "s": "decided OAuth2", "t": "decision", "i": "h", "b": "main"}
]
}
{
"d": {"decision": "Use OAuth2"}, // Full data
"e": ["auth", "oauth2"], // Entities
"t": "decision", // Type
"g": ["architecture"], // Tags
"i": "h", // Importance
"b": "main", // Branch
"c": "2024-01-15T10:30:00", // Created
"u": "2024-01-15T10:30:00", // Updated
"a": 3, // Access count
"ev": [{"n": "note", "t": "..."}] // Evolution notes (if any)
}
Example Silent Flow
User: "Let's build a REST API with Python"
Claude: [silently: remember '{"decision": "REST API", "language": "Python"}' -t architecture -i h]
[responds about REST API setup WITHOUT mentioning memory]
User: "I prefer FastAPI over Flask"
Claude: [silently: remember '{"preference": "FastAPI over Flask", "reason": "user preference"}' -i h]
[continues discussion using FastAPI WITHOUT saying "I'll remember"]
User: "What did we decide about the API?"
Claude: [silently: get api]
[uses retrieved context to answer accurately]
User: "Actually, let's use Flask instead"
Claude: [silently: remember '{"decision": "Changed to Flask", "previous": "FastAPI"}' -i h]
[silently: evolve <fastapi-memory-id> "User changed preference to Flask"]
[acknowledges change WITHOUT mentioning memory update]
Troubleshooting
User: "Let's build a REST API with Python"
Claude: [silently: remember '{"decision": "REST API", "language": "Python"}' -t architecture -i h]
[responds about REST API setup WITHOUT mentioning memory]
User: "I prefer FastAPI over Flask"
Claude: [silently: remember '{"preference": "FastAPI over Flask", "reason": "user preference"}' -i h]
[continues discussion using FastAPI WITHOUT saying "I'll remember"]
User: "What did we decide about the API?"
Claude: [silently: get api]
[uses retrieved context to answer accurately]
User: "Actually, let's use Flask instead"
Claude: [silently: remember '{"decision": "Changed to Flask", "previous": "FastAPI"}' -i h]
[silently: evolve <fastapi-memory-id> "User changed preference to Flask"]
[acknowledges change WITHOUT mentioning memory update]
Memory not found:
- Use
searchwith different keywords - Check
entitiesto see what's indexed - Use
recall --last 10to see recent memories
Context seems stale:
- Always run
sync --startat session beginning - Check current branch with
branches
After git operations:
- After
git merge: runmerge-branch <source-branch> - After
git checkout:sync --startwill load correct branch context
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。