Dev

Code-Graph-RAG: Operate Multilingual Codebases with Natural Language

Analyze multilingual codebases with Tree-sitter and build a knowledge graph in Memgraph. Query, edit, and optimize code using natural language.

4 min read Reviewed & edited by the SINGULISM Editorial Team

Code-Graph-RAG: Operate Multilingual Codebases with Natural Language
Photo by Markus Spiske on Unsplash

Code-Graph-RAG is a tool that combines Tree-sitter and Memgraph to analyze multilingual codebases and build a knowledge graph. Developed by vitali87, a trending GitHub project, it allows users to query the graph in natural language and perform code editing and optimization. It is characterized by its ability to handle environments where multiple programming languages coexist within a monorepo using a unified graph schema.

Structuring Complex Codebases

The tool reads all source files in a repository, extracts functions, classes, methods, modules, and their relationships, and stores them in Memgraph as an interconnected graph. This makes the entire structure of the codebase comprehensible as data.

Once the graph is built, users can ask questions in natural language. For example, a question like “What is the list of functions called from the entry point of this project?” returns an answer based on the actual code structure. It can also be used to retrieve the source code of a specific function or class by intent or name, and to find unnecessary dead code.

Latest Features and Multilingual Support

As of August 2026, the project has added several notable new features. First, structural support for Ruby. Through a pluggable hierarchy using ast-grep, a language can be added with a single YAML pattern file, generating Module, Function, and Class nodes and import edges without a hand-written parser.

In addition, a structural search and replace feature has been implemented. Using ast-grep, it searches for code using abstract syntax tree patterns rather than text or regular expressions, and performs replacements. This is exposed as an agent tool, enabling structural transformations across the entire codebase.

Furthermore, data flow tracking is now available for four languages: C#, Java, C, and Go. It adds an untrusted data flow edge called FLOWS_TO, tracking value propagation through assignments, function calls, and I/O sinks. This is an effective feature for security audits and bug identification.

Architecture and Installation

The system consists of two main components. One is a Tree-sitter-based multilingual parser that analyzes the codebase and imports it into Memgraph using a language-agnostic schema. The other is a RAG system (codebase_rag/) that converts natural language into Cypher queries through an interactive CLI, retrieves code, and executes AI-powered editing and optimization.

Currently supported languages are Python, TypeScript, JavaScript, Rust, Go, Java, C, C++, C#, PHP, Lua, and Dart. Scala is under development, and Ruby has structural support. It can be installed from PyPI as the “cgr” package, with installation via uv or pipx recommended. Docker (for Memgraph), cmake, and ripgrep are also required.

Editorial Opinion

In the short term, Code-Graph-RAG has the potential to improve the efficiency of debugging and code reviews. A natural language interface is likely to lower the barrier, especially in understanding large legacy codebases and sharing intent across cross-functional teams. When introducing it, setting up the Memgraph production environment and a graph update strategy will likely become new challenges.

In the long term, this suggests a shift in the development paradigm—“conversing with code.” It can be seen as a step in the evolution of AI-driven development support tools from mere assistants to partners that understand and operate on the semantic structure of codebases. In the future, integration into CI/CD pipelines and automation of pre-release risk analysis are also within scope, pointing toward more integrated development workflows.

However, can this approach—which depends on the accuracy of graph construction and the interpretation of natural language queries—correctly cover all code patterns and intents? In particular, how to handle elements that cannot be captured by structure alone, such as implicit knowledge and business logic, will likely determine the practical utility of this kind of tool.

References

Source: GitHub Trending

Comments

← Back to Home