# π» ghost-qa **Autonomous headless browser QA & self-healing verification loop for coding agents.** `v2.1.1` β the 8-Trap Deep Browser Inspection Engine: 3 viewports Γ light/dark, QA Health Score (A+β¦F), interactive HTML dashboard, and regression diffing. [](https://github.com/avivgerz-hue/ghost-qa/actions/workflows/ci.yml) [](https://www.npmjs.com/package/ghost-qa) [](https://www.npmjs.com/package/ghost-qa) [](./LICENSE) [](https://nodejs.org) [](https://playwright.dev) > β **If this tool helps your AI coding workflow, please give this repository a Star!** It helps more developers discover the project. ### π§° The VibeFoundry Agent Suite *One command each β star all three and keep the whole suite free & maintained:* - π¨ **[unslop](https://github.com/avivgerz-hue/unslop)** β UI Design DNA & Anti-Slop Engine (`npx -y unslop-mcp@latest init`) - π‘οΈ **[vibe-shield](https://github.com/avivgerz-hue/vibe-shield)** β Security Scanner for AI Code (`npx -y @vibefoundry/vibe-shield@latest scan .`) - π» **[ghost-qa](https://github.com/avivgerz-hue/ghost-qa)** β Autonomous Headless Browser QA (`npx -y ghost-qa@latest test http://localhost:3000`)  ```bash npx -y ghost-qa@latest test http://localhost:3000 ```  Coding agents (Claude Code, Codex, Cursor, Windsurf) write code **blind** β then declare victory while the actual browser has React hydration errors, broken buttons, 500ing APIs, or mobile layout overflow. `ghost-qa` fixes that. One command launches a headless browser against your running app, crawls the live DOM, safely pokes every button, traps runtime/network/layout failures, and hands the agent a structured **Self-Healing Bug Report** so it fixes its own bugs *before* telling you it's done. ```bash npx -y ghost-qa test http://localhost:3000 ``` No test scripts. No config. No mercy for "it works on my machine". > Prefer running straight from GitHub instead of npm? `npx -y github:avivgerz-hue/ghost-qa test http://localhost:3000` works identically β every command in this README accepts either package source (`ghost-qa mcp`, `ghost-qa init`, β¦). --- ## β‘ Quickstart ```bash # 1. Start your app as usual npm run dev # β http://localhost:3000 # 2. Verify it in a real browser (one-time: downloads Chromium) npx playwright install chromium npx -y ghost-qa test http://localhost:3000 # 3. Teach your coding agent to do this automatically, forever npx -y ghost-qa init ``` `ghost-qa init` installs `.claude/skills/ghost-qa/SKILL.md` and appends the strict **"Verify in Browser Before Done"** protocol to `CLAUDE.md`, `AGENTS.md`, and `.cursorrules`. From then on, your agent runs ghost-qa itself, fixes what it finds, and only reports completion on a PASS. --- ## π The Autonomous Self-Healing QA Loop ``` ββββββββββββββββββββββββββββββββββββββββββββ β CODING AGENT β β Claude Code Β· Codex Β· Cursor Β· Windsurf β βββββ¬βββββββββββββββββββββββββββββββ²ββββββββ writes code β β Self-Healing βΌ β Bug Report βββββββββββββββββ βββββββββββ΄βββββββββββ β DEV SERVER β β AGENT DIAGNOSTIC β β localhost:3000 β β verdict Β· #ids Β· β βββββββββ¬ββββββββ β fix playbook β β serves live DOM βββββββββββ²βββββββββββ βΌ β Markdown / JSON ββββββββββββββββββββββββββββββββββββββββββ΄βββββββββββ β π» ghost-qa β β β β Route Crawler βββΊ Interaction Runner β β β β β β βΌ βΌ β β βββββββββββ ββββββββββββ βββββββββββ β β β CONSOLE β β NETWORK β β LAYOUT β β β β A11Y β β PERF β β 8 TRAPS β β β β TRAP β β TRAP β β TRAP β β β βββββββββββ ββββββββββββ βββββββββββ β β Desktop 1440Γ900 Β· Tablet 768Γ1024 Β· Mobile 375Γ812 β ββββββββββββββββββββββββββββββββββββββββββββββββββββββ β fix bugs ββββββββ re-run until β PASS ``` 1. The agent writes code and starts the dev server. 2. `ghost-qa test` crawls every internal route on **Desktop 1440Γ900, Tablet 768Γ1024 and Mobile 375Γ812**, in **light + dark** colour schemes, exercising interactive controls. 3. Eight traps capture everything the browser actually experienced, scored into a deterministic **QA Health Score (0β100, Grade A+β¦F)**. 4. Failures return as a token-efficient diagnostic (`GHOST-QA-REPORT.md` + `PATCH-PROMPT.md` with exact selectors); the agent fixes root causes and re-runs. 5. `ghost-qa compare before.json after.json` proves the fix: the loop ends only at **score 95β100 (A+)**, zero critical/major remaining, and **zero new regressions**. --- ## πͺ€ The 8-Trap Deep Browser Inspection Engine *(v2.0.0)* ### 1. Console & Framework Runtime Trap β `src/traps/console-trap.ts` - Uncaught `pageerror` exceptions with stack traces - Unhandled promise rejections - **React hydration mismatches** ("Text content did not match", "A tree hydrated butβ¦") - **Duplicate-key warnings** and **Content-Security-Policy violations** *(new in v2)* - `console.error` (major) and `console.warning` (minor) β with dev-server noise (`[vite]`, HMR, React DevTools banners) filtered out ### 2. Network & Asset Integrity Trap β `src/traps/network-trap.ts` - HTTP `5xx` API crashes (critical) and `4xx` responses (major) - Failed `fetch`/`XHR` requests, **timed-out requests**, and connection failures - **CORS-blocked requests and failed CORS preflights** with remediation guidance - Broken static assets, broken images (`naturalWidth === 0`), **broken inline SVGs (0Γ0)**, **>500KB unoptimized payloads**, and missing favicons (minor) ### 3. Layout, Responsive Geometry & Collision Trap β `src/traps/layout-trap.ts` - **Horizontal overflow**: `scrollWidth > innerWidth`, with the offending elements named (critical on mobile) - **Overlapping interactive elements** via bounding-box collision math, with exact selectors + boxes *(new in v2)* - **Touch targets < 44Γ44px** on touch viewports (WCAG 2.5.5 / Apple HIG), **clipped text**, and **off-screen interactives** *(new in v2)* - Zero-dimension interactive elements β buttons rendered at 0Γ0 that no human could tap - Missing `` on mobile ### 4. Accessibility (WCAG 2.1 AA) & Keyboard Focus Trap β `src/traps/a11y-trap.ts` - Buttons and links with **no accessible name** (icon-only controls screen readers can't identify) - Images **missing `alt`** attributes (descriptive alt, or `alt=""` for decorative) - Form inputs with **no associated label** β a placeholder is not a label - **Real computed contrast ratios** (`getComputedStyle` foreground vs effective background, WCAG formula) *(new in v2)* - **Heading hierarchy** (missing `