Skip to content
← All posts

Tutorial · 22 November 2026 · 6 min read

How to Build a WordPress Website With Claude Code, Step by Step

Build a WordPress site with Claude Code, step by step: local setup, WP-CLI, a CLAUDE.md, a block theme, plugins and testing, with every command included.

By Nagz Studio

Ask a chatbot to "build me a WordPress site" and you get a wall of PHP to paste somewhere. Claude Code is different in one way that matters: it works inside your project. It reads your files, runs commands in your terminal, edits the theme and checks the result, while you approve each step.

That makes Claude Code genuinely useful for building a WordPress website, as long as you set it up the way you'd set up a new developer joining the project: a working local site, clear rules, a brief and a way to check the work. This post walks through the setup we use, step by step.

What you need

  • Claude Code. Anthropic's coding tool, used from the terminal or an editor such as VS Code. It needs a paid Claude plan or an Anthropic API account. Install it with the steps in Anthropic's Claude Code docs.
  • A local WordPress install. XAMPP, Local or any setup where WordPress runs on your machine. Never point an AI tool at a live client site.
  • WP-CLI. WordPress's command-line tool. It's what lets Claude Code create pages, install plugins and change settings without clicking through the admin.
  • Git. So every change can be reviewed and undone.
  • A brief. The pages, the sections on each, the brand colours and fonts, and the plugins the site needs. The better the brief, the less you correct later.

Step 1: Set up a local WordPress site with WP-CLI

Create the site from the terminal, inside your local server's web folder:

wp core download
wp config create --dbname=client_site --dbuser=root --dbpass=""
wp db create
wp core install --url=http://localhost/client-site --title="Client Site" \
  --admin_user=admin --admin_email=you@example.com

Check that WP-CLI can see it with wp option get siteurl. If that prints your local address, Claude Code will be able to work with the site too.

Then start a Git repository for the theme. We keep only the theme (and any custom plugin) in version control, not WordPress core:

cd wp-content/themes
mkdir client-theme && cd client-theme
git init

Step 2: Write a CLAUDE.md with your rules

Claude Code reads a file called CLAUDE.md at the start of every session in that folder. It's where you put the rules you'd otherwise repeat in every message. Ours for a WordPress theme looks like this:

# Client theme

- A block theme: theme.json, templates/, parts/, patterns/. No page builder.
- Prefix every PHP function and handle with clienttheme_.
- Escape all output (esc_html, esc_attr, esc_url) and sanitise all input.
- Follow the WordPress coding standards.
- Never edit WordPress core or plugin files.
- Use WP-CLI for content and settings. Show the command before running anything
  that deletes or overwrites.
- Brand: primary #0F172A, accent #84CC16, headings Inter, body Inter.

Keep it short and specific. "Write good code" does nothing; "escape all output" changes what gets written.

Step 3: Plan before anything is written

Start Claude Code in the theme folder with claude, paste the brief, and ask for a plan, not code: the file list, the templates, the patterns for each section and the plugins. Claude Code has a plan mode for exactly this (Shift+Tab cycles through the modes), where it reads and proposes but doesn't change files.

Read the plan the way you'd read a junior developer's. Is every page in the brief covered? Is it inventing a feature nobody asked for? Correcting a plan takes a minute; correcting a finished theme takes an afternoon.

Step 4: Build the block theme

Once the plan is right, let it build. A block theme is a good fit for this way of working because most of it is plain files with a clear structure:

  • style.css: the theme header (name, version, text domain).
  • theme.json: colours, fonts, spacing and layout widths. Your brand lives here, and the editor picks it up automatically.
  • templates/: index.html, front-page.html, page.html, single.html, 404.html.
  • parts/: header.html and footer.html.
  • patterns/: one PHP file per section, such as the hero, services, testimonials and the contact block.
  • functions.php: only what blocks can't do: enqueueing a script, registering a block style, adding theme support.

Activate it with wp theme activate client-theme and open the site. Ask for one template or pattern at a time and look at each in the browser before moving on. Big batches hide small mistakes.

Step 5: Show it what's wrong

Claude Code can't see your browser. When something looks off, take a screenshot and give it to Claude Code with a specific note: "the hero text overlaps the image below 400px wide", not "fix the hero". It reads images, and a screenshot plus one sentence beats three paragraphs of description.

If you're working from a design file, export each section as an image and give it the image with the measurements that matter. Expect close, not pixel-perfect, and plan to do the last 10% of the polish yourself.

Step 6: Content, menus and plugins with WP-CLI

This is where Claude Code saves the most clicking. Ask it to create the pages from the brief and it will run commands such as:

wp post create --post_type=page --post_title="About" --post_status=publish
wp plugin install contact-form-7 wp-mail-smtp --activate
wp option update blogdescription "Plumbing and heating in Leeds"
wp rewrite structure "/%postname%/"

It can also put the right patterns on each page, so the client sees a real layout with their real text, not lorem ipsum. If the client wrote their copy in Word, DocxToWP brings it in as blocks, with the images, instead of pasting.

Writing the blog posts with Claude Code as well? DocxToWP Pro has a WordPress MCP server: connect Claude Code once, ask for a post, and it arrives on the site as a formatted draft with the Yoast SEO or Rank Math fields, categories, tags and a featured image filled in. The AI can only create drafts, so a person always reviews and publishes.

Read each command before you approve it. WP-CLI is powerful: wp db reset and wp post delete do exactly what they say.

Not sure which plugins to ask for? Our list of 12 free plugins to install on a new WordPress site gives one per job, each linked to its WordPress.org page.

Step 7: Test it like a client will use it

The site looking right in your browser isn't the finish line. Before anyone else sees it:

  • Turn on WP_DEBUG in wp-config.php and click through every page. Fix every notice and warning, then turn it off.
  • Send every form and check the email actually arrives.
  • Check at phone width, tablet and a wide desktop, in at least two browsers.
  • Log in as the client's role, not as admin, and try the edits they'll make.
  • Run the theme through Theme Check or a similar standards check if it might be reused.

You can ask Claude Code to write a test checklist from the brief and work through it with you, which catches the "we promised a newsletter signup" kind of gap. Or start from ours: the WordPress website testing checklist has 62 checks, free to copy.

Step 8: Review the code, then commit

Ask for a summary of what changed, then read the diff yourself with git diff. Look for:

  • output that isn't escaped
  • functions without your prefix
  • hard-coded URLs to your local site
  • anything it added that wasn't in the brief

Commit at the end of each working step, so you can always go back to the last good state.

Where Claude Code still needs you

It's a fast and capable developer that has never met your client. In our experience, it needs you for:

  • Judgment about the client. What they'll actually edit, what they'll break, what they meant in the brief.
  • Design taste. It follows a design well; it doesn't replace a designer.
  • Long sessions. In a very long conversation, early instructions fade. Rules that matter go in CLAUDE.md, and a fresh session per task keeps the context clean.
  • Security and credentials. Never give it production database passwords or SSH keys for a live server. Build locally, review, then deploy the way you always do.
  • Checking its claims. When it says a test passed, look at the output. "It should work" isn't "it works".

After launch

Once the site is on its real domain, run a check from the outside. Our free WordPress launch check tests speed, search basics, broken links, HTTPS, security headers and WordPress settings, and it catches things a local build can't show you, like a staging "discourage search engines" setting that came along to production. Then work through what to set up in week one after launch.

Which step takes you the longest on a WordPress build today: the theme, the content or the testing?