CLI
Create Command
The create
command generates a new codemod function with the necessary boilerplate.
Usage
Arguments
NAME
: The name of the codemod to create (e.g., “rename-function”)
Options
--description
,-d
: A description of what the codemod should do. This will be used to generate an AI-powered implementation.
Generated Files
When you run codegen create rename-function
, it creates:
The generated codemod will have this structure:
Examples
Create a basic codemod:
Create with an AI-powered implementation:
Next Steps
After creating a codemod:
- Edit the implementation in the generated .py file
- Test it with
codegen run rename-function
- Deploy it for team use with
codegen deploy rename-function
Common Issues
If you see “File already exists”:
- Choose a different name for your codemod, or
- Use the
--overwrite
flag to replace the existing file
The codemod name will be converted to snake_case for the Python file (e.g., update-imports
becomes update_imports.py
).