This is the moment everything else in this course has been building toward: an AI coding agent generating an entire block theme from a description of the site you want, not a single function or hook. It’s also the moment where skipping every guardrail from this course is most tempting, because the output looks impressively complete in seconds. This lesson is a structured workflow that gets you the speed without skipping the review, ending at your local Studio site, never at production.
A local Studio site (Lesson 1), Claude Code or Cursor connected and working inside
that site’s wp-content/themes/ directory (Lesson 2), and the wp-secure-code skill
from Lesson 4 active in the theme’s repo.
Step 1: know what you’re actually asking the agent to produce
A WordPress block theme (built for the Site Editor) is a specific, well-defined file structure, not an open-ended pile of PHP:
my-generated-theme/
├── style.css # Theme header comment, required
├── theme.json # Global styles, color palette, layout settings
├── templates/
│ ├── index.html # Fallback template, required
│ ├── single.html
│ └── page.html
├── parts/
│ ├── header.html
│ └── footer.html
└── patterns/
└── hero-section.php
Knowing this structure matters because it lets you ask for the theme in stages that match how the Site Editor actually reads a theme, rather than one enormous undifferentiated request.
Step 2: turn the plain-English brief into a structured prompt
A vague brief produces a vague, generic theme. Add the specifics an agent actually needs to make real decisions:
Vague:
"Build me a theme for a small bakery."
Structured:
"Generate a WordPress block theme for a small neighborhood bakery called
'Maple & Rye'. Warm, earthy color palette (terracotta, cream, deep brown),
serif display font for headings, sans-serif for body text. Pages needed:
Home (hero image, About teaser, hours, CTA to order), Menu (a list of
items with price, using a reusable pattern), Contact (address, hours,
embedded map placeholder). Use theme.json for the color palette and
typography, don't hardcode colors in template markup. Base the header and
footer as separate template parts so they're editable independently."
The structured version gives the agent a name, a palette, specific pages, and an
explicit instruction about where configuration should live (theme.json, not
inline styles), which is exactly the kind of decision an ungoverned generation tends
to get wrong by scattering hardcoded values through every template instead.
Step 3: generate in stages, not all at once
Staging the generation this way means a bad decision in theme.json (the wrong
palette, a typography choice that doesn’t match the brief) gets caught before it’s
baked into ten templates, instead of after.
// File: theme.json (excerpt, generated in stage 1)
{
"version": 2,
"settings": {
"color": {
"palette": [
{ "slug": "terracotta", "color": "#c1633c", "name": "Terracotta" },
{ "slug": "cream", "color": "#f5efe3", "name": "Cream" },
{ "slug": "deep-brown", "color": "#3a2b22", "name": "Deep brown" }
]
},
"typography": {
"fontFamilies": [
{ "slug": "heading-serif", "fontFamily": "\"Playfair Display\", serif", "name": "Heading serif" },
{ "slug": "body-sans", "fontFamily": "\"Inter\", sans-serif", "name": "Body sans" }
]
}
}
}
Step 4: install and view the generated theme, locally only
Copy or have the agent write the generated theme directly into your local Studio
site’s wp-content/themes/ directory, since that’s the folder you granted it access
to in Lesson 2. Activate it from wp-admin like any other theme, then open the Site
Editor to actually look at what got generated.
# Context: local Studio site path, not a hosted or production site
wp-content/themes/maple-and-rye/
Step 5: this is where the workflow stops, until you’ve reviewed it
Nothing generated here goes anywhere near a production site yet. The next lesson is the actual review checklist, escaping, capability checks, nonce usage, accessibility, that a theme has to pass before you’d consider it done. Treat the local Studio install as the entire scope of “safe full-site generation” for now, deploying is a separate, deliberate, human-triggered action using Studio’s sync feature from Lesson 1, never something folded into the generation step itself.
If a coding agent suggests pushing the generated theme straight to a live site because it “looks done,” decline. A theme that renders correctly in the Site Editor has cleared exactly one bar, it hasn’t been checked for escaping, capability checks, or accessibility yet, all of which the next lesson covers.
Recap
Generating a full block theme from a plain-English brief works best staged,
theme.json and structure first, shared parts second, templates third, patterns
last, with a specific, detail-rich prompt instead of a vague one. Every stage gets
installed and reviewed on your local Studio site, and nothing here authorizes a
deploy to production, that stays a manual, human-triggered step using Studio’s sync
feature, and only after the theme passes the hardening checklist in the next lesson.
Resources & further reading
- Block theme overview, developer.wordpress.org
- theme.json reference, developer.wordpress.org
- Template parts, developer.wordpress.org