Creating a Codemod
Create a new codemod in Hypermod, continue editing it in the Sandbox, and prepare it for deployment across your repositories.
A codemod is a reusable code transformation that lets you update code safely and consistently. In Hypermod, your codemods live in your Library and are created in the Sandbox editor.
If you're brand new to codemods, start with What is a codemod? and Your first codemod. If you already know what you want to build, follow the steps below.
Before you begin
Make sure you can sign in and access your Hypermod workspace. If you have not connected repositories yet, follow the Installation guide first.
How to create a codemod
1. Log in to Hypermod
Start by signing in to your Hypermod account and opening your dashboard.
2. Open the Library page
From the dashboard, navigate to Library. This is where you can browse codemods created by you, your team, and the community.
3. Click New codemod
In the top-right corner of the Library page, click New codemod. Hypermod will open the Sandbox so you can start building your codemod right away.
4. Build your codemod in the Sandbox
Once the Sandbox opens, you can write, test, and refine your codemod.
If you want help learning the editor itself, read Using the Editor.
If you want help writing the transformation logic, these guides are the best next steps:
- Your first codemod
- Understanding ASTs
- Import manipulation
- React & JSX
- TypeScript
- Best practices
- Codemodding gotchas
5. Save your codemod
When your codemod is ready, save it so it appears in your Library. From there, you can continue iterating on it, share it with your team, or use it in a deployment.
What happens next?
Once your codemod is created, the next step is usually to deploy it to one or more repositories.
Continue to Creating deployments to learn how to package your codemod into a workflow and open pull requests across connected repositories.
Tips for a smoother first codemod
- Start with one focused change instead of trying to automate everything at once.
- Use the Sandbox preview and tests to validate behavior before deploying widely.
- Give your codemod a clear, descriptive name so it is easy to find later in the Library.
- If you expect to reuse the codemod, keep it general and document the intended input/output in your project files.