Skip to lesson
Exit
Building AI-Native Workflows1 / 3

2 min lesson

Retrieval that respects code structure

Choose two examples from the table in "Retrieval that respects code structure" and explain what each teaches you to do.

Step 1 of 3

Retrieval that respects code structurebeyond text similarity

Plain text similarity finds code that reads alike. Code retrieval needs more: the function that calls this one, the type this signature depends on, the imports a change must update. Blend semantic search with structural signals from the symbol graph.

Signal
Embedding similarity
Finds
Code that’s semantically related to the query
Misses on its own
Exact call sites and import edges
Signal
Symbol / keyword search
Finds
Exact references to a function or type name
Misses on its own
Conceptually related but differently named code
Signal
Call graph / imports
Finds
Direct callers and dependents that must change together
Misses on its own
Distant-but-relevant logic

Production code retrieval combines these; any one alone leaves blind spots.

Learn more

Full explanation

When RAG helps vs. when it doesn’t

When RAG helps vs. when it doesn’tmatch the strategy to the task

Retrieve a slice

Large repo, change is local.

Question spans scattered files.

Best default for big codebases.

Whole-file context

Edit is confined to one or two files.

Files fit comfortably in budget.

Skip retrieval; just attach them.

Whole-repo context

Repo is small.

Change touches everything.

Cheaper to include than to retrieve.