memory-management
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMemory Management
记忆管理
Persistent memory system that ensures Claude never repeats mistakes and always applies learned patterns across conversations.
持久化记忆系统,确保Claude在跨对话过程中不会重复犯错,并且始终应用已习得的模式。
2 Tools Only
仅包含2个工具
- - Load all active rules before starting work. No query needed.
mcp__claude-recall__load_rules - - Store a rule or learning. Immediately active in this conversation.
mcp__claude-recall__store_memory
- - 开始工作前加载所有活跃规则。无需查询。
mcp__claude-recall__load_rules - - 存储规则或习得的知识。在本次对话中立即生效。
mcp__claude-recall__store_memory
When to Use
使用场景
- Starting any task - Call before Write, Edit, or significant Bash operations
load_rules - When user corrects your work - Call with
store_memorymetadata.type: "correction" - When user mentions preferences - Call with
store_memorymetadata.type: "preference" - After overcoming a challenge - Call with
store_memorymetadata.type: "failure" - DevOps/workflow rules - Call with
store_memorymetadata.type: "devops"
- 开始任何任务 - 执行编写、编辑或重要Bash操作前调用
load_rules - 用户纠正你的工作时 - 调用并设置
store_memorymetadata.type: "correction" - 用户提及偏好时 - 调用并设置
store_memorymetadata.type: "preference" - 完成克服了挑战的任务时 - 调用并设置
store_memorymetadata.type: "failure" - DevOps/工作流规则 - 调用并设置
store_memorymetadata.type: "devops"
Key Directives
核心指令
- ALWAYS load rules before acting - Call before Write, Edit, or significant Bash operations
load_rules - Apply what you find - Use retrieved preferences, patterns, and corrections
- Ask before storing - Before calling , briefly tell the user what you plan to store and ask for confirmation. Example: "I'd like to remember that you prefer tabs over spaces. Store this?" Only call the tool after the user agrees.
store_memory - Capture corrections immediately - User fixes are highest priority (still ask first)
- Store learning cycles - When you fail then succeed, that's valuable knowledge
- Never store secrets - No API keys, passwords, tokens, or PII
- 执行前务必加载规则 - 执行编写、编辑或重要Bash操作前必须调用
load_rules - 应用检索到的内容 - 使用检索到的偏好、模式和纠正内容
- 存储前先询问 - 在调用前,简要告知用户你计划存储的内容并请求确认。示例:"我想记录你偏好使用制表符而非空格。是否存储?" 仅在用户同意后调用该工具。
store_memory - 立即捕获修正内容 - 用户的修正内容优先级最高(仍需先询问)
- 存储学习周期 - 当你从失败到成功时,这是有价值的知识
- 绝不存储机密信息 - 不得存储API密钥、密码、令牌或个人身份信息(PII)
Quick Reference
快速参考
Load Rules (Before Every Task)
加载规则(每项任务前执行)
mcp__claude-recall__load_rules({})Returns all active preferences, corrections, failures, and devops rules in one call. Deterministic and complete.
mcp__claude-recall__load_rules({})一次调用返回所有活跃的偏好、修正、失败经验和DevOps规则。结果确定且完整。
Store Memory (When Something Important Happens)
存储记忆(发生重要事件时)
mcp__claude-recall__store_memory({
"content": "Description of what to remember",
"metadata": { "type": "preference|correction|devops|failure" }
})Returns the stored rule with an field and to apply it immediately. No need to call again.
activeRule_directiveload_rulesmcp__claude-recall__store_memory({
"content": "Description of what to remember",
"metadata": { "type": "preference|correction|devops|failure" }
})返回包含字段和的已存储规则,指示立即应用该规则。无需再次调用。
activeRule_directiveload_rulesSame-Session Rules
同会话规则
When you call , the response includes:
store_memory- : The stored content formatted as a rule
activeRule - : Instructions to apply the rule immediately
_directive
This means rules stored mid-conversation are active right away without reloading.
当你调用时,响应包含:
store_memory- : 格式化为规则的已存储内容
activeRule - : 立即应用该规则的指令
_directive
这意味着在对话过程中存储的规则会立即生效,无需重新加载。
What Gets Stored
可存储内容
Automatic Capture (You Don't Need to Store)
自动捕获(无需手动存储)
The system auto-captures when users say:
- "I prefer X" / "Always use X" / "Never do X" -> Preferences
- "We use X for Y" / "Tests go in X" -> Project conventions
- "This is a [type] project" -> Project context
当用户说出以下内容时,系统会自动捕获:
- "我偏好X" / "始终使用X" / "永远不要做X" -> 偏好设置
- "我们用X做Y" / "测试放在X中" -> 项目约定
- "这是一个[类型]项目" -> 项目上下文
Manual Storage Required
需要手动存储
Store these explicitly:
Corrections (highest priority):
User: "No, put tests in __tests__/ not tests/"
-> Store: "CORRECTION: Test files go in __tests__/ directory, not tests/"
metadata: { "type": "correction" }Complex workflows:
-> Store: "Deploy process: 1) npm test 2) docker build 3) push to ECR 4) kubectl apply"
metadata: { "type": "devops" }Learning cycles (fail -> fix -> success):
-> Store: "REST API failed due to CORS. Solution: Use GraphQL endpoint instead."
metadata: { "type": "failure" }修正内容(最高优先级):
User: "No, put tests in __tests__/ not tests/"
-> Store: "CORRECTION: Test files go in __tests__/ directory, not tests/"
metadata: { "type": "correction" }复杂工作流:
-> Store: "Deploy process: 1) npm test 2) docker build 3) push to ECR 4) kubectl apply"
metadata: { "type": "devops" }学习周期(失败->修复->成功):
-> Store: "REST API failed due to CORS. Solution: Use GraphQL endpoint instead."
metadata: { "type": "failure" }Memory Priority Order
记忆优先级顺序
- Corrections - User explicitly fixed a mistake (HIGHEST)
- DevOps - Git, testing, deploy, architecture patterns
- Preferences - Code style, tool choices, conventions
- Failures - Learning cycles and past mistakes
- 修正内容 - 用户明确指出的错误修正(最高优先级)
- DevOps - Git、测试、部署、架构模式
- 偏好设置 - 代码风格、工具选择、约定
- 失败经验 - 学习周期和过往错误
What NOT to Store
不可存储内容
Never store:
- API keys, tokens, passwords, secrets
- Personal emails, phone numbers, addresses
- Database connection strings with credentials
- Any sensitive configuration values
Safe to store:
- "We use JWT for auth" (pattern, not credentials)
- "API base URL is https://api.example.com" (non-sensitive)
- "PostgreSQL for production, SQLite for tests" (tool choice)
不得存储:
- API密钥、令牌、密码、机密信息
- 个人邮箱、电话号码、地址
- 包含凭证的数据库连接字符串
- 任何敏感配置值
可安全存储:
- "We use JWT for auth"(模式,而非凭证)
- "API base URL is https://api.example.com"(非敏感)
- "PostgreSQL for production, SQLite for tests"(工具选择)
Example Workflows
示例工作流
Starting a New Task
开始新任务
1. User: "Add user authentication"
2. Load rules first:
mcp__claude-recall__load_rules({})
3. Response includes:
## Preferences
- auth_method: JWT with httpOnly cookies
## Corrections
- Never use localStorage for auth tokens
4. Implement using JWT + httpOnly cookies (not sessions, not localStorage)
5. User approves -> Done (no need to store, just applied existing knowledge)1. User: "Add user authentication"
2. Load rules first:
mcp__claude-recall__load_rules({})
3. Response includes:
## Preferences
- auth_method: JWT with httpOnly cookies
## Corrections
- Never use localStorage for auth tokens
4. Implement using JWT + httpOnly cookies (not sessions, not localStorage)
5. User approves -> Done (no need to store, just applied existing knowledge)User Corrects Your Work
用户纠正你的工作
1. You: Created auth with localStorage tokens
2. User: "No, we always use httpOnly cookies for security"
3. Fix the code
4. Ask: "I'd like to remember: always use httpOnly cookies for auth tokens, never localStorage. Store this?"
5. User: "Yes"
6. Store the correction:
mcp__claude-recall__store_memory({
"content": "CORRECTION: Always use httpOnly cookies for auth tokens, never localStorage",
"metadata": { "type": "correction" }
})
7. Response includes activeRule - apply it immediately1. You: Created auth with localStorage tokens
2. User: "No, we always use httpOnly cookies for security"
3. Fix the code
4. Ask: "I'd like to remember: always use httpOnly cookies for auth tokens, never localStorage. Store this?"
5. User: "Yes"
6. Store the correction:
mcp__claude-recall__store_memory({
"content": "CORRECTION: Always use httpOnly cookies for auth tokens, never localStorage",
"metadata": { "type": "correction" }
})
7. Response includes activeRule - apply it immediatelyOvercoming a Challenge
克服挑战
1. Tried: Redis sessions for auth
Failed: "Session sync issues in k8s cluster"
2. User suggested: "Try stateless JWT"
3. Implemented JWT -> Works!
4. Ask: "I'd like to remember: Redis sessions fail in k8s due to sync issues; use stateless JWT instead. Store this?"
5. User: "Yes"
6. Store the learning:
mcp__claude-recall__store_memory({
"content": "Auth in k8s: Redis sessions failed (sync issues). JWT stateless tokens work correctly.",
"metadata": { "type": "failure", "learning_cycle": true }
})1. Tried: Redis sessions for auth
Failed: "Session sync issues in k8s cluster"
2. User suggested: "Try stateless JWT"
3. Implemented JWT -> Works!
4. Ask: "I'd like to remember: Redis sessions fail in k8s due to sync issues; use stateless JWT instead. Store this?"
5. User: "Yes"
6. Store the learning:
mcp__claude-recall__store_memory({
"content": "Auth in k8s: Redis sessions failed (sync issues). JWT stateless tokens work correctly.",
"metadata": { "type": "failure", "learning_cycle": true }
})Inline Citations
内联引用
When returns memories, the response includes a instructing you to cite any memory you actually apply. When you use a retrieved memory in your work, add a brief inline note:
load_rules_citationDirective(applied from memory: always use httpOnly cookies for auth tokens)
This gives the user visibility into which stored knowledge is influencing your decisions. Only cite memories you actually use.
To disable citations, set the environment variable .
CLAUDE_RECALL_CITE_MEMORIES=false当返回记忆内容时,响应包含,指示你引用任何实际应用的记忆。当你在工作中使用检索到的记忆时,添加简短的内联注释:
load_rules_citationDirective(applied from memory: always use httpOnly cookies for auth tokens)
这能让用户了解哪些已存储的知识影响了你的决策。仅引用你实际使用的记忆。
要禁用引用功能,设置环境变量。
CLAUDE_RECALL_CITE_MEMORIES=falseTroubleshooting
故障排除
Load rules returns nothing:
- This may be a new project with no history yet
- Store rules as you learn them with
store_memory
Automatic capture missed something:
- Store it manually with appropriate type
- Future calls will find it
load_rules
The Learning Loop: Load rules -> Apply -> Execute -> Capture outcomes -> Better next time
加载规则返回空内容:
- 这可能是一个尚无历史记录的新项目
- 使用存储你习得的规则
store_memory
自动捕获遗漏了内容:
- 使用合适的类型手动存储
- 后续的调用会找到该内容
load_rules
学习循环:加载规则 -> 应用 -> 执行 -> 捕获结果 -> 下次做得更好