DEV Community

VibeFoundry
VibeFoundry

Posted on Edited on

How to Catch Broken Mobile Layouts, Silent 500 API Errors, and AI UI Slop in React, Next.js & Vite Apps

Passing npm run build and tsc --noEmit only proves your TypeScript syntax compiled. When an AI coding agent builds a frontend feature, the bugs that actually break production happen at runtime in the browser, in the CSS cascade, and in exposed API routes.

To give both human developers and coding agents (Claude Code, Cursor, Windsurf, Copilot) a deterministic verification loop, I built three open-source TypeScript CLI and MCP tools that run locally in seconds.


Step 1: Catch Runtime Browser Failures Across 3 Viewports with ghost-qa

When you run:

npx -y ghost-qa test http://localhost:3000
Enter fullscreen mode Exit fullscreen mode

ghost-qa (https://github.com/avivgerz-hue/ghost-qa) launches headless Playwright against your live dev server (localhost:3000 or localhost:5173), crawls your routes across Desktop (1440x900), Tablet (768x1024), and Mobile (375x812), and inspects 8 runtime traps:

  1. Console & Uncaught Page Exceptions: Hydration mismatches, undefined property reads, and runtime crashes that never show up in tsc.
  2. Failed Network & API Requests: Silent 4xx / 5xx fetches, CORS failures, and broken asset URLs.
  3. Layout & Spatial Collisions: Horizontal mobile overflow, overlapping sibling elements, clipped text, and interactive buttons smaller than the 44x44px touch target minimum.
  4. Accessibility & Keyboard Tab-Order: Missing accessible names, broken ARIA roles, and dead focus traps.
  5. Performance & Core Web Vitals: DOM bloat, render-blocking assets, and slow page timings.
  6. Link Integrity: Dead internal routes and broken anchors.
  7. SEO & Social Graph Completeness: Missing canonical tags, titles, or OpenGraph metadata.
  8. Dark / Light Theme Parity: Unstyled elements when toggling color schemes.

It outputs a QA Health Score (0–100, A+ to F) plus a self-contained interactive report.html with viewport screenshots and a ghost_qa_compare baseline diff tool.


Step 2: Audit 72 UI & CSS Design Craft Rules with unslop

Even when a page renders without crashing, AI agents default to recognizable "AI UI slop": low-contrast gray text on dark cards, 5 competing font sizes in one card, arbitrary spacing values, and generic purple-to-blue gradients.

When you run:

npx -y unslop-mcp audit .
Enter fullscreen mode Exit fullscreen mode

unslop (https://github.com/avivgerz-hue/unslop) statically analyzes your JSX/TSX, HTML, Vue, Svelte, CSS, and Tailwind files across 72 rules and 7 design pillars:

  • Color & Atmospheric Polarity: Computes true WCAG 2.1 AA/AAA and APCA perceptual contrast math across your foreground/background token pairs.
  • Typography & Scannable Hierarchy: Flags competing font scales, missing line-length caps (max-w-prose), and uncalibrated tracking.
  • Layout & Spatial Architecture: Enforces consistent grid rhythm and spacing tokens.
  • Surface & Elevation, Copy, Motion & Token Architecture: Replaces generic AI defaults with 10 curated studio design archetypes (swiss-editorial, linear-precision, anthropic-warm-editorial, neo-brutalist, and more) and generates a prioritized UNSLOP-REPORT.md refactor blueprint.

Step 3: Scan 92 Security & Agent-Poisoning Rules with vibe-shield

Finally, before pushing your branch:

npx -y @vibefoundry/vibe-shield@latest scan .
Enter fullscreen mode Exit fullscreen mode

vibe-shield (https://github.com/avivgerz-hue/vibe-shield) runs 92 static security rules (80 application code rules + 12 MCP/Agent Skill poisoning rules) mapped to OWASP Top 10:2025 and CWE:

  • Catches SUPABASE_SERVICE_ROLE_KEY and private secrets imported into "use client" bundles.
  • Flags unauthenticated Next.js API routes, Server Actions, and Stripe checkout endpoints.
  • Detects SQL migrations that enable RLS with permissive USING (true) policies.
  • Audits third-party SKILL.md, .cursorrules, and .mcp.json files for hidden Unicode prompt injection and credential exfiltration.

Connect All Three to Your Coding Agent in One Command

Each tool includes an init command (npx -y @vibefoundry/vibe-shield@latest init, npx -y ghost-qa init, npx -y unslop-mcp init) that automatically wires up MCP configs and SKILL.md rules for Claude Code, Cursor, Windsurf, Copilot, Cline, Roo, OpenCode, and Zed:

Give them a run on your current project—and if they catch something useful, a star on GitHub is hugely appreciated!

Top comments (1)

Collapse
 
mp3sss31 profile image
mp3sss •

The gap between tsc --noEmit and what breaks production is real: type checking can't see a hydration mismatch, a silently failing fetch, or an element that only overflows at 375px. Running headless Playwright across fixed desktop/tablet/mobile viewports and checking console exceptions, failed requests, and spatial collisions catches the class of bugs a build never will, and treating these as deterministic gates in CI keeps an agent-generated UI from slipping through on visuals alone. The touch-target and ARIA/tab-order traps are worth keeping in the set too; AI-generated interfaces frequently ship usable-looking layouts that fail keyboard or screen-reader use. The same loop applies to Electron renderers: automated sweeps over window resizes and device-scale factors surface overflow and runtime renderer errors that compile-time checks miss.