← Back to glossary
+Suggest a term
Tool·Builder Tools·Added 23 days ago

CodeGraph

Also known as: code graph, code knowledge graph, codebase knowledge graph

A tool that builds a persistent knowledge graph of a codebase's structure: functions, classes, call chains, and routes. Agents and IDEs query this graph instead of re-reading raw files, cutting token usage dramatically for structural questions.

When a coding agent needs to understand how a function is called across a large codebase (a large set of interconnected code files), the naive approach is to stuff as much code as possible into the context window (the working memory available to the model in one session). That's expensive and often hits limits. CodeGraph takes a different approach: it pre-indexes the codebase into a structured knowledge graph that maps every function, class, route, and call chain, then lets agents and IDEs query that graph directly for structural questions.

The indexing runs via tree-sitter (a widely used code parsing library that understands syntax across 150+ languages), builds a static binary with no external dependencies, and stores the result locally. The graph handles even very large codebases, including the Linux kernel, in a few minutes. For agents asking questions like 'what calls this function?' or 'where is this class imported?', querying the graph rather than re-reading raw code can reduce token usage by up to 99% for those specific query types.

CodeGraph is specialist territory today because the setup requires understanding how your agent framework queries context, and integrating a local graph server into that pipeline is an extra configuration step. But the underlying concept is becoming increasingly relevant as agentic workflows operate on larger codebases. The broader pattern, pre-computing structural indexes so agents spend token budget on reasoning rather than reading, is one of the key ideas in context engineering for code-heavy tasks.

This definition is AI-generated and refreshed weekly. It may contain inaccuracies. Use your own judgment, especially for production decisions.
Related terms
Context engineeringAgentic codingRAGContext windowllms.txt