How we migrated a WordPress site to Astro with an AI agent (and kept it editable)
Codeso sells tiles, stone and bathroom fittings in Romania. Their site, codeso.ro, ran on WordPress: the Astra theme, a page builder, and ten plugins loading on the homepage. One of those plugins, call-now-button, existe
Codeso sells tiles, stone and bathroom fittings in Romania. Their site, codeso.ro, ran on WordPress: the Astra theme, a page builder, and ten plugins loading on the homepage. One of those plugins, call-now-button, existed to show a phone button. That's it.
astra ยท nicepage ยท astra-addon ยท call-now-button ยท gdpr-cookie-compliance
gtranslate ยท simple-tags ยท tag-groups ยท ultimate-addons-for-gutenberg ยท wp-whatsapp-chat
The site worked. It was slow, and every small change seemed to need one more plugin, but it worked, and the people running the shop knew how to edit it. That last part is what makes these migrations hard. Getting an agent to rebuild a site in Astro is pretty easy now. Getting a site that the owner can still change next month, without calling a developer, is not.
We build Brim.js to solve exactly that, so this is partly a story about our own framework. But most of what we learned applies to any migration where the content has to stay editable.
Start with a boring list
Before touching code, we went through the old site and wrote down three things: which pages exist, which content repeats, and what the owner actually changes.
For Codeso the answer was a handful of one-off pages (home, about, contact), a catalogue of more than 1,400 products in 12 categories, 19 finished projects, a few articles, and a pile of PDF catalogues from manufacturers.
That list ended up deciding almost everything. Anything that repeats becomes a content type. Anything one-off becomes a page with editable text. If you skip the list and let the agent "just migrate the site", you get 1,400 hand-written product pages, and nobody wants to maintain those.
Code in git, content in a database
The second decision was where everything lives. Layout, CSS and components go in the code, in git. Texts, photos and products go in a database.
It sounds obvious, but it's the thing that keeps the site maintainable. The agent (or you) can write whatever design you want, with no page builder in the way. And the owner can change a price or a headline without a deploy, and without any way to break the layout.
Setting up
Four commands:
npm create @brimsites/brim@latest codeso
cd codeso && npm install
npx brim user add [email protected] # the account that edits the site
npm run dev
That gives you an Astro project with an editor at /admin/edit, and an AGENTS.md file that tells a coding agent how the project works. That file turned out to matter a lot more than we expected.
What "editable" means in practice
In Brim.js, any text or image the owner should be able to change is a component with a stable ID:
---
import { Text } from "@brimsites/brimjs/components";
---
<Text nodeId="trends-title" as="h2" class="trends__title">
Trends 2027
</Text>
The text in the code is just the default. When the owner edits it on the page, their version is saved in the database under trends-title, and the source file stays as it is. The catch is that the ID can never change. Rename it and the owner's edit is gone, which is why it's one of the first rules in AGENTS.md.
Letting Claude Code do the migration
We opened Claude Code in the project and started with something like this:
Migrate codeso.ro into this project: the same pages and products, a cleaner
design. Every text, image and button editable. Products as a content type.
It read AGENTS.md first, then went through the old site. The products became a content type, basically a list of fields, and the owner gets a form for each product. The real one ended up with 25 fields (finishes, sizes, manufacturer, PDF links and so on). Here's the core of it, with the field names translated from Romanian:
export const product = defineContentType({
key: "product",
path: "/products/[category]/[slug]",
fields: [
{ name: "category", vocabulary: "category", required: true },
{ name: "description", type: "textarea" },
{ name: "image", type: "image" },
{ name: "maker", type: "text" },
{ name: "sizes", type: "text" },
],
});
The fixed pages were rebuilt as Astro components, with every heading, paragraph and button wrapped in an editable component.
The content itself didn't go into git. The agent wrote a scraper for the old site and an import script that pushes everything through the site's API. Each item is created as private, gets its photos, and is published only at the end, so a half-imported product never shows up on the live site:
def ensure(type_, slug, title, data):
it = existing[type_].get(slug)
if not it:
it = call("POST", "/items", {"type": type_, "title": title, "slug": slug,
"visibility": "private", "data": data})["item"]
return it
def finish(it, title, data):
return call("PUT", "/items", {"id": it["id"], "title": title, "slug": it["slug"],
"visibility": "published", "data": data})["item"]
We did get this wrong once. Early on, the seed photos ended up committed to the repo, and it grew past a gigabyte before anyone noticed. Keep photos and catalogues out of git from day one. It's much easier than cleaning up the history later.
It also wasn't one prompt. It took several sessions of comparing pages side by side, fixing categories and re-running the import. The import script was written so you can run it again safely, and we ran it a lot. When it was done, npx brim check came back with no errors, and the site had over 1,400 product pages.
What the owner sees
The owner signs in and the page turns into the editor. They click a headline and type, swap a photo, or add a product through its form, and it gets its own page straight away.
What they can't do is move the grid or change the font. That's on purpose. The content is theirs, the design stays in the code, and that's exactly why it doesn't fall apart six months later.
Letting an AI assistant edit the content
Every Brim.js site also has an MCP endpoint at /admin/mcp. MCP is the standard way AI assistants call tools. The owner connects Claude or ChatGPT, signs in, and can ask for things like "change the headline" or "write an article about the new collection, in Romanian and English". It uses the same tools as the editor, so it can change content but never the code.
Deploying
We asked the agent to deploy it. It installed the hosting CLI, we logged in once, and it deployed. If you'd rather host it yourself, anything that runs Node works: npm run build, then npm start. The deploy docs cover both.
If you're about to do this
- Make the list first. It tells you what your content types are.
- Keep content out of git from day one, especially images.
- Give the agent written rules (
AGENTS.mdor similar), and plan for a few rounds, not one prompt. - Let the owner try the editor before launch, not after.
Try it
The docs and the starter prompt are at brimjs.org. Brim.js is new, and we're a small team. If you try it, tell us in Discussions what broke or what's missing. That's genuinely what decides what we work on next.
Originally posted on the Brim.js blog, where the post is itself an editable page.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes โ full credit and traffic to the original publisher.