Skip to content
developjikPublic

About

Zero-config visual & accessibility evidence for agent-authored PRs — before/after screenshots, pixel diff, and a11y delta without Storybook.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

proofshot

한국어 · English

CI license: MIT npm node >= 20

Before/after screenshots, pixel diffs, and accessibility deltas for pull requests — without Storybook.

Agent-authored PRs move fast and describe themselves in prose. A reviewer still has to answer the only question that matters for a UI change: what does it look like now, and did anything get worse? proofshot answers that with evidence: it builds no stories, needs no account, and turns a PR into a table of changed screens with before/after images, a diff PNG, and the a11y issues the change introduced.

  • Zero setup. Point it at two build directories or two URLs. Routes are inferred from the diff (next-app, next-pages, react-router, Vite/SPA, static HTML).
  • Actual screenshots. Playwright captures every route at desktop and mobile widths, full page.
  • Pixel diff, not vibes. pixelmatch reports the changed-pixel ratio and writes a diff PNG.
  • Accessibility delta. A lightweight DOM checker reports what got worse (missing alt, nameless buttons/links, unlabelled fields, heading jumps, duplicate ids, missing landmarks or lang, new console errors) — before and after, so a regression is named, not guessed.
  • A PR comment you can post as-is. report.md starts with a stable marker so the workflow edits its previous comment instead of piling up new ones.

Why not Storybook + Chromatic?

proofshot Storybook + Chromatic Code-diff review tools (hunk, crit)
Setup point at two builds/URLs; routes inferred from the diff write and maintain stories for every state none
What reviewers see the real app screens for the routes the PR touched hand-written component stories source diff only
A11y before/after issue delta per route, no service addon/axe, separate reporting none
Cost / account MIT, local, no account paid SaaS, per-snapshot billing local
Where results live report.md + artifact, postable as a PR comment hosted visual review UI terminal / PR

The gap it fills: a PR touches a page and a stylesheet, and no story exists for that page. proofshot screenshots what the PR actually changed, with no story to write.

Quick start

Status: early MVP, published on npm. Install as @developjik/proofshot — keep the @developjik scope: the unscoped proofshot on npm is an unrelated third-party package.

# from npm, no clone
npx -y @developjik/proofshot compare --base ../main/dist --head ./dist

# or from a checkout (npm install also builds dist/)
git clone https://github.com/developjik/proofshot && cd proofshot
npm install && node dist/bin/cli.js compare --base ./demo/before --head ./demo/after --routes /,/pricing

Every command below takes the same flags, so prepend whichever entry point you use (npx -y @developjik/proofshot or node dist/bin/cli.js).

# Compare two builds (proofshot serves both directories itself)
proofshot compare --base ../main-dist --head ./dist --out proofshot-out

# Or two running URLs
proofshot compare --base-url http://localhost:3000 --head-url http://localhost:3001

# Only some routes, one viewport, fail the job on any change
proofshot compare --base ./before --head ./after \
  --routes /,/pricing --viewports desktop --fail-on change

# What would it capture for this diff?
proofshot routes --base-ref origin/main --head-ref HEAD

# Add the pull-request workflow
proofshot init

Open proofshot-out/report.md. It looks like this (from examples/report.md, generated by the demo fixtures in demo/):

## 📸 proofshot

**1 changed · 1 unchanged · 0 failed** · **1 a11y regression** — `demo/before` → `demo/after`

| Route | Viewport | Pixel diff | a11y | Console | Status |
| --- | --- | --- | --- | --- | --- |
| `/` | desktop | **2.32%** | ⚠️ +4 | 0 → 1 | 🔴 changed |
| `/pricing` | desktop | **0%** | ✅ 0 | 0 | 🟢 unchanged |

**New issues**
- `img-alt` `section.hero > div.shot-row > img:nth-of-type(1)` — image has no alt attribute
- `button-name` `section.hero > div.actions > button.icon-only` — button has no accessible name
- `heading-order` `main > section.logos > h3` — heading jumps from h1 to h3
- `console-error` `console` — Acme Studio: GET /api/tokens returned 500

Each changed row also gets a before / after / diff image table in the collapsed evidence section. The committed example lives in examples/report.md.

Route inference

No config needed for the common layouts. proofshot routes --files <list> prints exactly what would be captured and why.

Layout Changed file Captured route
Next.js App Router src/app/dashboard/page.tsx /dashboard
Next.js App Router (group / dynamic) src/app/(marketing)/blog/[slug]/page.tsx /blog/[slug]
Next.js Pages Router pages/blog/[slug].tsx /blog/[slug]
React Router src/pages/Pricing.tsx (rendered by <Route path="/pricing">) /pricing
React Router (definition changed) src/App.tsx every route it declares
Vite / SPA src/pages/UserSettings.tsx, src/App.tsx /user-settings, /
Static HTML pricing/index.html /pricing
Stylesheet src/app/globals.css / (list routes in config to widen)

Rules of thumb:

  • app/** is always read as Next.js App Router.
  • src/pages/** is read as React Router when a route renders that component, as Next.js Pages Router when the repo has Next (next.config.*, pages/_app.*, or a next dependency), and as a Vite pages folder otherwise.
  • Tests, stories, docs, lockfiles and build output never produce routes.
  • Dynamic segments stay literal (/blog/[slug]) and are filled from params in the config.

.proofshot.json

Everything is optional; the file only exists to override.

{
  "base": "../main-build/dist",
  "head": "./dist",
  "routes": ["/", "/pricing", "/blog/[slug]"],
  "params": { "slug": "hello-world" },
  "viewports": [
    { "name": "desktop", "width": 1280, "height": 800 },
    { "name": "mobile", "width": 390, "height": 844 }
  ],
  "threshold": 0.1,
  "fullPage": true,
  "settleMs": 400,
  "a11y": true,
  "outDir": "proofshot-out"
}

What the a11y delta checks

A DOM-only checker (no axe dependency, no browser extension):

Rule Reports
img-alt visible <img> / input[type=image] with no alt (decorative alt="" and role=presentation are allowed)
button-name <button> or role=button whose accessible name is empty
link-name <a href> with no text, label, title or image alt
input-label form field with no <label>, aria-label, aria-labelledby or title
heading-order heading level jumping down by more than one (h1 → h3)
duplicate-id an id used more than once
landmark-main no <main> / role=main
html-lang / page-title missing document language or title
console-error new console.error / uncaught exception messages

Issues are keyed by rule + selector + detail, so the delta is exact: new issues are named,

  • fixed* ones are counted. The table shows the net (⚠️ +4, 🎉 −1, ✅ 0), and each capture lists its raw counts (images 1 · buttons 1 · links 0 · fields 0 · headings 1 · console 1).

PR workflow

proofshot init          # writes .github/workflows/proofshot.yml

The generated workflow runs proofshot with npx -y @developjik/proofshot@latest — the scoped package is required (unscoped proofshot on npm is somebody else's package). If you generated .github/workflows/proofshot.yml with proofshot ≤ 0.1.0, regenerate it with proofshot init --force or change the npx line to @developjik/proofshot@latest yourself. The workflow builds the PR head and the base commit (via git worktree), runs proofshot compare --base ../proofshot-base/dist --head ./dist, uploads the evidence folder as an artifact, and posts report.md with:

gh pr comment "$PR" --body-file proofshot-out/report.md --edit-last --create-if-none

so the PR always carries exactly one up-to-date proofshot comment. Adjust the two build output paths and the ROUTES env value for your app.

CLI

proofshot compare --base <dir|url> --head <dir|url> [options]
proofshot routes [--base-ref main] [--head-ref HEAD] [--files a,b] [--json]
proofshot init [--force]
Option Meaning
--base, --head build directory or URL to capture (--base-url / --head-url are aliases)
--routes comma-separated routes; skips inference
--base-ref, --head-ref git range used for route inference (default origin/main...HEAD)
--threshold percent of changed pixels that counts as a change (default 0.1)
--viewports desktop,mobile or phone=390x844 (default desktop + mobile)
--full-page, --no-full-page full-page screenshots (default on)
--settle milliseconds to wait after load before the screenshot (default 400)
--a11y, --no-a11y toggle the accessibility delta (default on)
--fail-on change,a11y,error exit 1 when any of those occurred
--json machine-readable report on stdout
--out output directory (default proofshot-out)

Exit codes: 0 report written · 1 capture failure or --fail-on triggered · 2 usage error.

Using an existing Chromium

Playwright downloads its own browser (npx playwright install chromium). If the environment already has one, point proofshot at it:

PROOFSHOT_CHROMIUM_PATH=/usr/bin/chromium npx -y @developjik/proofshot compare ...

What gets written

proofshot-out/
  report.md              # PR comment / artifact index
  report.json            # same data, machine-readable
  base-<route>-<vp>.png  # before
  head-<route>-<vp>.png  # after
  <route>-<vp>-diff.png  # only when pixels changed

<route> is a readable slug (up to 32 characters) plus a 128-bit prefix of the SHA-256 hash of the normalized route. This keeps / and /root, nested and hyphenated routes, and Unicode routes distinct. Names are stable when route order changes. Consumers should use the image paths in the report rather than reconstructing filenames. Existing screenshots need to be regenerated after this change.

Before/after/diff images are referenced by relative name from report.md, so the artifact is self-contained. GitHub PR comments cannot inline files from an artifact — download the artifact (or commit the folder) when you need to open the images.

How it works

  1. Routes — git diff → inferRoutes (framework heuristics above), or .proofshot.json.
  2. Capture — one Chromium, one context per viewport, every route on both sides; lazy content is scrolled into view, animations disabled, document.fonts.ready awaited.
  3. Diff — pngjs + pixelmatch; differing screenshot heights are padded with the page background and flagged (before 1280×1725 → after 1280×1860).
  4. A11y — DOM snapshot per capture, keyed issue delta between sides.
  5. Report — a summary table plus a collapsed evidence section per changed route.

Runs are sequential per viewport and parallel across the two sides.

Limitations

  • The a11y checker is intentionally small. It catches the problems that UI PRs introduce most often; it is not a WCAG audit (no contrast, focus order, ARIA validity). Pair it with axe for the full rule set.
  • Route inference is static. Dynamic expressions (<Route path={route} ...>), custom routers and monorepo aliases need .proofshot.json routes.
  • Pixel diffs are sensitive to font rendering and OS. Compare like with like (same container, same browser build) — the workflow does this by running both sides on the same runner.
  • A pixel change threshold cannot tell a fix from a regression. proofshot shows the evidence and the a11y delta; a human (or an agent) still judges.
  • Once the two screenshots differ in size, the padded area is white; content that only moved because the page grew is counted as changed.

Development

npm install
npx playwright install chromium
npm run typecheck
npm test                 # 48 unit tests + Real Playwright E2E on demo/before vs demo/after
npm run build
npm run demo             # writes proofshot-out/report.md from the fixtures

The E2E suite drives the real capture/diff/a11y pipeline against demo/ — a home page that changes (new hero, colour, icon-only button, alt-less image, heading jump, console error) and a pricing page that does not. It asserts the changed/unchanged split, each a11y rule, the diff images, and the report.

MIT © Jung Ingwon (developjik)

Optional axe-core checks (DEV-125)

Install axe-core in the project where you run proofshot, then opt in:

npm install --save-dev axe-core
proofshot compare --base dist-before --head dist-after --routes / --a11y axe --fail-on a11y

Axe is off by default and resolved lazily from the working project's dependencies. With no --a11y axe, capture, the lightweight accessibility checker, and report output are unchanged. The axe engine runs locally in the loaded DOM, not on screenshots. New violations fail --fail-on a11y; baseline violations are listed as existing and do not fail again. report.json includes axe.regressions, axe.existing, and axe.fixes with rule id, impact, and selector target paths. The generated PR comment body (report.md) shows the same new/existing split. No comment is posted automatically.

Missing axe-core, injection restrictions, or unsupported pages are explicitly marked skipped, never reported as a clean axe pass. If either side is skipped, no baseline delta is claimed. Incomplete checks are counted as needing manual review. Axe cannot prove full WCAG conformance or all keyboard/focus behavior. Set axe: true in the programmatic runCompare options to enable the same checks. The existing config a11y boolean still selects the lightweight checker, not axe.

When axe is enabled, Markdown is a bounded PR summary (at most 60k characters, up to 20 details per category); the JSON artifact retains every issue. Reports without axe are unchanged. Unavailable child frames mark the audit partial: unmeasured baseline frame issues are not called new, and partial head audits never claim fixes. Frame-local scans omit top-level-only document title/main/heading rules.

Axe delta identity is rule + selector path, including the full ancestor path for ID-less frames. Moving an ID-less frame or changing selectors can appear as fixed/new even if content is unchanged, as with any selector-based baseline. Give stable unique IDs to audited frames or refresh the baseline after intentional layout moves. Unmeasured baseline frame issues are listed as Unclassified rather than silently discarded.

Development baseline (DEV-128)

Use Node.js 22.12.0 (.nvmrc) for development and CI. Vitest 5.1.1 requires Node 22.12+ on its supported release lines; Node 20.19 is outside its declared development support range. It may execute there, but CI does not treat that as supported test-runner usage. This development requirement does not change the package engine declaration. Runtime compatibility must be checked using the built package, separately from the test runner. TypeScript 7.0.2 is the development compiler baseline.

For early Node20 compatibility, build bundles pixelmatch ESM as CJS and includes its original license. Consumer engines are unchanged.

Nested React Router JSX

Static literal JSX routes keep their parent URL: a settings child of /dashboard maps to /dashboard/settings. Index routes without a path use the parent URL (an explicit path is preserved), and pathless layout routes add no segment. Nested absolute paths must start with their parent's path, as React Router requires. Dynamic path expressions, spread route attributes and malformed Route nesting stop inference with advice to set .proofshot.json routes or pass --routes, rather than guessing a child URL without its parent. This uses a Node20-compatible Babel7 JSX parser, not arbitrary JavaScript execution. Object-style route inference retains its existing limited support.

The nested-router browser fixture uses isolated, lockfile-pinned React and React Router test dependencies. Its test runs npm ci --ignore-scripts in that fixture; these packages are not dependencies of the published proofshot CLI.

Interaction scenes

Configure optional scenes to capture modal, error, empty or other UI states after click/fill/press/wait steps. Both revisions run the same steps, each scene has its own a11y delta, and blocked scenes do not stop other captures. Route-only users keep the existing output. See scene setup and safety and the example configuration. Use a disposable test environment: these steps are real UI actions, not a dry run.

Visual + announcement evidence

An opt-in local livesay evidence-pack example uses the existing scene grammar to bind screenshots, DOM checks and simulated announcement changes to one base/head pair. It generates proposed comment Markdown only, with explicit unverified collection states.

Git path inference API

When passing Git's slash-separated paths directly to inferRoutes, use inferRoutes(changed.files, { gitPaths: true }), where changed is the result of changedFiles(...). CLI and compare set this automatically. This avoids interpreting a literal POSIX backslash as a Windows directory separator. Filename decoding supports valid UTF-8 names, not arbitrary non-UTF-8 bytes.

About

Zero-config visual & accessibility evidence for agent-authored PRs — before/after screenshots, pixel diff, and a11y delta without Storybook.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages