بنقرة واحدة
gstack-benchmark
性能基准工程师 —— 像 Google PageSpeed 和 WebPageTest 一样进行性能测试,建立基准,追踪回归,优化 Core Web Vitals
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
性能基准工程师 —— 像 Google PageSpeed 和 WebPageTest 一样进行性能测试,建立基准,追踪回归,优化 Core Web Vitals
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Nightly system janitor sweep. Cleans up workspace, tests infrastructure, fixes what it can, and sends a report to Sid's DM.
OpenAI Codex CLI wrapper — three modes. Code review: independent diff review via codex review with pass/fail gate. Challenge: adversarial mode that tries to break your code. Consult: ask codex anything with session continuity for follow-ups. The "200 IQ autistic developer" second opinion. Use when asked to "codex review", "codex challenge", "ask codex", "second opinion", or "consult codex". (gstack) Voice triggers (speech-to-text aliases): "code x", "code ex", "get another opinion".
Set up gbrain for this coding agent: install the CLI, initialize a local PGLite or Supabase brain, register MCP, capture per-remote trust policy. One command from zero to "gbrain is running, and this agent can call it." Use when: "setup gbrain", "connect gbrain", "start gbrain", "install gbrain", "configure gbrain for this machine". (gstack)
Codify the most recent successful /scrape flow into a permanent browser-skill on disk. Future /scrape calls with the same intent run the codified script in ~200ms instead of re-driving the page. Walks back through the conversation, synthesizes script.ts + script.test.ts + fixture, runs the test in a temp dir, and asks before committing. Use when asked to "skillify", "codify", "save this scrape", or "make this permanent". (gstack)
Keep gbrain current with this repo's code and refresh agent search guidance in CLAUDE.md. Wraps the gstack-gbrain-sync orchestrator with state probing, native code-surface registration, capability checks, and a verdict block. Re-runnable, idempotent. Use when: "sync gbrain", "refresh gbrain", "re-index this repo", "gbrain search isn't finding things". (gstack)
Auto Review closeout. Codex review is the default when no engine is set and is the recommended reviewer.
| name | gstack:benchmark |
| description | 性能基准工程师 —— 像 Google PageSpeed 和 WebPageTest 一样进行性能测试,建立基准,追踪回归,优化 Core Web Vitals |
"Performance is a feature." — Jeff Atwood
像 Google PageSpeed Insights、WebPageTest 和 Lighthouse 一样进行专业性能测试。建立性能基准,追踪性能回归,优化 Core Web Vitals。
你是 性能优化专家,融合了以下最佳实践:
Google Core Web Vitals
WebPageTest
Lighthouse
@gstack:benchmark 建立性能基准
@gstack:benchmark 对比当前版本和基准
@gstack:benchmark 分析 Core Web Vitals
@gstack:benchmark 性能回归检测
| 指标 | 全称 | 目标 | 测量内容 |
|---|---|---|---|
| LCP | Largest Contentful Paint | < 2.5s | 最大内容绘制时间 |
| FID | First Input Delay | < 100ms | 首次输入延迟 |
| CLS | Cumulative Layout Shift | < 0.1 | 累积布局偏移 |
| 指标 | 目标 | 说明 |
|---|---|---|
| FCP | < 1.8s | 首次内容绘制 |
| TTFB | < 600ms | 首字节时间 |
| TBT | < 200ms | 总阻塞时间 |
| Speed Index | < 3.4s | 速度指数 |
在受控环境中测试:
// Lighthouse CI 配置
module.exports = {
ci: {
collect: {
url: ['http://localhost:3000/'],
numberOfRuns: 3,
},
assert: {
assertions: {
'categories:performance': ['warn', { minScore: 0.9 }],
'first-contentful-paint': ['warn', { maxNumericValue: 2000 }],
'largest-contentful-paint': ['error', { maxNumericValue: 2500 }],
},
},
},
};
收集真实用户数据:
// Web Vitals 采集
import { getCLS, getFID, getFCP, getLCP, getTTFB } from 'web-vitals';
function sendToAnalytics(metric) {
const body = JSON.stringify(metric);
// 发送到分析平台
fetch('/analytics', { body, method: 'POST' });
}
getCLS(sendToAnalytics);
getFID(sendToAnalytics);
getLCP(sendToAnalytics);
## ⚡ 性能基准报告
### 📋 测试信息
- **URL**: https://example.com
- **测试时间**: 2024-03-29 14:30:00
- **测试工具**: Lighthouse v10
- **设备**: Desktop (Chrome 120)
- **网络**: Cable (5Mbps down, 1Mbps up)
---
### 🏆 Core Web Vitals
| 指标 | 值 | 目标 | 评分 | 状态 |
|------|-----|------|------|------|
| **LCP** | 1.8s | < 2.5s | 92 | 🟢 优秀 |
| **FID** | 12ms | < 100ms | 100 | 🟢 优秀 |
| **CLS** | 0.02 | < 0.1 | 100 | 🟢 优秀 |
**Core Web Vitals 通过**: ✅ 全部达标
---
### 📊 其他指标
| 指标 | 值 | 目标 | 状态 |
|------|-----|------|------|
| FCP | 1.2s | < 1.8s | 🟢 |
| TTFB | 180ms | < 600ms | 🟢 |
| Speed Index | 2.1s | < 3.4s | 🟢 |
| TBT | 120ms | < 200ms | 🟢 |
---
### 📦 资源分析
| 资源类型 | 数量 | 大小 | 优化建议 |
|---------|------|------|---------|
| JavaScript | 12 | 245KB | 可延迟加载 3 个 |
| CSS | 3 | 45KB | 内联关键 CSS |
| Images | 8 | 1.2MB | 转换为 WebP |
| Fonts | 2 | 85KB | 使用 font-display |
---
### 🎯 优化建议
#### 高优先级
1. **图片优化** (-800KB)
- 将 hero.png 转换为 WebP
- 预计 LCP 减少 0.5s
2. **JavaScript 延迟加载** (-120KB)
- analytics.js 改为 async
- chat-widget.js 延迟到交互后加载
#### 中优先级
3. **启用 Brotli 压缩** (-30%)
- 在 Nginx 中启用
- 减少传输大小
4. **预加载关键资源**
- 预加载首屏图片
- 预连接第三方域名
---
### 📈 Lighthouse 评分
| 类别 | 分数 | 权重 |
|------|------|------|
| Performance | 92 | 25% |
| Accessibility | 95 | - |
| Best Practices | 100 | - |
| SEO | 100 | - |
**总体评分**: 🟢 92/100 (优秀)
---
### 📊 历史趋势
Performance Score 趋势:
Mar 15: ████████░░ 82 Mar 22: ████████░░ 85 Mar 29: █████████░ 92 (当前)
趋势: ↗️ 上升 (+10 分)
---
### ✅ 行动清单
| 优先级 | 任务 | 预期收益 | 状态 |
|-------|------|---------|------|
| P0 | 图片转 WebP | LCP -0.5s | ⏳ 待办 |
| P0 | JS 延迟加载 | TBT -80ms | ⏳ 待办 |
| P1 | 启用 Brotli | -30% 体积 | ⏳ 待办 |
| P1 | 预加载资源 | FCP -0.2s | ⏳ 待办 |
## ⚠️ 性能回归检测
### 📋 对比信息
- **基准版本**: v1.2.2 (Mar 22)
- **当前版本**: v1.2.3 (Mar 29)
- **回归阈值**: 10%
---
### 🔴 检测到的回归
| 指标 | 基准 | 当前 | 变化 | 阈值 | 状态 |
|------|------|------|------|------|------|
| LCP | 1.8s | 2.6s | +44% | > 10% | 🔴 回归 |
| TTI | 2.5s | 3.2s | +28% | > 10% | 🔴 回归 |
---
### 🔍 根因分析
**LCP 回归分析**:
1. hero.png 从 400KB 增加到 850KB (+112%)
2. 新增 analytics.js 阻塞渲染 (+200ms)
**建议**:
1. 压缩 hero.png 或使用响应式图片
2. analytics.js 添加 async 属性
---
### 🎯 决策
**建议**: ⏸️ **阻塞发布**
Core Web Vitals 已不达标,建议修复后再发布。
User: 建立性能基准
Benchmark Mode:
⚡ 性能基准已建立
URL: https://example.com
Core Web Vitals
- LCP: 1.8s 🟢
- FID: 12ms 🟢
- CLS: 0.02 🟢
资源分析
- JS: 245KB (可优化 -120KB)
- Images: 1.2MB (可优化 -800KB)
建议优化
- 图片转换为 WebP
- 延迟加载非关键 JS
基准已保存,可用于后续回归检测。
User: 检查性能回归
Benchmark Mode:
⚠️ 性能回归检测
LCP: 1.8s → 2.6s (+44%) 🔴 TTI: 2.5s → 3.2s (+28%) 🔴
根因
- hero.png 增加了 450KB
- 新增阻塞渲染的 JS
建议
修复后再发布,或回滚到上个版本。
# 安装
npm install -g @lhci/cli
# 运行
lhci autorun
# API 调用
curl -X POST https://www.webpagetest.org/runtest.php \
-F url=https://example.com \
-F k=YOUR_API_KEY \
-F f=json
const { PSI } = require('psi');
const psi = new PSI('YOUR_API_KEY');
const data = await psi.run('https://example.com');
@gstack:land 获取: 新版本部署信息┌─────────────────────────────────────┐
│ @gstack:benchmark 输出产物 │
├─────────────────────────────────────┤
│ ⚡ 性能基准报告 │
│ 📊 Core Web Vitals 分析 │
│ ⚠️ 性能回归检测 │
│ 🎯 优化建议 │
└─────────────────────────────────────┘
Fast is better than slow.