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 codegen 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 codegen => 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 'codegen.sdk.extensions.utils': The compiled cython extensions are out of sync. Update them with uv sync --reinstall-package codegen.
  • 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.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_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.7-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_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.7-cp313-cp313-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

graph_sitter-0.56.7-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.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_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.7-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_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.7-cp312-cp312-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

File metadata

File hashes

Hashes for graph_sitter-0.56.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 ce4598beb602ee7d633949852d2eef1f52b991cb04cbb242fa59f603472c35c9
MD5 fb37f8c8260fc38efdea93d53b226c2d
BLAKE2b-256 46cdc5c393323033c2a2a1b51be934840c738e0363482dbb535cb8a799e63d11

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.7-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for graph_sitter-0.56.7-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4b897e84d3b754cef7a7986bdd7744cf130fdfa16783e9887153a2de8587e74d
MD5 f4dd1251354e84ec4119199fd6828cbc
BLAKE2b-256 e2675a5b70a759a0dc291d06e823e13f0ec36b6a0ca77dbf4b40b25d193a7df5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9e3b57f3aa9960385c091b2f7345267c71ea08a245b960e340842d35bb864eeb
MD5 bc2a608f467a36738c765bd59b93f6f9
BLAKE2b-256 8504a8a5e1eb3cf90a6f29687ac7cddc8d9cd708445b292b90c8ccc3ad2b5c1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.7-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 061f08ecaf705e9eacede9195ac598781ab953a10c62c557fe0b522832596d72
MD5 e8cb1b7e52cbc1072667d313441f33ab
BLAKE2b-256 d2764c54bcd6bda3a133286318088a6a0d7850eebacbe148d4ec5c733a8f23b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 e5a72e71eac94b6a3d5f0b5974612f32737cf6d0e2cb9a7c872942d8ba823f67
MD5 138d11097f788c1ec1f59b019d9e240b
BLAKE2b-256 dfb108877f19fa4dbebdb6136cbd100cf5fc760c385eb9c931292172b723394a

See more details on using hashes here.

File details

Details for the file graph_sitter-0.56.7-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for graph_sitter-0.56.7-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f7706b0b024bf4fc03cbfae3501f48ecaadea60e39eca275a2865aac5dee077d
MD5 c8243c72f93822b0360ca216dab91d71
BLAKE2b-256 3a686f41036551ec44451646f99cef1fca6844e90f25cd3f03c7b8ca4cff5211

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8fa7924fc57982129fd9559dc0900dd116e543e5cf6fefd4e2eec5dc0e356737
MD5 50164e86bc71341fa1391489ca294142
BLAKE2b-256 3ba8ba0d235a70362c67065028b4d0d0cd34da22e77904afeb06cbb9360fbaa2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graph_sitter-0.56.7-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0202a8765c90b44c976c5a573cfce0653b23f31aca76b99ff7993683cc00ab62
MD5 2da7872c88cbd1cd6fd19650bf0d24f1
BLAKE2b-256 e04afe566b81ed6b9ac195bcdfc905a48a5330dd2f194d2ba5dd20ae22aebd77

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