vitali87/code-graph-rag

The ultimate RAG for your monorepo. Query, understand, and edit multi-language codebases with the power of AI and knowledge graphs

What it solves

Code-Graph-RAG helps developers understand, query, and modify large, multi-language codebases by transforming source code into a searchable knowledge graph. It solves the problem of traditional text-based search or simple RAG, which often lack the structural awareness of how functions, classes, and modules relate across a repository.

How it works

The system consists of two primary components:

  1. Multi-language parser: Uses Tree-sitter to analyze source code and extract structural elements (functions, classes, methods, modules) and their relationships. This data is stored in a Memgraph database using a language-agnostic schema.
  2. RAG system: An interactive CLI that converts natural language queries into Cypher queries to retrieve precise code structures from the graph, which are then used to ground AI-powered responses, edits, and optimizations.

Who it’s for

Software engineers and architects who work with complex monorepos or multi-language projects and need a way to perform structural search, find dead code, or automate code refactoring using AI.

Highlights

  • Broad Language Support: Supports Python, TypeScript, Rust, Go, Java, C, C++, C#, PHP, Lua, and Dart, with structural support for Ruby via ast-grep.
  • AST-based Editing: Allows for surgical code patching and structural search-and-replace using AST patterns instead of regex.
  • Data-Flow Tracing: Tracks how values move through assignments and function calls in C#, Java, C, and Go.
  • MCP Server: Integrates as a Model Context Protocol server, allowing AI clients like Claude Code to interact with the codebase directly.
  • Dead Code Detection: Identifies unused code by walking call and reference edges from entry points.