Skip to main content

Documentation Index

Fetch the complete documentation index at: https://codegeninc-fix-system-prompt-typo.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

The init command sets up Codegen in your repository, creating necessary configuration files and pulling documentation locally.

Usage

codegen init [OPTIONS]

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 run init, Codegen creates a .codegen directory in your repository with the following structure:
.codegen/
├── config.toml         # Configuration file with repo and org info
├── codemods/          # Your codemods live here
│   └── my_codemod.py  # Created via `codegen create my-codemod`
├── docs/              # Local documentation for offline access
│   ├── api/
│   ├── examples/
│   └── tutorials/
└── prompts/           # Generated system prompts for AI assistance
Only config.toml and the codemods/ directory are tracked in Git. The rest of the .codegen directory is automatically added to your .gitignore.
This setup allows you to:
  • 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
We recommend keeping your Codegen codemods in the .codegen/codemods/ directory (this is the default when using codegen 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

Codegen 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:
git init
git remote add origin <your-repo-url>
codegen init

Examples

Initialize with default settings (uses git repo info):
codegen init
Initialize with custom organization and repo:
codegen init --organization-name "my-org" --repo-name "my-project"

Next Steps

After initializing:
  1. Create your first codemod:
codegen create my-function . -d "describe what you want to do"
Note: The second parameter (.) specifies the path where the codemod should be created. This is required.
  1. Run it:
codegen run my-function --apply-local

Updating

You can run init again to update your local documentation and configuration:
codegen init
This will refresh the .codegen directory while preserving your existing configuration.