session-search

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
If you are Claude Code: Do NOT use this skill directly. Use the
session-searcher
subagent via the Task tool instead - it handles this more efficiently without polluting your context.
如果你是Claude Code: 请勿直接使用此技能。请通过Task工具使用
session-searcher
子代理——它能更高效地处理此任务,且不会污染你的上下文。

session-search

session-search

Search and find previous code agent sessions (Claude-Code or Codex-CLI) for specific work, decisions, or code patterns.
搜索并查找过往代码Agent会话(Claude-Code或Codex-CLI)中的特定工作内容、决策或代码模式。

Workflow

工作流程

  1. Understand the query: Identify what the user is looking for (code patterns, decisions, specific work, design direction)
  2. Search with aichat: Run
    aichat search --json -n 10 "[query]"
    (use
    -g "project"
    to filter by project)
  3. Parse results: Use
    jq
    to extract fields from JSONL output (session_id, project, created, snippet, file_path)
  4. Deep dive if needed: Read session files at
    ~/.claude/projects/*/[session-id].jsonl
    (max 3 files)
  5. Summarize: Return a focused summary with key findings and references
Run
aichat search --help
to see all options (date filters, branch filters, etc.) and JSONL field names.
  1. 理解查询内容:明确用户的需求(代码模式、决策、特定工作内容、设计方向)
  2. 使用aichat进行搜索:运行
    aichat search --json -n 10 "[query]"
    (使用
    -g "project"
    按项目筛选)
  3. 解析结果:使用
    jq
    从JSONL输出中提取字段(session_id、project、created、snippet、file_path)
  4. 必要时深入查看:读取
    ~/.claude/projects/*/[session-id].jsonl
    路径下的会话文件(最多3个文件)
  5. 总结内容:返回包含关键发现和参考信息的聚焦式总结
运行
aichat search --help
查看所有选项(日期筛选、分支筛选等)以及JSONL字段名称。

Output Format

输出格式

Return a concise summary containing:
  1. Key Findings: 2-3 bullet points answering the query
  2. Relevant Sessions: Session IDs and dates for reference
  3. Specific Content: Code snippets or quotes if directly relevant
Format as clean markdown, not raw JSON.
返回简洁的总结,包含以下内容:
  1. 关键发现:2-3个回答查询要点的项目符号
  2. 相关会话:供参考的会话ID和日期
  3. 具体内容:直接相关的代码片段或引用内容
格式为清晰的Markdown,而非原始JSON。

Example

示例

Query: "Find sessions where we discussed authentication design"
bash
aichat search --json -n 10 "authentication design"
Summary:
  • Session abc123 (Dec 10): Discussed JWT vs session-based auth, decided on JWT
  • Session def456 (Dec 8): Implemented refresh token rotation pattern
查询:"查找我们讨论过认证设计的会话"
bash
aichat search --json -n 10 "authentication design"
总结:
  • 会话abc123(12月10日):讨论了JWT与基于会话的认证,最终决定采用JWT
  • 会话def456(12月8日):实现了刷新令牌轮转模式

Constraints

约束条件

  • ALWAYS use
    --json
    flag with aichat search (otherwise it spawns interactive UI)
  • NEVER return raw JSON output to the user - summarize and distill findings
  • NEVER read more than 3 session files per query
  • If no results found, suggest alternative search terms
  • ONLY report information directly observed in files - never infer or extrapolate
  • 始终在aichat搜索中使用
    --json
    标志(否则会启动交互式UI)
  • 切勿向用户返回原始JSON输出——需进行总结和提炼
  • 每次查询读取的会话文件不得超过3个
  • 如果未找到结果,建议用户尝试其他搜索关键词
  • 仅报告文件中直接观察到的信息——切勿推断或引申

Error Handling

错误处理

If
aichat search
command fails or is not found, ask user to install:
bash
uv tool install claude-code-tools   # Python package
cargo install aichat-search         # Rust search TUI
Prerequisites:
  • Node.js 16+ (for action menus)
  • Rust/Cargo (for aichat-search)
If user doesn't have uv or cargo:
bash
curl -LsSf https://astral.sh/uv/install.sh | sh           # uv
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh  # Rust
如果
aichat search
命令执行失败或未找到,请提示用户安装:
bash
uv tool install claude-code-tools   # Python包
cargo install aichat-search         # Rust搜索TUI
前置要求:
  • Node.js 16+(用于操作菜单)
  • Rust/Cargo(用于aichat-search)
如果用户没有uv或cargo:
bash
curl -LsSf https://astral.sh/uv/install.sh | sh           # uv
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh  # Rust