code-graph-rag is a free, open source databases project written in Python and released under MIT. It has 5,148 GitHub stars, 676 forks and 119 open issues, and was last pushed 26 hours ago. On this registry it ranks #57 of 81 tracked projects in Databases, with 5 head-to-head comparisons available. It gained 10 stars over the last 3 tracked days.

What is code-graph-rag?

What it is

Code-Graph-RAG is a Python developer tool for multi-language codebase analysis and retrieval-augmented generation. It parses repositories with Tree-sitter, extracts functions, classes, methods, modules, and relationships, and stores them in a Memgraph knowledge graph under one language-agnostic schema. It lives in the Python AI developer-tools ecosystem.

The project addresses the problem of understanding large monorepos where code is spread across many languages and files. Instead of relying only on text search or manual reading, it turns repository structure into queryable graph data, so users can ask natural-language questions, retrieve source code, edit code with AST-based patching, and find dead code.

Key capabilities

  • It fully parses Python, TypeScript, TSX, JavaScript, Rust, Go, Java, C, C++, C#, PHP, Lua, and Dart, while Scala is in development and other languages have structural support through ast-grep.
  • It builds a unified Memgraph knowledge graph that connects functions, classes, methods, modules, and their relationships across a mixed-language monorepo.
  • It converts natural-language questions into Cypher queries, retrieves matching code, and returns answers grounded in repository structure.
  • It supports AST-based surgical patching with a diff preview, and it can optimize code against language best practices or user-defined standards.
  • It finds dead code by walking call and reference edges from entry points, and it supports structural search and rewrite through ast-grep patterns.
  • It overlays runtime behavior by tracing a test run or production eBPF profiles with cgr trace and merging observed calls into the graph.

Who uses it and how

  • Developers explore monorepos by asking about functions, classes, modules, and calls without reading every file.
  • Maintainers retrieve source for named symbols or by intent, then preview edits before applying them.
  • Teams audit code health by locating dead code, applying standards, and inspecting structural patterns.
  • Users combine static graph analysis with runtime traces to expose dispatch behavior.

Getting started

Install Code-Graph-RAG from PyPI with uv tool install or pipx install, using the treesitter-full and semantic extras. Run cgr against a repository to parse it, build the Memgraph graph, and query or edit the codebase.

When to use it — and when not to

Use Code-Graph-RAG when a team needs graph-based code understanding across multiple languages in one monorepo and can operate Memgraph as the backing database. Do not choose it if a single-language repository needs only simple text search, or if the team cannot maintain a graph database and a re-ingestion process. Some languages are still in development or only structurally supported, and GitHub releases and PyPI lag git tags, so users may need to track the repository directly for the newest fixes.

project readme (upstream, from github) — read inline

vitali87/code-graph-rag | Trendshift

CI Codecov Quality Gate Status Enterprise Support PyPI Version PyPI Downloads SkillsLLM Security Check OpenSSF Scorecard OpenSSF Best Practices

Code-Graph-RAG

Code-Graph-RAG parses a multi-language codebase with Tree-sitter, builds a knowledge graph of its structure in Memgraph, and lets you query, edit, and optimise that code in plain English. It works across a monorepo of mixed languages under one unified graph schema.

Latest News 🔥

  • File System Operations: Improved handling of file system operations with platform-neutral joins and safeguards against removing project root.
  • Cache Management: Enhanced cache management with atomic publishing, dedicated cache stamps, and improved deletion handling for orphan caches.
  • Graph Querying: Introduced deterministic graph query tools for more precise analysis of code relationships.
  • Re-ingestion & Parsing: Improved re-ingestion processes, including handling of deleted files, re-parsing of related files, and rebuilding of key data structures.
  • Security & Stability: Addressed security concerns by blocking removal of project root and improved stability by preventing skipped edits and handling orphaned caches.
  • C++ & Go Integration: Enhanced integration with C++ and Go, including parsing of module interfaces and handling of module-level class aliases.

See NEWS.md for the full history.

What It Does

Point Code-Graph-RAG at a repository and it reads every source file, extracts functions, classes, methods, modules, and the relationships between them, and stores the result as an interconnected graph. Once the graph exists you can:

  • Ask questions about the codebase in natural language and get answers grounded in the real structure.
  • Retrieve the actual source of any function, class, or method by name or by intent.
  • Edit code through the agent with AST-based surgical patching and a diff preview before anything changes.
  • Optimise code against language best practices or your own coding standards.
  • Find dead code by walking call and reference edges from entry points.
  • Search and rewrite structurally by AST pattern with ast-grep.
  • Overlay runtime behaviour: trace a test run (or pull production eBPF profiles) with cgr trace and merge the calls that actually happened into the graph, exposing dispatch that static analysis cannot see.

How It Works

The system has two components:

  1. Multi-language parser. A Tree-sitter based parser reads the codebase and ingests functions, classes, methods, modules, and their relationships into Memgraph under a single language-agnostic schema.
  2. RAG system (codebase_rag/). An interactive CLI that turns natural language into Cypher queries, retrieves matching code, and drives AI-powered editing and optimisation.
Source Code -> Tree-sitter Parser -> AST Analysis -> Memgraph Knowledge Graph
                                                             |
User Query -> AI Model (Cypher Gen) -> Cypher Query -> Graph Results -> Response

See the Architecture Overview and Graph Schema for the full picture.

Supported Languages

Python, TypeScript, TSX, JavaScript, Rust, Go, Java, C, C++, C#, PHP, Lua, and Dart are fully supported. Scala is in development, and Ruby, Kotlin, Swift, Elixir, Haskell, Solidity, Bash, and Nix have structural support (modules, functions, classes where the language has them, and imports) through the pluggable ast-grep tier. See the Language Support matrix for per-language capabilities.

Installation

cgr is published to PyPI. Install it system-wide with the treesitter-full (all languages) and semantic (vector search) extras:

# with uv (recommended)
uv tool install "code-graph-rag[treesitter-full,semantic]"

# or with pipx
pipx install "code-graph-rag[treesitter-full,semantic]"

Which version am I getting?

Three version lines exist and they intentionally differ:

where what it tracks
git tags every version, one per merge
GitHub Releases (binaries, signatures) every 50th version, plus any security fix
PyPI every 50th version, plus any security fix

So the newest tag on main usually runs ahead of the newest release, often by tens of patch versions; they coincide only just after a release. Nothing is stuck, the cadences differ by design. A security fix does NOT wait for the cadence: it ships a release and a PyPI upload immediately.

uv tool install and pipx install give you the newest PyPI version, which is the newest RELEASE, not the newest tag. Interim tags exist so every merge is addressable; binaries and PyPI uploads follow the cadence above.

To run code newer than the latest release, install from git:

uv tool install "code-graph-rag[treesitter-full,semantic] @ git+https://github.com/vitali87/code-graph-rag@main"

You also need Python 3.12+, Docker (for Memgraph), cmake, and ripgrep. Full prerequisites, source installs, and environment setup are in the Installation guide.

[!NOTE] The wheel is pure Python (py3-none-any), so the package itself installs on any platform with Python 3.12 or newer (dependencies may still need platform wheels or build tools, such as cmake for pymgclient). The piwheels build for Debian Bookworm shows as failed because Bookworm's system Python is 3.11, which is below our floor. On Raspberry Pi OS Bookworm, pin the interpreter explicitly, for example uv tool install --python 3.12 "code-graph-rag[treesitter-full,semantic]"; uv downloads Python 3.12 automatically and the PyPI wheel installs normally.

Quick Start

# Start the packaged Memgraph + Qdrant stack (no compose file needed)
cgr daemon up

# Parse a repository into the graph, then query it
cgr start --repo-path /path/to/repo --update-graph
cgr start --repo-path /path/to/repo

Repeat the first command for each repository you want indexed; the graph is shared, and syncing one project leaves the others alone. To start over from an empty graph, add --clean — it deletes every project in the shared graph, not just this one, and asks for confirmation first when other projects would be destroyed.

The Quick Start guide walks through parsing, querying, and exporting in five minutes.

MCP Server

Code-Graph-RAG runs as an MCP server so Claude Code and other MCP clients can query and edit your codebase directly. See the MCP Server guide for setup

readme truncated — read the full docs on github

Frequently asked questions

Is code-graph-rag free to use?

code-graph-rag is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does code-graph-rag do?

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

What is code-graph-rag written in?

code-graph-rag is primarily written in Python. Its source is publicly available at https://github.com/vitali87/code-graph-rag, and it has 5,148 GitHub stars.