关于 search-tools
search-tools 是一项根据查询类型指导代码搜索工具选择的技能,区分语义、结构、文本和字面搜索,并说明各工具的要求与示例。
主要功能
- 01按搜索意图选择工具
- 02使用 LEANN 进行语义搜索
- 03使用 AST-grep 进行结构搜索
- 04使用 Morph 进行文本搜索
- 05使用 Grep 搜索字面内容和正则表达式
适用场景
- 01查找概念性代码模式
- 02定位函数调用或使用位置
- 03搜索文件中的词语或 TODO
- 04查找准确名称或正则表达式
MCP 相关
指南指出 AST-grep 需要 MCP 服务;未说明其他 MCP 服务的配置或管理方式。
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ parcadei/ continuous-claude-v3 --skill search-tools安装后在 Claude Code 中输入/search-tools确认已加载。
详细介绍
搜索工具层级
搜索代码时,请使用以下决策树:
决策树
Need CONCEPTUAL/SEMANTIC search?
(how does X work, find patterns, understand architecture)
→ Use LEANN (/leann-search) - embedding-based semantic search
→ PreToolUse hook auto-redirects semantic Grep queries
Need to understand code STRUCTURE?
(find function calls, class usages, refactor patterns)
→ Use AST-grep (/ast-grep-find)
Need to find TEXT in code?
→ Use Morph (/morph-search) - 20x faster
→ If no Morph API key: fall back to Grep tool
Simple one-off search?
→ Use built-in Grep tool directly
工具对比
| 工具 | 最适合 | 要求 |
|---|---|---|
| LEANN | 语义搜索:“缓存如何工作”“错误处理模式”等概念性查询 | 已构建索引 |
| AST-grep | 结构化模式:“查找所有对 foo() 的调用”、重构、按类型查找用法 | MCP 服务 |
| Morph | 快速文本搜索:“查找提及 error 的文件”、在整个代码库中 grep | API 密钥 |
| Grep | 字面模式、类/函数名、正则表达式 | 无(内置) |
示例
LEANN(语义/概念性):
- “身份验证如何工作”
- “查找错误处理模式”
- “速率限制在哪里实现”
AST-grep(结构化):
- “查找所有返回 Promise 的函数”
- “查找所有使用 useState 的 React 组件”
- “将所有导入 X 的语句重构为导入 Y”
Morph(文本搜索):
- “查找所有提及 ‘authentication’ 的文件”
- “搜索 TODO 注释”
Grep(字面匹配):
class ProviderAdapterdef __init__- 正则表达式模式
LEANN 命令
# Search with semantic query
leann search opc-dev "how does blackboard communication work" --top-k 5
# List available indexes
leann list
# Rebuild index (when code changes)
leann build opc-dev --docs dir1 dir2 --no-recompute --no-compact --force
评论
支持 Markdown