storefront-critic
by durt4918
README.md
# storefront-critic
**Hostile, stateless visual QA for AI-generated e-commerce storefronts — available as a CLI tool and an MCP server.**
---
## The Problem
AI coding agents can generate a full e-commerce storefront in 2 minutes, **but self-grading suffers from anchoring bias**. When the same agent that wrote the JSX and CSS inspects its own work, it rationalizes broken product images, overlooks mobile horizontal overflow, ignores invisible CTAs, and declares half-finished blank renders "Live."
`storefront-critic` separates **building** from **judging**. It captures real headless Chromium renders across desktop and mobile viewports, extracts deterministic DOM/network failure signals, and hands everything to a **completely stateless Vision LLM** enforcing a hostile zero-base e-commerce rubric.
---
## Architecture
```text
┌──────────────────────────────────────────────┐
Live Storefront URL │ src/capture.ts (Playwright Headless Chrome) │
─────────────────────► │ • desktop_above_fold.png (1440x900) │
│ • desktop_full.png (1440x900 fullPage) │
│ • mobile_above_fold.png (390x844 iPhone) │
│ • Probes: console errors, HTTP >= 400, │
│ horizontal overflow, broken <img>, │
│ blank/uniform viewport detection │
└──────────────────────┬───────────────────────┘
│ PNG buffers + DOM telemetry
▼
┌──────────────────────────────────────────────┐
│ src/critic.ts (Stateless Vision LLM + Zod) │
│ • Providers: Gemini (@google/genai) │
│ OpenAI (openai) │
│ • Starts at 0.0 / 10.0 │
│ • Enforces Hard Fails (4.0/10 score cap) │
│ • Ship Gate: >= 8.5 AND 0 hard fails │
└───────────┬──────────────────────┬───────────┘
│ │
┌─────────────────▼──────┐ ┌──────────▼──────────────────┐
│ src/cli.ts (CLI) │ │ src/mcp.ts (MCP Server) │
│ • report.json (Zod) │ │ • audit_storefront_url() │
│ • report.md │ │ • JSON defect loop for │
│ • 3 PNG screenshots │ │ Claude Code / Cursor / │
│ • CI exit codes │ │ Antigravity │
└────────────────────────┘ └─────────────────────────────┘
```
---
## Hostile Visual Rubric
Every storefront starts at **0.0 / 10.0** and must earn every point.
### Automatic Hard Fails (caps overall score at `4.0 / 10.0`)
- Blank or empty render (`innerText.length < 50` or uniform blank viewport)
- Broken `<img>` elements (`naturalWidth === 0` or broken media)
- Horizontal overflow on mobile (`scrollWidth > innerWidth` at `390x844`)
- Overlapping or clipped text or buttons
- Missing or invisible primary CTA above the fold
- Console errors or 4xx/5xx runtime failures breaking render
### Scoring Categories (`0.0–2.0` pts each = `10.0` max)
1. **Above-the-Fold Clarity & Value Prop**
2. **Visual Hierarchy & Typography Polish**
3. **Mobile Responsiveness & Tap Targets**
4. **Product Imagery & Trust Signals**
5. **CTA Visibility & Conversion Friction**
### Ship Gate
**PASS** only if `overallScore >= 8.5` **AND** `hardFails.length === 0`.
---
## Quickstart
### 1. Install & Configure
```bash
git clone https://github.com/your-org/storefront-critic.git
cd storefront-critic
npm install
npx playwright install chromium
cp .env.example .env
```
Edit `.env` and set **either** `GEMINI_API_KEY` (default: `gemini-3.5-flash-lite`) **or** `OPENAI_API_KEY` (default: `gpt-4o`):
```env
VISION_PROVIDER=gemini
GEMINI_API_KEY=your_gemini_api_key_here
GEMINI_MODEL=gemini-3.5-flash-lite
```
### 2. CLI Usage
Run a full audit against any live URL:
```bash
npx tsx src/cli.ts https://example-storefront.dev --out ./audit
```
Artifacts written to `./audit`:
- `desktop_above_fold.png` (1440x900)
- `desktop_full.png` (1440x900 full page)
- `mobile_above_fold.png` (390x844 iPhone viewport)
- `report.json` (Zod-validated structured JSON)
- `report.md` (human-readable audit summary)
Need to inspect screenshots and DOM probes without spending Vision LLM tokens?
```bash
npx tsx src/cli.ts https://example-storefront.dev --out ./audit --capture-only
```
**CLI Exit Codes:**
- `0` — Storefront **PASSED** the Ship Gate (`overallScore >= 8.5` and `0` hard fails)
- `2` — Audit succeeded, but storefront **FAILED** the Ship Gate
- `1` — Configuration, network, or runtime error
### 3. MCP Server Usage (Automated Self-Repair Loop)
Build the project (or run directly via `npx tsx`):
```bash
npm run build
```
Add `storefront-critic` to your MCP client configuration (Claude Code, Cursor, or Antigravity):
```json
{
"mcpServers": {
"storefront-critic": {
"command": "npx",
"args": ["tsx", "/absolute/path/to/storefront-critic/src/mcp.ts"],
"env": {
"VISION_PROVIDER": "gemini",
"GEMINI_API_KEY": "your_gemini_api_key_here"
}
}
}
}
```
Once connected, your coding agent gains a single tool:
- **`audit_storefront_url(url: string)`** — returns the strict JSON audit report.
Example agent loop prompt:
> *"Run `audit_storefront_url` against `http://localhost:3000`. Fix every `hardFail` and `critical`/`high` ticket in `defectTickets`, re-run `audit_storefront_url`, and repeat until `passedShipGate` is `true`."*
---
## Example JSON Defect Ticket Output
```json
{
"url": "http://localhost:3000",
"auditedAt": "2026-12-03T18:00:00.000Z",
"provider": "gemini",
"model": "gemini-3.5-flash-lite",
"overallScore": 4.0,
"passedShipGate": false,
"hardFails": [
"Broken images detected: 1 visible <img> element(s) failed to load (naturalWidth === 0).",
"Horizontal overflow on mobile: scrollWidth (512px) exceeds viewport (390px) by 122px."
],
"categoryScores": {
"aboveTheFoldClarity": {
"score": 1.4,
"rationale": "Headline communicates the product category, but subhead wraps awkwardly onto 4 lines."
},
"visualHierarchyTypography": {
"score": 1.2,
"rationale": "Consistent sans-serif scale, though card padding is uneven across the 3-column grid."
},
"mobileResponsivenessTapTargets": {
"score": 0.3,
"rationale": "Fixed 480px promo banner forces 122px horizontal scroll on 390px mobile viewport."
},
"productImageryTrustSignals": {
"score": 0.4,
"rationale": "Hero product image fails to load (HTTP 404); no shipping or return guarantee visible."
},
"ctaVisibilityConversionFriction": {
"score": 1.1,
"rationale": "Primary CTA button exists above the fold on desktop, but contrast ratio is weak on mobile."
}
},
"defectTickets": [
{
"severity": "critical",
"viewport": "mobile",
"selectorOrArea": ".promo-banner",
"issue": "Fixed width (480px) causes 122px horizontal overflow on the 390x844 mobile viewport.",
"suggestedFix": "Replace width: 480px with width: 100%; max-width: 480px; box-sizing: border-box."
},
{
"severity": "critical",
"viewport": "both",
"selectorOrArea": "img.hero-product",
"issue": "Primary hero product image returns HTTP 404 and renders with naturalWidth === 0.",
"suggestedFix": "Update src to a valid optimized product asset and set explicit aspect-ratio and alt text."
}
]
}
```
---
## 45-Second Demo Video
> **TODO:** Embed 45-second demo recording showing an AI coding agent failing the Ship Gate (`4.0/10`), reading `defectTickets` via MCP `audit_storefront_url`, repairing the storefront, and passing (`>= 8.5/10`) on the next pass.
>
> ``
---
## Benchmark Table
> **TODO:** Populate with evaluation results across AI-generated storefronts before and after automated MCP self-repair loops.
| Storefront Template / Generator | Initial Score | Initial Hard Fails | Repair Passes | Final Score | Ship Gate |
| --- | :---: | :---: | :---: | :---: | :---: |
| _TBD — Minimalist Apparel Store_ | — | — | — | — | — |
| _TBD — Specialty Coffee DTC_ | — | — | — | — | — |
| _TBD — Consumer Hardware Landing_ | — | — | — | — | — |
| _TBD — Skincare Bundle Funnel_ | — | — | — | — | — |
---
## Project Structure
```text
storefront-critic/
├── src/
│ ├── capture.ts # Playwright multi-viewport capture + DOM/network/blank-render probes
│ ├── critic.ts # Stateless Vision LLM evaluator (Gemini/OpenAI) + Zod rubric enforcement
│ ├── cli.ts # CLI entrypoint -> screenshots, report.json, report.md
│ └── mcp.ts # Minimal MCP server exposing audit_storefront_url(url)
├── .env.example
├── .gitignore
├── LICENSE
├── package.json
└── tsconfig.json
```
---
## License
[MIT](./LICENSE)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues