Skip to main content
This guide walks you through setting up Codemod in your agent, building a JSSG codemod, and testing and publishing it to the registry. It assumes you are familiar with codemods. If not, check out this intro to codemods.
Codemod 2.0 is published on npm under the next tag, and latest is still 1.x. That is why the commands in these docs run npx codemod@next: a plain npx codemod runs 1.x.

1. Set up Codemod in your coding agent

Experimental. This can change in a minor release of the CLI, but not in a patch. Pin the CLI version (npx codemod@<version>) if you build on it.
Start by installing Codemod Master Skill and Codemod MCP for your preferred coding agent:
This is the main setup path for Codemod’s AI-native CLI. It installs Codemod Master Skill and Codemod MCP so your agent can use Codemod CLI with built-in best practices for building, running, testing, and publishing codemods.

2. Scaffold and build your codemod

Create a dedicated folder or repo for your codemod work, then scaffold a starter package:
The starter package gives your agent a concrete structure to refine or replace while keeping the workflow, tests, and publishing flow in place. Once the package is scaffolded, you can ask your AI agent to help you build codemods for things like framework upgrades, design system migrations, i18n work, code-mining tasks, and more. Tell the agent to follow Performant codemods in jssg-gotchas: use discriminating selectors or token gates, avoid per-file full-repo walks, and time a no-op vs. a real run on the same entry path before publishing. For JavaScript, TypeScript, or Java packages, prefer @jssg/utils over hand-written import, style, and rename helpers. Use semantic analysis when symbol origin matters, such as for generic method names, renames, or aliases. To count edits, return { edit, data } with an entry per real edit and a field such as kind so the workflow can group by variant. For read-only mining, return { edit: null, data }. Use codemod jssg test to snapshot the data in data.json beside the standalone fixtures. For example:

Simplify JSX disabled={true} attributes to their equivalent shorthand.

Open in Cursor

Prompting best practices

Tips for writing effective prompts and getting the most out of building codemods with AI.
You will end up with a Codemod package:
my-codemod
codemod.yaml
package.json
src
workflow.ts
scripts
simplify-disabled.ts
tests
fixtures
input.tsx
expected.tsx

3. Validate and test

From your scaffolded codemod package directory, validate the workflow and run the generated tests. Validate the workflow schema:
Run the tests, which run the workflow against your input/expected fixtures:
The tests are in tests/workflow.test.ts: it runs the workflow on each fixture in tests/fixtures and compares the files it leaves with the expected ones. A fixture is a directory with simple input.*/expected.* file pairs, or input/ + expected/ directory snapshots when your codemod creates or deletes files. Fixtures you add there, including ones MCP generates, are picked up by the test file. For test structure, CI integration, and debugging strategies, see Testing workflows.

4. Run your codemod

From the same package directory, run your codemod on a target codebase:
For all CLI options, see CLI reference.

5. Publish

When you’re happy with the result, publish from the package directory: Share your codemod with your team or the community:
Your codemod is now in the Codemod Registry and runnable by anyone via npx codemod@next @your-scope/codemod-name. For CI/CD automation, trusted publishers, and API keys, see the Publishing guide.

Next steps

Scale your migrations

Your migration experience does not stop here. When you’re managing migrations across large codebases or multiple teams, the same codemod package can power Campaigns for automated multi-repo rollouts and Insights for tracking adoption progress. See the Platform quickstart for the full enterprise workflow.

Getting help

Join the community

Ask questions, get help, and connect with other codemod users on Slack.

Book a call

Schedule a demo or get hands-on help from the Codemod team.

Learn more

CLI reference

Full CLI command reference.

Workflow reference

Every workflow.ts API: steps, tasks, approvals, and results.

JSSG

Learn the transformation engine in depth.

Publishing

Authentication methods and CI/CD setup.