Skip to main content
This guide takes you from zero to a published codemod. Each step includes just enough to get started, with links to deeper documentation.

Building codemods

Codemods can be built using:
  • MCP — AI-assisted creation in your IDE (recommended for getting started)
  • CLI — Scaffold and build locally with npx codemod init
  • Studio — Web-based prototyping with live runner and AST viewer
Once you have a codemod package, validation, running, and publishing work the same way regardless of how you built it.
1

Generate a codemod

Make sure you have MCP installed, then ask your AI assistant to create a codemod. Be specific about what you want to transform:
Create a jssg codemod that converts all console.log statements to console.info in TypeScript files. 

The codemod should:
- Target .ts and .tsx files
- Only transform console.log calls (not console.error, console.warn, etc.)
- Preserve all arguments and formatting
- Include test cases for the transformation

MCP best practices

Tips for writing effective prompts and getting the most out of your AI assistant.
You’ll get a complete package structure:
my-codemod
README.md
codemod.yaml
workflow.yaml
scripts
codemod.ts
tests
fixtures
input.tsx
expected.tsx
For more on package structure, see Package Structure.Need the live runner or AST viewer? If you need tools like the live runner, AST viewer, or shareable links, you can bring your codemod into Codemod Studio and continue development there.
2

Validate your codemod

Run tests to ensure your codemod works correctly:
npx codemod jssg test ./scripts/codemod.ts --language tsx
For test structure, CI integration, and debugging strategies, see Testing.
3

Run your codemod

Run your codemod on a target codebase:
npx codemod workflow run -w ./my-codemod/ -t /path/to/your/project
For all CLI options and running from the registry, see CLI reference.
4

Publish your codemod

Share your codemod with your team or the community:
npx codemod login
npx codemod publish
Your codemod is now in the Codemod Registry and runnable via npx codemod @codemod-name.For CI/CD automation and more publishing features, see Publishing guide.

Getting help

Next steps