codemod-automationlisted
Install: claude install-skill rustcircle/c101
# Codemod automation
A codemod is a deterministic, re-runnable program that edits code. The deliverable is the rule plus
its tests plus the diff it produced, so the diff can be regenerated after every rebase.
Behaviour-preserving restructuring of a few sites by hand is `refactoring-playbook`; this skill
starts where hand edits stop scaling.
Verified versions (October 2026): ast-grep 0.51 (the short `sg` alias now prints a deprecation
warning; use `ast-grep`), ruff 0.17, LibCST 1.9. Check `<tool> --version` and `--help` before use;
flags move.
Deep material:
[per-tool command crib](references/tool-cribs.md) |
[ast-grep rule reference and the tested utcnow rules](references/ast-grep-rules.md)
## 1. When to automate
| Sites | Shape | Do |
|---|---|---|
| < ~10 | any | hand edit or LSP rename |
| ~10-30 | identical syntax | LSP rename / IDE structural replace, or a one-off `ast-grep run -r` with review |
| > ~30, or across repos | any repeatable shape | written, tested codemod (this procedure) |
| any count | needs type info to decide (overloads, which `get` method) | type-aware tool: OpenRewrite, ts-morph, LibCST with metadata, gopls, clang-tidy |
| tail that no rule covers | irregular | manual or LLM-assisted, each hunk reviewed (section 8) |
Never `sed`/`perl -pi` over source except for a unique literal token (a version string, a
UUID-like identifier). Regex rewrites hit strings, comments and unrelated names, and miss
multi-line call forms, keyword arguments and differen