Get the FREE Ultimate OpenClaw Setup Guide →

codemod-executor

Scanned
npx machina-cli add skill a5c-ai/babysitter/codemod-executor --openclaw
Files (1)
SKILL.md
2.8 KB

Codemod Executor Skill

Executes automated code transformations using AST-based tools for large-scale refactoring, framework migrations, and language version upgrades.

Purpose

Enable automated code transformations for:

  • Framework migration (React, Angular, Vue)
  • Language version upgrades
  • API deprecation handling
  • Pattern standardization
  • Large-scale refactoring

Capabilities

1. AST-Based Transformations

  • Parse source code to AST
  • Apply transformation rules
  • Generate modified source
  • Preserve code style

2. Pattern Matching and Replacement

  • Define source patterns
  • Specify target patterns
  • Handle edge cases
  • Support wildcards and captures

3. Multi-File Transformations

  • Apply across entire codebase
  • Handle import updates
  • Coordinate cross-file changes
  • Manage side effects

4. Dry-Run Preview

  • Preview changes before applying
  • Generate diff reports
  • Estimate impact scope
  • Identify risky transformations

5. Rollback Support

  • Create transformation checkpoints
  • Enable selective rollback
  • Track applied codemods
  • Maintain change history

6. Custom Codemod Creation

  • Define new transformation rules
  • Test codemods in isolation
  • Document transformation logic
  • Share across teams

Tool Integrations

ToolLanguageIntegration Method
jscodeshiftJavaScript/TypeScriptCLI
ts-morphTypeScriptLibrary
RectorPHPCLI
ScalafixScalaCLI
OpenRewriteJavaCLI / Maven
BowlerPythonCLI
ast-grepMulti-languageCLI / MCP
gofmt -rGoCLI

Output Schema

{
  "executionId": "string",
  "timestamp": "ISO8601",
  "codemod": {
    "name": "string",
    "version": "string",
    "description": "string"
  },
  "results": {
    "filesProcessed": "number",
    "filesModified": "number",
    "filesSkipped": "number",
    "transformations": "number"
  },
  "changes": [
    {
      "file": "string",
      "transformations": [
        {
          "type": "string",
          "line": "number",
          "before": "string",
          "after": "string"
        }
      ]
    }
  ],
  "errors": [],
  "warnings": []
}

Integration with Migration Processes

  • code-refactoring: Large-scale refactoring
  • framework-upgrade: Framework migrations
  • language-version-migration: Syntax upgrades
  • code-translation: Language conversion assist

Related Skills

  • refactoring-assistant: Suggests transformations
  • static-code-analyzer: Pre-transformation analysis

Related Agents

  • code-transformation-executor: Orchestrates codemods
  • framework-upgrade-specialist: Framework-specific codemods

Source

git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/specializations/code-migration-modernization/skills/codemod-executor/SKILL.mdView on GitHub

Overview

Codemod Executor runs automated AST-based transformations for large-scale refactoring, framework migrations, and language-version upgrades. It applies precise rules across multi-file projects while preserving style and behavior. This enables scalable, auditable migrations with repeatable results.

How This Skill Works

The tool parses source files into an abstract syntax tree, applies defined transformation rules, and emits modified code. It supports pattern matching with captures, multi-file coordination, and optional dry-run previews with diffs and impact estimates. Rollback checkpoints and testable codemods help ensure safety during production migrations.

When to Use It

  • Migrating a React/Angular/Vue project to a newer framework version across many files
  • Upgrading a language version in a legacy codebase to leverage newer syntax and features
  • Replacing deprecated APIs with modern equivalents across large codebases
  • Standardizing coding patterns or conventions across a vast repository
  • Coordinating cross-file changes after a library or module restructure

Quick Start

  1. Step 1: Define or load a codemod rule with the source and target patterns
  2. Step 2: Run a dry-run against a targeted subset of files to preview changes
  3. Step 3: Apply the codemod, run tests, and review diffs before full deployment

Best Practices

  • Always start with a dry-run to preview changes and identify risky transforms
  • Define precise AST transformation rules with clear edge-case handling
  • Test codemods in isolation before applying to the entire codebase
  • Roll out changes in small batches and validate with tests before full-scale use
  • Maintain transformation checkpoints and a changelog to enable rollback if needed

Example Use Cases

  • Migrate React class components to hooks across 500+ files with minimal behavioral changes
  • Upgrade TypeScript syntax across a monorepo from an older version to a newer one
  • Replace deprecated API usages with modern alternatives in a services layer
  • Normalize and update import paths after a major library restructure
  • Coordinate cross-file API deprecations during a framework migration

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers