Skip to content

Commit 056ff8d

Browse files
authored
Merge pull request #78 from woocommerce/26-03/claude-code-plugin
Add AI-Assisted Development docs + Claude Code plugin integration
2 parents 0c070fd + b59c063 commit 056ff8d

File tree

8 files changed

+426
-542
lines changed

8 files changed

+426
-542
lines changed

.cli-help-cache.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/ai/getting-started.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
description: "Install the QIT plugin for Claude Code to get AI-powered test creation, debugging, and quality automation. For other AI assistants, use the QIT documentation index at llms.txt to provide context."
3+
---
4+
5+
# AI-Assisted Development
6+
7+
QIT integrates with AI assistants to help you develop test packages, debug failures, and automate quality workflows.
8+
9+
## Claude Code Plugin (Recommended)
10+
11+
The QIT CLI ships as a **Claude Code plugin**. Once installed, Claude can handle any QIT task autonomously — it fetches live documentation, runs commands, creates test packages, and debugs failures without you needing to provide manual context.
12+
13+
### Install
14+
15+
In Claude Code, run:
16+
17+
```
18+
/plugin marketplace add woocommerce/qit-cli
19+
/plugin install qit@woocommerce-qit
20+
```
21+
22+
That's it. Claude now has QIT expertise. Try asking:
23+
24+
- "Run a security scan on my plugin"
25+
- "Create E2E tests for this extension"
26+
- "My QIT tests are failing, help me debug"
27+
- "Set up qit.json for this project"
28+
- "What test packages are available for cross-compatibility testing?"
29+
30+
### How It Works
31+
32+
The plugin provides a skill that uses **progressive disclosure** from QIT's live documentation:
33+
34+
1. Claude fetches the [documentation index](https://qit.woo.com/docs/llms.txt) to find relevant pages
35+
2. It reads the specific docs needed for your task
36+
3. It acts on what it learned — running commands, writing code, interpreting results
37+
38+
This means Claude always has current information, even as QIT evolves.
39+
40+
### What Claude Can Do
41+
42+
With the QIT plugin, Claude can:
43+
44+
- **Run any QIT test** — managed tests, test packages, or both
45+
- **Create test packages** — follows a [structured methodology](./test-packages/writing-with-agents.md) that includes user research, UI observation, and persona-based test design
46+
- **Debug failures** — read CTRF reports, analyze artifacts, identify root causes
47+
- **Configure projects** — generate `qit.json` with profiles, environments, and groups
48+
- **Manage environments** — start, stop, and interact with Docker test environments
49+
- **Publish packages** — validate and publish test packages to the QIT registry
50+
51+
---
52+
53+
## Other AI Assistants
54+
55+
If you're using GPT-4, GitHub Copilot, or another AI assistant, QIT provides two machine-readable documentation files you can feed to your AI:
56+
57+
- **[llms.txt](https://qit.woo.com/docs/llms.txt)** — Documentation index with descriptions. Feed this to your AI and ask it to fetch the pages relevant to your task.
58+
- **[llms-full.txt](https://qit.woo.com/docs/llms-full.txt)** — Complete documentation in a single file. Use when your AI can accept large context.
59+
60+
These follow the [llmstxt.org](https://llmstxt.org) standard and contain the same documentation that the Claude Code plugin accesses.
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
description: "How to use Playwright MCP browser tools with Claude Code to observe real UI before writing QIT test packages. Covers the observe-first workflow: start a QIT environment, navigate the running site, capture exact selectors from browser snapshots, then write tests from observed reality instead of guesswork."
3+
---
4+
5+
# How to Write Tests with AI Browser Observation
6+
7+
When using Claude Code to write QIT test packages, the **Playwright MCP** tools let Claude observe the real running site before writing any test code. This eliminates guessed selectors, incorrect assumptions about UI layout, and tests that fail because the page doesn't work the way the AI assumed.
8+
9+
## Why This Matters
10+
11+
Without browser observation, AI assistants guess at selectors and page structure based on source code. This leads to:
12+
- Wrong selectors (`#place_order` when the real button is `[name="checkout"]`)
13+
- Missing wait conditions (AJAX-loaded content that isn't there on page load)
14+
- Incorrect flow assumptions (collapsed checkout sections that need expanding first)
15+
16+
With Playwright MCP, Claude sees exactly what a user sees and writes tests against the real page.
17+
18+
## Prerequisites
19+
20+
- [Claude Code](https://code.claude.com) with the QIT plugin installed
21+
- Playwright MCP available in Claude Code (included by default)
22+
- Docker (for running QIT environments)
23+
24+
## The Observe-First Workflow
25+
26+
### 1. Start a QIT environment
27+
28+
```bash
29+
qit env:up --plugin=your-extension
30+
```
31+
32+
This gives you a running WordPress + WooCommerce site with your extension installed.
33+
34+
### 2. Ask Claude to explore the UI
35+
36+
Once the environment is running, ask Claude to navigate the site:
37+
38+
> "Navigate to the admin settings page for my extension and show me what's there."
39+
40+
Claude will use Playwright MCP tools to:
41+
- `browser_navigate` to the site URL
42+
- `browser_snapshot` to capture the page structure (accessible names, roles, form fields)
43+
- Report back what it sees
44+
45+
### 3. Explore the customer-facing experience
46+
47+
> "Now go to the frontend. Add a product to the cart and go to checkout. Show me what shipping options appear."
48+
49+
Claude navigates the storefront, interacts with forms, and captures the exact state of the page at each step.
50+
51+
### 4. Write tests from observed selectors
52+
53+
After exploring, Claude knows:
54+
- The exact accessible names for buttons, fields, and links
55+
- How the page behaves (loading states, AJAX updates, collapsed sections)
56+
- What "working correctly" looks like
57+
58+
It writes Playwright tests using selectors it actually saw, not selectors it guessed.
59+
60+
### 5. Debug failures interactively
61+
62+
When a test fails, instead of guessing what went wrong:
63+
64+
> "Navigate to the checkout page and show me what's there right now. My test expected a shipping rate but failed."
65+
66+
Claude can see the current page state and compare it to what the test expected.
67+
68+
## What Claude Observes
69+
70+
The `browser_snapshot` tool returns an **accessibility tree** — a structured representation of the page that includes:
71+
72+
- Element roles (button, link, textbox, heading)
73+
- Accessible names (the text a screen reader would announce)
74+
- Form field values and states (checked, disabled, expanded)
75+
- Page structure and hierarchy
76+
77+
This is more reliable than CSS selectors because accessible names are stable across themes and minor UI changes.
78+
79+
## Example Interaction
80+
81+
```
82+
You: I need E2E tests for my shipping extension. Start an environment and explore what it does.
83+
84+
Claude: [starts env:up, navigates to admin settings]
85+
I can see your extension adds a "Shipping Zones" tab with these fields:
86+
- "Enable/Disable" checkbox (currently checked)
87+
- "Method Title" text field (value: "Flat Rate Shipping")
88+
- "Cost" number field (value: "10.00")
89+
- "Tax Status" dropdown (options: Taxable, None)
90+
91+
Let me check the frontend...
92+
[navigates to checkout]
93+
At checkout with a product in cart, I see:
94+
- Shipping method "Flat Rate Shipping" at $10.00 is selected
95+
- No other shipping options available
96+
97+
Based on what I observe, here are the high-value tests:
98+
1. Verify shipping rate appears at checkout with correct amount
99+
2. Verify changing the cost in admin reflects at checkout
100+
3. Verify disabling the method hides it from checkout
101+
...
102+
```
103+
104+
## Tips
105+
106+
- **Always explore before writing.** If Claude suggests writing tests without first navigating the site, ask it to observe the real UI first.
107+
- **Check both admin and frontend.** Most extensions have configuration in wp-admin and output on the storefront. Tests should cover both sides.
108+
- **Re-observe after environment changes.** If you reset the database or change settings, have Claude take a fresh snapshot.
109+
- **Use snapshots for debugging.** When a test fails, ask Claude to navigate to the failing page and snapshot it — the accessibility tree often reveals why a selector didn't match.

0 commit comments

Comments
 (0)