
Multi-language monorepo RAG: Tree-sitter parses your codebase into a Memgraph knowledge graph so you can query, edit, and refactor in plain English.
Multi-language monorepo RAG: Tree-sitter parses your codebase into a Memgraph knowledge graph so you can query, edit, and refactor in plain English.
Code Graph RAG (published on PyPI as `cgr`) parses a mixed-language codebase with Tree-sitter, ingests functions, classes, methods, modules, and their relationships into a Memgraph knowledge graph under a single language-agnostic schema, and exposes an interactive CLI that turns natural-language questions into Cypher queries. Once the graph exists, you can ask questions grounded in the real structure, retrieve source by intent, edit code through the agent with AST-based surgical patching and a diff preview, optimize code against language best practices, and find dead code by walking call and reference edges from entry points. A new pluggable ast-grep tier adds languages from a single YAML pattern file (Ruby just joined this way), and FLOWS_TO taint edges follow values through assignments, function calls, and I/O sinks in C, Java, C, and Go for data-flow tracing. Structural search-and-replace via ast-grep is exposed as agent tools so you can match and transform structure across the whole codebase instead of relying on text or regex.
Code Graph RAG (Retrieval-Augmented Generation) utilizes Tree-sitter to parse multi-language monorepos into a Memgraph knowledge graph. This allows developers to query, edit, and refactor their codebases using plain English, significantly enhancing code comprehension and collaboration across teams.
Code Graph RAG is an innovative tool designed for software developers working with large codebases. By leveraging Tree-sitter, a powerful parser generator, it effectively breaks down code into a structured format. This structured data is then represented as a knowledge graph in Memgraph, a graph database that excels in handling complex relationships and queries.
Code Graph RAG integrates multiple programming languages into a cohesive system, enabling natural language queries, structural code edits, and comprehensive codebase management. It leverages advanced technologies like AST parsing and AI-assisted features to improve code comprehension, refactoring, and onboarding.
Code Graph RAG stands out by combining several innovative features to streamline code management.
Multi-Language Graph Ingest: Utilizing Tree-sitter, Code Graph RAG parses numerous languages, including Python, JavaScript, Java, and more, into a language-agnostic Memgraph schema. This allows developers to work with a unified data model, enhancing collaboration across diverse codebases.
Natural-Language Cypher: The interactive command-line interface (CLI) enables users to pose questions in plain English, which are then translated into Cypher queries. For example, when asking, "Where is the refund logic in this monorepo?" users receive precise answers based on the actual code structure, eliminating the need to sift through outdated documentation.
AST-Based Surgical Editing: Code modifications are performed through Abstract Syntax Tree (AST) patches. With a diff preview available before applying changes, developers can visualize the impact of their edits, ensuring accuracy and reducing errors.
Structural Search & Replace: By exposing ast-grep as an agent tool, users can perform complex search and replace operations based on AST patterns instead of relying on traditional regex, which is often less reliable in structured code.
Pluggable ast-grep Tier: Adding support for new languages is straightforward; for instance, Ruby can be introduced using a single YAML pattern file, which defines Module, Function, and Class nodes along with their import edges.
AI-Assisted Refactoring: The system supports renaming or restructuring APIs across different languages, applying necessary AST patches while providing a preview of changes before they are committed.
Cross-Language Data-Flow Audits: Developers can trace data through assignments and function calls to monitor where sensitive information is used, enhancing security and compliance.
Dead-Code Cleanup: By analyzing call edges from entry points, Code Graph RAG can identify and eliminate unreachable functions and modules, optimizing the codebase.
Codebase Onboarding: New engineers or AI agents can explore a queryable graph of the code, facilitating an efficient onboarding process that promotes better understanding and faster integration into projects.
Code Graph RAG features a Multi-Language Graph Ingest, Natural-Language Cypher for intuitive queries, AST-Based Surgical Editing for precise code modifications, Structural Search & Replace for effective code pattern matching, and a Pluggable ast-grep Tier for easy language additions, enhancing versatility and user experience.
Code Graph RAG utilizes the Tree-sitter parser to convert code from various programming languages—including Python, TypeScript, JavaScript, Rust, Go, Java, C, C++, C#, PHP, Lua, and Dart—into a unified, language-agnostic Memgraph schema. This feature enables developers to manage and analyze codebases written in different languages seamlessly.
The Natural-Language Cypher allows users to interact with the codebase by asking questions in plain English. This interactive Command-Line Interface (CLI) translates these queries into Cypher queries, providing answers based on the actual code structure rather than relying solely on vector representations. This significantly enhances the user experience, making complex code queries accessible to developers of all skill levels.
With AST-Based Surgical Editing, developers can make structural changes to their code with precision. The system offers a diff preview, allowing users to visualize changes before they are applied. This feature is crucial for maintaining code integrity, as it prevents unwanted modifications and encourages thoughtful edits.
The structural search and replace functionality leverages the ast-grep tool, enabling users to search for specific Abstract Syntax Tree (AST) patterns across an entire codebase. Unlike traditional regex, this method ensures accuracy and context, allowing developers to rewrite code more effectively.
Adding new languages is straightforward with the pluggable ast-grep tier. Developers can introduce new language support using a simple YAML pattern file. For example, Ruby was integrated by specifying node types such as Module, Function, and Class, along with their import edges, demonstrating the flexibility of the system.
Code Graph RAG is designed for software developers, engineers, and teams working with monorepos. It enhances code understanding and management by providing features like AI-assisted refactoring, cross-language data flow audits, dead-code cleanup, and onboarding tools for new engineers, ensuring efficient navigation and collaboration within complex codebases.
Code Graph RAG is particularly beneficial for teams that manage large monorepos, which are repositories that house multiple projects or packages. Its primary functionalities include:
Monorepo Q&A: Users can ask questions like "Where is the refund logic in this monorepo?" and receive precise answers grounded in the actual code structure rather than outdated documentation. This capability drastically reduces the time spent searching for specific logic.
AI-Assisted Refactoring: Developers can rename or restructure APIs across different programming languages using Abstract Syntax Tree (AST) patches. This feature includes a diff preview, allowing teams to visualize changes before committing them, minimizing errors and ensuring consistency.
Cross-Language Data-Flow Audits: Code Graph RAG enables users to trace data through assignments and function calls, providing visibility into how sensitive data is handled. This feature is essential for compliance with data protection regulations and for identifying potential security vulnerabilities.
Dead-Code Cleanup: By analyzing call edges from entry points, Code Graph RAG identifies unreachable functions and modules, helping teams to streamline their codebase and improve maintainability.
Codebase Onboarding: For new engineers or agents, it offers a queryable graph that can be explored in natural language. This interactive approach accelerates onboarding and enhances understanding of complex code structures.
Code Graph RAG provides a free tier that allows users to explore basic functionalities. For enhanced capabilities, it offers several paid plans that vary in pricing, starting at competitive rates, tailored to meet different user needs and usage levels.
Code Graph RAG is designed to cater to both casual users and professional developers. The free tier allows users to explore essential functionalities without any financial commitment. This is perfect for individuals or small teams who want to experiment with the tool's capabilities.
For users needing more advanced features, Code Graph RAG offers several paid plans. These plans typically include additional functionalities such as increased API limits, advanced analytics, and priority support. For example, the basic paid plan may start at around $15 per month, offering richer features compared to the free version. Higher tiers can cost up to $100 per month or more, depending on the scale of usage and required features.
Businesses and developers can select a plan that aligns with their specific needs, whether they require enhanced data processing, collaboration tools, or integrations with other software solutions.
To get started with Code Graph RAG, visit the official GitHub repository to sign up and explore its features. You can find comprehensive documentation and examples that will help you understand how to implement and utilize this powerful tool effectively.
Code Graph RAG (Retrieval-Augmented Generation) is an innovative tool that leverages AI to enhance code understanding and generation. By visiting the GitHub repository, you can access the following resources:
To effectively utilize Code Graph RAG, consider the following steps:
Compare Code Graph RAG: vs Semantica · vs Paritok · vs Prompt Golf · vs TencentDB Agent Memory