Every Sitecore team still on JSS will eventually face the same question. Content SDK is where the platform is heading, but your site has hundreds of components, custom middleware, and years of accumulated patterns. Nobody wants to touch every file by hand, and nobody wants to trust a blind find-and-replace either.
We recently migrated an XM Cloud site from JSS to Content SDK 2.1 on the Next.js Pages Router. We let AI handle the repetitive refactoring and kept people focused on the parts that need judgment. This post covers how we set that up and the problems that only appeared after the code compiled.
The Problem: Mostly Repetition, but Not Entirely
On paper, the move is a long list of mechanical changes: imports move, prop shapes change, and data fetching patterns get replaced. Hidden in that list are a handful of spots that need a person to think, and at first glance, they look like everything else. Do it all by hand and you spend weeks on changes a machine could make in seconds. Hand it all to a generic AI prompt and you get confident-looking code that quietly breaks whatever was never standard to begin with.
The upgrade also changes more than your code. Content SDK 2.1 brings Next.js 16, Turbopack as the default bundler, and a Node.js 24 requirement. Several of our hardest issues came from that platform shift, not from our components.
The Solution: Teach the AI Your Codebase, Then Hand It a Procedure
The AI is only as good as the instructions you give it. Before migrating a single file, we gave it two things: steering files that describe how our team writes code and migration workflows that spell out the job step by step.
Steering Files: Your Project's Conventions
Most AI coding tools can load persistent project instructions into every request. Cursor calls them rules (.cursor/rules/), Claude Code reads CLAUDE.md, and many tools also read a shared AGENTS.md. Whatever the name, write down what you would tell a new developer in their first week:
- Naming. File names, component names, functions, hooks, types, and variables. If component files are PascalCase, hooks start with use, and prop types follow a prefix convention, say so.
- Folder structure and imports. Where components, utilities, types, and middleware live, and which path aliases to use instead of relative imports.
- Component architecture. How a Sitecore-bound component is shaped. For example, a thin wrapper that reads fields and passes them to presentational variants, always using the SDK's field helpers so content stays editable in Pages.
- Utility functions. Pure, typed, no side effects, one responsibility each, kept in a shared folder instead of inside components.
- Middleware. One concern per handler, explicit ordering, and failures that log and pass the request through instead of taking the site down.
- Styling. How styles are applied, plus the traps. With Tailwind, class names have to be complete literal strings, or production builds drop them.
Steering files aren't migration-specific. They stay in the repo after launch and shape every future change, and the next developer to join the team benefits as much as the AI does.
Workflows: The Migration as a Procedure
A workflow is different. It's an ordered procedure the AI works through one step at a time, like a runbook. Ours turned each change in Sitecore's upgrade guide into an explicit step: replace the @sitecore-jss imports, rename the context APIs, rename the GraphQL service classes, replace temp/config with sitecore.config, and so on. Each step makes one kind of change, so it's easy to run, review, and rerun. Here's one step, slightly shortened:
## Step 3: Update Property Names
| Old | New |
| ----------------------- | ------------ |
| `context` | `page` |
| `sitecoreContext` | `page` |
| `updateSitecoreContext` | `updatePage` |
> The context → page rename applies only to the useSitecore() return value.
> The raw Layout Service response still uses context. Do not rename
> layout?.sitecore?.context in getComponentServerProps service files.Three things made the workflow reliable:
- Precise scope. Blanket renames break things. Without the note above, the AI would have "fixed" service code that was already correct. Wherever a rename applies in one place but not another, the step says so and shows a correct example of each.
- Broad searches. The import step searches for @sitecore-jss/ rather than one package name, so less common variants like sitecore-jss-react don't slip through. The config step covers both alias and relative imports of temp/config.
- A verification checklist. The workflow ends with one checkbox per step, plus "TypeScript compiles" and "app runs without runtime errors," so the AI and the reviewer can both confirm nothing was skipped.
The workflow also grew as we went. Every time we fixed something by hand, it became a new step or note, so later components got the fix automatically. Components and interfaces, middleware, and the remaining custom code each got their own workflow because each needed different instructions.
Running It
Our process:
- Review Sitecore's upgrade guide so the target is clear.
- Create a fresh Content SDK head from the starter template and confirm it builds.
- Add steering files that describe your team's conventions.
- Copy components over from the JSS head.
- Run the component and interface workflow, then review every change.
- Install, build, fix errors, and repeat until the site compiles.
- Repeat with custom middleware (now called "proxy" in Next.js 16), API routes, and remaining custom code, each with its own workflow.
- Run the site locally and fix runtime errors until it is clean.
Two choices made this work. A fresh starter gave us a known-good baseline, so every later failure was clearly ours to explain. Building after every pass made the build the referee: AI output that reads well can still fail to compile, and a tight loop caught problems while they could be traced to a single change.
What a Green Local Build Did Not Tell Us
Each of these got past a successful local build. Check them before you launch:
- Use Node 24. Content SDK 2.1 requires it, but npm only warns on older versions, and the failures show up later as missing modules. If you use nvm-windows, update it first because older versions can't install Node 24.
- Remove --inspect from NODE_OPTIONS. Turbopack's workers all inherit it and fight over debugger ports, which froze our machine.
- Run bootstrap before generating the component map. Otherwise, the build fails on a fresh clone because the .sitecore folder doesn't exist yet.
- Run a full production build locally. Dev mode only renders the pages you open. Our build failed on an internal test page whose components had no datasource.
- Make outputFileTracingRoot and turbopack.root match. When they didn't, the Vercel build succeeded, but the site's JavaScript never ran. Set both to the head's folder and set that folder as the Root Directory in Vercel.
The Impact: Attention Went Where It Mattered
AI took most of the repetitive refactoring off our plate, but the bigger change was where our time went. The team could spend its effort on custom data plugins, middleware, and the platform issues above, which are the things that put a launch at risk. Because generated changes followed the same conventions, reviews moved quickly and the unusual changes stood out.
Both pieces outlived the migration. The steering files still guide every change to the site, and the workflows carry over to the next JSS migration with minor changes.
Conclusion
AI doesn't remove the need to understand a migration. It rewards teams that do. Write down how your team builds software in steering files, turn the migration into a step-by-step workflow, and treat every generated change as a draft that still needs review. Then prove it in a clean environment, not just on your machine.
Get those pieces right and the AI handles the repetition while your team handles the judgment. You also finish with something you didn't have before: a codebase documented well enough for the next developer, human or AI, to pick up and run with.
Planning a move from JSS to Content SDK and want to see how this approach could apply to your site? Get in touch.

