Skip to content

code_similar

Anchor on a symbol you already know, get back the ones that resemble it.

code_similar({ name: "authenticate_user", top_k: 5 })

Returns symbols sorted by cosine similarity to the anchor’s vector:

=== Similar to `authenticate_user` ===
0.812 │ verify_credentials (FUNCTION) │ src/auth/verify.rs:30
0.747 │ check_api_key (FUNCTION) │ src/auth/api_key.rs:18
0.681 │ validate_session (METHOD) │ src/session.rs:112

The anchor itself is excluded from results.

NameTypeDefaultDescription
namestringrequiredName of the anchor symbol
top_kinteger10Results to return
  • “Show me other code that does what X does” — quickly find parallels across a codebase
  • Refactor planning — know which functions will probably need the same change
  • Discovery — surface duplicates and near-duplicates

Embeddings must exist for the anchor symbol. Run code_embed_index({}) or enable auto-index.