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 codegen 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 codegen => 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 'codegen.sdk.extensions.utils': The compiled cython extensions are out of sync. Update them with uv sync --reinstall-package codegen.
  • 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.8-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_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.8-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_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.8-cp313-cp313-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

graph_sitter-0.56.8-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.8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_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.8-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_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.8-cp312-cp312-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

graph_sitter-0.56.8-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.8-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for graph_sitter-0.56.8-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 77e2a34d041b00d66dc97d1e6fecd5bf3c2f06a85daca80c9d37a7e129080438
MD5 79f4d971e426a6d241a1a49743210aa6
BLAKE2b-256 3e4c21d6fbd808ef12778426de64497d1df9acfd56b229c90e39f2d9af906875

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.8-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 76a470187c61298150cb3a8007a7812b5f1d0e9747688b7a1ef79b8f9e0607a8
MD5 eba37e3caf85631493a1969d9ecb2451
BLAKE2b-256 c1f8c27da7a182b0dd62045415b1cd0086e84691f4978ffc75409171d7d40bd0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.8-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b75983aba1d5db7a7d7e9150fc2798fdf799433f7f6cdf1ae87b911aa5fd2bcb
MD5 858e67d8079eef33a959504746d9525c
BLAKE2b-256 d9ec19b3e9dfef1f766f1bdb893a2ada5f2b765b013788f1980ca1472866efa2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.8-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 79caba589cdef68c92aad26006465f15c4496828e6cac9d4572e3ba2b904f6af
MD5 4e0bdac2691269132be7944fda32ae7e
BLAKE2b-256 5eb848fa393706b887fdcef0ffdb3f1928a9dcc31660ee95ea3bf5cbabfe0c12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 c5c34ceeadeb5f40fca9750dc892047bbc56e91fd241633860ee239b9aa6a6e1
MD5 8ba7d4f73aedb89997188d17bad674b2
BLAKE2b-256 c5efa9130446fe66d6ac54a66fc31525b5742a2b3612d6eb96c806fe00dba0a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.8-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6cab63730b4a61af9c661a9cf1ef70bc5035a1c08f02572237bb60feebdcb446
MD5 799db31da9e1a35f72c3bc7a6a490ab5
BLAKE2b-256 0f48d82b6840bb9353b02afbb5c6cb84f7243862945ff21a1c6c547eafc2ad2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7e0fa020bb13d90c08e37bf22ca18a6488d5428f40871b4531650b8a111c6b08
MD5 bc130fc518453d605caa005bfea7576f
BLAKE2b-256 a87e26ff7b111608a08ac51c61dedd0e638518587d158b029c917493c8978ce4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.8-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 4f936359dd51f3ce5484e8a7400aa5bc30b9af1b5ec14656f2fdf998cb0a62c6
MD5 947d22821a78697f01f861dbeac0f4ca
BLAKE2b-256 db2b2d136e73195f8b40070b37f3223c55b74be8c7d026c89f08756403e7a956

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