Initializing portfolio

000

Aravind.
All articles
AI2 min read

Querying a Codebase as a Graph, Not a Pile of Text

code-graph-rag parses repositories with Tree-sitter into a Memgraph knowledge graph, so questions about call paths get exact answers instead of similarity guesses.

AravindChief Technology Officer & Advisor · AI, Cloud & Cybersecurity
Querying a Codebase as a Graph, Not a Pile of Text

Most AI coding tools retrieve by similarity. You ask about authentication, they find chunks of code that look like they're about authentication, and you hope the relevant caller was in the top ten. Code-graph-rag takes a different route: parse the repository into a knowledge graph first, then answer questions by querying the graph.

How it's built

Tree-sitter parses the codebase and extracts functions, classes and modules. Those get ingested into a Memgraph knowledge graph under one schema, regardless of source language. Natural language questions are then translated into Cypher queries against that graph.

The difference in kind matters. "Which functions call this one, transitively" is a graph traversal with an exact answer. As a similarity search it's a guess.

Language coverage is broad: Python, TypeScript, TSX, JavaScript, Rust, Go, Java, C, C++, C#, PHP, Lua and Dart are fully supported. Ruby gets structural capability through an ast-grep integration. Scala is still in progress.

What you can do with it

Beyond asking questions, it edits. AST-based modifications, structural search and replace, code optimisation, and real-time updates with diff previews before anything is written. Dead code detection falls out of the architecture almost for free — traverse the call graph and see what nothing reaches.

There's an interactive CLI, an MCP server so Claude Code can use it as a tool, semantic and structural search, and graph export.

Setup is uv tool install "code-graph-rag[treesitter-full,semantic]", then cgr daemon up to start the Memgraph stack and cgr start to parse and query. MIT licensed. Around 3.1k stars, 527 forks, and 4,690 commits on main — an actively maintained project rather than a weekend demo.

Where this fits

The unglamorous case for this tooling is legacy estates. Anyone who has tried to work out what a twenty-year-old ERP integration actually touches knows the problem isn't reading code, it's establishing reach. A call graph answers that; a vector search offers plausible-looking neighbours.

The running Memgraph instance is a real operational dependency, and the graph needs re-parsing as the code moves. Worth knowing before you propose it as standard tooling. For a one-off comprehension exercise on a codebase nobody understands any more, that cost is trivial next to the alternative.

Source: vitali87/code-graph-rag on GitHub

#Open Source#GitHub#RAG#Knowledge Graph#Code Search

Comments

Checking you're human…

Keep reading

Get the next essay first

Checking you're human…

By subscribing you agree to our Privacy Policy. Unsubscribe anytime.