Free — no signup required

Automated Migration: The "Codemod" Strategy

3 min read

Don't Ask, Do.

The psychological resistance to deprecation usually stems from effort. Developers agree the new tool is better, but they are too busy to rewrite their config files. The Platform Engineer's most powerful tool is removing that effort entirely through automated migration.

Think of it like a spell-checker that doesn't just highlight errors — it fixes them for you. You don't ask 50 teams to change apiVersion: apps/v1beta1 to apiVersion: apps/v1 in their Kubernetes manifests. You write a script that does it for them, opens a pull request in each of their repositories, and sends them a Slack message saying "I already did the migration — just click Merge."

The Codemod Workflow

A codemod (short for "code modification") is an automated script that parses source code or configuration files and transforms them according to defined rules. The workflow has four steps:

Step 1: Scan — Find all repositories or files using the old pattern, typically with a recursive grep across every YAML file in your repos for the deprecated string.

Step 2: Transform — Apply the change programmatically. For a simple string swap across many files, a find + sed one-liner is often enough.

For more complex transformations — like restructuring nested YAML keys, updating function signatures in code, or migrating between SDK versions — use purpose-built tools:

Language / Format Tool Use Case
JavaScript / TypeScript jscodeshift AST-based JS/TS code transforms
Java / Kotlin OpenRewrite Dependency upgrades, API migrations
Python libcst Syntax-tree-aware Python transforms
YAML / JSON yq, jq Structured config file transforms
Go gorename, gofmt -r Symbol renaming, pattern rewrites

Step 3: Open Pull Requests — Use the GitHub or GitLab API to submit the change to each affected repository automatically. Tools like multi-gitter (for GitHub) can open PRs across hundreds of repositories from a single command, running your transform script against every repo in an org and opening a branch, title, and body for each resulting PR in one pass.

Step 4: Notify — Send a targeted Slack message or email to the team that owns each repository, linking directly to their PR. Do not send a generic broadcast — send a personalized message: "Hey @team-payments, I've opened PR #142 in your repo to migrate off the deprecated API. It's a one-line change. Please merge by Friday."

The Residual 10%

Automated migration rarely achieves 100% coverage. Some repositories will have unusual patterns the script doesn't handle, or the change will require human judgment. Track migration progress in a dashboard (a simple spreadsheet works), and follow up personally with the teams that haven't merged after one week. The combination of automation plus personal follow-up is far more effective than either alone.

Interview Tip

A common platform engineering interview question is: "How would you migrate 200 teams off a deprecated internal library?" The answer that impresses interviewers has three parts: (1) automated codemods to do the mechanical work, (2) bulk PR creation so teams only have to click Merge, and (3) a tracking dashboard to identify stragglers for personal follow-up. Mentioning that you'd also instrument the old library to emit deprecation warnings in CI output shows senior-level thinking.

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free