How to Update code-graph-rag: Complete Upgrade Guide

Updating code-graph-rag requires pulling the latest source from the GitHub repository, reinstalling the Python distribution using uv or pipx, and rebuilding the knowledge graph to refresh Memgraph with the latest codebase structure.

code-graph-rag is a Python-based tool that parses multi-language codebases with Tree-sitter, builds a knowledge graph in Memgraph, and provides a natural-language RAG interface. Keeping the tool updated ensures you benefit from the latest language support, security patches, and performance improvements available in the vitali87/code-graph-rag repository.

Update Methods Overview

The update process for code-graph-rag consists of three logical layers: fetching the newest source code, reinstalling the Python distribution with updated dependencies, and refreshing the graph data. According to the repository's README.md, the project distributes a PEP 517-compatible wheel on PyPI and supports direct installation from the source tree using either uv or pipx.

When you update the package, the system rebuilds compiled extensions such as Tree-sitter parsers for your host platform. This prevents binary version mismatches that could cause parsing failures when scanning repositories.

Step-by-Step Update Workflow

Fetch the Latest Source Code

Begin by pulling the latest commit from the main branch to guarantee you have the most recent bug-fixes and AST-grep patterns. The repository's default branch is the authoritative source for all updates.

git clone https://github.com/vitali87/code-graph-rag.git
cd code-graph-rag
git checkout main
git pull origin main

Recent releases may add support for new languages. For example, Ruby support was added in recent updates as documented in README.md at line 76.

Reinstall the Python Distribution

After fetching the source, reinstall the package to update compiled extensions and dependencies. The README.md (lines 119-124) lists two preferred installation methods.

Option A: Using uv (Recommended)

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

Option B: Using pipx

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

Both commands install the optional treesitter-full and semantic extras defined in pyproject.toml, ensuring all parsing capabilities are available.

Refresh the Knowledge Graph

Once the package is updated, you must rebuild the graph to clear stale in-memory caches and re-index the codebase. The core update loop resides in realtime_updater.py at line 374, where updater.run() initializes the scanning process.


# Re-scan your project to rebuild the knowledge graph

cgr scan /path/to/your/project

This command invokes the GraphUpdater class located in codebase_rag/graph_updater.py, which parses files, builds the graph structure, and flushes data to Memgraph.

Advanced Update Scenarios

Schema Migrations

If a new schema version is released, apply migrations to update the Memgraph database structure without losing existing relationship data.

cgr upgrade-schema

This command applies any schema migrations defined in the codebase_rag/ package. The scripts/release.sh file contains automation logic used by maintainers to handle version bumps, which can help you understand when schema changes are necessary.

Runtime Tracing Updates

To enrich the graph with dynamic call edges after updating, re-run the runtime tracer on your test suite.

cgr trace /path/to/your/project/tests

This updates the graph with runtime call data that static analysis cannot detect, ensuring your knowledge graph reflects the actual execution paths in your codebase.

Summary

  • Pull the source from the main branch to get the latest fixes and language support.
  • Reinstall using uv or pipx with the [treesitter-full,semantic] extras to update compiled parsers.
  • Run cgr scan to rebuild the Memgraph knowledge graph and clear cached data.
  • Apply schema migrations with cgr upgrade-schema when moving between major versions.
  • Optional tracing with cgr trace updates dynamic call relationships in the graph.

Frequently Asked Questions

How do I verify which version of code-graph-rag is currently installed?

Check your installed version by running cgr --version or examining the package metadata in your Python environment. Since the project uses PEP 517 packaging defined in pyproject.toml, you can also use pip show code-graph-rag or uv pip list to view the current installation details.

Will updating code-graph-rag delete my existing graph data in Memgraph?

Running cgr scan rebuilds the graph schema but preserves the database connection settings. However, the GraphUpdater class in codebase_rag/graph_updater.py flushes and repopulates node data, which may overwrite existing entities. Always back up your Memgraph instance before performing major version updates.

What is the difference between using uv and pipx for updates?

uv provides faster installation and better environment isolation for Python tools, while pipx creates isolated environments specifically for Python applications. Both methods support the [treesitter-full,semantic] extras required for full language parsing. The README.md (lines 119-122) recommends uv for its performance, but pipx (lines 122-124) remains a viable alternative for users with existing pipx workflows.

Do I need to rebuild the graph after every minor update?

While minor updates may not change the schema structure, rebuilding the graph with cgr scan ensures that Tree-sitter parsers match the updated binaries installed with the package. The realtime_updater.py file contains logic at line 374 that handles debounced updates, but a manual full scan guarantees consistency between the parser version and the indexed codebase.

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 →