mem-search

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Memory 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
search
MCP tool:
search(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:
  • query
    (string) - Search term
  • limit
    (number) - Max results, default 20, max 100
  • project
    (string) - Project name filter
  • type
    (string, optional) - "observations", "sessions", or "prompts"
  • obs_type
    (string, optional) - Comma-separated: bugfix, feature, decision, discovery, change
  • dateStart
    (string, optional) - YYYY-MM-DD or epoch ms
  • dateEnd
    (string, optional) - YYYY-MM-DD or epoch ms
  • offset
    (number, optional) - Skip N results
  • orderBy
    (string, optional) - "date_desc" (default), "date_asc", "relevance"
使用
search
MCP工具:
search(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
    (字符串)- 搜索关键词
  • limit
    (数字)- 最大结果数,默认20,上限100
  • project
    (字符串)- 项目名称筛选条件
  • type
    (字符串,可选)- 可选值为"observations""sessions"或"prompts"
  • obs_type
    (字符串,可选)- 多个值用逗号分隔:bugfix、feature、decision、discovery、change
  • dateStart
    (字符串,可选)- 格式为YYYY-MM-DD或时间戳(毫秒)
  • dateEnd
    (字符串,可选)- 格式为YYYY-MM-DD或时间戳(毫秒)
  • offset
    (数字,可选)- 跳过前N条结果
  • orderBy
    (字符串,可选)- 排序方式,默认"date_desc",可选"date_asc""relevance"

Step 2: Timeline - Get Context Around Interesting Results

步骤2:时间线 - 获取目标结果的上下文信息

Use the
timeline
MCP tool:
timeline(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:
depth_before + 1 + depth_after
items in chronological order with observations, sessions, and prompts interleaved around the anchor.
Parameters:
  • anchor
    (number, optional) - Observation ID to center around
  • query
    (string, optional) - Find anchor automatically if anchor not provided
  • depth_before
    (number, optional) - Items before anchor, default 5, max 20
  • depth_after
    (number, optional) - Items after anchor, default 5, max 20
  • project
    (string) - Project name filter
使用
timeline
MCP工具:
timeline(anchor=11131, depth_before=3, depth_after=3, project="my-project")
或者通过查询自动定位锚点:
timeline(query="authentication", depth_before=3, depth_after=3, project="my-project")
返回结果: 按时间顺序排列的
depth_before + 1 + depth_after
条记录,包含锚点前后的observations、sessions和prompts内容。
参数说明:
  • anchor
    (数字,可选)- 作为中心的observation ID
  • query
    (字符串,可选)- 若未提供anchor,则通过查询自动定位锚点
  • depth_before
    (数字,可选)- 锚点之前的记录数,默认5,上限20
  • depth_after
    (数字,可选)- 锚点之后的记录数,默认5,上限20
  • 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
get_observations
MCP tool:
get_observations(ids=[11131, 10942])
ALWAYS use
get_observations
for 2+ observations - single request vs N requests.
Parameters:
  • ids
    (array of numbers, required) - Observation IDs to fetch
  • orderBy
    (string, optional) - "date_desc" (default), "date_asc"
  • limit
    (number, optional) - Max observations to return
  • project
    (string, optional) - Project name filter
Returns: Complete observation objects with title, subtitle, narrative, facts, concepts, files (~500-1000 tokens each)
查看步骤1的标题和步骤2的上下文,挑选相关的ID,舍弃无关的。
使用
get_observations
MCP工具:
get_observations(ids=[11131, 10942])
当需要获取2条及以上observations时,务必使用
get_observations
——单次请求对比N次单独请求更高效。
参数说明:
  • ids
    (数字数组,必填)- 要获取的observation ID列表
  • orderBy
    (字符串,可选)- 排序方式,默认"date_desc",可选"date_asc"
  • limit
    (数字,可选)- 返回的最大observations数量
  • project
    (字符串,可选)- 项目名称筛选条件
返回结果: 完整的observation对象,包含标题、副标题、叙述内容、事实、概念、文件(每条约500-1000个token)

Saving Memories

保存内存

Use the
save_memory
MCP tool to store manual observations:
save_memory(text="Important discovery about the auth system", title="Auth Architecture", project="my-project")
Parameters:
  • text
    (string, required) - Content to remember
  • title
    (string, optional) - Short title, auto-generated if omitted
  • project
    (string, optional) - Project name, defaults to "claude-mem"
使用
save_memory
MCP工具存储手动记录的observations:
save_memory(text="Important discovery about the auth system", title="Auth Architecture", project="my-project")
参数说明:
  • text
    (字符串,必填)- 要保存的内容
  • title
    (字符串,可选)- 简短标题,若省略则自动生成
  • project
    (字符串,可选)- 项目名称,默认为"claude-mem"

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消耗