vitali87/code-graph-rag
Graph-backed RAG for querying and editing multilingual codebases
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
Code-Graph-RAG is a code index and retrieval agent, not a general-purpose RAG database. Tree-sitter parses source into ASTs, and the indexer extracts symbols and relationships into a unified graph schema across languages. Compiler-grade frontends and runtime traces can enrich the graph where available. SQLite stores the graph in-process by default; Memgraph and Neo4j are opt-in backends that use the same Cypher queries.
The Python application in codebase_rag/ uses a model to turn questions into Cypher, then retrieves graph results and matching source to ground the response. The application requires the cgr-graph-rs native extension. From v0.7.180, the Rust engine framework is enabled by default with a Python fallback; that fallback does not remove the package's native extension requirement. The CLI is the direct interface, and MCP exposes query and edit capabilities to clients such as Claude Code.
Key Capabilities & Differentiators
The graph supports source lookup, relationship queries, and dead-code analysis by walking call and reference edges from entry points. Optional vector search adds intent-based lookup, while ast-grep supports structural search and rewrite. Agent-driven edits use AST-based patching with a diff preview before changes. cgr trace can merge observed calls from test runs or production eBPF profiles, revealing dispatch that static analysis misses for the workloads actually observed.
Full language support is listed for Python, TypeScript, TSX, JavaScript, Rust, Go, Java, C, C++, C#, PHP, Lua, Dart, Julia, and Lean 4; Scala is still in development. The ast-grep tier provides structural support for Ruby, Kotlin, Swift, Elixir, Haskell, Solidity, Bash, and Nix, including modules, functions, classes where applicable, and imports. That tier should not be treated as equivalent to full call or reference analysis. Optional capture groups are excluded from the default index and can be enabled with --capture or CGR_CAPTURE.
Trade-offs & Limitations
Compared with keyword search or vector-only code RAG, explicit edges are more useful when a question depends on callers, imports, or reachability rather than text similarity. The cost is an index that must stay current and whose usefulness depends on parser and edge coverage. Model-generated Cypher can also misread the question. Runtime overlays improve coverage for exercised paths, but an unobserved call is not proof of dead code. Use a representative repository to measure index build time, peak memory, and graph size; size local inference separately for the chosen model and concurrency.
Embedded SQLite is the lower-operations starting point. Use Memgraph or Neo4j when a separately managed graph service fits your operating model; do not assume a performance gain without testing the actual workload. The default graph can contain multiple projects, and --clean clears all of them, not just the selected repository. Isolate graph files where project boundaries matter. The MIT license supports self-hosting, but review model data flows and MCP filesystem access separately before exposing proprietary workspaces or enabling editing.
Hardware & Deployment Guide
Install with uv tool or pipx on CPython 3.12+ with ripgrep. Native wheels constrain platform compatibility: Linux x86_64 and aarch64, macOS, and Windows x64 are listed. The default deployment needs neither Docker nor a database server. Build the index with cgr start --repo-path /path/to/repo --update-graph; the default database is ~/.cgr/graph.sqlite, configurable through SQLITE_GRAPH_PATH. For the opt-in Memgraph path, install the memgraph extra, set GRAPH_BACKEND=memgraph, and use cgr daemon up to start the packaged Memgraph and Qdrant stack.
The Dockerfile uses uv and a Rust toolchain to build cgr-graph-rs from rust/. Release v0.7.129 introduced ordered parallel hashing and cross-checked Rust discovery against the Python walk; v0.7.180 made the Rust framework the default and added Go and patched C/C++ grammars. The supplied manifest is at 0.7.185 while the listed release is v0.7.180, consistent with source versions running ahead of published packages. Pin the tested artifact, especially when evaluating language coverage. For offline deployment, validate model inference and any optional semantic search dependencies separately from local graph storage.
semantic extra adds vector search.cgr trace adds observed calls from test runs or production eBPF profiles to the graph.Teams maintaining a multilingual monorepo that need answers grounded in call and import relationships, with a local index and optional MCP integration for reviewed edits.
Keyword or similarity search already meets your needs, your critical languages only have structural coverage, or you cannot validate the client and model data paths against your source-handling policy.
Quick Start & Installation
# with uv (recommended) uv tool install "code-graph-rag[treesitter-full,ast-grep,semantic]" # or with pipx pipx install "code-graph-rag[treesitter-full,ast-grep,semantic]"
Comparison vs. Top RAG, Data & Memory Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| code-graph-rag ★ | 5.5k | +20 | Python | MIT | Graph-backed RAG for querying and editing multilingual codebases |
| Scrapling | 107.9k | +1.8k | Python | BSD-3-Clause | Python HTTP and browser crawlers that turn websites into RAG-ready Markdown |
| cognee | 33.8k | +174 | Python | Apache-2.0 | Graph and vector retrieval for persistent agent memory across sessions |
| crawl4ai | 88.5k | +408 | Python | Apache-2.0 | Async browser crawler that turns web pages into Markdown and JSON for RAG |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/vitali87/code-graph-rag.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about code-graph-rag
How do I index a repository and connect an assistant?
cgr start --repo-path /path/to/repo --update-graph to build or refresh the index, then start an interactive session without --update-graph. The default index lives at ~/.cgr/graph.sqlite; set SQLITE_GRAPH_PATH to isolate it. MCP provides an alternative integration for clients such as Claude Code that need query or edit access.Do I need a GPU, and how should I size the runtime?
Can we self-host it for commercial work without sending source off-site?
When is this a better fit than ripgrep or vector-only code RAG?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy