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.11-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.11-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.11-cp313-cp313-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

graph_sitter-0.56.11-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.11-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.11-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.11-cp312-cp312-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

graph_sitter-0.56.11-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.11-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for graph_sitter-0.56.11-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 77bb62ffbd76587feb91a325b4f67af52d46146f9453f21223dd99a308d3d1a5
MD5 bd81ca69c71defd98994db0fcb649d81
BLAKE2b-256 8edecd1e4f1fc1aceb53ee3d5f6014e32c7322eea133198f67e270e25488d501

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.11-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.11-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 bb286e112252629abdde27f4263cd5472b66e8517b467f8f9b39f323f56d3503
MD5 358b7e780218e15d250bb6b89a5d8112
BLAKE2b-256 f729acfc4377c20f45ab6097ba2f8e928672b42e6144d1cbc34f8cf3ebb75e95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.11-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 67b58c3be13df594b047bf341b79d562744448bf52fb6b71a2d56094913bbd78
MD5 5aced3dd24d474176f7452009678721c
BLAKE2b-256 60c07de518309432c34bd2021e259a94e7fca75ae0fadccfbdcca14d6018bd70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.11-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 dd397eb16689b1427d5c43f148260539a514c775a1764ccc7cbfe2413bc7fd72
MD5 a47ce35648ccdb97a7bd2ec0192fd931
BLAKE2b-256 36ea7fe7a73388f75331fcedef0e03958d045d8c7d55bfa11b131dee5294ac3a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.11-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 e8613fa43b1fdad48fd6add573e05a3b28ba9ce1f4141961d6bdcc79bd83ec84
MD5 00afe2d7c8e4f90621579897dc139756
BLAKE2b-256 7432c60da27e123726382327afefc1312ae540c31b0125fd12967d29ac0782c8

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.11-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.11-cp312-cp312-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 2bfa68db71ad78b4f467419271a041ae91be75ffd5c0afcbc8f01cfbffe7acdd
MD5 a6c3f2cbcbc6e3a6de7705c6b91dbd98
BLAKE2b-256 90d2110955b4e5018f29abf5771b181139987b3996adb636e17c522a63dc90ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.11-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 564d0c8c1da75783b94ad85a8d2411005d02d0a2beb8bf02cae2595af3746513
MD5 1a2e294b4009fb5459915e351df089b8
BLAKE2b-256 616cce0de1bc25ec3fbe06fa10497043095bd87c39c4715061440fbfd6459c54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.11-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1697856d30f2601d9b45ab30de65986fcca8eb32e2b32dab25fd3eea72872b37
MD5 bd2db790f268d210acc22868b1fa9fd9
BLAKE2b-256 300bea2b846f5ff9dc72c0ad27160b0f50efbbc46d92adadcf53132c3926a5b4

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