mem-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMemory Search
内存搜索
Search past work across all sessions. Simple workflow: search -> filter -> fetch.
搜索所有会话中的历史工作内容。简单工作流:搜索 -> 筛选 -> 获取。
When to Use
使用场景
Use when users ask about PREVIOUS sessions (not current conversation):
- "Did we already fix this?"
- "How did we solve X last time?"
- "What happened last week?"
当用户询问过往会话(非当前对话)相关内容时使用:
- "我们已经修复过这个问题了吗?"
- "上次我们是怎么解决X问题的?"
- "上周发生了什么?"
3-Layer Workflow (ALWAYS Follow)
三层工作流(必须严格遵循)
NEVER fetch full details without filtering first. 10x token savings.
绝对不要在未筛选的情况下直接获取完整详情。这样能节省10倍的token消耗。
Step 1: Search - Get Index with IDs
步骤1:搜索 - 获取带ID的索引
Use the MCP tool:
searchsearch(query="authentication", limit=20, project="my-project")Returns: Table with IDs, timestamps, types, titles (~50-100 tokens/result)
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #11131 | 3:48 PM | 🟣 | Added JWT authentication | ~75 |
| #10942 | 2:15 PM | 🔴 | Fixed auth token expiration | ~50 |Parameters:
- (string) - Search term
query - (number) - Max results, default 20, max 100
limit - (string) - Project name filter
project - (string, optional) - "observations", "sessions", or "prompts"
type - (string, optional) - Comma-separated: bugfix, feature, decision, discovery, change
obs_type - (string, optional) - YYYY-MM-DD or epoch ms
dateStart - (string, optional) - YYYY-MM-DD or epoch ms
dateEnd - (number, optional) - Skip N results
offset - (string, optional) - "date_desc" (default), "date_asc", "relevance"
orderBy
使用 MCP工具:
searchsearch(query="authentication", limit=20, project="my-project")返回结果: 包含ID、时间戳、类型、标题的表格(每条结果约50-100个token)
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #11131 | 3:48 PM | 🟣 | Added JWT authentication | ~75 |
| #10942 | 2:15 PM | 🔴 | Fixed auth token expiration | ~50 |参数说明:
- (字符串)- 搜索关键词
query - (数字)- 最大结果数,默认20,上限100
limit - (字符串)- 项目名称筛选条件
project - (字符串,可选)- 可选值为"observations""sessions"或"prompts"
type - (字符串,可选)- 多个值用逗号分隔:bugfix、feature、decision、discovery、change
obs_type - (字符串,可选)- 格式为YYYY-MM-DD或时间戳(毫秒)
dateStart - (字符串,可选)- 格式为YYYY-MM-DD或时间戳(毫秒)
dateEnd - (数字,可选)- 跳过前N条结果
offset - (字符串,可选)- 排序方式,默认"date_desc",可选"date_asc""relevance"
orderBy
Step 2: Timeline - Get Context Around Interesting Results
步骤2:时间线 - 获取目标结果的上下文信息
Use the MCP tool:
timelinetimeline(anchor=11131, depth_before=3, depth_after=3, project="my-project")Or find anchor automatically from query:
timeline(query="authentication", depth_before=3, depth_after=3, project="my-project")Returns: items in chronological order with observations, sessions, and prompts interleaved around the anchor.
depth_before + 1 + depth_afterParameters:
- (number, optional) - Observation ID to center around
anchor - (string, optional) - Find anchor automatically if anchor not provided
query - (number, optional) - Items before anchor, default 5, max 20
depth_before - (number, optional) - Items after anchor, default 5, max 20
depth_after - (string) - Project name filter
project
使用 MCP工具:
timelinetimeline(anchor=11131, depth_before=3, depth_after=3, project="my-project")或者通过查询自动定位锚点:
timeline(query="authentication", depth_before=3, depth_after=3, project="my-project")返回结果: 按时间顺序排列的条记录,包含锚点前后的observations、sessions和prompts内容。
depth_before + 1 + depth_after参数说明:
- (数字,可选)- 作为中心的observation ID
anchor - (字符串,可选)- 若未提供anchor,则通过查询自动定位锚点
query - (数字,可选)- 锚点之前的记录数,默认5,上限20
depth_before - (数字,可选)- 锚点之后的记录数,默认5,上限20
depth_after - (字符串)- 项目名称筛选条件
project
Step 3: Fetch - Get Full Details ONLY for Filtered IDs
步骤3:获取 - 仅为筛选后的ID获取完整详情
Review titles from Step 1 and context from Step 2. Pick relevant IDs. Discard the rest.
Use the MCP tool:
get_observationsget_observations(ids=[11131, 10942])ALWAYS use for 2+ observations - single request vs N requests.
get_observationsParameters:
- (array of numbers, required) - Observation IDs to fetch
ids - (string, optional) - "date_desc" (default), "date_asc"
orderBy - (number, optional) - Max observations to return
limit - (string, optional) - Project name filter
project
Returns: Complete observation objects with title, subtitle, narrative, facts, concepts, files (~500-1000 tokens each)
查看步骤1的标题和步骤2的上下文,挑选相关的ID,舍弃无关的。
使用 MCP工具:
get_observationsget_observations(ids=[11131, 10942])当需要获取2条及以上observations时,务必使用——单次请求对比N次单独请求更高效。
get_observations参数说明:
- (数字数组,必填)- 要获取的observation ID列表
ids - (字符串,可选)- 排序方式,默认"date_desc",可选"date_asc"
orderBy - (数字,可选)- 返回的最大observations数量
limit - (字符串,可选)- 项目名称筛选条件
project
返回结果: 完整的observation对象,包含标题、副标题、叙述内容、事实、概念、文件(每条约500-1000个token)
Saving Memories
保存内存
Use the MCP tool to store manual observations:
save_memorysave_memory(text="Important discovery about the auth system", title="Auth Architecture", project="my-project")Parameters:
- (string, required) - Content to remember
text - (string, optional) - Short title, auto-generated if omitted
title - (string, optional) - Project name, defaults to "claude-mem"
project
使用 MCP工具存储手动记录的observations:
save_memorysave_memory(text="Important discovery about the auth system", title="Auth Architecture", project="my-project")参数说明:
- (字符串,必填)- 要保存的内容
text - (字符串,可选)- 简短标题,若省略则自动生成
title - (字符串,可选)- 项目名称,默认为"claude-mem"
project
Examples
示例
Find recent bug fixes:
search(query="bug", type="observations", obs_type="bugfix", limit=20, project="my-project")Find what happened last week:
search(type="observations", dateStart="2025-11-11", limit=20, project="my-project")Understand context around a discovery:
timeline(anchor=11131, depth_before=5, depth_after=5, project="my-project")Batch fetch details:
get_observations(ids=[11131, 10942, 10855], orderBy="date_desc")查找近期的bug修复记录:
search(query="bug", type="observations", obs_type="bugfix", limit=20, project="my-project")查找上周的工作内容:
search(type="observations", dateStart="2025-11-11", limit=20, project="my-project")了解某一发现的上下文:
timeline(anchor=11131, depth_before=5, depth_after=5, project="my-project")批量获取详情:
get_observations(ids=[11131, 10942, 10855], orderBy="date_desc")Why This Workflow?
为什么采用此工作流?
- Search index: ~50-100 tokens per result
- Full observation: ~500-1000 tokens each
- Batch fetch: 1 HTTP request vs N individual requests
- 10x token savings by filtering before fetching
- 搜索索引: 每条结果约50-100个token
- 完整observation: 每条约500-1000个token
- 批量获取: 1次HTTP请求对比N次单独请求
- 通过先筛选再获取,节省10倍的token消耗