Most AI coding assistants fail the moment your question spills beyond a single file. They stare at an open tab, guess what your imports might be doing, and hallucinate helper functions when asked how an authentication middleware interacts with downstream microservices.
Sourcegraph Cody takes a radically different route. Instead of treating code like natural prose and stuffing arbitrary chunks into a vector database, it mounts large language models on top of Sourcegraph's decade-long code search and graph intelligence infrastructure. At 365Finds, we evaluate developer tools based on architectural reality rather than marketing claims. Here is how Sourcegraph Cody actually indexes entire repositories, resolves cross-file dependencies, and produces grounded code explanations.
The Architectural Core: Three Coordinated Retrieval Layers
Code is not ordinary text. A variable name has strict scope; an interface method has concrete implementations across unrelated directories; a utility function in Repo A might be imported by fifty microservices in Repo B. Standard vector retrieval-augmented generation (RAG) breaks down here because vector distance cannot tell whether a snippet is a production handler or a mocked test fixture.
To overcome this, Sourcegraph Cody couples generative models with a multi-layered context engine:
+-------------------------------------------------------------------+
| Developer Prompt |
| "How does our auth middleware validate JWTs?" |
+---------------------------------+---------------------------------+
|
v
+-------------------------------------------------------------------+
| Cody Context Engine |
| |
| [SCIP Code Graph] [Zoekt Text Search] [Vector Indices] |
| - Precise definitions - Sub-millisecond regex - Semantic matching |
| - Call references - Exact symbol matches - Intent-to-code |
| - Cross-repo boundaries - Global file indexing - Fuzzy concepts |
| |
| [IDE / Editor Context] |
| - Open tabs, cursor position, local AST (Tree-Sitter) |
+---------------------------------+---------------------------------+
|
Ranked, Pruned Token Payload
v
+-------------------------------------------------------------------+
| Frontier LLM (Claude / GPT) |
| Produces grounded, file-cited explanation |
+-------------------------------------------------------------------+
1. SCIP (Source Code Intelligence Protocol): Compiler-Level Precision
The backbone of Sourcegraph Cody's architectural understanding is SCIP, an open-source, Protocol Buffers-based standard developed by Sourcegraph.
Unlike basic linters or lightweight text splitters, language-specific SCIP indexers (scip-typescript, scip-python, scip-java, scip-go, etc.) parse code structurally through Abstract Syntax Trees (ASTs) during automated builds:
- Global Symbol Identification: Every class, function, variable, and interface is assigned a globally unique identifier containing its package manager, package name, version, and descriptor hierarchy.
- Relationship Mapping: SCIP deterministically links symbol definitions to every reference and implementation across your entire organization's repositories.
- Eliminating Hallucinations: When you ask Cody to explain a function, it doesn't speculate on where an imported class is defined. It queries the SCIP graph, fetches the exact definition and upstream callers, and passes them as verified facts to the language model.
2. Zoekt: Trigram-Based Inverted Search
For exact keyword matching, error codes, configuration strings, and raw syntax, Cody uses Zoekt, Sourcegraph's ultra-fast indexed search engine:
- Zoekt splits repository content into trigrams (3-character sequences), enabling sub-second regular expression and literal searches across tens of thousands of repositories.
- When an explanation requires inspecting configuration files (
docker-compose.yml, Helm charts, YAML pipelines) where compiler ASTs do not apply, Zoekt immediately retrieves the exact matches.
3. Vector Embeddings: Semantic Concept Retrieval
To bridge natural language inquiries with codebase implementations, Sourcegraph indexes code chunks into vector databases using embedding models (such as customized MPNet variants or OpenAI embeddings):
- When a developer asks "Where do we handle token renewal backoff?", vector search locates functions like
refreshExponentialDelayeven if the words "renewal" or "backoff" never appear in the identifier. - Vector search provides candidate candidates; the SCIP graph then validates which candidates actually connect to the runtime execution path.
The Execution Pipeline: From Question to Explanation
When you submit a prompt such as "Explain how our payment webhook handler verifies Stripe signatures and updates order records", Sourcegraph Cody executes a four-phase pipeline:
- Query Parsing and Intent Extraction: Cody breaks down your natural language prompt into target concepts, file paths, potential symbol names, and operational scope. It checks your active editor buffer and nearby tabs via Tree-Sitter for immediate context.
- Multi-Source Retrieval:
- Zoekt scans for literal terms like
Stripe-Signatureor webhook endpoints. - Vector search pulls code blocks semantically related to signature verification and order state mutations.
- SCIP traverses the call graph starting from the webhook route, pulling in the exact signature validation utility, the order service interface, and the database persistence models.
- Zoekt scans for literal terms like
- Context Assembly and Budget Packing: Frontier models have token limits and attention degradation over long contexts. Cody deduplicates retrieved blocks, ranks them by structural proximity and semantic score, and prunes boilerplate to build a high-signal context payload.
- Grounded Generation: Cody feeds the structured payload into the configured LLM (e.g., Claude 3.5 Sonnet or GPT-4o), instructing it to synthesize the explanation strictly from the supplied context and cite exact file paths and line numbers.
365Finds Analysis: Where Cody Excels and Where Friction Lies
365Finds views Sourcegraph Cody as one of the few developer tools addressing the true bottleneck of AI-assisted engineering: cross-boundary codebase context.
| Evaluation Dimension | Sourcegraph Cody Implementation | 365Finds Assessment |
|---|---|---|
| Architectural Depth | Combines SCIP compiler graphs with Zoekt regex search | Superior. Far more reliable than naive RAG tools that slice files into arbitrary 500-token chunks. |
| Multi-Repository Scope | Queries across thousands of connected repos via Sourcegraph server | Essential for Enterprises. Solves the microservices blindspot that paralyzes local-only assistants. |
| Setup & DevOps Overhead | Requires repository indexing, executors, and CI/CD pipelines for SCIP | High Friction. Teams must maintain indexing infrastructure to extract maximum value. |
| Graceful Degradation | Falls back to local embeddings and text search if SCIP is absent | Noticeable Drop in Intelligence. Explanations lose cross-repo call hierarchy without deep indexing. |
| Context Governance | Context Filters allow regex-based inclusion/exclusion per repo | Enterprise-Ready. Essential for preventing proprietary code leakage into external LLMs. |
The Real-World Catch
Cody's deep contextual power is directly tied to your indexing hygiene. In our assessment at 365Finds, if you use Cody purely as a standalone IDE extension without connecting it to an enterprise Sourcegraph instance with SCIP indexing enabled, you get roughly 30% of its potential. It behaves like an above-average local assistant.
However, when connected to a properly configured Sourcegraph backend where executors continuously run scip-* indexers on every commit, Cody outclasses standard coding assistants. It answers architectural questions across fifty microservices with precision, pointing directly to the exact config and interface definitions.
365Finds Verdict and Recommendation
- We Recommend Sourcegraph Cody If: You work in a medium-to-large engineering organization with hundreds of repositories, microservice architectures, or massive monorepos where no single engineer holds the entire architecture in their head. The combination of SCIP graph precision and Zoekt search justifies the setup investment.
- Consider Alternatives If: You are a solo developer or working within a single small monorepo. Tools like GitHub Copilot or Cursor with local indexing require near-zero infrastructure maintenance and provide a faster out-of-the-box experience for single-codebase workflows.
Sourcegraph Cody succeeds because it recognizes an uncomfortable truth: language models do not understand code architecture on their own; they need a compiler-accurate code graph to guide them.