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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

graph_sitter-0.56.12-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.12-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for graph_sitter-0.56.12-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 d61b4372cb481e629b9cd5edf5c92c94ec791dad39be0cb31cde075f5c194995
MD5 c49d32677fa6cc0c4c997313cbb784ef
BLAKE2b-256 d10ce4742e27a1da26920d767ad6a9d09ac19d3126c79ece1aa8c8ec5d8039fd

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.12-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.12-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 4d4f29567d0104058ebef3c56601b29d855a32506c019f5396efccce7d6d9f5b
MD5 bcec044950da045601609848bc3ba520
BLAKE2b-256 e86ec876b2c7b09ebe5db275493111b76e36ca685220710a97b7b371fafa0c91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.12-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2f2a2326c227e9a46c57235102c71433667885a6aa7e4667c60e260dae589e7d
MD5 b6f907d9f5deb34bf95d44a87432b2e5
BLAKE2b-256 73d4428ddd537d05b5bc9dbb006e3ae5cb98734d1c9c6a11b21f913864bf4170

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.12-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c5d3602bee640405c1891f04ea00f041d1b984853eaf97ae024ef81ff91cb291
MD5 a8d4974464e76db58f80d7c29bdc7582
BLAKE2b-256 2ae14e00ee0d361dbb4741bfc406664e455e1761990643a9f8d8bf79931a0cf9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.12-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 0efcef4f1c3c92bbaad2f7ed936af1455f772a9b54d4bfff72e9734dfe7891dc
MD5 8fc801044593075842b034aad13bdee1
BLAKE2b-256 ef99c73dbef26d6bdc13a6b2cf356b3e6dc2078b84498a94a009ac2efff7638a

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.12-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.12-cp312-cp312-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 6fcb5a78f95befa87931584b367536f400b9515689845e445251d73354ce49d6
MD5 ba6ca1b923a4afd7e15573d8125bcb26
BLAKE2b-256 3081a7ae7e309262371926d44fc7fdf225ccf30f6f094f71d99f578c2fefcba7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.12-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3e6edf22e7f154dd2812d2186f95f790700a2e02cb284b59f1bb7c2406892c61
MD5 ea97a0e045df8bfa030a0670e00a22e3
BLAKE2b-256 92ad835d3a2938248fbf6fe048f662e26e426a6bbae57094b741ce6348c3186d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.12-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 38e9329a93ee402588cbb0377f79fbff1ad279caf8bb08e206cfe249a0b71a59
MD5 57629635287b671be53960d5ef14b050
BLAKE2b-256 70363c68ae4266a395ee0aa38066b091a1e6986a7c2596c43a5941f0081aad56

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