Get started with using the Codemod command-line interface.
codemod learn
learn
command uses the diff of the latest edited file to automatically build a codemod using Codemod Studio.
After running this command, if any git diff exists, the Codemod Engine will use the diff as before/after snippets in Codemod Studio.
codemod build
codemod search
list
and ls
codemod init
codemod publish
publish
command inside the codemod package directory:
codemod unpublish
codemod run
codemod
command to run codemods.
Codemod CLI allows you to run codemods:
Example
Go to project directory
List available codemods
codemod list
to see all available codemods in Codemod Registry. Alternatively, you can search for codemods of a specific framework like codemod search next.js
.Run codemod
next/13/app-router-recipe
codemod.To do so, we will run:codemod
command, Codemod CLI will attempt to run a codemod as long as it is not followed by a reserved command name.--exclude
option can be used to specify a glob pattern of the files to be ignored by the codemod.By default, Codemod CLI excludes the patterns defined in the .gitignore
found in the project’s root directory.