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:112The anchor itself is excluded from results.
Arguments
Section titled “Arguments”| Name | Type | Default | Description |
|---|---|---|---|
name | string | required | Name of the anchor symbol |
top_k | integer | 10 | Results to return |
When to use
Section titled “When to use”- “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
Prereq
Section titled “Prereq”Embeddings must exist for the anchor symbol. Run code_embed_index({}) or enable auto-index.
See also
Section titled “See also”- code_semantic_search — natural-language query instead of anchor
- code_related — graph-based neighborhood (callers + callees)