code-graph-rag
The ultimate RAG for your monorepo. Query, understand, and edit multi-language codebases with the power of AI and knowledge graphs
What is code-graph-rag?
The ultimate RAG for your monorepo. Query, understand, and edit multi-language codebases with the power of AI and knowledge graphs
Overview of code-graph-rag
What it is
Code-Graph-RAG is a tool that parses a multi-language codebase using Tree-sitter, optionally enhanced by compiler-grade frontends and runtime traces, and builds a knowledge graph of its structure in an embedded graph database. It allows users to query, edit, and optimise code in plain English across a monorepo of mixed languages under a single unified graph schema.
Key features
- Parses source files to extract functions, classes, methods, modules, and their relationships into an interconnected graph.
- Answers natural language questions about the codebase, grounded in the real structure.
- Edits code through an agent with AST-based surgical patching and a diff preview before changes.
- Optimises code against language best practices or user-defined coding standards.
- Finds dead code by walking call and reference edges from entry points.
- Supports dynamic call tracing to merge runtime behaviour into the graph, exposing dispatch that static analysis cannot see.
- Runs as an MCP server for integration with Claude Code and other MCP clients.
Use cases
- Querying and understanding a large monorepo with multiple programming languages.
- Editing code across the codebase using natural language instructions.
- Optimising code to follow best practices or custom standards.
- Detecting and removing dead code from entry points.
- Overlaying runtime behaviour from test runs or production eBPF profiles to augment static analysis.
Getting started
bash# Parse a repository into the graph, then query itcgr start --repo-path /path/to/repo --update-graphcgr start --repo-path /path/to/repo
License and pricing
License: MIT. The project is open source.
這是什麼
Code-Graph-RAG 是一個工具,它使用 Tree-sitter 解析多語言程式碼庫,並可選地透過編譯器級前端和執行時追蹤來增強,然後在嵌入式圖形資料庫中建立其結構的知識圖譜。它允許使用者以純英文查詢、編輯和優化跨多種語言的單一儲存庫中的程式碼,並使用統一的圖形架構。
主要功能
- 解析原始碼檔案,提取函式、類別、方法、模組及其之間的關係,形成相互連接的圖譜。
- 以自然語言回答關於程式碼庫的問題,答案基於實際結構。
- 透過代理程式進行程式碼編輯,使用基於 AST 的精確修補,並在變更前提供差異預覽。
- 根據語言最佳實踐或使用者自訂的編碼標準來優化程式碼。
- 透過從入口點遍歷呼叫和引用邊緣來尋找無效程式碼。
- 支援動態呼叫追蹤,將執行時行為合併到圖譜中,揭露靜態分析無法看到的調度。
- 可作為 MCP 伺服器運行,與 Claude Code 和其他 MCP 客戶端整合。
使用情境
- 查詢和理解包含多種程式語言的大型單一儲存庫。
- 使用自然語言指令跨程式碼庫進行編輯。
- 優化程式碼以遵循最佳實踐或自訂標準。
- 從入口點檢測並移除無效程式碼。
- 從測試運行或生產環境的 eBPF 分析中疊加執行時行為,以增強靜態分析。
快速開始
bash# 將儲存庫解析到圖譜中,然後查詢它cgr start --repo-path /path/to/repo --update-graphcgr start --repo-path /path/to/repo
授權與價格
授權:MIT。此專案為開源。
Based on the project's public README and repository metadata.