mcpField
S
search-router

search-router

github.com/parcadei开发3.9k487 次安装39 周前更新
代码仓库

关于 search-router

根据查询类型选择代码搜索方式的路由 Skill,代码探索优先使用 TLDR,其他需求则采用结构或文本搜索。它帮助开发者查找实现、标识符和代码关系,并减少无关输出。

主要功能

  1. 01按搜索类型分派查询
  2. 02使用 TLDR 探索代码
  3. 03提供 AST 模式搜索指引
  4. 04提供语义搜索指引
  5. 05注重 Token 效率的搜索流程

适用场景

  1. 01查找符号或功能实现
  2. 02追踪调用链和数据流
  3. 03按结构查找函数或导入项
  4. 04搜索非代码文本或正则表达式

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/parcadei/continuous-claude-v3 --skill search-router

安装后在 Claude Code 中输入/search-router确认已加载。

详细介绍

搜索工具路由器

针对每种查询类型,使用令牌效率最高的搜索工具。

适用场景

  • 搜索代码模式
  • 查找某项功能的实现位置
  • 查找特定标识符
  • 了解代码的工作原理

决策树

Query Type?
├── CODE EXPLORATION (symbols, call chains, data flow)
│   → TLDR Search - 95% token savings
│   DEFAULT FOR ALL CODE SEARCH - use instead of Grep
│   Examples: "spawn_agent", "DataPoller", "redis usage"
│   Command: tldr search "query" .
│
├── STRUCTURAL (AST patterns)
│   → AST-grep (/ast-grep-find) - ~50 tokens output
│   Examples: "def foo", "class Bar", "import X", "@decorator"
│
├── SEMANTIC (conceptual questions)
│   → TLDR Semantic - 5-layer embeddings (P6)
│   Examples: "how does auth work", "find error handling patterns"
│   Command: tldr semantic search "query"
│
├── LITERAL (exact text, regex)
│   → Grep tool - LAST RESORT
│   Only when TLDR/AST-grep don't apply
│   Examples: error messages, config values, non-code text
│
└── FULL CONTEXT (need complete understanding)
    → Read tool - 1500+ tokens
    Last resort after finding the right file

令牌效率对比

工具输出大小最适合
TLDR~50-500默认:代码符号、调用图、数据流
TLDR Semantic~100-300概念查询(P6,基于嵌入)
AST-grep~50 tokens函数/类定义、导入、装饰器
Grep~200-2000最后手段:非代码文本、正则表达式
Read~1500+找到文件后深入理解

示例

# CODE EXPLORATION → TLDR (DEFAULT)
tldr search "spawn_agent" .
tldr search "redis" . --layer call_graph

# STRUCTURAL → AST-grep
/ast-grep-find "async def $FUNC($$$):" --lang python

# SEMANTIC → TLDR Semantic
tldr semantic search "how does authentication work"

# LITERAL → Grep (LAST RESORT - prefer TLDR)
Grep pattern="check_evocation" path=opc/scripts

# FULL CONTEXT → Read (after finding file)
Read file_path=opc/scripts/z3_erotetic.py

最佳流程

1. AST-grep: "Find async functions" → 3 file:line matches
2. Read: Top match only → Full understanding
3. Skip: 4 irrelevant files → 6000 tokens saved

相关技能

  • /tldr-search - 默认 - 代码探索,节省 95% 的令牌
  • /ast-grep-find - 结构化代码搜索
  • /morph-search - 快速文本搜索

评论

支持 Markdown