Core Concepts
Tern helps you plan, execute, and refine large-scale code migrations. Here’s how it’s organized.
Migrations
A migration is your top-level project. Think “Upgrade to React 18” or “Migrate from Enzyme to React Testing Library.”
Each migration has a name and start date, links to one or more repos, contains a hierarchy of tasks, and lives in your organization.
Migrations help you organize complex work that touches multiple files across multiple repositories.
Tasks
Tasks are units of work inside a migration. They’re hierarchical—parent tasks can contain subtasks for breaking down complex migrations.
Each task has a search query to find matching code, notes with transformation instructions, and an optional parent task for organization. Example: “Convert Button component tests” with search file:Button.test.tsx and transformation steps.
Tasks can nest to organize work:
React 18 Migration
├── Breaking Changes
│ ├── Migrate ReactDOM.render to createRoot
│ └── Add children prop to FC types
├── Dependency Upgrades
│ ├── Upgrade React packages
│ └── Upgrade MobX to 7.4.0+
└── Test Updates
└── Migrate Enzyme to React Testing LibraryThis structure helps you see the big picture, track progress, and understand dependencies between changes.
Repos
Migrations often touch multiple codebases—upgrading a shared library affects all services that use it, or you’re standardizing patterns across a monorepo. Associate multiple repos with a migration and Tern searches all of them when finding matches for your tasks.
Your code stays local. Tern links to repos on your filesystem via the CLI and runs all searches and transformations there.
Codemods
A codemod is a script that programmatically edits code—parsing it into an AST, making changes, and writing it back. For mechanical transformations (renaming a function, updating an import path), codemods are faster and more reliable than LLM-per-file approaches. See Workflows for how Tern generates and runs codemods.
Next Steps
- Learn how Workflows execute transformations at scale
- Understand Search Syntax to write precise queries
- See Task Instructions for defining transformation steps
