Skip to main content


Running codemods is made simple through our CLI tool, @hypermod/cli.

@hypermod/cli is responsible for running the provided transform against your entire codebase. Under the hood, it is a wrapper of jscodeshift's cli, which provides additional functionality

For usage please refer to the @hypermod/cli API reference.

How to run Community codemods

To run a hypermod package, install and use the @hypermod/cli.

  • npm: npm install -g @hypermod/cli or
  • yarn: yarn global add @hypermod/cli

For example, say we want to run transforms for @mylib/button and migrate from version 13 to the latest version 14, we could run the following:

codemod-cli --packages @mylib/button@14.0.0 project/path/to/src

The following sequence of events will follow:

  1. @hypermod/cli will then attempt to download a Hypermod package for the @mylib/button package matching version 14.0.0
  2. Download the package from NPM
  3. Locate the hypermod.config.js
  4. Attempt to find a transform for 14.0.0
  5. Run the transform against the path project/path/to/src

Run codemods in sequence

It's also possible to run a series of codemods, one after the other, to migrate your usage of @mylib/button across multiple major versions, from say v14, v15 and finally v16. Assuming codemods for those versions exist.

This is done my providing the --sequence (or -s) flag to @hypermod/cli.

codemod-cli --packages @mylib/button@14.0.0 --sequence project/path/to/src

This time around, we use the provided version (14.0.0) as the start of a semver range between 14.0.0-@latest. We then fetch all codemods that match and run them one after another.

Running local transforms

For local transform files, not published to the community repo, you can supply your own transform the same way you would with jscodeshift.

codemod-cli --transform path/to/transform.ts project/path/to/src

Parsing TypeScript & Flow

By default @hypermod/cli will use babel as the default parser and only transform files with a .js extensions.

If your repo depends on flow or typescript, it's important to remember to specify ts, tsx or flow as the --parser and or jsx, ts, tsx as --extensions to make sure jscodeshift can interpret the files properly.

Please refer to the @hypermod/cli API reference for more information.