Agent Skills guide
Skill recipe: a framework migration
A worked Agent Skill recipe for framework and API upgrades: codemods, before/after replacements, banned legacy patterns and verification checks.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn this page
A framework migration skill packages your team’s upgrade map, deprecated API replacements and verification commands into one SKILL.md folder so coding agents stop mixing old and new idioms during a major version bump. Instead of pasting the same release notes into twenty pull requests, the agent loads the exact before/after rules whenever it touches a file on the old API.
Without a migration skill, models lean on older patterns from training data. Ask an agent to migrate a component from Tailwind CSS v3 to v4 or from React Router v6 to v7, and it will often keep legacy config keys, invent half-migrated wrappers or skip the project’s post-upgrade checks. This recipe shows a portable structure you can adapt to any major library or internal SDK upgrade, checked against the Agent Skills specification on 21 November 2026. If Agent Skills are new to you, start with what Agent Skills are.
What goes in
- Scope and trigger: the exact package names, old version and target version, so the skill triggers only on files still using the legacy API.
- Mechanical changes first: the official codemod or search command to run before hand-editing files.
- Before/after mapping: the five to ten breaking changes the model gets wrong most often, kept short in
SKILL.mdwith the full list inreferences/api-map.md. - Hard stops: changes that need a human decision (schema migrations, auth middleware, runtime polyfills).
- Verification loop: type-check, build, test and grep checks that prove no legacy imports remain in the touched folder.
SKILL.md
---
name: acme-sdk-v4-migration
description: >-
Migrates TypeScript modules from @acme/sdk v3 to v4: replaces removed
client constructors, updates pagination helpers, converts error codes
and runs verification checks. Use when upgrading files that import
from @acme/sdk or fixing v4 type errors. Not for greenfield modules.
---
# Migrating @acme/sdk from v3 to v4
Migrate one module or directory at a time on its own branch. Do not mix
unrelated refactors into a migration pull request.
## 1. Find legacy call sites
Run a read-only search inside the target directory before editing:
```bash
rg -n "@acme/sdk|createAcmeClient|fetchAllPages" <target-dir>
```
## 2. Apply the verified replacements
Use these exact v4 forms (see `references/api-map.md` for edge cases):
- `createAcmeClient({ apiKey })` -> `new AcmeClient({ token: apiKey })`
- `client.orders.list({ page })` -> `client.orders.list({ cursor })`
- `err.code === "NOT_FOUND"` -> `err instanceof AcmeNotFoundError`
- Remove `client.close()`; v4 uses standard `fetch` with no persistent pool.
## 3. Stop and ask before changing
Stop and ask the developer if a file contains any of:
- Custom HTTP interceptors or retry wrappers around v3 internals.
- Serialised v3 cursor tokens stored in a database table.
- Public types re-exported by a shared package consumed by other repos.
## 4. Verify before reporting done
Run every check below on the touched package and paste the real result:
1. `npm run typecheck` passes with zero errors.
2. `npm test` passes, including at least one test covering the updated path.
3. `rg -n "createAcmeClient|fetchAllPages" <target-dir>` returns no matches.
Keeping the mapping concrete and compact leaves room in context for the actual code being migrated, while the grep step at the end gives an objective completion signal. Because the hard-stop list sits right above the verification commands, the agent sees the boundary before it starts inventing shims for complex wrappers.
Example of the difference
Consider a billing module that calls createAcmeClient, iterates through pages with fetchAllPages, and catches err.code === "NOT_FOUND" to return a 404 response.
- Without the skill, an agent often rewrites the constructor correctly from TypeScript hints, leaves
err.code === "NOT_FOUND"untouched becauseerris typed asunknown, and wrapsclient.orders.listin a new compatibility helper so it does not have to update callers. Type checking passes, yet error handling breaks silently at runtime and the helper adds dead weight to every future PR. - With the skill, the agent runs the search first, replaces all three patterns in one pass, removes
client.close(), updates the unit test to assertAcmeNotFoundError, and proves withrgthat zero legacy symbols remain insrc/billing/.
When you migrate twenty packages across a monorepo, that difference saves hours of repetitive code review comments and stops half-migrated helpers from spreading. Because every developer and coding agent reads the same four rules, pull requests look consistent regardless of who ran the session or which model executed the edits.
references/api-map.md
Put the long tail of breaking changes in references/api-map.md: renamed option fields, removed default exports, error-class inheritance trees and one short before/after snippet per subtle case. Link it one level deep from SKILL.md with a relative path so the agent loads it only when it hits an edge case outside the main four replacements.
Organise references/api-map.md into three compact tables so the agent can scan it without burning tokens:
| Section | What to put in each row |
|---|---|
| Renamed symbols | Old import path, new import path, and whether a codemod handles it |
| Changed return shapes | Old property path, new property path, and nullability change |
| Removed options | Old option key, replacement or removal note, and whether a human decision is needed |
If the upstream library ships an official codemod (such as npx @next/codemod or npx @tailwindcss/upgrade), document the exact pinned version and flags in step 1 of SKILL.md so the agent runs the deterministic transform first and spends its tokens only on the remaining manual fixes.
Testing it
Test the skill in a fresh session on three real files from your repository before sharing it with the team:
- Routine file: imports
createAcmeClientand callsorders.list. Confirm the agent updates both without inventing wrapper helpers, updates or adds a test for the changed error class, and reports all three verification commands with real output. - Hard-stop file: contains a custom HTTP interceptor or a re-exported public type. Confirm the agent pauses, cites the matching rule from section 3, and asks before editing.
- Unrelated file: does not import
@acme/sdk. Confirm the skill does not trigger and leaves the session’s context untouched.
Compare the diff and review time against a baseline run without the skill, following testing and evaluating Agent Skills. Keep a short log of any missed edge case during the first two pull requests and add one row to references/api-map.md each time the model stumbles on a real repository idiom.
Once the migration finishes across the repository, add a lint rule (for example ESLint no-restricted-imports) to block legacy imports, then delete the skill folder so it stops taking up description tokens in future sessions.
Pairs well with
- Verification before completion to make sure the agent runs the real build and test commands before declaring a module migrated.
- Vercel composition patterns and Modern Python as real-world examples of opinionated refactor skills in the Agent Skills directory.
- Parallel refactor with git worktrees when migrating several independent packages concurrently.
- Agent Skill design patterns and how to install Agent Skills for committing the skill into
.agents/skills/or.claude/skills/.
Related
- Agent Skill best practices: nine design patterns with real examples
Agent skill best practices as nine design patterns, from checklists and routers to script-backed and gated skills, each with a real example and when to use it.
- Skill recipe: your design system
A worked skill that teaches coding agents your tokens, components and do and don't rules, with detail in reference files so it loads only when needed.
- Refactor in parallel with git worktrees and two agents
Use git worktrees to run Claude Code and Codex in parallel on the same refactor from one written plan, compare tests, diff size and readability, then merge one.
- How to test and evaluate Agent Skills
Check a skill triggers when it should, stays quiet when it shouldn't and beats the baseline, using a small eval set you can rerun.