ScriptsApr 9, 2026·2 min read

Codemod — AI-Powered Code Migration CLI

Scaffold, share, and run large-scale code migrations with AI. First-class ast-grep support, multi-step YAML workflows, community codemod registry. Apache-2.0, 970+ stars.

SC
Script Depot · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

  1. Run a community codemod instantly:
npx codemod @codemod/next/13/app-router
  1. Or create your own codemod:
npx codemod init my-migration
  1. Publish to the registry:
npx codemod publish my-migration

Intro

Codemod is an AI-powered CLI for scaffolding, sharing, and running large-scale code migrations, with 970+ GitHub stars. It supports multi-step YAML workflows, first-class ast-grep patterns, and a community registry of pre-built codemods for popular framework upgrades (Next.js, React, etc.). Best for teams facing major framework upgrades or large refactoring projects. Works with any language that ast-grep supports.

Check out more developer scripts on TokRepo Script Depot.


Codemod — AI-Powered Code Migration Platform

The Problem

Upgrading frameworks (Next.js 12→13, React class→hooks, Express→Fastify) across hundreds of files is tedious and error-prone. Manual find-and-replace misses edge cases. AI chat can't handle 500-file refactors consistently.

The Solution

Codemod provides deterministic AST-based transformations enhanced with AI. Define migration rules once, run them across your entire codebase with confidence.

Key Features

  • Codemod CLI — execute migrations from terminal or CI
  • YAML Workflows — coordinate multi-step migrations with matrix strategies and approval gates
  • ast-grep support — powerful AST pattern matching for precise code transformations
  • Community Registry — discover and share codemods for popular migrations
  • MCP Integration — use codemods from AI coding assistants
  • Validation — dry-run mode, diff preview, and rollback support

Quick Start

# Run a community codemod (e.g., Next.js App Router migration)
npx codemod @codemod/next/13/app-router

# Initialize a new custom codemod
npx codemod init my-codemod

# Define a multi-step workflow
npx codemod workflow run -w my-codemod/workflow.yaml

# Publish your codemod to the registry
npx codemod publish my-codemod

# Search the registry
npx codemod search "react hooks"

Example: YAML Workflow

name: upgrade-nextjs-13
steps:
  - name: app-router
    codemod: @codemod/next/13/app-router
  - name: metadata
    codemod: @codemod/next/13/metadata
  - name: image-component
    codemod: @codemod/next/13/next-image

Popular Community Codemods

  • Next.js App Router migration
  • React class components → hooks
  • Security patch automations
  • TypeScript strict mode upgrades

FAQ

Q: What is Codemod? A: Codemod is an open-source CLI and platform for running AI-powered code migrations at scale. It uses AST-based transformations to safely refactor large codebases.

Q: Is Codemod free? A: Yes, fully open-source under Apache-2.0. The CLI and community registry are free.

Q: What languages does Codemod support? A: Any language supported by ast-grep, including JavaScript, TypeScript, Python, Go, Rust, Java, C, and more.


🙏

Source & Thanks

Created by Codemod. Licensed under Apache-2.0.

codemod/codemod — ⭐ 970+

Thanks to the Codemod team for making large-scale code migrations manageable.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets