Search Hierarchy

parcadei/Continuous-Claude-v3/.claude/skills/search-hierarchy

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

Search Tool Hierarchy

AI 生成的概览

指导智能体为每种查询类型选择最省 token 的代码搜索工具。

功能
该技能提供决策树和对比表,将查询类型映射到搜索工具:结构化代码模式用 AST-grep,语义问题用 LEANN,精确标识符用 Grep,需要完整上下文时用 Read。它列出应做与不应做的规则、示例命令,以及先使用 AST-grep、只读取最佳匹配的最优流程。它还描述了一个钩子,用于检测查询类型并相应地阻止或重定向搜索。
适用场景
在搜索代码库并需要在结构化、语义、字面或完整上下文搜索之间做选择时使用。它面向希望减少 token 消耗、同时定位相关文件和定义的智能体。
运行要求
需要可用的 AST-grep、LEANN 和 Grep 搜索工具,以及用于完整上下文的文件读取能力。它引用了一个 grep-to-leann.sh 钩子,但本身不附带脚本。

Search Tool Hierarchy

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

Decision Tree

Query Type?├── STRUCTURAL (code patterns)│   → AST-grep (~50 tokens output)│   Examples: "def foo", "class Bar", "import X", "@decorator"│├── SEMANTIC (conceptual questions)│   → LEANN (~100 tokens if path-only)│   Examples: "how does auth work", "find error handling patterns"│├── LITERAL (exact identifiers)│   → Grep (variable output)│   Examples: "TemporalMemory", "check_evocation", regex patterns│└── FULL CONTEXT (need complete understanding)    → Read (1500+ tokens)    Last resort after finding the right file

Token Efficiency Comparison

ToolOutput SizeBest For
AST-grep~50 tokensFunction/class definitions, imports, decorators
LEANN~100 tokensConceptual questions, architecture, patterns
Grep~200-2000Exact identifiers, regex, file paths
Read~1500+Full understanding after finding the file

Hook Enforcement

The grep-to-leann.sh hook automatically:

  1. Detects query type (structural/semantic/literal)
  2. Blocks and suggests AST-grep for structural queries
  3. Blocks and suggests LEANN for semantic queries
  4. Allows literal patterns through to Grep

DO

  • Start with AST-grep for code structure questions
  • Use LEANN for "how does X work" questions
  • Use Grep only for exact identifier matches
  • Read files only after finding them via search

DON'T

  • Use Grep for conceptual questions (returns nothing)
  • Read files before knowing which ones are relevant
  • Use Read when AST-grep would give file:line
  • Ignore hook suggestions

Examples

bash
# STRUCTURAL → AST-grepast-grep --pattern "async def $FUNC($$$):" --lang python
# SEMANTIC → LEANNleann search opc-dev "how does authentication work" --top-k 3
# LITERAL → GrepGrep 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

来源与署名

来源:parcadei/Continuous-Claude-v3位于.claude/skills/search-hierarchy提交d07ff4b

许可证: 无许可证

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

举报或申请下架