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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

graph_sitter-0.56.9-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.9-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for graph_sitter-0.56.9-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 51a7b33819d0bfee8d720ccba59d93cba5b4b2e623d3a05ed753fc914391efec
MD5 c5ee344863c6347d3f6315f48bdf63e6
BLAKE2b-256 36c8023f0bca868da3f4589cc7ac757275ba8951ba7bf3b781182543dccbfd60

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.9-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.9-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 c79a78abe0e599051c8858b260ce4a4cbf6ea7c5e4ec45d4fed220a35c0d39dd
MD5 d241b8fa3c64af027456ff71500e2811
BLAKE2b-256 1b503df5b06155fe96306d08237aa611607a0afa8580d34278675e6632158bda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.9-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d69e893419a1efadbcbb92279163bd71076483e2223e1de4e507490319f92460
MD5 50ed78c4c718d92b219f7b13ed9b3b98
BLAKE2b-256 f39c23a8ff99d1f2a9e79beeea6cc9886187082addf134383fd33dc988d1f8d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.9-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a4eb880675d292375d5f5ca36636a49bb8f12704df040aed25bc215d1097bf5a
MD5 59822418b39041c56535862d76a72b6a
BLAKE2b-256 99bbe64964a319f258084ed64476daeaf709ed9e62069873f3a1bff35225449d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.9-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 20f9acfecdecd73dfe3ba1c0cc36b91091fe57584af2a8c7b04f882d05343f51
MD5 6346229536beaf81b636287c0f5232a3
BLAKE2b-256 5b0d771feb32ff833325c2500d9f5336eceb52a23deec8f2e0f6a068f9d6446f

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.9-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.9-cp312-cp312-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 4e89384a09ffcf71566b82f00a709004619c1f9dd961005d57abda159a21eaab
MD5 be5296e03fcacc93229dd93be42149fa
BLAKE2b-256 0b3ff72eee6710ce9ea5d2730d213f5811daf3788fef11861518c0bbb9afae85

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2fa130a819c0956a66675ceec04cabbaccad0f98a8a63dc10a533ffda34fcdba
MD5 1612e2704ba7ab981f296337c757e3b1
BLAKE2b-256 0f69c09a034802c551bbbb6dd131df623ae256b588fd971776544981db246569

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.9-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 321766bf956a2e07e50e4683bc9d3a9e17bfbeb9cb89448b2cc0e7a3142a44d8
MD5 72df3fe907cc4b6d77f135cf9ef2ba33
BLAKE2b-256 651a924356637ed95f7bf9df2aee2f7a0aa9cb4626cbb91455d79364dc56eefc

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