Graph RAG for Code with GitNexus

Rajistics - data science, AI, and machine learning · Beginner ·🔍 RAG & Vector Search ·2mo ago

Key Takeaways

The video demonstrates the use of GitNexus with GraphRAG for efficient code searching, providing a practical alternative to traditional search methods, and showcasing its capabilities in understanding the structure of a code base.

Full Transcript

Have you ever sat there watching your agent search a code base? Or maybe you're tired of spending lots of tokens when you do search a code base? Today, we're going to give you a practical alternative for better searching code bases. Now, for searching code, I've long talked about using a genetic search, using a coding model with a tool like grep works really great, especially if you know the exact name, message. Grep is really fast, it's predictable, it can crunch through a lot of code pretty fast. But, as your code bases get bigger, and if you start searching for things where you don't know the exact text, where you need to understand the structure of the code base and how things are laid out, well, I've got a different approach for you today from GitNexus using GraphRAG. And I know I've made fun of GraphRAG before because the reality is is the hard part of GraphRAG is setting up the problem, thinking of all the plumbing that you have to do. What are all your nodes? What are your relationships going to do? And I see lots of teams spending a lot of time building out a graph infrastructure. The great thing about the GitNexus tool that I'm showing you today, it's already taken care of that. All you have to do is point it at a code base, and very quickly it builds it, you can get started doing it. And so, that's what I want to show you show off today is how that works. So, to start with, I'm using a the VS Code data set. It's a large data set, I like using it for this. I'll give you a repo if you want to reproduce it as well. Now, the first thing I'm going to do is just do a traditional search, where I'm going to use and say, "Hey, can you find this particular query for me?" And to help me identify what is the best piece of that. So, now, I'm going to start the search. Just for background today, I'm in work at OpenHands, I'm using the OpenHands agent canvas, so that's what the UI looks like. So, I've given it the query. Let's see what happens. You'll see it's already spending some time thinking. It's looking, finding the repo in my local workspace. Now, it's starting to go through the process of looking for that particular file. Now, it's going to take a little while, so I want to pause and we'll have to fast-forward the video to the end. Okay, it's back. I'll give you the the final length of how long it took in the video. It looks like it was well over a minute here to do that where it went through the search, started to figure out what's going on, started to find the starting point for this. The accuracy of this, as we'll talk about later, the graph rack actually does a better job on many of these queries like this, but I wanted to give you a sense of how long a traditional query took, as well as let's look and see what the cost was for this particular one, almost kind of 800,000 tokens that went through there. Now, we're going to switch and we're going to do a new chat, and here we're going to take advantage of Git Nexus. Now, to set up Git Nexus, I used the ability I downloaded it, used the ability to connect via an MCP to it. So, it makes it very easy to connect. You run an initial um I can't remember what the name of it, like an analyze over it, which will run through, index everything that you have. So, that's one thing is you do have to have that up-front step, but even on my VS Code repo, which was really big, I think it didn't even take a couple of minutes at most to do that. So, very quick. So, now let's go ahead and do the same repo, but I'm going to say now I'm going to have it use our Git Nexus MCP for that. So, let's go ahead and run that query. And I think that the the startup here is starting up the session on my local thing, and we'll see here it's off and running. Thinking through what it's doing. Let's see exactly what it's doing, and you can see it's already returned back results that quickly to do that. So, it just used the MCP because of the way the rag system is, it's already set there. Can look through that piece like that. Gave us, in our case, the top ranked symbol, code snippet, all this stuff that we want, kind of why we want to be here as well. Now, remember the advantage of this is it understands the entire structure of our code base because it's taken time to map that out. >> [clears throat and cough] >> So, here's what we can do is we can also run some different types of queries as well. So, let me give you a little bit of idea of some other things that we can ask around that. So, here I'm going to ask it to give me a little bit of context around this command execute. So, let's go and see what it does when I do that. So, here's a full 360 context. I've given that information again, like source code, incoming edges. So, what are the things that own that class? What do they execute with? So, now as a developer, you can see how all these pieces are fitting together by giving you the boundaries and doing all of these pieces. If you make a change, for example, that change could touch other core components of the code. Kind of what is the blast radius of a change? We can also do a query here and understand what are the other related pieces? What are the things that it's going to touch doing this analysis for us and we can take a look here. It's gone through, figures out in this case, right, that the risk is critical if we do this change, how many other things are affected like this. So, very easy to get deeper, further insights into this. Easy to set up. You can use this with any coding agent with the MCP. There's a lot more you can do on it. I've got another video coming in about the documentation. You can also use it to see find beautiful visualizations of your code base, but I'm staying a little bit practical here as well. So, a very useful tool, especially for people that spend a lot of time searching and working with code bases. Go check it out.

Original Description

Hands-on with GitNexus on the VS Code codebase to see where GraphRAG helps coding agents. Blog: https://rajivshah.com/blog/gitnexus-openhands-vscode.html Repo: https://github.com/rajshah4/openhands-gitnexus-example ━━━━━━━━━━━━━━━━━━━━━━━━━ ★ Rajistics Social Media » ● Home Page: http://www.rajivshah.com ● LinkedIn: https://www.linkedin.com/in/rajistics/ ● Reddit: https://www.reddit.com/r/rajistics/ ━━━━━━━━━━━━━━━━━━━━━━━━━
Sign in to unlock AI tutor explanation · ⚡30

The video teaches how to use GitNexus with GraphRAG for efficient code searching, providing a practical alternative to traditional search methods. It showcases the capabilities of GraphRAG in understanding the structure of a code base and demonstrates how to integrate it with a coding agent using MCP.

Key Takeaways
  1. Download and install GitNexus
  2. Connect to GitNexus using MCP
  3. Run an initial analysis on the code base
  4. Use GraphRAG for code searching
  5. Integrate GitNexus with a coding agent
💡 GraphRAG provides a more efficient and accurate way of searching code bases by understanding the structure of the code and providing context-aware results.

Related Reads

📰
How RAG Actually Works — and the Five Stages Tutorials Skip
Learn the five stages of RAG and how it works to generate grounded answers from unstructured data
Medium · LLM
📰
RAG Sistemlerinde Hibrit Arama: Neden Sadece Semantic Search Yetmiyor?
Learn why hybrid search is necessary in RAG systems and how to implement it for better results
Medium · NLP
📰
Top 30 Databricks RAG Interview Questions and Answers — 2026
Learn the top 30 Databricks RAG interview questions and answers to enhance your knowledge of Retrieval-Augmented Generation and boost your career in data science
Medium · Data Science
📰
Building a Grounded RAG from Scratch: A working journal
Learn to build a grounded RAG from scratch in a 7-part journal series, covering the fundamentals of RAG and its applications
Medium · RAG
Up next
What exactly is retrieval augmented generation?
Vizuara
Watch →