sqry-semantic-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesesqry Semantic Code Search Skill
sqry 语义代码搜索技能
Use this skill when users ask to:
- Find functions, classes, methods, or variables by name or kind
- Search for code with specific visibility (public/private)
- Trace call relationships (callers, callees, call paths)
- Analyze code dependencies and impact of changes
- Find duplicate code, circular dependencies, or unused symbols
当用户提出以下需求时可使用该技能:
- 按名称或类型查找函数、类、方法或变量
- 搜索具有特定可见性(公开/私有)的代码
- 追踪调用关系(调用方、被调用方、调用路径)
- 分析代码依赖和变更影响范围
- 查找重复代码、循环依赖或未使用的符号
What Makes sqry Different
sqry的独特优势
sqry uses "semantic" in the compiler sense, not the NLP sense. It parses code like a compiler using AST analysis and graph queries — not ML embeddings over text.
- - Find functions with "auth" in the name
kind:function name:*auth* - - Find everything that calls
callers:authenticateauthenticate() - - Find classes implementing the Serialize trait
kind:class impl:Serialize - - Find functions returning Result types
returns:Result
sqry所说的「语义」是编译器层面的语义,而非NLP层面的语义。 它通过AST分析和图查询像编译器一样解析代码,而非基于文本的ML嵌入。
- - 查找名称中包含「auth」的函数
kind:function name:*auth* - - 查找所有调用
callers:authenticate的代码authenticate() - - 查找实现了Serialize trait的类
kind:class impl:Serialize - - 查找返回Result类型的函数
returns:Result
Setup
安装配置
bash
undefinedbash
undefinedInstall
安装
curl -fsSL https://raw.githubusercontent.com/verivus-oss/sqry/main/scripts/install.sh | bash -s -- --component all
curl -fsSL https://raw.githubusercontent.com/verivus-oss/sqry/main/scripts/install.sh | bash -s -- --component all
Index your project
为你的项目构建索引
sqry index .
sqry index .
Configure MCP for your agent
为你的Agent配置MCP
sqry mcp setup --tool claude # or codex, gemini
sqry mcp status
undefinedsqry mcp setup --tool claude # 也可以选择codex、gemini
sqry mcp status
undefinedQuick Tool Selection
快速工具选择
This is the primary way to find the right tool. For full parameter details, see references/tool-reference.md.
I know the symbol name and want to...
- See its definition ->
get_definition - See its signature/docs ->
get_hover_info - See all references ->
get_references - See who calls it -> (depth=1) or
direct_callers(multi-depth)relation_query - See what it calls -> (depth=1) or
direct_callees(multi-depth)relation_query - See who imports/exports/returns it -> with
relation_query: imports, exports, returnsrelation_type - See call tree ->
call_hierarchy - See its context + source ->
explain_code - See what breaks if I change it ->
dependency_impact - Check if it's in a cycle ->
is_node_in_cycle - Find similar symbols ->
search_similar
I want to search for symbols...
- By name substring ->
pattern_search - By name with ranking ->
get_workspace_symbols - By kind/visibility/language ->
semantic_search - With results grouped for RAG ->
hierarchical_search
I want to analyze the codebase...
- Find circular dependencies ->
find_cycles - Find dead code ->
find_unused - Find duplicate code ->
find_duplicates - Compare git versions ->
semantic_diff - Get overall stats ->
get_graph_stats - Get health metrics ->
get_insights - Get complexity scores ->
complexity_metrics - Check Rust macro expansion cache ->
expand_cache_status
I want to visualize/export...
- Dependency tree ->
show_dependencies - Subgraph around symbols ->
subgraph - Graph as DOT/Mermaid/D2 ->
export_graph - Call path between A and B ->
trace_path - Cross-language edges ->
cross_language_edges
I want to inspect the index...
- Check index health ->
get_index_status - List indexed files ->
list_files - List indexed symbols ->
list_symbols - See all symbols in a file ->
get_document_symbols - Rebuild from scratch ->
rebuild_index
I need natural language help...
- Translate English to sqry query ->
sqry_ask
这是查找合适工具的主要方式。如需完整参数详情,请参考 references/tool-reference.md。
我知道符号名称,想要...
- 查看它的定义 ->
get_definition - 查看它的签名/文档 ->
get_hover_info - 查看所有引用 ->
get_references - 查看谁调用了它 -> (深度=1)或
direct_callers(多深度)relation_query - 查看它调用了什么 -> (深度=1)或
direct_callees(多深度)relation_query - 查看谁导入/导出/返回了它 -> 搭配(imports、exports、returns)使用
relation_typerelation_query - 查看调用树 ->
call_hierarchy - 查看它的上下文+源码 ->
explain_code - 查看修改它会影响什么 ->
dependency_impact - 检查它是否处于循环依赖中 ->
is_node_in_cycle - 查找相似符号 ->
search_similar
我想要搜索符号...
- 按名称子串搜索 ->
pattern_search - 按名称排序搜索 ->
get_workspace_symbols - 按类型/可见性/语言搜索 ->
semantic_search - 获取适合RAG的分组结果 ->
hierarchical_search
我想要分析代码库...
- 查找循环依赖 ->
find_cycles - 查找死代码 ->
find_unused - 查找重复代码 ->
find_duplicates - 对比git版本差异 ->
semantic_diff - 获取整体统计信息 ->
get_graph_stats - 获取健康指标 ->
get_insights - 获取复杂度评分 ->
complexity_metrics - 检查Rust宏展开缓存 ->
expand_cache_status
我想要可视化/导出...
- 依赖树 ->
show_dependencies - 符号周边子图 ->
subgraph - 导出为DOT/Mermaid/D2格式的图 ->
export_graph - A和B之间的调用路径 ->
trace_path - 跨语言关联边 ->
cross_language_edges
我想要检查索引...
- 检查索引健康状态 ->
get_index_status - 列出已索引文件 ->
list_files - 列出已索引符号 ->
list_symbols - 查看某个文件中的所有符号 ->
get_document_symbols - 从零重建索引 ->
rebuild_index
我需要自然语言帮助...
- 将英语翻译成sqry查询语句 ->
sqry_ask
Tool Categories (34 tools)
工具分类(共34个工具)
Tool names use the prefix in Claude Code, or equivalent for your agent. Load references/tool-reference.md for full parameter schemas.
mcp__sqry__| Category | Tools | When to load details |
|---|---|---|
| Search (6) | semantic_search, hierarchical_search, explain_code, search_similar, pattern_search, get_workspace_symbols | Need |
| Navigation (4) | get_definition, get_references, get_hover_info, get_document_symbols | Usually no extra params needed |
| Relations (6) | relation_query, direct_callers, direct_callees, call_hierarchy, trace_path, dependency_impact | Need |
| Graph (4) | subgraph, export_graph, show_dependencies, cross_language_edges | Need |
| Analysis (7) | semantic_diff, find_duplicates, find_cycles, is_node_in_cycle, find_unused, complexity_metrics, sqry_ask | Need |
| Index (7) | get_index_status, get_graph_stats, get_insights, list_files, list_symbols, rebuild_index, expand_cache_status | Usually no extra params needed |
在Claude Code中工具名称使用前缀,其他Agent可使用对应等价前缀。加载 references/tool-reference.md 可查看完整参数 schema。
mcp__sqry__| 分类 | 工具 | 何时需要加载详情 |
|---|---|---|
| 搜索(6个) | semantic_search, hierarchical_search, explain_code, search_similar, pattern_search, get_workspace_symbols | 需要 |
| 导航(4个) | get_definition, get_references, get_hover_info, get_document_symbols | 通常不需要额外参数 |
| 关系查询(6个) | relation_query, direct_callers, direct_callees, call_hierarchy, trace_path, dependency_impact | 需要 |
| 图操作(4个) | subgraph, export_graph, show_dependencies, cross_language_edges | 需要 |
| 分析(7个) | semantic_diff, find_duplicates, find_cycles, is_node_in_cycle, find_unused, complexity_metrics, sqry_ask | 需要 |
| 索引(7个) | get_index_status, get_graph_stats, get_insights, list_files, list_symbols, rebuild_index, expand_cache_status | 通常不需要额外参数 |
Query Basics
查询基础
Queries use predicates. Multiple predicates are AND-combined.
field:valuekind:function name:*auth* # functions with "auth" in name
callers:authenticate # who calls authenticate?
kind:class path:src/models # classes in src/models
lang:rust kind:struct impl:Debug # Rust structs implementing DebugKey fields: , , (alias: ), (alias: ), , , ,
namekindpathfilelanglanguageparentscope.namescope.typescope.ancestorRelation fields: , , , , , ,
callerscalleesimportsexportsreturnsimplreferencesOperators: (exact/glob), (regex)
field:valuefield~=patternFilters (JSON parameter, not query string): ("public"/"private"), (array), (array), (float)
visibilitylanguagesymbol_kindscore_minFor full predicate reference, see references/query-syntax.md.
查询使用谓词格式,多个谓词默认按AND逻辑组合。
字段:值kind:function name:*auth* # 名称中包含auth的函数
callers:authenticate # 谁调用了authenticate?
kind:class path:src/models # src/models下的类
lang:rust kind:struct impl:Debug # 实现了Debug trait的Rust结构体核心字段:、、(别名:)、(别名:)、、、、
namekindpathfilelanglanguageparentscope.namescope.typescope.ancestor关系字段:、、、、、、
callerscalleesimportsexportsreturnsimplreferences运算符:(精确匹配/glob匹配)、(regex匹配)
字段:值字段~=pattern过滤器(JSON参数,非查询字符串):("public"/"private")、(数组)、(数组)、(浮点数)
visibilitylanguagesymbol_kindscore_min完整谓词参考请查看 references/query-syntax.md。
Handling Ambiguous Symbols
处理歧义符号
When names like , , , exist in multiple files:
newinithandleprocess- Scope with :
file_path{ "symbol": "handle", "file_path": "src/api/router.rs" } - Use qualified names:
"symbol": "UserService::authenticate" - Fall back to with
get_referencesfilter when relation tools failpath - Search first: Use with
semantic_search+kind:+name:to find the exact symbol, then use its qualified namepath:
Rule of thumb: If the name could exist in more than one file, always provide or use a qualified name.
file_path当、、、这类名称存在于多个文件中时:
newinithandleprocess- 通过限定范围:
file_path{ "symbol": "handle", "file_path": "src/api/router.rs" } - 使用限定名称:
"symbol": "UserService::authenticate" - 当关系工具查询失败时,搭配过滤器回退到
pathget_references - 先搜索:使用搭配+
kind:+name:的path:找到精确符号,再使用它的限定名称semantic_search
经验法则:如果名称可能存在于多个文件中,始终提供或使用限定名称。
file_pathOutput Size Tips
输出大小优化建议
Some tools produce large output. Always start narrow, expand if needed:
- Use (depth=1) before
direct_callers(full tree)call_hierarchy - Set ,
max_results, ormax_depthconservatively firstmax_nodes - Add ,
path, orkindfilters to reduce noiselanguage - Prefer over
get_hover_infofor quick lookupsexplain_code
For per-tool risk scenarios and mitigations, see references/tool-reference.md.
部分工具会产生大量输出,请始终遵循先缩小范围,按需扩展的原则:
- 先使用(深度=1)再使用
direct_callers(完整树)call_hierarchy - 一开始保守设置、
max_results或max_depth的数值max_nodes - 添加、
path或kind过滤器减少噪音language - 快速查询优先使用而非
get_hover_infoexplain_code
每个工具的风险场景和缓解方案请查看 references/tool-reference.md。
Supported Languages (37)
支持的语言(37种)
Full relation support (28): C, C++, C#, CSS, Dart, Elixir, Go, Groovy, Haskell, HTML, Java, JavaScript, Kotlin, Lua, Perl, PHP, Python, R, Ruby, Rust, Scala, Shell, SQL, Svelte, Swift, TypeScript, Vue, Zig
Symbol extraction + imports (9): JSON, Oracle PL/SQL, Pulumi, Puppet, Salesforce Apex, SAP ABAP, ServiceNow Xanadu, ServiceNow XML, Terraform
Note: JSON and ServiceNow XML are plugins, excluded from the default index. Include them with , , or per-plugin: , .
HighWallClock--include-high-costSQRY_INCLUDE_HIGH_COST=1--enable-plugin json--enable-plugin servicenow-xml完整关系支持(28种):C、C++、C#、CSS、Dart、Elixir、Go、Groovy、Haskell、HTML、Java、JavaScript、Kotlin、Lua、Perl、PHP、Python、R、Ruby、Rust、Scala、Shell、SQL、Svelte、Swift、TypeScript、Vue、Zig
仅符号提取+导入支持(9种):JSON、Oracle PL/SQL、Pulumi、Puppet、Salesforce Apex、SAP ABAP、ServiceNow Xanadu、ServiceNow XML、Terraform
注意:JSON和ServiceNow XML属于插件,默认不纳入索引。如需包含可使用、,或按插件启用:、。
HighWallClock--include-high-costSQRY_INCLUDE_HIGH_COST=1--enable-plugin json--enable-plugin servicenow-xmlWhen NOT to Use sqry
何时不应该使用sqry
- Literal text search: Use grep/rg for exact text patterns
- File finding: Use find/glob for file names
- Reading files: Use cat/read for file contents
- Code execution: sqry only searches, doesn't run code
- 精确文本搜索:使用grep/rg搜索精确文本模式
- 查找文件:使用find/glob匹配文件名
- 读取文件:使用cat/read获取文件内容
- 代码执行:sqry仅用于搜索,不会运行代码
Reference Files (load on demand)
参考文件(按需加载)
Only load these when you need details beyond Quick Tool Selection:
- references/tool-reference.md - Full tool tables with all parameters, filter details, output size risks
- references/query-syntax.md - Complete predicate syntax, MCP vs CLI differences, quoting rules
- references/graph-queries.md - Graph tool parameters, edge types, use cases
- references/workflows.md - Step-by-step workflows: understand-before-changing, security audit
- references/examples.md - 50+ example queries across all categories
仅当你需要快速工具选择之外的详情时才加载这些文件:
- references/tool-reference.md - 包含所有参数、过滤器详情、输出大小风险的完整工具表
- references/query-syntax.md - 完整谓词语法、MCP与CLI差异、引号规则
- references/graph-queries.md - 图工具参数、边类型、使用场景
- references/workflows.md - 分步工作流:变更前理解代码、安全审计
- references/examples.md - 覆盖所有分类的50+示例查询