Using Codegen in Your IDE
Get up and running with Codegen programs in IDEs like VSCode, Cursor and PyCharm.
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.
MCP Server Setup
This is an optional step but highly recommended if your IDE supports MCP support and you use AI Agents. The MCP server is a local server that allows your AI Agent to interact with the Codegen specific tools, it will allow an agent to:
- ask an expert to create a codemod
- improve a codemod
- get setup instructions
Configuration
Usage with Cline:
Add this to your cline_mcp_settings.json:
Usage with Cursor:
Under the Settings
> Feature
> MCP Servers
section, click “Add New MCP Server” and add the following:
Create a New Codemod
Generate the boilerplate for a new code manipulation program using codegen create:
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:
- Create a new codemod in
.codegen/codemods/organize_types/
- Generate a custom
system-prompt.txt
based on your task - 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
.codegen/.venv/bin/python path/to/codemod.py
or via your editor’s debuggerViewing Changes
We recommend viewing changes in your IDE’s native diff editor.