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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

graph_sitter-0.56.10-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.10-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for graph_sitter-0.56.10-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 778605a4b59ec8e91b33cd7e6ac03787a02b5d9fe7896911fc2a14b491820625
MD5 3feeb9fb8b00b673e55948e0435e76f8
BLAKE2b-256 0f64efdd1ca68bbcfbee8f8880ff903651dc45b8f8349f7c13a83b24ef31ff6c

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.10-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.10-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0eda3a8e278f315b195e1ba4cd7ee863752a251095644d4bc2c4ecdb89b4cfd8
MD5 5d9bc0f831039d90ad20b0853a532e2c
BLAKE2b-256 bca2e19b78e9e604250bc8e376ea6a8f4d745fcc182b8bc2102b79236d507b75

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.10-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 92cf443da6429381ffdcf556c94c74ddf40feacde23640251d167b57c13ac178
MD5 607c68a78da7321feb8cc5e040f76790
BLAKE2b-256 6c16a845bfd7d2039bb11fcbee05daf47d7d432fbc7c5420be1d101af32cbbfb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.10-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 2818a5fcd704e759a2d80b5bae71a8314bd18684430e9ea620d6a5c82f9c1de8
MD5 8c6872e736854a849492c5dc3945527a
BLAKE2b-256 9d23da422fde6b6c973cd81cc95b2dfe403747d328ce4c9a89aa78f59b061b52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.10-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 1367c4c0adc3cfe5a505e22a0f0e53e7f0212464ceb2d0d7f76e15d531d4b5fa
MD5 eaa6d6e750eb57b8523a09f78597127c
BLAKE2b-256 9591f0cbc13c8cb8845883a1fb0ff9b3034bb08d5afbd76eb83518ef92be066b

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.10-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.10-cp312-cp312-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0f4fe82d165228ba4d15cdea64282a6984424adfbb8b39cc6e888423dc4426cd
MD5 4292cd31cc73e66e0042d1f8d5189de7
BLAKE2b-256 6366c6a71742199fdc73de2e3b136f9399aca22112516a3e7071d8eb625ed722

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.10-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6786167c42a34fe8ef773a642e0cd22086144bc26df4cfc2052f5c9b052f04fa
MD5 68ca5c1a57e9dc1995d1351ac3fb4141
BLAKE2b-256 e8d87ed81f2236540f12d4be15f9646da1f7c18aa74db655ce7464b6d7692660

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.10-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 70c7ef2f2f1b6baeb43bd368b48008b2b3ed8f9a7d17ba49b1cd98263d51e14d
MD5 7e36939405d44ce89acddf09e694d23c
BLAKE2b-256 72593bde4f58077b1210090ee86dbc5b67f5277f9102a97b2e8bd9a2eec7b87f

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