davila7/claude-code-templates / cli-tool/components/skills/development/performance-profiling
performance-profiling
VerifiedPerformance profiling principles. Measurement, analysis, and optimization techniques.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 3.0 KB |
| scripts/lighthouse_audit.py | script | 2.6 KB |
scripts/lighthouse_audit.py
View on GitHub#!/usr/bin/env python3
"""
Skill: performance-profiling
Script: lighthouse_audit.py
Purpose: Run Lighthouse performance audit on a URL
Usage: python lighthouse_audit.py https://example.com
Output: JSON with performance scores
Note: Requires lighthouse CLI (npm install -g lighthouse)
"""
import subprocess
import json
import sys
import os
import tempfile
def run_lighthouse(url: str) -> dict:
"""Run Lighthouse audit on URL."""
try:
with tempfile.NamedTemporaryFile(suffix='.json', delete=False) as f:
output_path = f.name
result = subprocess.run(
[
"lighthouse",
url,
"--output=json",
f"--output-path={output_path}",
"--chrome-flags=--headless",
"--only-categories=performance,accessibility,best-practices,seo"
],
capture_output=True,
text=True,
timeout=120
)
if os.path.exists(output_path):
with open(output_path, 'r') as f:
report = json.load(f)
os.unlink(output_path)
categories = report.get("categories", {})
return {
"url": url,
"scores": {
"performance": int(categories.get("performance", {}).get("score", 0) * 100),
"accessibility": int(categories.get("accessibility", {}).get("score", 0) * 100),
"best_practices": int(categories.get("best-practices", {}).get("score", 0) * 100),
"seo": int(categories.get("seo", {}).get("score", 0) * 100)
},
"summary": get_summary(categories)
}
else:
return {"error": "Lighthouse failed to generate report", "stderr": result.stderr[:500]}
except subprocess.TimeoutExpired:
return {"error": "Lighthouse audit timed out"}
except FileNotFoundError:
return {"error": "Lighthouse CLI not found. Install with: npm install -g lighthouse"}
def get_summary(categories: dict) -> str:
"""Generate summary based on scores."""
perf = categories.get("performance", {}).get("score", 0) * 100
if perf >= 90:
return "[OK] Excellent performance"
elif perf >= 50:
return "[!] Needs improvement"
else:
return "[X] Poor performance"
if __name__ == "__main__":
if len(sys.argv) < 2:
print(json.dumps({"error": "Usage: python lighthouse_audit.py <url>"}))
sys.exit(1)
result = run_lighthouse(sys.argv[1])
print(json.dumps(result, indent=2))
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 193k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 193k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 193k | Updated | Claude CodeCodex | Verified | Install |