# graph-sitter

A detour at Codegen: an open-source library for codebase refactors, built on Tree-sitter.

Published: 2025-01-28

[View the HTML version](https://jay.ai/blog/graph-sitter)

---

![codegen-sh/graph-sitter](https://jay.ai/blog/images/graph-sitter/link-repo.png)

While building [Codegen](https://jay.ai/blog/codegen), we took a detour to solve a problem that kept blocking our agents: making large-scale, structural changes to a codebase reliably. The answer was **graph-sitter** — an open-source library for programmatic codebase refactors, built on top of [Tree-sitter](https://tree-sitter.github.io/tree-sitter/).

Instead of nudging files one edit at a time, graph-sitter builds an in-memory graph of a codebase — functions, classes, imports, and their relationships — and exposes high-level APIs that match how engineers actually think about refactors and migrations. It became the foundation for our "act via code" thesis.

We first put that foundation behind an IDE built specifically for refactors — [see the demo here](https://x.com/mathemagic1an/status/1825924799329362153?s=20).

## The thesis behind it

[**Act via Code**](https://jay.ai/blog/act-via-code) — Why the next step for software agents is a more expressive action space — writing and executing programs against well-designed APIs.

## Links & milestones

[**IDE for refactors**](https://x.com/mathemagic1an/status/1825924799329362153?s=20) — Announcing an IDE purpose-built for codebase refactors.

[**Open-source release**](https://x.com/mathemagic1an/status/1884660574241657048?s=20) — Introducing graph-sitter as an open Python library for manipulating codebases.

[**graph-sitter.dev**](https://graph-sitter.dev/) — The project site and docs.

[← Back to the Codegen story](https://jay.ai/blog/codegen)

Jay Hack, Founder

