# 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 Save as a script file and run: ## 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. --- ## 快速使用 1. 立即运行社区 codemod: ```bash npx codemod @codemod/next/13/app-router ``` 2. 或创建自定义 codemod: ```bash npx codemod init my-migration ``` 3. 发布到注册表: ```bash npx codemod publish my-migration ``` --- ## 简介 Codemod 是一个 AI 驱动的代码迁移 CLI 工具,GitHub 970+ star。支持多步骤 YAML 工作流、ast-grep AST 模式匹配和社区 codemod 注册表。适合面临大规模框架升级或重构项目的团队。 --- ## Codemod — AI 驱动的代码迁移平台 ### 解决的问题 跨数百个文件升级框架(Next.js 12→13、React class→hooks)既繁琐又容易出错。Codemod 提供基于 AST 的确定性转换,配合 AI 增强,一次定义迁移规则,全代码库可靠执行。 ### 核心功能 - **CLI 执行** — 终端或 CI 中运行迁移 - **YAML 工作流** — 多步骤迁移,支持矩阵策略和审批关卡 - **ast-grep** — 精确的 AST 模式匹配 - **社区注册表** — 发现和分享热门迁移方案 - **MCP 集成** — 从 AI 编码助手使用 codemod ### FAQ **Q: Codemod 是什么?** A: 一个开源 CLI 和平台,用于大规模 AI 驱动的代码迁移。使用基于 AST 的转换安全重构大型代码库。 **Q: 免费吗?** A: 完全免费开源,Apache-2.0 许可。 --- ## 来源与感谢 > 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/a414acda-33ca-11f1-9bc6-00163e2b0d79 Author: Script Depot