How to Install Code-Graph-RAG: Complete Setup Guide for Multi-Language Code Intelligence

Install Code-Graph-RAG using uv tool install "code-graph-rag[treesitter-full,semantic]", launch the Docker services with cgr daemon up, and index your repository with cgr start --repo-path ./your-repo --update-graph to begin querying code via natural language.

Code-Graph-RAG is an open-source code intelligence system that parses multi-language codebases into knowledge graphs and enables natural-language querying. According to the vitali87/code-graph-rag source code, the tool combines Tree-sitter AST parsing with Memgraph storage to create a two-component architecture for AI-powered code analysis. This guide walks you through installing Code-Graph-RAG and configuring its dependencies for immediate use.

Prerequisites

Before installing Code-Graph-RAG, ensure your system meets the following requirements:

  • Docker – Required to run the Memgraph graph database and Qdrant vector search containers
  • CMake and ripgrep – Needed to build Tree-sitter grammars for multi-language parsing
  • uv or pipx – Modern Python package installers for the CLI entry point
  • gcc (or equivalent) – Required to compile native Tree-sitter components

Step-by-Step Installation

1. Install the Python CLI Tool

The cgr command-line interface is published on PyPI and provides the primary entry point for the system. Use either uv or pipx to install the package with full language support.


# Recommended: using uv

uv tool install "code-graph-rag[treesitter-full,semantic]"

# Alternative: using pipx

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

The [treesitter-full,semantic] extras ensure all Tree-sitter grammars and semantic embedding capabilities are included.

2. Start the Database Services

Code-Graph-RAG requires both Memgraph (for the knowledge graph) and Qdrant (for vector search). The CLI provides a bundled Docker Compose setup to launch both services.

cgr daemon up

This command initializes the Docker containers and exposes the necessary ports for graph and vector operations.

3. Parse Your Repository

Once the services are running, index your target codebase. The parser extracts entities—functions, classes, modules, and imports—and populates the Memgraph graph according to the unified schema defined in the architecture.

cgr start --repo-path /path/to/your/repo --update-graph

The --update-graph flag triggers the Tree-sitter parser in codebase_rag/graph_updater.py, which handles incremental updates from filesystem events to the graph.

4. Query the Graph

After indexing, interact with your codebase using natural language questions. The system translates queries into Cypher via templates defined in codebase_rag/cypher_queries.py and retrieves relevant code snippets.

cgr start --repo-path /path/to/your/repo

You can now ask questions such as "Where is UserService defined?" or "What functions call process_data?" and receive grounded answers drawn from the actual source code.

Optional: Reset the Graph

To clean the shared graph and start fresh with a different repository:

cgr start --repo-path /path/to/your/repo --clean

Understanding the Architecture

Code-Graph-RAG operates as a two-component system that bridges static analysis with generative AI.

Multi-Language Parser – Uses Tree-sitter to generate language-agnostic ASTs and stores entities in Memgraph. This component resides in codebase_rag/graph_loader.py and codebase_rag/graph_updater.py, which manage graph persistence and incremental updates.

RAG CLI – Translates natural-language questions into Cypher queries, retrieves source snippets, and drives AI-powered editing. The query generation logic leverages codebase_rag/function_registry.py to register LLM-callable functions for semantic search and code modification.

Core Source Files and Their Roles

The following files compose the core of the parsing pipeline and RAG interaction layer:

Summary

  • Install the CLI using uv tool install or pipx install with the [treesitter-full,semantic] extras to ensure complete language support
  • Launch backing services with cgr daemon up to provision Memgraph and Qdrant containers automatically
  • Index repositories using cgr start --repo-path <path> --update-graph to parse code into the knowledge graph via Tree-sitter
  • Query naturally by running cgr start --repo-path <path> without the update flag, leveraging Cypher templates and vector embeddings
  • Reset the graph state with the --clean flag when switching between projects

Frequently Asked Questions

What is the difference between using uv and pipx to install Code-Graph-RAG?

Both uv and pipx install the cgr CLI in isolated environments, preventing dependency conflicts with your system Python. The uv tool is generally faster and recommended by the project maintainers, but pipx works identically for end-users. Either method requires the [treesitter-full,semantic] extras to ensure all Tree-sitter grammars and embedding models are available.

Why does Code-Graph-RAG require Docker?

Code-Graph-RAG relies on Memgraph as its graph database and Qdrant for vector similarity search. Rather than requiring manual database configuration, the cgr daemon up command orchestrates these services via Docker containers, ensuring consistent versions and persistent storage across restarts.

Can I parse multiple repositories simultaneously?

While the CLI supports parsing different repositories, the Memgraph instance maintains a shared graph namespace. To avoid entity collisions between projects, use the --clean flag when switching repositories, or run separate Docker instances for complete isolation.

How do I verify that the Tree-sitter parsers compiled correctly?

After installation, run cgr start --repo-path ./test-repo --update-graph on a small sample repository. If the command executes without CMake or GCC errors and reports entities being added to the graph, the native Tree-sitter components compiled successfully. Check codebase_rag/graph_updater.py for detailed logging of the parsing pipeline if issues occur.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →