author-codemod

Automate AST-based code transformations across multi-file repositories.

9|3|Updated Jun 13, 2026
One-click install
npx skills add https://github.com/Sir-chawakorn/sanook-cli --skill author-codemod
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: author-codemod
Source: https://github.com/Sir-chawakorn/sanook-cli/tree/main/skills/author-codemod
Command: npx skills add https://github.com/Sir-chawakorn/sanook-cli --skill author-codemod

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill solves the risk of using naive find-and-replace tools for structural code changes, which often mangle strings, comments, or shadowed variables. It provides a reliable way to perform mechanical edits across large codebases while maintaining semantic correctness.

Core Features & Use Cases

  • Grammar-Aware Transformation: Uses AST-based tools like jscodeshift, ast-grep, and ts-morph to ensure edits only target valid code nodes.
  • Safety-First Workflow: Enforces fixture-based testing and dry-run verification before applying changes to the filesystem.
  • Use Case: Automatically migrate an entire repository from a deprecated API to a new one, such as renaming a function across all imports, exports, and call sites without breaking unrelated string literals or comments.

Quick Start

Use the author-codemod skill to generate and run a transformation script that renames the function getUser to fetchUser across all files in the current directory.

Frequently Asked Questions about author-codemod

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate API migrations and rename functions across a multi-file TypeScript repository?

AST manipulation targets valid code nodes to rename functions or migrate APIs across multi-file repositories. This approach updates imports, exports, and call sites while preserving formatting and avoiding false positives in strings or comments.

What is grammar-aware code transformation and how does it differ from find-and-replace?

Grammar-aware code transformation uses Abstract Syntax Trees to ensure edits target valid code nodes. Unlike naive find-and-replace, it maintains semantic correctness by avoiding accidental modifications to shadowed variables, string literals, or comments.

Does this approach work with jscodeshift, ast-grep, and ts-morph for JavaScript refactoring?

Yes, this workflow integrates with jscodeshift, ast-grep, and ts-morph to ensure semantic integrity. These AST-based tools provide the structural parsing required to execute complex code transformations and idiom shifts safely.

How do I safely verify structural code edits before applying them to the filesystem?

You verify structural code edits by enforcing a safety-first workflow with fixture-based testing and dry-run verification. This ensures the transformation script produces the expected changes before applying them to the filesystem.

Why does naive find-and-replace fail during complex signature updates?

Naive find-and-replace fails during signature updates because it mangles strings, comments, or shadowed variables. Grammar-aware AST manipulation solves this by evaluating the structural context to maintain semantic correctness.