Get started with using the Codemod command-line interface.
ast-grep
and new features.To use the new CLI:codemod init
codemod search
list
and ls
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:
codemod [codemod-name]@[version]
.Example: Running a codemod from registry
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.await
or import.meta
in your codemods, you can use this flag..mjs
or .mts
extension to omit using this compatibility flag.