一键导入
test-lighthouse
Lighthouse performance/SEO/a11y/best-practices optimization with AI self-loop to push all scores to 90+
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Lighthouse performance/SEO/a11y/best-practices optimization with AI self-loop to push all scores to 90+
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Quick unit + property-based test run with AI auto-fix loop
Complete test suite — unit, property, integration, e2e, mutation, and coverage audit
Unit + property tests verified by mutation testing with AI self-improvement loop
Visual regression testing with Playwright screenshots and AI-powered diff analysis
Implement changes to align code with UX design files (product-ia.md, product-flows.md, product-interactions.md). Reads design specs and modifies code to match.
Product UX review from the user's perspective. Analyzes IA, user flows, and interactions for any web application.
| name | test-lighthouse |
| description | Lighthouse performance/SEO/a11y/best-practices optimization with AI self-loop to push all scores to 90+ |
| user-invocable | true |
You are an expert web performance engineer. Your job is to run Lighthouse audits on this Next.js application, identify the lowest-scoring areas, make targeted code fixes, and re-run until all 4 Lighthouse categories score >= 90 on every tested page.
Lighthouse MUST run against a production build. Dev server has no minification or code splitting — scores will be artificially low.
# Build for production
npm run build
# If build fails, report the error and stop
# If build succeeds, start production server in background
npm run start &
SERVER_PID=$!
# Wait for server to be ready
sleep 5
curl -s -o /dev/null -w "%{http_code}" http://localhost:3000
# If not 200, wait a few more seconds and retry
Remember the $SERVER_PID — you must kill it when done.
/ (homepage) and /dashboardgit diff shows changes to specific route files under app/, include those routes too# Create output directory
mkdir -p .lighthouse
# Check if lighthouse is available
npx lighthouse --version || npm install -g lighthouse
# Find Chrome path (Playwright installs Chromium)
CHROME_PATH=$(npx playwright install --dry-run chromium 2>/dev/null | grep -o '/.*chromium.*' || echo "")
# Fallback: check common paths
if [ -z "$CHROME_PATH" ]; then
CHROME_PATH=$(find ~/Library/Caches/ms-playwright -name "chrome" -o -name "chromium" 2>/dev/null | head -1)
fi
# If still not found, let Lighthouse use system Chrome
# For each page, run 3 times
for PAGE in "/" "/dashboard"; do
PAGE_NAME=$(echo "$PAGE" | tr '/' '_' | sed 's/^_//')
[ -z "$PAGE_NAME" ] && PAGE_NAME="homepage"
for RUN in 1 2 3; do
npx lighthouse "http://localhost:3000${PAGE}" \
--output=json \
--output-path=".lighthouse/${PAGE_NAME}_run${RUN}.json" \
--chrome-flags="--headless=new --no-sandbox" \
--only-categories=performance,accessibility,best-practices,seo \
--quiet
done
done
For each page, read the 3 JSON reports and compute the median score for each of the 4 categories:
Also extract the top audit opportunities with their estimated savings (e.g., "Properly size images — potential savings of 250 KiB").
Create a score matrix for all pages:
| Page | Performance | Accessibility | Best Practices | SEO |
|---|
Categorize each score:
For each category below 90, identify the top opportunities sorted by impact:
Performance opportunities to look for:
Accessibility opportunities to look for:
Best Practices opportunities to look for:
SEO opportunities to look for:
Performance:
<img> tags with next/image (automatic optimization, WebP, lazy loading)width and height to all images (prevents CLS)dynamic(() => import(...), { ssr: false }) for heavy below-fold componentsnext/font for Google Fonts (eliminates render-blocking font requests)font-display: swap to any custom @font-face declarations<link rel="preconnect" href="https://rtypufgrcyggevlmwxsj.supabase.co" />
loading="lazy" or dynamic importsAccessibility:
alt text to every <img> and next/imageh1 → h2 → h3, no skips)role attributes to landmark regions if semantic HTML isn't used<label htmlFor="...">)Best Practices:
SEO:
<meta> tags):
// In page.tsx or layout.tsx
export const metadata: Metadata = {
title: 'Page Title | Elenvo',
description: 'Clear, compelling description under 160 chars',
openGraph: {
title: 'Page Title | Elenvo',
description: '...',
type: 'website',
url: 'https://elenvo.ai/page',
},
twitter: {
card: 'summary_large_image',
title: 'Page Title | Elenvo',
description: '...',
},
}
app/robots.ts and app/sitemap.ts if missing<main>, <nav>, <header>, <footer>, <article>)<h1>After making fixes:
# Kill old server
kill $SERVER_PID 2>/dev/null
# Rebuild and restart
npm run build
npm run start &
SERVER_PID=$!
sleep 5
# Run Lighthouse again (3 runs, median) on all tested pages
# ... same as Step 2
Decision logic:
git checkout -- <files>), try a different approach# Kill the production server
kill $SERVER_PID 2>/dev/null
# Optionally clean up .lighthouse/ directory
# rm -rf .lighthouse
Present results as a before/after table for each page:
| Page | Category | Before | After | Delta | Status |
|------------|-----------------|--------|-------|-------|--------|
| / | Performance | 72 | 91 | +19 | PASS |
| / | Accessibility | 85 | 95 | +10 | PASS |
| / | Best Practices | 88 | 92 | +4 | PASS |
| / | SEO | 67 | 91 | +24 | PASS |
| /dashboard | Performance | 65 | 90 | +25 | PASS |
| /dashboard | Accessibility | 90 | 93 | +3 | PASS |
| /dashboard | Best Practices | 78 | 91 | +13 | PASS |
| /dashboard | SEO | 72 | 92 | +20 | PASS |
Then provide:
If a category is 85-89 and the only remaining opportunities are:
Then explain this to the user and let them decide whether to accept or push further.
npm run build && npm run start — NEVER npm run devexport const metadata or generateMetadata(), not manual <meta> tags