.codegen directory contains your project’s Codegen configuration, codemods, and supporting files. It’s automatically created when you run codegen init.
Directory Structure
Initialization
The directory is created and managed using thecodegen init command:
The
--fetch-docs flag downloads API documentation and examples specific to your project’s programming language.Virtual Environment
Codegen maintains its own virtual environment in.codegen/.venv/ to ensure consistent package versions and isolation from your project’s dependencies. This environment is:
- Created using
uvfor fast, reliable package management - Initialized with Python 3.13
- Automatically managed by Codegen commands
- Used for running codemods and Jupyter notebooks
- Gitignored to avoid committing environment-specific files
codegen init and used by commands like codegen run and codegen notebook.
To debug codemods, you will need to set the python virtual environment in your IDE to
.codegen/.venvConfiguration
The.env file stores your project settings:
Git Integration
Codegen automatically adds appropriate entries to your.gitignore:
- While most directories are ignored, your codemods in
.codegen/codemods/andconfig.tomlare tracked in Git - The virtual environment and Jupyter notebooks are gitignored to avoid environment-specific issues
Working with Codemods
Thecodemods/ directory is where your transformation functions live. You can create new codemods using:
- Create a new file in
.codegen/codemods/ - Generate a system prompt in
.codegen/prompts/(if using--description) - Set up the necessary imports and decorators
Jupyter Integration
Thejupyter/ directory contains notebooks for interactive development:
A default notebook is created during initialization to help you explore your codebase.
Next Steps
After initializing your.codegen directory:
- Create your first codemod:
- Run it:
- Deploy it for team use: