docs: Lighthouse CI on Vercel preview deploys - #4
Merged
Conversation
Genericized writeup for setting up Lighthouse CI on a Next.js app on Vercel, paired with the merkur-frontend pilot (PR #94). Captures the five common gotchas (preview-build race, runner variance, PWA score drag, single-URL coverage, auth/draft pages) and the pilot-week "warn first, tighten later" approach. Lands in docs/ next to roadmap.md so it's discoverable from the contributor side. Closing section frames it as complementary to Henrik's PR #2 (run-Lighthouse-from-task), not in competition: the .lighthouserc.cjs page list is the same list improve-performance would target if pointed at the repo. Requested by Per Andre via #night-shift Slack thread. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The trigger (deployment_status) and the LHCI config are platform-level, not framework-level. Title + intro were narrower than the actual content. Same workflow applies to Astro, Remix, Nuxt, plain static, etc. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Forgot to stage the content edit in the rename commit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
perandre
pushed a commit
that referenced
this pull request
May 28, 2026
New task that reads the real Lighthouse CI artifact (per docs/lighthouse-ci-vercel.md) and opens a PR fixing one concrete measured violation. Complements improve-performance (heuristic, source-read) without replacing it. 1. Pre-flight: skip if open night-shift/lhci-fix PR exists for this scope. 2. Download the latest successful LHCI workflow artifact via `gh run download`. 3. Parse `lhr-*.json` reports for failing audits with concrete `details.items[]` pointing at specific files / resources. 4. Pick the highest-leverage one (mobile beats desktop, earlier key pages beat later, larger measured savings beats smaller). 5. Apply a small fix only — single component / image / config tweak. Exit silently on multi-file refactors. 6. Open a PR titled `night-shift/lhci-fix: <one-line>` with the audit ID, measured value, predicted impact, and verification checklist. - `improve-performance` is agent heuristic — it reads source and finds opportunities. Generic. Default-on. - `act-on-lhci-artifact` is data-driven — it consumes real Lighthouse measurements from preview deploys. Opt-in via `LHCI enabled: yes` in the project's Night Shift Config since not all projects have LHCI set up. - They catch different things and can coexist on the same project without conflict (each has its own slug-based dedup pre-flight). Project's `CLAUDE.md` Night Shift Config: ``` - LHCI enabled: yes - LHCI artifact source: github-actions # default; `vercel-comment` exits silently - LHCI workflow: lighthouseci.yml # filename; defaults to this ``` If `LHCI enabled` isn't `yes`, the task exits silently. Setup for LHCI itself lives in `docs/lighthouse-ci-vercel.md` (PR #4, still open). Slotted at `order: 4.5` (between improve-performance@4 and dep-audit@5) in the `audits` bundle. Same `scope: app`, `mode: pull-request`, `slug: lhci-fix`. Bumps NIGHT_SHIFT_VERSION 2026-05-19b → 2026-05-20a per AGENTS.md. Context for Per Andre: this is the response to "do you want to do a PR on using the Lighthouse CI artifact for Merkur project? Could also be a separate, new task" — went with the separate-task path since the existing improve-performance task is heuristic, not artifact-driven, and folding them would force every project to choose one or the other. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
perandre
pushed a commit
that referenced
this pull request
May 28, 2026
New task that reads the real Lighthouse CI artifact (per docs/lighthouse-ci-vercel.md) and opens a PR fixing one concrete measured violation. Complements improve-performance (heuristic, source-read) without replacing it. 1. Pre-flight: skip if open night-shift/lhci-fix PR exists for this scope. 2. Download the latest successful LHCI workflow artifact via `gh run download`. 3. Parse `lhr-*.json` reports for failing audits with concrete `details.items[]` pointing at specific files / resources. 4. Pick the highest-leverage one (mobile beats desktop, earlier key pages beat later, larger measured savings beats smaller). 5. Apply a small fix only — single component / image / config tweak. Exit silently on multi-file refactors. 6. Open a PR titled `night-shift/lhci-fix: <one-line>` with the audit ID, measured value, predicted impact, and verification checklist. - `improve-performance` is agent heuristic — it reads source and finds opportunities. Generic. Default-on. - `act-on-lhci-artifact` is data-driven — it consumes real Lighthouse measurements from preview deploys. Opt-in via `LHCI enabled: yes` in the project's Night Shift Config since not all projects have LHCI set up. - They catch different things and can coexist on the same project without conflict (each has its own slug-based dedup pre-flight). Project's `CLAUDE.md` Night Shift Config: ``` - LHCI enabled: yes - LHCI artifact source: github-actions # default; `vercel-comment` exits silently - LHCI workflow: lighthouseci.yml # filename; defaults to this ``` If `LHCI enabled` isn't `yes`, the task exits silently. Setup for LHCI itself lives in `docs/lighthouse-ci-vercel.md` (PR #4, still open). Slotted at `order: 4.5` (between improve-performance@4 and dep-audit@5) in the `audits` bundle. Same `scope: app`, `mode: pull-request`, `slug: lhci-fix`. Bumps NIGHT_SHIFT_VERSION 2026-05-19b → 2026-05-20a per AGENTS.md. Context for Per Andre: this is the response to "do you want to do a PR on using the Lighthouse CI artifact for Merkur project? Could also be a separate, new task" — went with the separate-task path since the existing improve-performance task is heuristic, not artifact-driven, and folding them would force every project to choose one or the other. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
docs/lighthouse-ci-vercel.md— a copy-pasteable writeup for setting up Lighthouse CI on Vercel preview deploys. Works with any framework on Vercel (Next.js, Astro, Remix, Nuxt, plain static, etc.) since the trigger is Vercel'sdeployment_statusGitHub event, which is platform-level, not framework-level.Requested in the #night-shift Slack thread (Per Andre: "Do you have a writeup or skill on how to set up Lighthouse CI on a Next project so I can replicate it on my side?").
Replaces the closed PR #3 which was opened from a fork before write access was granted.
What it covers
.lighthouserc.cjs) with inline comments explaining every non-obvious choice.pull_requesttrigger races Vercel's preview build → usedeployment_statusnumberOfRuns: 3+ medianlighthouse:no-pwapreset on day one/only → expliciturlsarraywarn→error, add preset, make a required check.Why a separate doc, not a manifest task
This is infrastructure setup — a one-time per-repo configuration. Once LHCI is running, the audit task PR #2 can consume its signal (or its own fresh runs). The doc explicitly frames itself as complementary to #2, not in competition.
Pilot reference
frontkom/merkur-frontend#94is the working pilot the doc is genericized from.