Skip to content

build: add puppeteer-based screenshot script#75

Merged
wilsonwangdev merged 1 commit into
mainfrom
build/screenshot-tool
Jun 1, 2026
Merged

build: add puppeteer-based screenshot script#75
wilsonwangdev merged 1 commit into
mainfrom
build/screenshot-tool

Conversation

@wilsonwangdev

Copy link
Copy Markdown
Owner

Summary

Adds build/screenshot.mjs and an npm run screenshot command that captures the local dev server across four viewports and four representative pages — used as a manual review aid for visual changes.

Viewport Size Purpose
x-card 1200×675 @2x X/Twitter share crop
og-image 1200×630 @2x OpenGraph share image
desktop 1440×900 @2x Standard desktop preview
mobile 390×844 @3x iPhone preview

Pages: /en/, /zh/, /en/concepts/harness-engineering/, /en/guides/skills-ecosystem/.

Why

The homepage section order was reverted on 2026-05-14 specifically because the X-card crop showed only the prompt block — without the timeline, the hero gave the wrong first impression. That signal came from a one-off manual screenshot. Codifying it as a script means the next visual change can run the same check in one command.

This complements rules/design-intent.md (PR #74) — the rule states the intent, this script gives reviewers a concrete way to verify it.

Implementation choices

  • puppeteer-core + system Chrome instead of full puppeteer. The full package downloads ~150 MB of bundled Chromium on every install; puppeteer-core reuses the user's installed Chrome / Chromium. Falls back to CHROME_PATH env var if auto-detection fails.
  • Output to assets/screenshots/, gitignored. Screenshots are a local-only review artifact, not committed.
  • Caret-pinned dep version matches the existing husky style in package.json.

Tested

  • npm install succeeds; package-lock.json updated for puppeteer-core transitive deps (lockfile diff is large but is entirely puppeteer's dependency closure — no typosquatting candidates spotted).
  • npm run screenshot runs against a local npm run dev instance and produces 16 PNGs under assets/screenshots/.
  • Script exits cleanly; no Chromium processes left orphaned.

Notes for reviewer

  • The lockfile diff (~1000 lines) is unavoidable for this kind of dep addition. All adds are in node_modules/puppeteer-core/** and its declared dependencies.
  • .claude/worktrees/ is intentionally not added to .gitignore here — that's agent-runtime state, better handled in a global gitignore.

Adds build/screenshot.mjs and an 'npm run screenshot' command that
captures the local dev server (http://localhost:3000) at four
viewports — X/Twitter card (1200x675), OpenGraph image (1200x630),
desktop (1440x900), mobile (390x844) — across the homepage (EN/ZH)
and two representative content pages.

Uses puppeteer-core with the system Chrome/Chromium binary so we
don't pull in the ~150 MB bundled Chromium download. Falls back to
CHROME_PATH env var.

Output goes to assets/screenshots/ (gitignored). The script is a
review aid — it underwrites the social-card-crop check referenced
in rules/design-intent.md (homepage section order was reverted on
2026-05-14 after this exact crop revealed the problem).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-master-handbook Ready Ready Preview, Comment Jun 1, 2026 3:55pm

@wilsonwangdev wilsonwangdev merged commit 1395454 into main Jun 1, 2026
3 checks passed
@wilsonwangdev wilsonwangdev deleted the build/screenshot-tool branch June 1, 2026 16:03
wilsonwangdev added a commit that referenced this pull request Jun 1, 2026
) (#77)

## Summary

Archives a 2026-05-08 investigation that had been sitting uncommitted in
a feature worktree until today, and closes the loop with the fix that
just shipped.


[journal/2026-05-08-wide-viewport-whitespace.md](journal/2026-05-08-wide-viewport-whitespace.md)
records:
- **What happened** — capturing 1280×720 social-launch screenshots
revealed ~35% horizontal whitespace because the site had exactly one
breakpoint (`max-width: 640px`) and a fixed `--max-w: 52rem`
- **Root cause** — review processes (Lighthouse,
frontend-interaction-review skill) optimized for correctness, not visual
density at wide viewports
- **Resolution** — closed by #76, which added `@media (min-width:
1100px)` widening `--max-w` to `64rem`. The two alternative options
(2-col layout, decorative frame) were rejected because they conflict
with `rules/design-intent.md` §5 (wide viewports widen content, not
whitespace or chrome)
- **Prevention** — ROADMAP item to add a viewport-density check to the
frontend-interaction-review skill's next revision

[ROADMAP.md](ROADMAP.md) gains three matching `[x]` rows in **Now** for
#74 / #75 / #76.

[.gitignore](.gitignore) adds `assets/social/` — launch screenshots are
local promotional artifacts. The first batch (May 8) is staying on disk
but won't be committed.

## Why this matters

The journal entry is exactly the "failures captured for agent
self-evolution" use case in CLAUDE.md. Without committing it, the
institutional memory of *why* PR #76 added that specific breakpoint at
1100px (and not, say, 1280px or 1440px) would have been lost. This PR
makes the chain `1280px screenshot reveals issue → root cause → option
list → chosen fix → rule §5` discoverable from a single file.

## Tested

Lint-only / docs-only changes. No build impact.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant