# 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. ## Install Copy the content below into your project: ## Quick Use 1. Run a community codemod instantly: ```bash npx codemod @codemod/next/13/app-router ``` 2. Or create your own codemod: ```bash npx codemod init my-migration ``` 3. Publish to the registry: ```bash 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](https://tokrepo.com/en/@Script%20Depot). --- ## 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 ```bash # 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 ```yaml 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](https://github.com/codemod). Licensed under Apache-2.0. > > [codemod/codemod](https://github.com/codemod/codemod) — ⭐ 970+ Thanks to the Codemod team for making large-scale code migrations manageable. --- ## Quick Use 1. Run a community codemod instantly: ```bash npx codemod @codemod/next/13/app-router ``` 2. Or scaffold a custom codemod: ```bash npx codemod init my-migration ``` 3. Publish to the registry: ```bash npx codemod publish my-migration ``` --- ## Introduction Codemod is an AI-powered code migration CLI tool with 970+ GitHub stars. It supports multi-step YAML workflows, ast-grep AST pattern matching, and a community codemod registry. Ideal for teams facing large-scale framework upgrades or refactors. --- ## Codemod — AI-Driven Code Migration Platform ### The Problem It Solves Upgrading frameworks across hundreds of files (Next.js 12→13, React class → hooks) is tedious and error-prone. Codemod provides deterministic AST-based transforms with AI enhancement — define a migration rule once and execute it reliably across the entire codebase. ### Core Features - **CLI execution** — run migrations in terminal or CI - **YAML workflows** — multi-step migrations with matrix strategies and approval gates - **ast-grep** — precise AST pattern matching - **Community registry** — discover and share popular migrations - **MCP integration** — use codemods from AI coding assistants ### FAQ **Q: What is Codemod?** A: An open-source CLI and platform for large-scale AI-driven code migrations using AST-based transforms for safe refactoring. **Q: Is it free?** A: Completely free and open source under the Apache-2.0 license. --- ## Source & Thanks > Created by [Codemod](https://github.com/codemod). Licensed under Apache-2.0. > > [codemod/codemod](https://github.com/codemod/codemod) — ⭐ 970+ --- Source: https://tokrepo.com/en/workflows/codemod-ai-powered-code-migration-cli-a414acda Author: Script Depot