init command sets up Graph-sitter in your repository, creating necessary configuration files and pulling documentation locally.
Usage
Options
--repo-name: The name of the repository (defaults to current git repo name)--organization-name: The name of the organization (defaults to git organization)
Directory Structure
When you runinit, gs creates a .codegen directory in your repository with the following structure:
Only
config.toml and the codemods/ directory are tracked in Git. The rest
of the .codegen directory is automatically added to your .gitignore.- Track and version your codemods with your repository
- Use
codebase.reset()without losing progress on your codemod implementation - Share codemods with your team through version control
Recommended Structure
We recommend keeping your Graph-sitter codemods in the.codegen/codemods/ directory (this is the default when using gs create). This:
- Keeps transformation code separate from your application code
- Makes it easy to find and manage all your codemods
- Ensures consistent behavior with
codebase.reset()
Local Documentation
Graph-sitter pulls documentation and examples locally to:- Provide offline access to guides and references
- Enable AI to give contextual help about your codebase
- Allow searching through examples and tutorials
Requirements
The command must be run from within a git repository. If you’re not in one, you’ll need to:Examples
Initialize with default settings (uses git repo info):Next Steps
After initializing:- Create your first codemod:
.) specifies the path where the codemod should be created. This is required.
- Run it:
Updating
You can runinit again to update your local documentation and configuration:
.codegen directory while preserving your existing configuration.