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 / flagDefaultDescription
<SYMBOL>requiredReference function or method name (simple or qualified).
--file <FILE>noneRestrict the probe to a symbol in this file (disambiguates overloads).
--path <PATH>.Search path.
--threshold, -t0.6Minimum MinHash similarity floor, from 0.0 to 1.0.
--limit, -l20Maximum 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:

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

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