Skip to content
TopicTracker
From HackerNewsView original
TranslationTranslation

Code Search: How Agents Search Across Snap's Codebase

Snap developed a code search system using code embeddings and a dual-encoder architecture to help AI agents search across its massive codebase. The system indexes code into vector embeddings for semantic search, enabling agents to efficiently find relevant code snippets, functions, and documentation by understanding intent rather than relying solely on keyword matching.

Background

- Snap Inc. is the parent company of Snapchat; its engineering team maintains a large, fast-moving monorepo (a single repository containing all code). - "Code Search" is Snap's internal system for searching across this monorepo. Unlike general web search, code search must understand syntax, definitions, references, and file structure at scale. - The blog post describes how Snap evolved from basic `grep`-style search to a purpose-built service that powers both human developers and automated coding agents (AI that writes or modifies code). - Key challenges: keeping the search index in sync with thousands of daily commits, supporting complex queries (e.g. "find all callers of this function"), and serving queries fast enough for interactive AI agents. - The system uses a custom indexing pipeline with a trie-based structure (for prefix/symbol matching) and a separate "Code Graph" for cross-reference resolution (e.g. jump-to-definition). - This matters because as more companies adopt AI coding assistants, robust internal code search becomes critical infrastructure — both for the AI to understand the codebase and for developers to verify AI-generated changes.

Related stories