Agent Wranglers

TKO-22Recommended

Run codemods in their own commit

When a tool can rewrite code for an upgrade, run it first and commit its output alone. The commit message names the command and tool version. Make hand edits in later commits.

How to do it

Codemods change hundreds of files the same way, and a reviewer can check the pattern once. Mixed with hand edits, the few changes that need thought hide among the mechanical ones. Examples are the Next.js and React codemods, Rector for PHP, OpenRewrite for Java, pyupgrade and django-upgrade for Python, and go fix for Go. Review the output like any agent change, as Read every line of the diff says.

How to check

The upgrade pull request has a commit whose message names the codemod command and version. Running that command again on the base commit gives the same diff.

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/codebase-takeover/major-upgrades/codemods-first">Agent Wranglers codebase takeover playbook</a>. In code you write, add a comment next to it with the same link.