Skip to content

feat(tasks): add act-on-lhci-artifact (data-driven perf companion)#19

Open
havardljohansen wants to merge 1 commit into
mainfrom
feat/lhci-artifact-driven-task
Open

feat(tasks): add act-on-lhci-artifact (data-driven perf companion)#19
havardljohansen wants to merge 1 commit into
mainfrom
feat/lhci-artifact-driven-task

Conversation

@havardljohansen
Copy link
Copy Markdown
Contributor

Summary

Response to your Slack question — "do you want to do a PR on using the Lighthouse CI artifact for Merkur project? Could also be a separate, new task, rather than merging into another". Went with separate task: the existing improve-performance is heuristic (agent reads source), this one is data-driven (real Lighthouse measurements). Folding them would force every project to pick one mode or the other.

What lands

  • tasks/act-on-lhci-artifact.md — new task. Reads the latest LHCI workflow artifact via gh run download, parses lhr-*.json, picks one concrete failing audit (LCP > budget, CLS > 0.1, render-blocking, unused-JS > 50 KB, etc.) with a knowable root cause from details.items[], opens a small PR with a targeted fix.
  • manifest.yml — slotted at order: 4.5 (between improve-performance and dep-audit) in the audits bundle. scope: app, mode: pull-request, slug: lhci-fix.
  • skills/night-shift/SKILL.md — version bump 2026-05-19b → 2026-05-20a per AGENTS.md rule.

Why opt-in, not default-on

The task gates on 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 → exit silently. Setup for LHCI itself stays in docs/lighthouse-ci-vercel.md (your PR #4, still open) — this task assumes that's already done.

How it relates to existing tasks

improve-performance act-on-lhci-artifact (new)
Evidence Source code Real Lighthouse measurements
Default On (for all projects) Off (opt-in via LHCI enabled)
Catches Structural (N+1, bundles, blocking I/O) Measured (LCP element, CLS shift, third-party blocking)
Slug perf lhci-fix
Dedup Own slug pre-flight Own slug pre-flight (no conflict)

Both can run on the same project without stacking — each has its own slug-based pre-flight.

Both rules from #18 applied to the new task spec

  • English-only PR title/body/commit messages. Doc-language stays in user-facing text the fix touches (alt text, meta descriptions, etc.).
  • Pre-flight dedup: gh pr list --search "night-shift/lhci-fix in:title" --state open → exit silently if one exists.

Test plan

  • Wire up LHCI enabled: yes in merkur-frontend's CLAUDE.md Night Shift Config
  • Trigger a Night Shift run; confirm task either acts on a measured violation or exits silently with reason logged
  • If PR opens: the audit ID + measured value + predicted impact in the body should match the actual artifact
  • LHCI re-run on the PR's preview deploy confirms the audit passes

Refs

🤖 Generated with Claude Code

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.

## What it does

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.

## Why a new task instead of folding into improve-performance

- `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).

## Config gating

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).

## Manifest

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`.

## Version

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) <[email protected]>
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