Skip to main content

Scriptable interface to a powerful, multi-lingual language server built on top of Tree-sitter

Project description


Scriptable interface to a powerful, multi-lingual language server.

PyPI Documentation Slack Community License Follow on X


Graph-sitter is a python library for manipulating codebases.

from graph_sitter import Codebase

# Graph-sitter builds a complete graph connecting
# functions, classes, imports and their relationships
codebase = Codebase("./")

# Work with code without dealing with syntax trees or parsing
for function in codebase.functions:
    # Comprehensive static analysis for references, dependencies, etc.
    if not function.usages:
        # Auto-handles references and imports to maintain correctness
        function.move_to_file("deprecated.py")

Write code that transforms code. Graph-sitter combines the parsing power of Tree-sitter with the graph algorithms of rustworkx to enable scriptable, multi-language code manipulation at scale.

Installation and Usage

We support

  • Running Graph-sitter in Python 3.12 - 3.13 (recommended: Python 3.13+)
  • macOS and Linux
    • macOS is supported
    • Linux is supported on x86_64 and aarch64 with glibc 2.34+
    • Windows is supported via WSL. See here for more details.
  • Python, Typescript, Javascript and React codebases
# Install inside existing project
uv pip install graph-sitter

# Install global CLI
uv tool install graph-sitter --python 3.13

# Create a codemod for a given repo
cd path/to/repo
gs init
gs create test-function

# Run the codemod
gs run test-function

# Create an isolated venv with graph-sitter => open jupyter
gs notebook

Usage

See Getting Started for a full tutorial.

from graph_sitter import Codebase

Troubleshooting

Having issues? Here are some common problems and their solutions:

  • I'm hitting an UV error related to [[ packages ]]: This means you're likely using an outdated version of UV. Try updating to the latest version with: uv self update.
  • I'm hitting an error about No module named 'graph_sitter.sdk.extensions.utils': The compiled cython extensions are out of sync. Update them with uv sync --reinstall-package graph-sitter.
  • I'm hitting a RecursionError: maximum recursion depth exceeded error while parsing my codebase: If you are using python 3.12, try upgrading to 3.13. If you are already on 3.13, try upping the recursion limit with sys.setrecursionlimit(10000).

If you run into additional issues not listed here, please join our slack community and we'll help you out!

Resources

Why Graph-sitter?

Software development is fundamentally programmatic. Refactoring a codebase, enforcing patterns, or analyzing control flow - these are all operations that can (and should) be expressed as programs themselves.

We built Graph-sitter backwards from real-world refactors performed on enterprise codebases. Instead of starting with theoretical abstractions, we focused on creating APIs that match how developers actually think about code changes:

  • Natural mental model: Write transforms that read like your thought process - "move this function", "rename this variable", "add this parameter". No more wrestling with ASTs or manual import management.

  • Battle-tested on complex codebases: Handle Python, TypeScript, and React codebases with millions of lines of code.

  • Built for advanced intelligences: As AI developers become more sophisticated, they need expressive yet precise tools to manipulate code. Graph-sitter provides a programmatic interface that both humans and AI can use to express complex transformations through code itself.

Contributing

Please see our Contributing Guide for instructions on how to set up the development environment and submit contributions.

Enterprise

For more information on enterprise engagements, please contact us or request a demo.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

graph_sitter-0.56.13-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64manylinux: glibc 2.34+ ARM64

graph_sitter-0.56.13-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64manylinux: glibc 2.5+ x86-64

graph_sitter-0.56.13-cp313-cp313-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

graph_sitter-0.56.13-cp313-cp313-macosx_10_13_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

graph_sitter-0.56.13-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64manylinux: glibc 2.34+ ARM64

graph_sitter-0.56.13-cp312-cp312-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64manylinux: glibc 2.5+ x86-64

graph_sitter-0.56.13-cp312-cp312-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

graph_sitter-0.56.13-cp312-cp312-macosx_10_13_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

File details

Details for the file graph_sitter-0.56.13-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for graph_sitter-0.56.13-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 40ae29d5dbfd76ec7ddb4484f78534e984510c71948c1c2ea6bf9e41aa9be804
MD5 6b480b6349e7332aca6e40e5e159f012
BLAKE2b-256 e320df5fc65f4762192635bc9559ab0d67bde51cc87c2c63de7a4cea1d75b539

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.13-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for graph_sitter-0.56.13-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 c7cb0028914ba501e91a81aed137845de23aae3fb4458f465381e5662934ba1a
MD5 5078009e30f1512b13edaaf22d2d7682
BLAKE2b-256 1fcbc37fd4db386f18ff9be2866e188b082664a20f774c2307cbb727e31b9370

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.13-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for graph_sitter-0.56.13-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6b03af8a2cea3ee08adb937ce2dacc8cfe2ac0be5a5ce3df22b75b3ab20e278c
MD5 75849b84bb23a07a4c395d158b5a2c73
BLAKE2b-256 d63efe16a39475e452afa291e6a954540a4bb9c48e0e0766b6c117f556ada84d

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.13-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for graph_sitter-0.56.13-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c517cfd25ce360e6da6d6f1fe763f32fe31674d67825ceae7f6d5cd1e9e075ef
MD5 0197c7257b0096331816c951474187ae
BLAKE2b-256 846aa8ff6c2871f4102387cf5ca94fdcc3e16bcb9fd6be121d49a3f11dd14655

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.13-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for graph_sitter-0.56.13-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 47043e1bc93c21ac706ad6c21febfe4f6b6a224d2c726216f76a1474cbab2227
MD5 ea0da8bdca7e737912fd3315b8f0e185
BLAKE2b-256 58e3e9f32aeb4679107ae5a321eba14f81cb17db8697cc4f91328c2c4e3ae297

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.13-cp312-cp312-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for graph_sitter-0.56.13-cp312-cp312-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 a5b2e99d8b8da7712bd5a5e559e82f26152663ba313ec4c1e3fbeec90e876fff
MD5 2657d5f0a4595097d4b742d52ed94248
BLAKE2b-256 e1b54e89dabf5c7d9371ea4a5da49f404e4df75992b38bd63d003fbb53602f92

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.13-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for graph_sitter-0.56.13-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 21d2ad5f0763ebe22a968cd35f7019f7bef5b671bb1ad2141277e02d6f3dfec6
MD5 15c279fce7f07d406e2c49a1e934f184
BLAKE2b-256 605d64cbe6585d4e1f6cd52f7af1f12e09505fcbac2a5817b8ec472b4066ebe6

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.13-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for graph_sitter-0.56.13-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b16c91ee49c7a11c6d0cefec76c384e663b0ad2b59fb693ccb9bbdf1fb05f546
MD5 5a3e3ab30e8f1a02aa67efa21ad3307a
BLAKE2b-256 70ad45c0ada0816a3598687f430e0ff1b5a692bd6e711bc495cfcce1468ee32d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page