Get up and running with Codegen programs in IDEs like VSCode, Cursor and PyCharm.

Make sure to install and initialize Codegen with codegen init

Configuring your IDE Interpreter

Codegen creates a custom Python environment in .codegen/.venv. Configure your IDE to use this environment for the best development experience.

Create a New Codemod

Generate the boilerplate for a new code manipulation program using codegen create:

codegen create organize-types \
  -d "Move all TypeScript types to \
      into a centralized types.ts file"

Passing in -d --description will get an LLM expert to compose an initial version for you. This requires a Github account registered on codegen.sh

This will:

  1. Create a new codemod in .codegen/codemods/organize_types/
  2. Generate a custom system-prompt.txt based on your task
  3. Set up the basic structure for your program

The generated codemod includes type hints and docstrings, making it easy to get IDE autocompletion and documentation.

Iterating with Chat Assistants

When you do codegen init, you will receive a system prompt optimized for AI consumption at .codegen/codegen-system-prompt.txt.

If you reference this file in “chat” sessions with Copilot, Cursor, Cody, etc., the assistant will become fluent in Codegen.

Collaborating with Cursor’s assistant and the Codegen system prompt

In addition, when you create a codemod with “-d”, Codegen generates an optimized system prompt in .codegen/codemods/{name}/{name}-system-prompt.txt. This prompt contains:

  • Relevant Codegen API documentation
  • Examples of relevant transformations
  • Context about your specific task

You can also drag and drop the system prompt (available here)file directly into chat windows like ChatGPT or Claude for standalone help.

Running and Testing Codemods

# Run => write changes to disk
codegen run organize-types

# Reset changes on disk
codegen reset
You can also run the program directly via .codegen/.venv/bin/python path/to/codemod.py or via your editor’s debugger

Viewing Changes

We recommend viewing changes in your IDE’s native diff editor.

What’s Next

Was this page helpful?