Shape Matching
sqry shape-match finds functions that are structurally similar to a reference
function. It matches on an identifier-blind body-shape descriptor (the
control-flow shape plus a MinHash of the body), so it finds rename-and-relocate
twins that fuzzy name matching misses. The same analysis is exposed to AI
assistants through the structural_similar MCP tool.
This is distinct from sqry similar, which matches on
symbol names. Shape matching ignores identifiers entirely and compares structure.
CLI usage
sqry shape-match <SYMBOL> [--file <FILE>] [--path <PATH>] [--threshold <N>] [--limit <N>]
| Argument / flag | Default | Description |
|---|---|---|
<SYMBOL> | required | Reference function or method name (simple or qualified). |
--file <FILE> | none | Restrict the probe to a symbol in this file (disambiguates overloads). |
--path <PATH> | . | Search path. |
--threshold, -t | 0.6 | Minimum MinHash similarity floor, from 0.0 to 1.0. |
--limit, -l | 20 | Maximum results to return. |
Reading the output
sqry shape-match resolve_api_key_with_config
Structural neighbours of auth::resolve_api_key_with_config (crates/grokrs-api/src/auth.rs:61)
floor 0.60, 5 match(es)
0.906 auth::resolve_from_env_then_provider crates/grokrs-api/src/auth.rs:145
0.656 tools::write_file::resolve_through_symlinks crates/grokrs-tool/src/tools/write_file.rs:210
0.625 auth::configured_source_from_parts crates/grokrs-api/src/auth.rs:126
0.625 AppConfig::load_with_profile crates/grokrs-core/src/lib.rs:534
Each match reports two things:
- The MinHash similarity (the leading number), an approximate structural
Jaccard score between
0.0and1.0. - An
[exact]marker when the structuralshape_hashis byte-identical to the reference. An exact match is a structural twin regardless of names:
sqry shape-match --threshold 0.5 configured_api_key_env
Structural neighbours of auth::configured_api_key_env (crates/grokrs-api/src/auth.rs:48)
floor 0.50, 20 match(es)
1.000 [exact] auth::configured_management_api_key_env crates/grokrs-api/src/auth.rs:106
0.750 auth::configured_api_key_source crates/grokrs-api/src/auth.rs:54
Tips
- Lower
--thresholdto widen the net; raise it to keep only close twins. The default0.6is a reasonable starting floor. - Use
--filewhen the reference name is overloaded across the codebase. - Because matching is identifier-blind, results can include call expressions and closures that share a body shape, not just top-level functions.
MCP tool
The standalone MCP server exposes the same analysis as structural_similar. It
reports the exact shape_hash identity plus the approximate MinHash similarity
for each neighbour, and is distinct from the name-based search_similar tool.
See also
- Field Reference for name-based
similar. - MCP Tools for the full tool reference.