Search Router

作者 parcadeid07ff4b06b62无许可证3.9K 个星标收录于 2026年10月8日更新于 2026年10月8日仓库8个月前更新

Choose the right search tool for each query type

AI 生成的概览

将代码搜索查询路由到最省 token 的工具,如 TLDR、AST-grep、Grep 或 Read。

功能
该技能提供一棵决策树,按查询类型选择搜索工具,涵盖代码探索、结构化 AST 模式、语义问题、字面文本和完整上下文阅读。它包含 token 效率对比表和每个工具的示例命令。它只产出指导建议,不产出搜索结果或文件。
适用场景
适用于搜索代码模式、定位某功能的实现位置、查找特定标识符或理解代码如何运作的场景。当 token 成本重要时,它帮助在多个工具之间做选择。
运行要求
不包含脚本,仅为说明性指令。其指导引用了外部工具和命令,如 tldr search、tldr semantic search、AST-grep、Grep 和 Read,这些需另行具备。

Search Tool Router

Use the most token-efficient search tool for each query type.

When to Use

  • Searching for code patterns
  • Finding where something is implemented
  • Looking for specific identifiers
  • Understanding how code works

Decision Tree

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

Token Efficiency Comparison

ToolOutput SizeBest For
TLDR~50-500DEFAULT: Code symbols, call graphs, data flow
TLDR Semantic~100-300Conceptual queries (P6, embedding-based)
AST-grep~50 tokensFunction/class definitions, imports, decorators
Grep~200-2000LAST RESORT: Non-code text, regex
Read~1500+Full understanding after finding the file

Examples

bash
# 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 Semantictldr 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

Optimal Flow

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

Related Skills

  • /tldr-search - DEFAULT - Code exploration with 95% token savings
  • /ast-grep-find - Structural code search
  • /morph-search - Fast text search

来源与署名

来源:parcadei/continuous-claude-v3位于.claude/skills/search-router提交d07ff4b

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架