Back to Devoured - August 12, 2026
DEVOURED
Code-Graph-RAG (GitHub Repo)

Code-Graph-RAG (GitHub Repo)

DevOps GitHub
Code-Graph-RAG allows developers to query and manipulate multi-language codebases in plain English by mapping them into a unified knowledge graph.
What: Code-Graph-RAG uses Tree-sitter to parse code into a Memgraph knowledge graph, supporting 14 languages. It functions as an MCP server for AI agents like Claude Code to perform structural code edits and taint-analysis tracking.
Why it matters: It signals a shift from text-based RAG to structural-based RAG, allowing AI models to understand code topology and dependency edges rather than just character sequences.
Takeaway: Install via `uv tool install "code-graph-rag[treesitter-full,semantic]"` and run `cgr daemon up` to start indexing your repository.
Deep dive
  • Uses Tree-sitter for multi-language AST parsing.
  • Stores metadata and relationships in Memgraph.
  • Enables natural language queries via Cypher generation.
  • Supports structural search and replace via ast-grep.
  • Tracks data-flow via FLOWS_TO taint edges.
  • Runs as an MCP server for integration with AI coding agents.
  • Requires Docker, cmake, and ripgrep.
Decoder
  • MCP (Model Context Protocol): An open standard for connecting AI assistants to data sources and development tools.
  • AST (Abstract Syntax Tree): A tree representation of the abstract syntactic structure of source code.
  • Cypher: A declarative graph query language for interacting with graph databases like Memgraph.
Original article

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 🔥

  • Ruby Support: Ruby joins the graph through a new pluggable ast-grep tier that adds a language from a single YAML pattern file, emitting Module, Function, and Class nodes plus import edges without a hand-written parser.
  • Structural Search & Replace: Find and rewrite code by AST pattern with ast-grep, exposed as agent tools so you can match and transform structure across the whole codebase instead of relying on text or regex.
  • Data-Flow Tracing: New FLOWS_TO taint edges follow values through assignments, function calls, and I/O sinks. This release adds C#, Java, C, and Go, bringing tracing to 10 languages (Python, JavaScript, TypeScript/TSX, Go, Java, Rust, C++, C, and C#).

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.

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

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 has structural support (modules, functions, classes, and imports) through the pluggable ast-grep tier.

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]"

You also need Docker (for Memgraph), cmake, and ripgrep.

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

MCP Server

Code-Graph-RAG runs as an MCP server so Claude Code and other MCP clients can query and edit your codebase directly.

Enterprise Services

Code-Graph-RAG is open source and free to use. For organisations that need more, we offer fully managed cloud-hosted solutions and on-premise deployments:

  • Cloud-Hosted Deployment: Managed cloud infrastructure for both the graph database and the AI agent connection. Zero infrastructure overhead, so we handle scaling, updates, and availability while your team focuses on building.
  • On-Premise & Air-Gapped Deployment: Deploy Code-Graph-RAG entirely within your own environment, including air-gapped networks. Full data sovereignty for regulated industries and security-sensitive organisations.

License

MIT.

Explore all 58 articles in today's digest

Fresh dev news, AI-digested daily. Never miss a trend at devoured.fyi