Run Command
The run command executes a registered codemod from .codegen/codemods
against a local repository.
graph-sitter run rename-function . --checkUsage
graph-sitter run LABEL [PATH] [OPTIONS]PATH defaults to the active Graph-sitter session when omitted. Pass PATH
explicitly for repeatable uvx and CI usage.
Arguments
LABEL: The name of the codemod to run (e.g., "rename-function")PATH: Optional repository path to transform
Options
--backend python|rust|auto: Choose the graph backend.--fallback python|error: Choose fallback behavior when the Rust backend is unavailable or unsupported for the requested API.--language auto|python|typescript: Choose the repository language.--subdir PATH: Limit parsing to a repository-relative subdirectory or file. Repeat to include multiple paths. This overrides any subdirectories declared by the registered codemod for this invocation.--arguments JSON: Pass arguments to the codemod as a JSON object. Typed Pydantic argument models are validated when present.--diff-preview N: Show the first N lines of the produced diff.--check: Run in a temporary copied repository, print the diff, leave the target unchanged, and exit non-zero when changes would be produced.--write: Apply changes to the target repository.
Examples
Preview a registered codemod:
graph-sitter run rename-function . --checkApply a registered codemod:
graph-sitter run rename-function . --writeRun with arguments:
graph-sitter run rename-function . --arguments '{"old_name":"getUserData","new_name":"fetchUserProfile"}' --checkRun against only part of a large repository:
graph-sitter run rename-function ./airflow --subdir airflow/providers --subdir tests/providers --checkRun against a TypeScript repository:
graph-sitter run rename-component ./next.js --language typescript --backend auto --fallback python --checkWith uvx
Published package form after release:
uvx --python 3.13 graph-sitter run rename-function . --arguments '{"old_name":"getUserData","new_name":"fetchUserProfile"}' --check
uvx --python 3.13 graph-sitter run rename-function ./airflow --subdir airflow/providers --checkBranch-built wheel validation form before release:
uvx --python 3.13 --from dist/<wheel>.whl graph-sitter run rename-function . --backend rust --fallback error --checkSafety Model
Use --check before --write for normal workflows. --check copies the target
repository to a temporary Git repo before running the codemod, so codemods that
call codebase.commit() internally do not mutate the original checkout.
For compatibility, run may still apply changes when neither --check nor
--write is supplied. New docs, CI, and agent workflows should always pass an
explicit mode.
Execution Flow
When you run a codemod, Graph-sitter:
- Parses the selected repository into a code graph.
- Resolves the registered codemod by
LABEL. - Validates and passes
--argumentswhen required. - Executes the codemod against the graph.
- Prints a diff preview and either reports or applies the changes.
For one-shot transformations that are not registered under
.codegen/codemods, use transform.