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
Code‑Graph‑RAG – AI‑powered code‑base knowledge graph
What it is – An open‑source tool that parses a multi‑language repository with Tree‑sitter, stores the extracted functions, classes, modules and their relationships in a Memgraph knowledge graph, and lets you interact with that graph through natural‑language queries. It also supports AI‑driven code editing, optimisation, dead‑code detection and runtime‑trace overlay.
How it works
- Parsing – Tree‑sitter walks every source file (Python, TS/JS, Rust, Go, Java, C/C++, C#, PHP, Lua, Dart, etc.) and builds an AST.
- Graph ingestion – The AST is transformed into a language‑agnostic schema and loaded into Memgraph.
- RAG loop – A CLI (
cgr) turns a user’s English question into a Cypher query via an LLM, runs it against the graph, and returns a grounded answer. The same loop can generate AST‑based patches for edits.
Key capabilities
- Natural‑language Q&A over the whole codebase, with results tied to real symbols.
- Source retrieval by name or intent.
- AI‑driven editing: surgical AST patches previewed as diffs before applying.
- Code optimisation against best‑practice rules or custom standards.
- Dead‑code detection by traversing call/reference edges.
- Structural search & rewrite using
ast‑greppatterns. - Dynamic tracing: merge eBPF or test‑run call graphs into the static graph to expose runtime dispatch.
- MCP server compatibility so tools like Claude Code can query/edit the graph directly.
Installation & usage
- Install the
cgrCLI from PyPI with the full Tree‑sitter and semantic extras (pipxoruv). - Run the bundled Memgraph + Qdrant stack with
cgr daemon up(Docker required). - Index a repo:
cgr start --repo‑path /path/to/repo --update‑graph. - Query or edit via the interactive CLI or programmatically through the Python SDK.
Why it matters
- Provides a single, language‑agnostic graph for monorepos that mix dozens of languages, something most code‑search tools lack.
- Bridges static analysis and runtime information, giving a more complete picture of how code actually behaves.
- Enables AI agents to make precise, AST‑level changes rather than crude text edits, reducing the risk of breaking code.
- Open‑source core with optional enterprise‑grade managed or air‑gapped deployments, making it suitable for regulated environments.
Resources
- Detailed docs: installation, quick‑start, CLI reference, architecture, SDK, and advanced topics.
- Community: CI badge, code‑coverage, SonarCloud quality gate, OpenSSF scorecards.
- Enterprise services for managed cloud or on‑premise hosting.
Bottom line – Code‑Graph‑RAG is a full‑stack, AI‑enhanced platform for turning any codebase into a queryable knowledge graph, enabling natural‑language insight, safe automated refactoring, and deeper static‑dynamic analysis.
Related
- Project
- Project
- Project
- Project
- Project