---
title: "Run codemods in their own commit · Agent Wranglers"
url: https://agentwranglers.se/playbook/codebase-takeover/major-upgrades/codemods-first
id: TKO-22
level: Recommended
updated: 2026-10-22
tokens: 574
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Run codemods in their own commit

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Major upgrades](https://agentwranglers.se/playbook/codebase-takeover/major-upgrades.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: TKO-22
- Level: Recommended
- Chapter: [Major upgrades](https://agentwranglers.se/playbook/codebase-takeover/major-upgrades.md)
- Rule: 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.
- 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.
- How: 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](https://agentwranglers.se/playbook/ai-assisted-development/reviewing-agent-output/read-every-diff.md) says.

## Related rules

- AID-15 [Read every line of the diff](https://agentwranglers.se/playbook/ai-assisted-development/reviewing-agent-output/read-every-diff.md) in AI-assisted development

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/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.

- Previous: [Upgrade one major version at a time](https://agentwranglers.se/playbook/codebase-takeover/major-upgrades/one-major-at-a-time.md)
- Next: [Test both versions during an upgrade](https://agentwranglers.se/playbook/codebase-takeover/major-upgrades/test-both-versions.md)
- [Major upgrades](https://agentwranglers.se/playbook/codebase-takeover/major-upgrades.md)
