‹ 首页

search-hierarchy

@parcadei · 收录于 1 周前 · 上游提交 5 个月前

Search Tool Hierarchy

适合你,如果你需要按层级结构搜索可用的工具或技能。

/ 下载安装
search-hierarchy.skill双击,或拖进 Claude 桌面版 / Cowork,即完成安装↓ .skill↓ .zip
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code~/.claude/skills/(项目级 .claude/skills/)
Codex CLI~/.codex/skills/
Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add parcadei/continuous-claude-v3/search-hierarchy
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- parcadei/continuous-claude-v3/search-hierarchy
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify parcadei/continuous-claude-v3/search-hierarchy
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
3859GitHub stars
~465上下文体积 · 单文件
镜像托管

怎么用

商店整理自技能原文 · 版本 d07ff4b · 表述以原文为准
它做什么

Claude 会根据查询类型自动选择最省 token 的搜索工具:代码结构用 AST-grep,概念问题用 LEANN,精确标识符用 Grep,最后才用 Read 读取文件。

什么时候触发

当用户提出代码搜索需求时触发,例如查找函数定义、理解架构或搜索特定标识符。

装好后可以这样说
触发 AST-grep 搜索代码结构
触发 LEANN 进行语义搜索
触发 Grep 精确匹配标识符
技能原文 SKILL.md作者撰写 · MIT · d07ff4b

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

| Tool | Output Size | Best For | |------|-------------|----------| | AST-grep | ~50 tokens | Function/class definitions, imports, decorators | | LEANN | ~100 tokens | Conceptual questions, architecture, patterns | | Grep | ~200-2000 | Exact 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
# STRUCTURAL → AST-grep
ast-grep --pattern "async def $FUNC($$$):" --lang python

# SEMANTIC → LEANN
leann search opc-dev "how does authentication work" --top-k 3

# LITERAL → Grep
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 matches
2. Read: Top match only → Full understanding
3. Skip: 4 irrelevant files → 6000 tokens saved
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。