쇼타임: SPEEDClaude 코드는 100/100 Lighthouse 점수 코드만 배송합니다.
hackernews
|
|
📦 오픈소스
#ai 딜
#ai 코딩
#claude
#claude code
#lighthouse
#성능 최적화
#코드 검증
원문 출처: hackernews · Genesis Park에서 요약 및 분석
요약
이 시스템은 AI 코딩 보조가 복잡하고 느린 코드를 배포하는 것을 막기 위해, 라이트하우스(Lighthouse) 점수, 구글 애널리틱스 실제 사용자 데이터, 검색 콘솔 지표라는 3가지 핵심 지표를 충족하지 못하면 자동으로 코드를 수정하도록 강제합니다. 개발자는 단일 명령어로 이 시스템을 프로젝트에 통합할 수 있으며, 점수가 100점(Performance, Accessibility, Best Practices, SEO)이 될 때까지 AI가 스스로 병목 현상을 분석하고 리팩토링을 반복합니다. 또한 실제 사용자 지표가 기준치보다 나빠지거나 검색 노출에 문제가 생기면 커밋이 차단되어 항상 최적화된 성능의 코드만 배포할 수 있습니다.
본문
Stop your AI from pushing bloated, slow code to production. This is a complete performance verification system that forces AI coding assistants (Claude Code, Cursor, GitHub Copilot, etc.) to validate code against three critical measures: - Synthetic Tests — Lighthouse (100% performance required) - Real User Data — Google Analytics Core Web Vitals (must not regress) - Search Health — Google Search Console (rankings, crawl errors, indexing) If any check fails, the AI automatically refactors its own code until it passes all three. ✅ Bulletproof Code — AI validates against both test scores AND real user data ✅ Zero Manual Setup — One command installs everything (Lighthouse + GA + GSC) ✅ Self-Healing — AI reads performance errors and fixes them automatically ✅ Graceful Degradation — Works with just Lighthouse on day one, add GA/GSC later ✅ Distribution Ready — Curl these files into any project Drop these files into your project: # 1. Core files curl -O https://raw.githubusercontent.com/YOUR_USERNAME/ai-performance-guardrails/main/CLAUDE.md curl -O https://raw.githubusercontent.com/YOUR_USERNAME/ai-performance-guardrails/main/lighthouserc.js mkdir -p scripts curl -o scripts/check-speed.js https://raw.githubusercontent.com/YOUR_USERNAME/ai-performance-guardrails/main/scripts/check-speed.js # 2. Install Lighthouse npm install -D @lhci/cli Then add to package.json : { "scripts": { "check-speed": "node scripts/check-speed.js" } } Done. Claude Code will load CLAUDE.md and enforce Lighthouse checks. First time setting up Google Cloud credentials? → Follow the credential setup guide (walks through everything step-by-step) Already have credentials? - Grab the setup script: curl -o setup.sh https://raw.githubusercontent.com/YOUR_USERNAME/ai-performance-guardrails/main/setup.sh bash setup.sh The script will: - Ask for your GA Property ID and GSC Site URL - Prompt for your Google Cloud service account JSON file path - Install MCP servers (analytics-mcp, mcp-server-gsc) - Wire everything into Claude Code settings - Run a smoke test - Add these files to your project (same as Option A): { "scripts": { "check-speed": "node scripts/check-speed.js" } } - Restart Claude Code so it loads the new MCP servers Done. The full 3-phase loop is now active. Every code change is validated to achieve this: ┌─────────────┬──────────────┬─────────────┬────────┐ │ Performance│ Accessibility│ Best │ SEO │ │ 100 │ 100 │ Practices │ 100 │ │ │ │ 100 │ │ └─────────────┴──────────────┴─────────────┴────────┘ Plus: Real user metrics don't regress (GA Core Web Vitals, GSC rankings) node scripts/check-analytics.js baseline The AI captures: - 📊 Core Web Vitals (LCP, CLS, INP) from Google Analytics - 📈 Top slowest pages by URL - 🔍 Top search queries and CTR from Google Search Console ⚠️ Any crawl errors or indexing failures These metrics are saved to .perf-baseline.json — the bar the AI cannot regress below. If GA/GSC not configured: Phase 1 is skipped silently. Lighthouse still runs. npm run check-speed (repeats until 100%) - You ask Claude Code to add/update code - Claude builds and runs Lighthouse - Results: - ✅ 100%? Proceed to Phase 3 - ❌ Below 100%? Claude reads the error, identifies the bottleneck (large bundles, unoptimized images, main thread blocking), refactors, and retries This loop repeats until Lighthouse reports 100% performance. node scripts/check-analytics.js validate The AI compares current metrics against the baseline from Phase 1: - 📊 Did Core Web Vitals improve or hold steady? - 🔍 Did search rankings or CTR drop? ⚠️ Are there new crawl errors? Results: - ✅ Improved or stable? Code is committed. Done. - ❌ Regression detected? Claude must refactor before committing. If GA/GSC not configured: Phase 3 is skipped silently. Code commits after Phase 2. | Service | Metrics | What It Catches | |---|---|---| | Lighthouse | Performance, Accessibility, Best Practices, SEO | Bloated bundles, unoptimized images, render-blocking resources, CLS issues | | Google Analytics | LCP, CLS, INP (Core Web Vitals) | Real user slowdowns that don't show in synthetic tests | | Search Console | Rankings, CTR, impressions, crawl errors | SEO regressions, indexing problems, search visibility drops | Edit lighthouserc.js : 'categories:performance': ['error', { minScore: 0.95 }], // 95% instead of 100% 'categories:accessibility': ['warn', { minScore: 0.8 }], If you're not using Next.js, edit scripts/check-speed.js : execSync('yarn build', { stdio: 'inherit' }); // Your build command execSync('yarn dev', { stdio: 'inherit' }); // Your dev server command In lighthouserc.js : 'cumulative-layout-shift': ['off'], // Don't enforce CLS 'first-contentful-paint': ['off'], // Don't enforce FCP "Cannot find module @lhci/cli" npm install -D @lhci/cli "Cannot connect to localhost:3000" - Ensure npm run start ornpm run dev works for your project - Update the start command in scripts/check-speed.js "Service account file not found" - Download your service account JSON from Google Cl
Genesis Park 편집팀이 AI를 활용하여 작성한 분석입니다. 원문은 출처 링크를 통해 확인할 수 있습니다.
공유