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
PrimeIntellect-ai/prime-agent(已於 2026-08-08 推過),故改推第 2 名。PrimeIntellect-ai/prime-agent 已連續霸榜 3 天,當初在 2026-08-08 推過,值得回頭再看一眼。這是什麼
code-graph-rag 是一套面向大型程式碼庫的 RAG + 知識圖譜 工具。它不是只把檔案切塊丟進向量庫,而是先用 Tree-sitter 讀取 repository,抽出 functions、classes、methods、modules,以及呼叫、引用、匯入等關係,寫進 Memgraph 形成可查詢的程式碼圖。使用者之後可以用自然語言詢問程式碼庫,系統會把問題轉成 Cypher 查詢,取回真實結構與原始碼片段,再輔助回答、搜尋、修改或最佳化。README 也提到它支援結構化搜尋與替換、dead code 偵測、AST-based patching,並在修改前提供 diff preview;這讓它比較像「懂 codebase 結構的 agent 工具層」,而不是一般全文搜尋。
為什麼上榜
這個專案今天在日榜拿到 96 顆星、累積約 2,971 stars,熱點很明顯:AI coding 工具正在從「單檔補全」走向「整個 monorepo 的理解與編輯」。code-graph-rag 的差異在於把自然語言、Cypher、AST 分析、圖資料庫與 MCP 串在一起,讓 AI 不只憑文字相似度猜答案,而能沿著函式、類別、模組、引用關係找證據,也比較容易說明答案從何而來。README 最新消息也強調 Ruby support、AST 結構化搜尋替換,以及 FLOWS_TO taint/data-flow tracing;這些更新指向一個更工程化的方向:讓 agent 能跨語言理解結構、追蹤資料流,並做更精準的 code rewrite。
適合誰,可以拿來做什麼
它最適合要處理 大型、多語言程式碼庫 的團隊或個人:例如接手陌生 monorepo、查某個功能從入口到實作的路徑、找 dead code、根據 coding standard 做最佳化,或讓 Claude Code 等 MCP client 直接查詢與編輯程式碼庫。README 列出完整支援 Python、TypeScript、TSX、JavaScript、Rust、Go、Java、C、C++、C#、PHP、Lua、Dart;Scala 開發中,Ruby 目前有結構支援。上手門檻不算零,因為除了 Python 套件外還需要 Docker 跑 Memgraph,也需要 cmake、ripgrep;但對已經在使用 AI coding agent、又希望它更懂專案結構的人,這類成本是合理的。
上手
README 提供明確安裝與 quick start。cgr 發佈在 PyPI,建議安裝包含所有語言 Tree-sitter 與 semantic/vector search 的 extras,並準備 Docker、cmake、ripgrep。
# with uv (recommended)
uv tool install "code-graph-rag[treesitter-full,semantic]"
# or with pipx
pipx install "code-graph-rag[treesitter-full,semantic]"
# Start the packaged Memgraph + Qdrant stack
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
README 也指出它可作為 MCP Server 執行,讓 Claude Code 與其他 MCP client 直接查詢、編輯 codebase;完整設定需看專案的 MCP guide。
README 重點摘要
- 核心架構是 Tree-sitter parser → Memgraph knowledge graph → Cypher/RAG query,用圖結構輔助 AI 理解程式碼。
- 可用自然語言查詢 codebase、取回 function/class/method 原始碼,並支援 agent 透過 AST 做較精準的修改。
- README 列出多語言支援,涵蓋 Python、TS/JS、Rust、Go、Java、C/C++/C#、PHP、Lua、Dart 等。
- 最新更新包含 Ruby 結構支援、AST pattern 搜尋替換,以及跨 C#、Java、C、Go 的
FLOWS_TO資料流追蹤。 - 安裝需 Python 工具鏈外,也要注意 Docker、cmake、ripgrep 等前置依賴。