用途
Lighthouse Audit 用于自动化运行 Google Lighthouse 审计,测量并跟踪 Core Web Vitals、SEO 和无障碍等指标,这些指标也是 Google 用于搜索排名的同类指标。
主要能力
- 性能优化:在变更前后测量 LCP、FID、CLS。
- SEO 审计:检查技术性 SEO 问题(如 meta 标签、结构化数据等)。
- 无障碍检查:识别无障碍问题以支持合规。
- 客户报告:生成专业的性能报告。
- 监控:跨多个页面长期跟踪分数。
审计类别包括:
| 类别 | 检查项 | 影响 |
|---|---|---|
| performance | LCP、FID、CLS、TTFB、Speed Index | 搜索排名 |
| seo | Meta 标签、标题、链接、移动端 | 搜索可见性 |
| accessibility | WCAG 合规、对比度、标签 | 合规 |
| best-practices | HTTPS、安全、现代 API | 信任 |
| pwa | Service worker、manifest、离线 | 类应用体验 |
Core Web Vitals 阈值:
| 指标 | 良好 | 需要改进 | 差 |
|---|---|---|---|
| LCP | ≤2.5s | 2.5s-4.0s | >4.0s |
| FID | ≤100ms | 100ms-300ms | >300ms |
| CLS | ≤0.1 | 0.1-0.25 | >0.25 |
| INP | ≤200ms | 200ms-500ms | >500ms |
使用方式
依赖安装:
pip install click pandas jinja2
# Also requires Chrome and Lighthouse CLI
# npm install -g lighthouse
# Or use Chrome DevTools built-in Lighthouse
命令示例:
单 URL 审计:
python scripts/main.py audit https://example.com --categories performance,seo
python scripts/main.py audit https://example.com --format html --output report.html
批量审计:
python scripts/main.py batch urls.txt --output results/
python scripts/main.py batch urls.txt --categories performance --format csv
前后对比:
python scripts/main.py compare https://example.com --baseline scores.json
python scripts/main.py compare https://example.com --baseline-url https://staging.example.com
长期监控:
python scripts/main.py history https://example.com --days 30
python scripts/main.py history https://example.com --plot
示例 1:全站性能审计
# Create URL list
cat > urls.txt << EOF
https://example.com/
https://example.com/pricing
https://example.com/features
https://example.com/blog
EOF
# Run batch audit
python scripts/main.py batch urls.txt --categories performance,seo,accessibility
# Output: results/audit_2024-01-15/
# ├── example.com_.json
# ├── example.com_pricing.json
# ├── example.com_features.json
# ├── example.com_blog.json
# └── summary.csv
示例 2:前后对比
# Save baseline
python scripts/main.py audit https://example.com --output baseline.json
# Make optimizations...
# Compare
python scripts/main.py compare https://example.com --baseline baseline.json
# Output:
# Core Web Vitals Comparison
# ─────────────────────────────
# Metric Before After Change
# LCP 3.2s 1.8s -44% ✓
# FID 120ms 45ms -63% ✓
# CLS 0.25 0.08 -68% ✓
# Performance 52 89 +37 pts
示例 3:生成客户报告
python scripts/main.py audit https://client-site.com \
--format html \
--output client-report.html \
--include-screenshots
# Output: Professional HTML report with:
# - Executive summary
# - Core Web Vitals scores
# - Screenshots of issues
# - Prioritized recommendations
输出格式
| 格式 | 用途 | 内容 |
|---|---|---|
| json | 自动化、存储 | 完整原始数据 |
| csv | 电子表格、分析 | 汇总分数 |
| html | 客户报告 | 可视化报告 |
| md | 文档 | Markdown 摘要 |
职责划分
Claude 负责:结构化分析框架、识别数据中的模式、创建可视化模板、建议优化方向、计算统计量。
由用户决定:指标定义、业务解读、仪表板设计、行动优先级、决策阈值。
适用场景
- 性能优化前后测量 LCP、FID、CLS。
- 技术性 SEO 审计。
- 无障碍合规检查。
- 客户性能报告生成。
- 多个页面分数的长期监控。
限制
该技能不能:访问你的实际数据、替代统计专业知识、做出业务决策、保证预测准确性。
相关技能
- schema-markup:修复结构化数据问题。
- image-batch:为 LCP 优化图片。
- link-checker:查找失效链接。
技能元数据
Mode: centaur
category: seo-tools subcategory: performance dependencies: [lighthouse, click, pandas] difficulty: beginner time_saved: 3+ hours/week