ClawKit Logo
ClawKitReliability Toolkit
Back to Registry
Official Verified developer tools Safety 3/5

codemod-gen

Generate codemods for large-scale code changes. Use when refactoring patterns across many files.

Why use this skill?

Use AI to generate jscodeshift codemods for large-scale code changes. Safely refactor, migrate, and modernize your codebase with natural language.

skill-install — Terminal

Install via CLI (Recommended)

clawhub install openclaw/skills/skills/lxgicstudios/codemod-gen
Or

What This Skill Does

The codemod-gen skill acts as an intelligent bridge between your natural language requirements and Abstract Syntax Tree (AST) manipulation. Instead of relying on brittle regex find-and-replace methods that often break code structures, this skill generates precise, logic-aware codemods using jscodeshift. By interpreting your intent—such as wanting to migrate an entire legacy codebase to a newer framework or enforcing strict structural changes—the agent crafts the necessary JavaScript logic to parse, transform, and rebuild your source files safely. It preserves your existing formatting and comments while ensuring that the transformations are applied consistently across thousands of files, making it an essential tool for large-scale technical debt reduction.

Installation

To add this skill to your OpenClaw environment, use the built-in package manager by executing the following command in your terminal: clawhub install openclaw/skills/skills/lxgicstudios/codemod-gen. Once installed, ensure you have a valid OPENAI_API_KEY set in your environment variables, as the agent requires this to perform the intelligent analysis of your refactoring requests. The tool is designed to be used with Node.js 18+ and requires no local installation of dependencies beyond the environment itself.

Use Cases

This tool excels in environments where manual refactoring is cost-prohibitive. Common use cases include massive framework version migrations (e.g., React Router v5 to v6), replacing deprecated library methods (such as swapping Moment.js for native date objects or date-fns), standardizing internal component architectures, or stripping away legacy boilerplate code. It is particularly effective for teams managing high-growth repositories where consistency across hundreds of modules is required to maintain architectural integrity.

Example Prompts

  1. "I need to update all instances of the deprecated 'UserFetch' API to the new 'useUser' hook pattern across the /src folder."
  2. "Please generate a codemod that replaces all instances of lodash 'get' methods with optional chaining syntax wherever possible."
  3. "Create a codemod to convert all class-based React components in our UI directory into modern functional components with hooks."

Tips & Limitations

While highly capable, codemods should always be treated with caution. Always execute these transformations on a dedicated git branch to allow for easy verification and rollback. Because codemods modify files directly, you must review the generated diffs carefully before committing the changes. We recommend running the tool incrementally—start by targeting a single sub-directory before applying the transformation to the entire codebase. Remember that while the AI understands standard JavaScript and TypeScript patterns, highly unconventional custom syntax might require manual inspection or adjustments to the generated jscodeshift script.

Metadata

Stars1601
Views0
Updated2026-02-27
View Author Profile
AI Skill Finder

Not sure this is the right skill?

Describe what you want to build — we'll match you to the best skill from 16,000+ options.

Find the right skill
Add to Configuration

Paste this into your clawhub.json to enable this plugin.

{
  "plugins": {
    "official-lxgicstudios-codemod-gen": {
      "enabled": true,
      "auto_update": true
    }
  }
}

Tags(AI)

#codemod#refactoring#ast#automation#developer
Safety Score: 3/5

Flags: file-write, file-read, code-execution, external-api