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
Start by installing Codemod Master Skill and Codemod MCP for your preferred coding agent:2. Scaffold and build your codemod
Create a dedicated folder or repo for your codemod work, then scaffold a starter package: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.
Prompting best practices
Tips for writing effective prompts and getting the most out of building codemods with AI.
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: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:5. Publish
When you’re happy with the result, publish from the package directory: Share your codemod with your team or the community: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.