Building a WordPress Theme with an AI Coding Agent
Yes, an AI coding agent can build a complete WordPress block theme, including theme.json, templates, patterns and valid Gutenberg markup.
· 8 min
Can an AI coding agent really build a WordPress theme?
Yes, an AI coding agent can build a complete WordPress theme. And I mean everything: templates, block patterns, a design system in theme.json, custom PHP functions. I know that for certain because I did it myself with Claude Code.
The finished theme ran on my site from March to May 2026. Pagespeed measured 99 to 100 points, with no Elementor or page builder in between.
That answer skips the part that actually counts, though. How do you get there? Whether it works well depends less on the tool. It depends mostly on how you set up the project before you type the first prompt.
If you skip that step, the agent still delivers something, but rarely what you actually wanted. Most of the time it's something you'll have to take apart again in the next session.
Here's what I learned building a complete block theme with an AI coding agent, failed first attempt included. Set up properly means, concretely: a clear folder structure, a short instructions file and a design system, all before a single template exists.
Structure before you prompt
Before you write a single line of theme code, decide on your folder structure. Otherwise you'll end up deciding it later anyway, just in the middle of building and under time pressure. Also decide what goes into the agent's instructions file, CLAUDE.md for Claude Code or the equivalent in your tool.
A theme.json-driven block theme needs a lot of files that work together. That includes templates, patterns, the file with the design tokens, functions.php for custom logic and CSS on top.
If the agent doesn't know beforehand how these pieces fit together, it invents its own structure. And by the second file at the latest, that structure no longer fits. Every new task then brings a new logic with it, because the agent lacks a memory that carries across sessions. In the end you have five different ideas of where a pattern should live, and none of them agrees with the other four.
I keep a planning folder next to the theme, not inside it. That way the agent's notes and plans are still around after launch. You'll read them again later, when you've forgotten why a decision went the way it did. If the folder sat inside the theme itself, it would get shipped along with it at some point, and nobody wants that.
The instructions file stays short, too. A CLAUDE.md under 40 lines that points to focused sub-documents works better than one file that's supposed to hold every naming convention and every design decision at once. The agent reads this file before every task.
Stuff it full and you pay for context that has nothing to do with the task at hand. The agent then loses sight of exactly the rules that would matter right now. I've described in more detail why an overloaded instructions file backfires in Context Engineering: Challenges and Tips.
The design system first: theme.json and tokens
Before the agent touches even one template, the design system goes into theme.json. That's the file where a block theme keeps colors, font sizes, spacing and shadows in one place.
If every value runs through this file, a single change to the token is enough. The change then applies everywhere the token is used. Otherwise you'll be chasing the same value through a dozen files one by one later, each time with the risk of missing a spot.
Give the agent a design direction before it touches theme.json. A few reference images are enough, a few adjectives, whatever gets the point across. Mine was "retro 70s, dark surfaces, accent colors", plus uploaded screenshots.
There was no mockup, and no existing site to copy from either. The agent still needs a starting point. Without any direction at all it invents its own, and that rarely fits the rest of the site.
Token values it comes up with on its own usually end up generic. They land somewhere between default blue and default gray.
Check the result in the browser after every token change, not only once the whole system is in place. That's the only way each step can actually be verified. This habit runs through every section still to come.
Templates and patterns, one at a time
Once the tokens are set, you build one template after another: home page, blog index, single post. Then come any other content types your site needs.
A pattern that shows up in the blog often shows up on the home page too. If it's maintained in one central place, its look changes everywhere at once as soon as you adjust it.
Block themes split this into templates and reusable patterns. If you keep that separation in your prompts as well, every step stays small enough to really check. Otherwise you end up with a tangle of changes you can no longer trace back.
In three weeks of building I didn't once ask for a complete page in a single prompt. Instead I checked one block in the browser, then the next. When two templates don't depend on each other, a capable agent runs both at the same time, several small tasks in parallel instead of one big one. That way each of them stays manageable enough to read through in a few minutes.
The same small-steps discipline is behind the prompting basics I use for every agent task, not just for WordPress. One big prompt is rarely faster than three small ones, it's just harder to check. And checking is exactly the work that actually stays with you.
Leave the Gutenberg block syntax to the agent
Gutenberg block markup has its own syntax. That includes wp:group blocks, spacing presets and nested block comments that have to match exactly. If a comment doesn't match, the editor throws an error, sometimes without a message that makes sense.
You still don't have to learn the syntax beforehand. That saves you from getting into a format that keeps evolving anyway.
I simply described what I wanted to see on the page. Claude Code knew the spec and wrote block markup that matched it exactly. What I had to bring was clarity about the result, not the syntax behind it and not knowing which attribute goes by which name.
You trade writing syntax for checking results. That's why the check has to be sharper than with code you typed yourself. Look at the block in the editor and on the front end.
A block that looks right in one place can still behave wrong in the other, because the editor loads its own styles and the live site loads different ones. With someone else's markup that I don't trust yet, I like to check the result in isolation first. For that I use, for example, a plain HTML preview without a project around it, before anything moves into the real theme.
Where it breaks
The mistake happens when you start prompting before the basics are in place: how the project is organized and how much the instructions file tries to carry. Without that groundwork, the agent delivers a pile of files that have nothing to do with each other, even if each one works on its own.
I know because that's exactly what happened to me. My first attempt failed for exactly this reason. I had copied a structure from a YouTube video, dropped a 400-line instructions file into the repo and started typing, with no design direction beyond "should look good".
The agent kept delivering pieces that didn't fit together: wrong colors, mismatched spacing. On top of that, the names for the same thing changed from session to session, without any one of them being really wrong.
The fix was fewer but better instructions: a file under 40 lines, plus a folder structure that was settled before the first line of code. After that, the same agent worked consistently on the same task across several sessions. Nothing about the technology had changed, only the preparation before it.
The missing structure cost me the entire first attempt. Set up properly, with a fixed folder structure and a short instructions file, it took just an afternoon. The actual building of the theme then stretched across the remaining three weeks of the second attempt.
Skills are the layer that keeps an agent from repeating the same mistake across sessions. If they're still new to you, my field report on Claude Code Skills covers what changed for me because of them.
The proof: what actually came out of it
I built the version above with Claude Code, on WordPress, PHP, Gutenberg and theme.json. I did it on my own, in about three weeks, on the second, this time structured attempt.
The finished result was a design system controlled entirely through theme.json. On top of that came templates and patterns for every content type on the site: for the home page, the blog and single posts, for the photo gallery and for the glossary with alphabetical navigation. Tool pages and use cases got their own templates as well. The theme also contained seven interactive tools, plus custom post types with structured data and sitemap control through functions.php.
The theme ran eric-hinzpeter.de from March to May 2026, independent of Elementor, with a Pagespeed score of 99 to 100. It has since been replaced by the Next.js site you're reading right now, also built with Claude Code.
The reasons had nothing to do with the theme's performance and everything to do with what else was supposed to go on the site.
If you're setting up Claude Code for the first time, my getting-started guide covers installation and the CLAUDE.md problem in more depth than there was room for here.
FAQ
- Can an AI coding agent really build a WordPress theme?
- Yes. I built a complete custom block theme this way, including the design system, all templates and patterns and custom functions, and ran it in production for about three months. The agent wrote almost all of the code, my job was giving direction and reviewing.
- Do I need to know Gutenberg block syntax to do this?
- No. You need to be able to describe what should happen on the page. Claude Code knows the block markup spec and writes valid wp:group blocks with spacing presets on its own. You still check the result in the editor and on the front end, because a block can render cleanly in one place and break in the other.
- What's the biggest mistake when building a theme with an AI agent?
- Most people skip the structure. I describe the exact mistake and the fix in the section "Where it breaks" above. Short version: settle the basics before you start prompting. The agent can't piece together a folder structure and an instructions file it never had after the fact.

Eric Hinzpeter
Eric Hinzpeter, Senior B2B Content Strategist. He builds AI agents and marketing automation for production use and writes up what comes out of it here.