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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

graph_sitter-0.56.14-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.14-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for graph_sitter-0.56.14-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 c5cfadcec6470afb52a57e73d49687e4a80adc9138964cd4debf58229efe9ff2
MD5 6faf27a18516a84d723b1a488e537ed1
BLAKE2b-256 a51473643aeef6e44efabce1c9a983035d841f31cf93e941e41c69cf5eea8872

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.14-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.14-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 eefbe22471dd9947f94939142c4a37560993ba1f8205815098906bcb806ad3df
MD5 6ac65b9bd55f5cd57cc6d9b732addc34
BLAKE2b-256 58a0d718532a873a5c35d5af816afc700af9a3e9e2fa91fbb51d08cbd333f32a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.14-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b97eef80eece38d62836eeb8365853c50de24ba10c2af68bcd37ad637d27a63d
MD5 6b44776dd148d768860f328531ba2c00
BLAKE2b-256 b869b56d193f901a434a0d693f0b2af96362a3e65e7181e0902162784fdd9c94

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.14-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d87fb58a884923fe05c9a16bdfbd2a4b65220aeedf3b14abe7c43d0fc5f9f65f
MD5 854d2227c074db03242ab2291ffc41b3
BLAKE2b-256 4da4e004f4a400db466ca244e28d89c49d83266c62c7f280c9b5dfa81dce80a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.14-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 da5bbbbac4e49bb8149cac48c3d5bd946509e11f06db81eb99fc0ff7f309f467
MD5 3f15815c563381c2920130dfdb1c503c
BLAKE2b-256 8b4288b80942cd98c324198de9e8f33a1333273b815b72f0568f901e98880954

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.14-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.14-cp312-cp312-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 c2050ef0b046b1f4cf6f7e82e91d413dbb50a90759b3ce79b42afff0a701d17d
MD5 033766e2bef0ac5df4c4b8e88caf5075
BLAKE2b-256 3c23163a98798754627c01bf47b228a0b4b6a640d5babee0e49a98a9e110b8cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.14-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ebe7c96b50936713ed96a16a097c1179a46812597354674a102cc9dba9c827b4
MD5 32cde641a6f9abbb60b8c7709ac35bdd
BLAKE2b-256 13aa6b5f57cb5ee9c71ec83e2dae66481c78c9f1bc2c121d65ce05f8d811fb98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.14-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8f00ce821c2c6b24fc425513b95414808b7131645241bb2f80344cf79f867abe
MD5 d40bc61c40e4cffd8dd6f55cb6d5fa25
BLAKE2b-256 002153978e3483571d0f3c3a8037a092bd08febbca461b716df021965f57b30d

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