memory-management

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Memory Management

记忆管理

Persistent memory system that ensures Claude never repeats mistakes and always applies learned patterns across conversations.
持久化记忆系统,确保Claude在跨对话过程中不会重复犯错,并且始终应用已习得的模式。

2 Tools Only

仅包含2个工具

  • mcp__claude-recall__load_rules
    - Load all active rules before starting work. No query needed.
  • mcp__claude-recall__store_memory
    - Store a rule or learning. Immediately active in this conversation.
  • mcp__claude-recall__load_rules
    - 开始工作前加载所有活跃规则。无需查询。
  • mcp__claude-recall__store_memory
    - 存储规则或习得的知识。在本次对话中立即生效。

When to Use

使用场景

  • Starting any task - Call
    load_rules
    before Write, Edit, or significant Bash operations
  • When user corrects your work - Call
    store_memory
    with
    metadata.type: "correction"
  • When user mentions preferences - Call
    store_memory
    with
    metadata.type: "preference"
  • After overcoming a challenge - Call
    store_memory
    with
    metadata.type: "failure"
  • DevOps/workflow rules - Call
    store_memory
    with
    metadata.type: "devops"
  • 开始任何任务 - 执行编写、编辑或重要Bash操作前调用
    load_rules
  • 用户纠正你的工作时 - 调用
    store_memory
    并设置
    metadata.type: "correction"
  • 用户提及偏好时 - 调用
    store_memory
    并设置
    metadata.type: "preference"
  • 完成克服了挑战的任务时 - 调用
    store_memory
    并设置
    metadata.type: "failure"
  • DevOps/工作流规则 - 调用
    store_memory
    并设置
    metadata.type: "devops"

Key Directives

核心指令

  1. ALWAYS load rules before acting - Call
    load_rules
    before Write, Edit, or significant Bash operations
  2. Apply what you find - Use retrieved preferences, patterns, and corrections
  3. Ask before storing - Before calling
    store_memory
    , 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.
  4. Capture corrections immediately - User fixes are highest priority (still ask first)
  5. Store learning cycles - When you fail then succeed, that's valuable knowledge
  6. Never store secrets - No API keys, passwords, tokens, or PII
  1. 执行前务必加载规则 - 执行编写、编辑或重要Bash操作前必须调用
    load_rules
  2. 应用检索到的内容 - 使用检索到的偏好、模式和纠正内容
  3. 存储前先询问 - 在调用
    store_memory
    前,简要告知用户你计划存储的内容并请求确认。示例:"我想记录你偏好使用制表符而非空格。是否存储?" 仅在用户同意后调用该工具。
  4. 立即捕获修正内容 - 用户的修正内容优先级最高(仍需先询问)
  5. 存储学习周期 - 当你从失败到成功时,这是有价值的知识
  6. 绝不存储机密信息 - 不得存储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
activeRule
field and
_directive
to apply it immediately. No need to call
load_rules
again.
mcp__claude-recall__store_memory({
  "content": "Description of what to remember",
  "metadata": { "type": "preference|correction|devops|failure" }
})
返回包含
activeRule
字段和
_directive
的已存储规则,指示立即应用该规则。无需再次调用
load_rules

Same-Session Rules

同会话规则

When you call
store_memory
, the response includes:
  • activeRule
    : The stored content formatted as a rule
  • _directive
    : Instructions to apply the rule immediately
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

记忆优先级顺序

  1. Corrections - User explicitly fixed a mistake (HIGHEST)
  2. DevOps - Git, testing, deploy, architecture patterns
  3. Preferences - Code style, tool choices, conventions
  4. Failures - Learning cycles and past mistakes
  1. 修正内容 - 用户明确指出的错误修正(最高优先级)
  2. DevOps - Git、测试、部署、架构模式
  3. 偏好设置 - 代码风格、工具选择、约定
  4. 失败经验 - 学习周期和过往错误

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密钥、令牌、密码、机密信息
  • 个人邮箱、电话号码、地址
  • 包含凭证的数据库连接字符串
  • 任何敏感配置值
可安全存储:

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 immediately
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 immediately

Overcoming 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
load_rules
returns memories, the response includes a
_citationDirective
instructing you to cite any memory you actually apply. When you use a retrieved memory in your work, add a brief inline note:
(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=false

Troubleshooting

故障排除

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
    load_rules
    calls will find it

The Learning Loop: Load rules -> Apply -> Execute -> Capture outcomes -> Better next time
加载规则返回空内容:
  • 这可能是一个尚无历史记录的新项目
  • 使用
    store_memory
    存储你习得的规则
自动捕获遗漏了内容:
  • 使用合适的类型手动存储
  • 后续的
    load_rules
    调用会找到该内容

学习循环:加载规则 -> 应用 -> 执行 -> 捕获结果 -> 下次做得更好