This is a collection of examples using Graph-sitter. You can use these examples to learn how to use Graph-sitter and build custom code transformations.
We recommend using uv with Python 3.13 for the best experience.
To install graph-sitter, please follow the official installation guide. Once Graph-sitter is installed, use these steps to run the examples in this repository:
Install the graph_sitter.cli globally
uv tool install graph-sitterInitialize Graph-sitter in your project
gs initActivate the virtual environment
source .codegen/.venv/bin/activateYour environment is now ready to run example codemods.
To configure your IDE for optimal use with Graph-sitter, follow our IDE setup guide.
Within the examples folder, each subdirectory contains a self-contained example with:
- An explanation of the transformation (
README.md) - A Graph-sitter script that performs the transformation (
run.py) - Sample code to transform, if not using a repository (
input_repo/)
To see a transformation, simply run the run.py script within the desired directory.
Have a useful example to share? We'd love to include it! Please see our Contributing Guide for instructions.
The Apache 2.0 license.