Install and set up Codegen in your development environment.

Prerequisites

We recommend using uv for installation. If you haven’t installed uv yet:

curl -LsSf https://astral.sh/uv/install.sh | sh

Installing Codegen

uv tool install codegen

This makes the codegen command available globally in your terminal, while keeping its dependencies isolated.

Quick Start

Let’s walk through a minimal example of using Codegen in a project:

  1. Navigate to your repository:

    cd path/to/your/project
    
  2. Initialize Codegen in your project with codegen init:

    codegen init
    

    This creates a .codegen/ directory with:

    .codegen/
    ├── .venv/            # Python virtual environment (gitignored)
    ├── config.toml       # Project configuration
    ├── codemods/         # Your codemod implementations
    ├── jupyter/          # Jupyter notebooks for exploration
    └── codegen-system-prompt.txt  # AI system prompt
    
  3. Create your first codemod with codegen create:

    codegen create organize-imports \
      -d "Sort and organize imports according to PEP8"
    

    The -d flag in codegen create generates an AI-powered implementation. This requires a Github account registered on codegen.sh

  4. Run your codemod with codegen run:

    codegen run organize-imports
    
  5. Reset any filesystem changes (excluding .codegen/*) with codegen reset:

    codegen reset
    

Next Steps

For more help, join our community Slack or check the FAQ.

Was this page helpful?