WordPress Block Theme Browser Testing Skill for Claude Code

·

,

·

I recently wrapped up a project to convert automattic.com from a WordPress classic theme to a block theme. One of the primary challenges was that the changes needed to be made incrementally without any disruption to the live site. Great care had to be taken to ensure testing was rigorous before I deployed new block theme templates, patterns and parts to a live site that was touched by many people across the company.

As I learned more about Claude Code and the ways in which it could be extended, I realized I could automate this and prevent Claude from declaring a task “done” after a frontend change, without first confirming the result actually looks correct in a browser.

I created a browser-testing skill that:

  • Detects whether any of the changes affect visual output
  • Maps the change to a URL defined in CLAUDE.md
  • Uses Chrome DevTools MCP or Playwright MCP to navigate to the URL and take a snapshot/screenshot
  • Includes the specific flags needed to handle certificate errors when launching either of these tools (necessary as I was using a sandbox for development)
  • Checks the page / post at desktop, tablet and mobile breakpoints
  • Falls back gracefully to generating a manual testing checklist if no browser tools are available

browser-testing Skill

Here’s the content of .claude/skills/browser-testing. It may require tweaking depending on the structure of your particular block theme:
---
name: browser-testing
description: Use when you have finished modifying any template, template part, CSS/SCSS, theme.json styles, or any file that affects visual presentation. Also use when the user asks you to check a page in the browser.
---

# Browser Testing

## Overview

After any change that could affect visual output, you MUST verify the result in the browser before considering the task complete. This is not optional.

## When to Use

**ALWAYS after modifying:**
- Templates (`/templates/*.html`)
- Template parts (`/parts/*.html`)
- CSS/SCSS files (`/includes/assets/css/`, block styles)
- `theme.json` (styles, colors, typography, spacing, layout)
- Block editor JS that affects frontend output
- PHP content filters (`/includes/content-filters.php`, etc.)
- Any file where the change would be visible on the frontend

**NOT needed for:**
- Pure PHP logic with no visual output (e.g., redirects, SEO meta tags)
- Build config changes (webpack, package.json scripts)
- Documentation-only changes

## Procedure

### 1. Identify affected pages

Use the Template-to-URL mapping table in CLAUDE.md to find which URL(s) correspond to the file you changed. If the change affects a shared part (header, footer, sidebar), test multiple pages that use it.

### 2. Check if browser MCP tools are available

Try to use Chrome DevTools or Playwright MCP. If neither is available, skip to the **Manual Testing Fallback** section below.

### 3. Ensure MCP is running with certificate flags

The site requires ignoring certificate errors. If the MCP server isn't already running, start it with the correct flag:
- **Chrome DevTools**: `npx chrome-devtools-mcp@latest --accept-insecure-certs`
- **Playwright**: `npx @playwright/mcp@latest --ignore-https-errors`

### 4. Navigate and take a snapshot

Use Chrome DevTools MCP or Playwright MCP to navigate to the affected URL on `https://automattic.com`.

```
navigate_page → take_snapshot (or take_screenshot)
```

### 5. Check for issues

Verify:
- Layout renders correctly (no broken blocks, missing content, overlapping elements)
- Typography and spacing look intentional
- Colors match the design system
- No console errors related to the change

### 6. Test responsive breakpoints

Resize or emulate at minimum:
- **Desktop** (1200px+)
- **Tablet** (768px)
- **Mobile** (375px)

Take screenshots or snapshots at each breakpoint if the change involves layout.

### 7. Report findings

Tell the user what you checked and whether it looks correct. If something is broken, fix it and re-test before claiming completion.

## Manual Testing Fallback

When browser MCP tools are not available, provide the user with a checklist so they can verify manually:

1. List the specific URL(s) to check (from the CLAUDE.md mapping table)
2. Describe what to look for based on the change you made
3. Note any breakpoints worth checking if the change involves layout
4. Ask the user to report back what they see

Do NOT skip this step — even without automated browser testing, the user must still be prompted to verify visually.

## Common Mistakes

- Skipping browser testing because "it's a small CSS change" — small changes can break layouts
- Only checking desktop — responsive issues are the most common problems
- Checking the wrong page — always consult the URL mapping table
- Forgetting shared parts affect multiple pages — a header change needs testing on more than one template

Template -> Url Mappings

Here’s a markdown snippet of the mapping section:
## Browser Testing

### Template → URL Mappings

| Template | URL(s) | Notes |
|---|---|---|
| `404.html` | Any non-existent URL (e.g. `/this-does-not-exist/`) | |
| `category.html` | `/category/company-news/` | |
| `index.html` | `/` (homepage) | |
| `page.html` | `/benefits/`, `/creed/` | Generic page template |
| `search.html` | `/?s=wordpress` | |
| `single-post.html` | Any published blog post from `/news/` | |

All URLs are relative to `https://automattic.com`.

Possible Future Improvements

  • In order to keep the skill itself generic, I opted to put the template-URL mappings in CLAUDE.MD, but I don’t really like that the skill has this dependency.
  • The browser testing is a bit slow. Perhaps something like agent-browser could help?

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *