🤖 What are codemods, when should you use them, and how do they give platform teams leverage?
July 8, 2025What are codemods?
Codemods are a special type of script that can be used to automatically modify source code. A codemod contains instructions that allow it to identify a certain piece of code. When run, the codemod finds a piece of code and then automatically modifies it. This is incredibly useful for repetitive, structured work.
When should you write a codemod?
As engineers become more experienced, they develop a taste of when to do a task manually vs. when to write a script to automate a task. When deciding whether to build a codemod, try to consider how long a task will take and whether you will run it once or many times.
Codemods are particularly effective for tasks like component migrations, API changes, or large-scale refactors.
If a codemod can save a signficant amount of time or you can hand it off to other engineers to share the load across teams, it's probably worth writing.
Codemods let teams share the load
More importantly, codemods enable distributed collaboration. Platform teams are often stuck implementing new tools, and also migrating product teams to those new tools one-by-one. Codemods are a tool that platform engineers can provide to equip product teams to execute updates autonomously within their domains. This shifts the focus of platform from actually executing migrations to enabling them at scale -- this becomes more crucial as a company grows in size.
Advances in AI have further lowered the barrier to codemod creation. Tasks that once required deep knowledge of ASTs or syntax tooling can now be prototyped and refined more efficiently with an LLM.
Codemods allow frontend platform teams to scale their efforts. Providing product teams with a codemod that can help them migrate to new components or tools can encourage consistency, reduce maintenance cost, and increase adoption.