Codegen is designed to be used with AI assistants. This document describes how to use Codegen with common AI tools, including Copilot, Cursor, Devin and more.

System Prompt

Codegen provides a .txt file that you can drag-and-drop into any chat assistant. This is roughly 60k tokens and will enable chat assistants like, ChatGPT, Claude 3.5 etc. to build effectively with Codegen.

Download System Prompt

Download System Prompt

Learn about leveraging this in IDE chat assistants like Cursor here

Generating System Prompts

The Codegen CLI provides commands to generate .md files that can be fed to any AI assistant for more accurate and contextual help.

When you create a new codemod via codegen create:

codegen create delete-dead-imports --description "Delete unused imports"

Codegen automatically generates an optimized “system prompt” that includes:

  • An introduction to Codegen
  • Codegen API documentation
  • Examples of relevant transformations

You can find this generated prompt in the .codegen/prompts/<codemod-name>-system-prompt.md file.

All contents of the .codegen/prompts directory are by default ignored the .gitignore file. after running codegen init

This .md file can be used with any AI assistant (Claude, GPT-4, etc.) to get more accurate and contextual help.

Example Workflow

1

Create a codemod with description

Use the create command with a detailed description of what you want to accomplish:

codegen create modernize-components --description "Convert class components to functional components with hooks"
2

Review the generated system prompt

Check the AI context that Codegen generated for your transformation: bash cat codegen-sh/codemods/modernize-components/prompt.md

3

Iterate in Copilot, Cursor or Windsurf

Reference your codemod when asking questions to get contextual help: @codegen-sh/codemods/modernize-components How should I handle componentDidMount?

4

Get contextual help

The AI will understand you’re working on React modernization and provide relevant suggestions about using useEffect hooks and other modern React patterns.

Copilot, Cursor and Windsurf (IDEs)

When using IDE chat assistants, you can leverage Codegen’s context by mentioning your codemod in composer mode:

@.codegen/codemods/upgrade-react18 @.codegen/prompts/system-prompt.md

This will ensure that the IDE’s native chat model is aware of the APIs and common patterns for Codegen.

Devin, OpenHands and Semi-autonomous Code Agents

Coming soon!

Was this page helpful?