What happens when your agent queries a pre-indexed graph instead of grepping fil...
W

What happens when your agent queries a pre-indexed graph instead of grepping fil...

What happens when your agent queries a pre-indexed graph instead of grepping fil...

56,501 stars
N/A forks
N/A contributors

README

Project documentation from GitHub

When Your Codebase Becomes a Queryable Graph

You know that feeling when you're deep in a massive codebase, grepping for some function or import, and you realize you've spent more time searching than actually writing code? That's the problem codegraph tries to solve in a pretty clever way.

Instead of running grep over files every time you ask something, it pre-indexes your codebase into a graph structure. Then your agent—or you—can query relationships between files, functions, classes, and dependencies without touching the filesystem. It's like having a mental map of your code, but faster and more accurate.

What It Does

Codegraph is a tool that builds a graph of your source code. It parses your project's files, extracts symbols (functions, classes, imports, exports), and links them together. The result is a queryable graph where you can ask questions like:

  • "What files import this module?"
  • "Where is this function defined?"
  • "What dependencies does this file have?"

It's designed to work with agents, but you can also use it directly from the command line.

Under the hood, it uses tree-sitter for parsing (so it's fast and language-aware) and stores the graph in a simple SQLite database. The query interface is a basic CLI or a Python library.

Why It's Cool

The real magic is the pre-indexing. Once you've scanned your codebase once, every subsequent query is a database lookup, not a filesystem traversal. That makes it:

  • Fast — especially for large projects where grep starts to hurt.
  • Structured — you get relationships, not just string matches. You can trace a function call through multiple files.
  • Agent-friendly — if you're building an AI coding assistant, this is way more efficient than making it grep every time.

The implementation is refreshingly simple. It's not trying to be a full code analysis platform. It's a focused tool that does one thing well: give you a queryable graph of your code.

How to Try It

Getting started is straightforward. Clone the repo and install with pip:

git clone https://github.com/colbymchenry/codegraph.git
cd codegraph
pip install .

Then index your project:

codegraph scan /path/to/your/project

After that, you can query:

codegraph query "find imports in src/main.py"

Or use it from Python if you're building an

Did you like this issue?

Join our weekly newsletter

Love discovering amazing projects?

Help us continue bringing you the best open-source discoveries every week.

Back to Projects
Last updated: May 22, 2026