We’re excited to announce the launch of the new Codemod CLI; your all-in-one toolkit for automating large-scale code transformations, refactors, and migrations. Whether you’re wrangling a monorepo, modernizing legacy code, or rolling out sweeping changes across dozens of projects, Codemod CLI brings power, safety, and flexibility to your workflow.
What’s new?
- First-class workflow authoring: Compose, validate, and run workflows with a single tool.
- Self-hostable & portable: No server required. Run anywhere you have a shell.
- Schema-validated shared state: Safely coordinate complex, multi-step migrations.
- Parallel & resumable: Run tasks in parallel, pause for manual approval, and resume after interruptions.
Quick Start: Your First Codemod Workflow
#1 Create a New Workflow Project
Codemod CLI supports three workflow types:
- Shell command workflow codemod: Automate any shell command or script.
- JavaScript ast-grep codemod: Use jssg (JavaScript ast-grep) for fast, pattern-based code transformations.
- YAML ast-grep codemod: Use YAML-based rules for language-agnostic AST transformations.
To create a new project, run:
npx codemod initYou’ll be prompted to choose your workflow type, project name, and other details. This sets up a ready-to-go project structure, including:
my-codemod/
├── codemod.yaml # Project metadata
├── workflow.yaml # Workflow definition
├── rules/ # ast-grep rules
├── jssg/ # jssg codemods
├── scripts/ # Custom scripts (for shell scripts)
└── tests/ # Test fixtures#2 Build Your Transform with Codemod Studio
For ast-grep YAML and jssg codemods, Codemod Studio is your visual playground for building, testing, and refining code transformations.
- Open ** Codemod Studio ** in your browser.
- Select your language and codemod type (ast-grep YAML or jssg).
- Write and test your transformation rules interactively.
- Once satisfied, copy your rule.
- Paste your rule into **
rules/config.yml** (for YAML) or **jssg/codemod.ts** (for jssg).
#3 Run Your Workflow with Codemod CLI
With your workflow and rules in place, you’re ready to validate and execute your codemod:
# Validate your workflow for errors
npx codemod workflow validate -w ./example-codemod/workflow.yaml # Replace with actual path
# Run the workflow locally
npx codemod workflow run -w ./example-codemod/workflow.yaml # Replace with actual pathNext steps
- Explore the Codemod CLI docs to learn more.
- For pro workflows and enterprise migrations, book us .
