DEV Community

Cover image for PixelBreak: I Built a Local-First Tool That Blocks Bad Commits Before They Break Your Frontend
Praveen Kumar
Praveen Kumar

Posted on AI-assisted

PixelBreak: I Built a Local-First Tool That Blocks Bad Commits Before They Break Your Frontend

Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady Submission 🦥

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady

What I Built

PixelBreak is a pre-commit hook + CLI tool that automatically catches responsive layout failures and visual regressions before they land in your repo — without any manual steps, subscriptions, or cloud services.

Every time you git commit, PixelBreak:

  1. Scans your running app at every configured viewport width (375px → 1920px) using a real Chromium browser
  2. Detects horizontal overflow and element clipping with deterministic pixel measurements
  3. Compares screenshots against the previous committed version automatically — no manual baseline setup
  4. Blocks the commit if anything breaks and opens a localhost dashboard showing exactly what changed

Who gets to be lazier: frontend developers who used to manually resize their browser at 5+ widths after every CSS change, or pay for Percy/Chromatic subscriptions. With PixelBreak, you just commit. The tool does the rest.


Demo

PixelBreak Dashboard — BLOCKED with 6 findings across 6 viewports
PixelBreak Dashboard — 6 findings blocked across 375px, 768px, 1024px, 1280px, 1440px, 1920px

PixelBreak visual diff — Baseline vs Current vs Diff overlay
Visual regression finding — Baseline (before), Current (after your change), Diff (changed pixels highlighted)

Since PixelBreak is a local-first tool, here's what a real terminal run looks like:

# Developer changes a CSS variable and tries to commit
git commit -m "style: update primary color"

# PixelBreak fires automatically
🔍 [PixelBreak] Running pre-commit checks...
🚀 Starting scan for project 'my-app'...
   Base URL: http://localhost:4173
   Profile:  responsive
   Widths:   [375, 768, 1024, 1280, 1440, 1920]px
   Git baseline: 1 staged file(s) detected — comparing against HEAD automatically.

📊 Scan Complete: 6 viewports, 8 findings

  🚨 BLOCKED [HIGH] horizontal-overflow @ 375px
     Element: #metrics-card overflows viewport by 857px

  🚨 BLOCKED [HIGH] horizontal-overflow @ 768px
     Element: #metrics-card overflows viewport by 464px

  🚨 BLOCKED [MODERATE] visual-regression @ 1024px
     0.09% pixel diff — 787 pixels changed

❌ Commit Gate: BLOCKED
   Dashboard: http://localhost:3847
Enter fullscreen mode Exit fullscreen mode

Clone and try it yourself:

git clone https://github.com/praveen-pravi6B/pixelbreak
cd pixelbreak && pnpm install && pnpm build
pnpm demo
node apps/runner/dist/cli.js init
node apps/runner/dist/cli.js baseline update
# Change fixtures/broken-demo/src/style.css and commit
Enter fullscreen mode Exit fullscreen mode

Code

GitHub logo praveen-pravi6B / pixelbreak

Local-first frontend regression testing — responsive breakpoint detection, visual diffs, and local AI explanations. Blocks bad commits before they ship.

PixelBreak

Local-first responsive breakpoint detection and visual regression testing — no cloud, no account, no drama.

PixelBreak checks your frontend before every Git commit. It tests only the viewport widths you configure, detects layout failures and visual regressions, shows evidence in a localhost dashboard, and uses a local LLM to explain issues and suggest CSS fixes — without sending your source code or screenshots to any cloud service.


Why PixelBreak?

  • Find where it breaks. Deterministic horizontal-overflow and layout-clipping detection at exactly the breakpoints your app supports.
  • See what changed. Pixel-level screenshot diffs with bounding-box evidence and diff overlays.
  • Understand the cause. A local LLM explains findings and proposes CSS patches — all on your machine.
  • Block bad commits. A severity-gated pre-commit hook stops high and critical regressions before they land.
  • Stay private. Zero telemetry. Zero cloud calls. No API key required.

Core Modules














Module What it does
Breakpoint Detective Configured
…






How I Built It

Open-source AI: llama.cpp running Qwen2.5-Coder-Instruct (GGUF, Q4_K_M quantization) locally on port 8080. No API key, no cloud, no bundled weights.

The AI is the explanation layer — not the detection layer. Detection is fully deterministic:

Detection (no AI involved):

  • @pixelbreak/layout-analyzer — injects JavaScript into Playwright pages to measure scrollWidth > clientWidth and element clipping geometry
  • @pixelbreak/visual-diff — uses pixelmatch to compare screenshots pixel-by-pixel and generate diff PNGs

AI layer (llama.cpp + Qwen2.5-Coder):

  • After deterministic detection blocks a commit, the AI receives: finding summary, measured pixel geometry, relevant computed CSS
  • Returns structured JSON: summary, likely cause, supporting evidence, and a CSS patch proposal
  • All responses are validated with a Zod schema — malformed output is rejected, never silently accepted
  • The model cannot change severity, waive findings, or apply patches. severity: finding.severity is copied from the finding object, never from the AI response.

Git-aware automatic baselines:

The most important UX decision: instead of requiring pixelbreak baseline update before every scan, PixelBreak uses git show HEAD:<file> to automatically get the previous version of staged files as the baseline. You just commit — no manual setup.

Stack:

  • pnpm workspaces monorepo (TypeScript, ESM throughout)
  • Playwright for Chromium automation
  • pixelmatch for pixel comparison
  • Zod for all schema validation
  • Commander.js for CLI
  • React + Vite for the localhost dashboard
  • Node.js built-in http for the dashboard server (no Express)

Why Does Open Innovation Matter?

I could have built this on Percy, Chromatic, or the Applitools API. But every hosted visual regression tool:

  • Sends your screenshots to their servers — a non-starter for internal dashboards, confidential UIs, or enterprise apps
  • Requires a subscription — free tiers run out, pricing changes, vendor disappears
  • Locks you into their severity rules — you file a ticket if you disagree
  • Breaks when you're offline or behind a corporate firewall

Open innovation made this possible in four concrete ways:

1. The AI runs on your hardware. Qwen2.5-Coder-Instruct via llama.cpp — download once, run forever, cost $0. No API key. No data leaving your machine. A team building a hospital admin panel can use PixelBreak without worrying about screenshots of patient data touching a third-party server.

2. You own the severity rules. The policy engine is a configurable YAML file. If your team disagrees with how a 0.08% pixel diff is classified, you change .pixelbreak.yml. No support ticket.

3. You can audit everything. When a security review found 9 vulnerabilities in my own code (command injection, path traversal, prototype pollution via YAML), I could read the exact lines, understand the attack vectors, fix them, and write tests that prove they're fixed. That's not possible with a black-box SaaS.

4. No lock-in by design. The AI adapter speaks the OpenAI-compatible /v1/chat/completions API. Swap llama.cpp for Ollama, LM Studio, or any future local inference server — zero code changes.


My Agent Session

Built with Claude Code across two sessions — foundation phases on a personal machine, AI engine + dashboard + security hardening in this session:

PixelBreak: Building a Local-First Frontend Regression Tool for Hacktoberfest 2026
You

Clone praveen-pravi6B/pixelbreak, add README, check CONTRIBUTORS.md, LICENSE already exists. Check planner file and implementation summary, then plan and execute. Switch to personal GitHub profile first.

Agent

Switched to personal profile. Repo has Phases A-D complete (Foundation, Breakpoint Detective, PixelTruth, Policy Engine). Missing: README, CONTRIBUTING, CONTRIBUTORS, THIRD_PARTY_NOTICES, ai-engine package, dashboard app.

You

Switch to plan mode — full check then tell me.

Agent

Explored the full monorepo with 3 parallel agents.

Missing files: README.md, CONTRIBUTING.md, CONTRIBUTORS.md, THIRD_PARTY_NOTICES.md
Missing packages: packages/ai-engine/, apps/dashboard/
Phases A-D complete: 6 packages, 1 CLI app, 25 tests

Hacktoberfest Week 3 deadline: October 25 2026. Theme: Slow and Steady — open-source AI that rewards laziness/automates tedious tasks.

4-day plan:
- Day 1: Documentation files
- Day 2: Phase E — packages/ai-engine/ (llama.cpp adapter)
- Day 3: Phase F — apps/dashboard/ (React + Vite)
- Day 4: Phase G — docs, verification, DEV post

You

Plan approved — execute.

Agent

Day 1 complete. Starting Phase E — Local AI Engine.

You

Start Phase E.

Agent

Building packages/ai-engine/ — llama.cpp HTTP adapter.

Key design constraints:
- Connects ONLY to local llama.cpp endpoint (http://localhost:8080)
- AI CANNOT change severity, waive findings, update baselines, or apply patches
- All output tagged isHypothesis: true
- Patch proposals are previews — never auto-applied
- If model unavailable: clear error, no silent pass

You

Start Phase F.

Agent

Building apps/dashboard/ (React + Vite) + report persistence + HTTP server.

Architecture:
- report-store.ts: saves ScanReport JSON to .pixelbreak/reports/
- dashboard-server.ts: Node.js http module server port 3847 (no Express)
- React app fetches /api/reports/latest on load

You

Start Phase G.

Agent
You

Try test cases: multiple cases and execute them.

Agent

Running 5 test cases:

Case 1: JS comment change — git baseline detects no visual impact → BLOCKED by pre-existing overflow only (no visual regression reported)

Case 2: CSS color change #6366f1 → #e11d48 — 8 findings: HIGH overflow at 375/768/1024px + MODERATE visual-regression at 5 viewports → BLOCKED

Case 3: Fix overflow (flex-wrap: wrap) — overflow fixed but visual regression HIGH (layout shifted >3%) → still BLOCKED

Case 4: Full fix + intentional layout approval → BYPASS commit, then:

Case 5: Non-visual JS change on fixed app — 0 findings → PASS ✅

Key insight: git-aware baseline correctly distinguishes JS-only changes from CSS/visual changes without any manual baseline update step.

You

Security review — I want this safe before publishing as a package.

Agent

Full security audit found 9 vulnerabilities. Fixed all:

Agent

PixelBreak complete and published to GitHub.

GitHub: https://github.com/praveen-pravi6B/pixelbreak
Tests: 84/84 passing
Security: 9 vulnerabilities fixed (3 CRITICAL, 6 HIGH)
CI: Build + Test + Size Labeler + Security Audit all passing
Branch protection: PRs required, owner bypass enabled
Deadline: October 25 2026


The Lazy Payoff

Before PixelBreak, a developer changing a CSS file would need to:

  1. Open browser dev tools → resize to 375px → does it look right? (memory-based)
  2. Resize to 768px → check again
  3. Resize to 1024px → check again
  4. Resize to 1280px, 1440px, 1920px → check, check, check
  5. Compare visually against "what it looked like before" → impossible from memory

Time per CSS change: 5–10 minutes if done properly. Realistically: skipped 90% of the time.

With PixelBreak: 0 extra minutes. The commit either goes through or it doesn't.

During this week's build, PixelBreak caught:

  • A min-width: 1200px on a flex container that caused 857px overflow at 375px — completely broken on mobile, would have shipped
  • A color variable change creating 787 changed pixels at 1024px — would have passed code review unnoticed
  • A table that overflowed at 375px when the metrics container was fixed — a bug introduced by fixing another bug, caught automatically

Community Wisdom: Visual regression testing for modern web apps by Rizwan Saleem — the hosted tool landscape that shaped the decision to go local-first.

Top comments (0)