The run command executes a codemod against your local codebase, showing you the changes and applying them to your filesystem.

codegen run rename-function

Usage

codegen run LABEL [OPTIONS]

Arguments

  • LABEL: The name of the codemod to run (e.g., “rename-function”)

Options

  • --diff-preview N: Show a preview of the first N lines of the diff
  • --arguments JSON: Pass arguments to the codemod as a JSON string (required if the codemod expects arguments)

Examples

Run a codemod:

codegen run rename-function

Run with a diff preview limited to 50 lines:

codegen run rename-function --diff-preview 50

Run with arguments (for codemods that require them):

codegen run rename-function --arguments '{"old_name": "getUserData", "new_name": "fetchUserProfile"}'

Output

The command will:

  1. Parse your codebase
  2. Run the codemod
  3. Show a diff preview (if requested)
  4. Apply changes to your filesystem

Execution Flow

When you run a codemod:

  1. Codegen parses your entire codebase into a graph representation
  2. The codemod function is executed against this graph
  3. Any changes made by the codemod are tracked
  4. Changes are automatically applied to your local files
  5. A summary of changes is displayed

The codebase parsing step may take a few moments for larger codebases. Learn more in How it Works

Was this page helpful?