Install command
Provided
Runs performance benchmarks and generates comparison report when session ends.
Open the source and read safety notes before installing.
Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.
Decision playbook
Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.
0
78
—
No baseline selected
No major trust-signal divergence detected in the current selection.
Confirm ownership and provenance before trusting install instructions.
Source link availableRequired
Open the canonical repository and verify ownership.
Source provenance statusRequired
Marked as source-backed.
Metadata reviewed
Registry metadata indicates a reviewed listing.
Validate risk disclosures before installation or API wiring.
Safety notes presentRequired
Review the listed safety guidance before running commands.
Privacy notes presentRequired
Review data handling notes before connecting accounts or secrets.
Trust level risk gateRequired
Trust level does not block evaluation.
Check package metadata and artifact integrity signals.
Install payload available
Install or copy payload is available for review.
Package verification flag
No package verification flag provided.
Checksum metadata
No checksum provided for downloaded artifact.
Use compare context to validate trade-offs before adoption.
Compare tray has multiple entries
Add at least one more entry to compare trust differences.
Baseline comparison available
No baseline peer selected yet.
Diverging trust signals identified
No major trust-signal divergence found.
Setup at a glance
Copy-ready — paste the snippet to get started.
Install command
Provided
Config snippet
Provided
Copy snippet
Provided
Prerequisites
None
Platforms
1 listed
Difficulty
0/100
Adoption plan
Current risk score 16/100. Use staged verification before broader rollout.
Validate source and review signals before any execution.
Confirm source provenanceRequired
Source URL/provenance metadata is present.
Confirm metadata review state
Listing has review metadata.
Verify install payload
Install/config payload exists and can be inspected.
Confirm safety, privacy, and package integrity signals.
Review safety notesRequired
Safety notes are present.
Review privacy notesRequired
Privacy notes are present.
Verify package integrity metadata
No package verification/checksum metadata.
Adopt in controlled steps based on the selected plan.
Run in isolated sandbox firstRequired
Use a constrained sandbox and observe behavior across multiple tasks.
Roll out graduallyRequired
Roll out to a small cohort before wider usage.
Set monitoring and fallback
Define rollback path and monitor errors after adoption.
Evidence readiness
Required evidence gates are covered (5/6 signals complete).
Source repository/provenance is listed.
Required in this preset
Review metadata is present.
Required in this preset
Safety notes are present.
Required in this preset
Privacy notes are present.
Optional in this preset
Package integrity metadata is missing.
Optional in this preset
Install payload is available.
Required in this preset
Required evidence gates are covered for this preset.
Decision timeline
5/6 steps complete with no blocking gaps for this preset.
triage
Source/provenance metadata is available.
triage
Review metadata is available.
verify
Safety notes are available.
verify
Privacy notes are available.
verify
Package integrity metadata is missing.
rollout
Install payload is available.
No required blockers for this timeline preset.
Safety & privacy surface
2 safety and 2 privacy notes across 2 risk areas. Review closely: credentials & tokens.
#!/usr/bin/env bash
# Performance Benchmark Report Hook
# Runs comprehensive performance benchmarks when the session ends
echo "⚡ Performance Benchmark Report" >&2
echo "=============================" >&2
# Initialize benchmark tracking
BENCHMARKS_RUN=0
BENCHMARKS_PASSED=0
BENCHMARKS_FAILED=0
TOTAL_DURATION=0
START_TIME=$(date +%s)
BENCHMARK_RESULTS_DIR=".performance-reports"
TIMESTAMP=$(date +"%Y-%m-%d-%H-%M-%S")
REPORT_FILE="$BENCHMARK_RESULTS_DIR/benchmark-$TIMESTAMP.json"
# Create benchmark results directory
mkdir -p "$BENCHMARK_RESULTS_DIR"
# Function to report benchmark results
report_benchmark() {
local status="$1"
local name="$2"
local duration="$3"
local details="$4"
BENCHMARKS_RUN=$((BENCHMARKS_RUN + 1))
case "$status" in
"PASS")
echo "✅ PASS: $name (${duration}s)" >&2
BENCHMARKS_PASSED=$((BENCHMARKS_PASSED + 1))
;;
"FAIL")
echo "❌ FAIL: $name (${duration}s)" >&2
BENCHMARKS_FAILED=$((BENCHMARKS_FAILED + 1))
;;
"SKIP")
echo "⏭️ SKIP: $name - $details" >&2
;;
"INFO")
echo "ℹ️ INFO: $name" >&2
;;
esac
if [ -n "$duration" ] && [ "$duration" != "0" ]; then
TOTAL_DURATION=$((TOTAL_DURATION + duration))
fi
}
# Function to run command with timing
run_timed_benchmark() {
local name="$1"
local command="$2"
local timeout_seconds="${3:-60}"
echo " 🏃 Running: $name..." >&2
local start_time=$(date +%s)
local output_file="/tmp/benchmark_${name//[^a-zA-Z0-9]/_}_$$"
if timeout "${timeout_seconds}s" bash -c "$command" > "$output_file" 2>&1; then
local end_time=$(date +%s)
local duration=$((end_time - start_time))
report_benchmark "PASS" "$name" "$duration"
# Show brief output
if [ -s "$output_file" ]; then
echo " 📊 Results:" >&2
head -5 "$output_file" | while read line; do
echo " $line" >&2
done
fi
else
local end_time=$(date +%s)
local duration=$((end_time - start_time))
report_benchmark "FAIL" "$name" "$duration"
# Show error output
if [ -s "$output_file" ]; then
echo " ❌ Error:" >&2
tail -3 "$output_file" | while read line; do
echo " $line" >&2
done
fi
fi
rm -f "$output_file"
}
# Function to detect project type and language
detect_project_type() {
local project_types=()
[ -f "package.json" ] && project_types+=("nodejs")
[ -f "requirements.txt" ] || [ -f "pyproject.toml" ] && project_types+=("python")
[ -f "go.mod" ] && project_types+=("go")
[ -f "Cargo.toml" ] && project_types+=("rust")
[ -f "composer.json" ] && project_types+=("php")
[ -f "Gemfile" ] && project_types+=("ruby")
[ -f "pom.xml" ] || [ -f "build.gradle" ] && project_types+=("java")
echo "${project_types[@]}"
}
# Initialize JSON report
cat > "$REPORT_FILE" << EOF
{
"timestamp": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
"session_id": "$(uuidgen 2>/dev/null || echo "session-$TIMESTAMP")",
"project_path": "$(pwd)",
"project_name": "$(basename "$(pwd)")",
"benchmarks": [
EOF
# Detect project types
PROJECT_TYPES=($(detect_project_type))
if [ ${#PROJECT_TYPES[@]} -eq 0 ]; then
report_benchmark "INFO" "No recognized project structure found"
else
echo " 📊 Detected project types: ${PROJECT_TYPES[*]}" >&2
fi
# 1. Node.js Benchmarks
if [[ " ${PROJECT_TYPES[*]} " =~ " nodejs " ]]; then
echo "📦 Node.js Performance Benchmarks" >&2
# Check for benchmark scripts in package.json
if [ -f "package.json" ]; then
BENCHMARK_SCRIPTS=$(jq -r '.scripts | to_entries[] | select(.key | test("benchmark|perf")) | .key' package.json 2>/dev/null || echo "")
if [ -n "$BENCHMARK_SCRIPTS" ]; then
echo "$BENCHMARK_SCRIPTS" | while read script; do
run_timed_benchmark "npm run $script" "npm run $script" 180
done
else
report_benchmark "SKIP" "Node.js benchmarks" "No benchmark scripts found in package.json"
fi
# Bundle size analysis
if command -v npx &> /dev/null; then
if [ -f "dist/" ] || [ -f "build/" ]; then
run_timed_benchmark "Bundle size analysis" "npx bundlesize" 60
fi
# Build performance
if jq -e '.scripts.build' package.json >/dev/null 2>&1; then
run_timed_benchmark "Build performance" "npm run build" 300
fi
# Test performance
if jq -e '.scripts.test' package.json >/dev/null 2>&1; then
run_timed_benchmark "Test suite performance" "npm test" 180
fi
fi
fi
fi
# 2. Python Benchmarks
if [[ " ${PROJECT_TYPES[*]} " =~ " python " ]]; then
echo "🐍 Python Performance Benchmarks" >&2
# pytest-benchmark
if command -v pytest &> /dev/null && ([ -f "pytest.ini" ] || [ -f "pyproject.toml" ]); then
run_timed_benchmark "pytest benchmarks" "pytest --benchmark-only --benchmark-json=/tmp/pytest_benchmark.json" 300
fi
# Python timeit benchmarks
if [ -f "benchmark.py" ]; then
run_timed_benchmark "Python benchmark.py" "python benchmark.py" 120
fi
# Memory profiling
if command -v python &> /dev/null && command -v pip &> /dev/null; then
run_timed_benchmark "Memory profiling" "python -c 'import psutil; print(f\"Memory usage: {psutil.virtual_memory().percent}%\")'" 10
fi
fi
# 3. Go Benchmarks
if [[ " ${PROJECT_TYPES[*]} " =~ " go " ]]; then
echo "🐹 Go Performance Benchmarks" >&2
if command -v go &> /dev/null; then
# Go test benchmarks
run_timed_benchmark "Go benchmarks" "go test -bench=. -benchmem" 180
# Build performance
run_timed_benchmark "Go build performance" "go build -o /tmp/go_build_test" 60
# Clean up
rm -f /tmp/go_build_test
fi
fi
# 4. Rust Benchmarks
if [[ " ${PROJECT_TYPES[*]} " =~ " rust " ]]; then
echo "🦀 Rust Performance Benchmarks" >&2
if command -v cargo &> /dev/null; then
# Cargo bench
run_timed_benchmark "Cargo benchmarks" "cargo bench" 300
# Build performance
run_timed_benchmark "Cargo build performance" "cargo build --release" 180
# Test performance
run_timed_benchmark "Cargo test performance" "cargo test" 120
fi
fi
# 5. Web Performance Benchmarks
echo "🌐 Web Performance Analysis" >&2
# Check if this looks like a web project
WEB_PROJECT=false
if [ -f "package.json" ] && grep -q '"next"\\|"react"\\|"vue"\\|"angular"\\|"express"\\|"koa"' package.json; then
WEB_PROJECT=true
elif [ -f "index.html" ] || [ -d "public" ] || [ -d "static" ]; then
WEB_PROJECT=true
fi
if [ "$WEB_PROJECT" = true ]; then
# Lighthouse audit (if available)
if command -v lighthouse &> /dev/null; then
# Check for running dev server
if curl -s http://localhost:3000 >/dev/null 2>&1; then
run_timed_benchmark "Lighthouse audit (localhost:3000)" "lighthouse http://localhost:3000 --output json --quiet --chrome-flags='--headless' --no-sandbox" 120
elif curl -s http://localhost:8080 >/dev/null 2>&1; then
run_timed_benchmark "Lighthouse audit (localhost:8080)" "lighthouse http://localhost:8080 --output json --quiet --chrome-flags='--headless' --no-sandbox" 120
else
report_benchmark "SKIP" "Lighthouse audit" "No local server detected"
fi
else
report_benchmark "SKIP" "Lighthouse audit" "Lighthouse not installed"
fi
# Bundle analyzer (if available)
if command -v npx &> /dev/null && [ -f "package.json" ]; then
if [ -d "dist" ] || [ -d "build" ] || [ -d ".next" ]; then
run_timed_benchmark "Bundle analysis" "npx webpack-bundle-analyzer --help >/dev/null && echo 'Bundle analyzer available'" 10
fi
fi
else
report_benchmark "SKIP" "Web performance" "Not a web project"
fi
# 6. Database Benchmarks
echo "🗄️ Database Performance Analysis" >&2
# Check for database connections
if [ -f ".env" ] && grep -q 'DATABASE_URL\\|DB_' .env; then
report_benchmark "INFO" "Database configuration detected"
# Simple connection test
if command -v psql &> /dev/null && grep -q 'postgres' .env 2>/dev/null; then
run_timed_benchmark "PostgreSQL connection test" "timeout 10s psql \"$(grep DATABASE_URL .env | cut -d'=' -f2)\" -c 'SELECT 1;'" 15
fi
if command -v mysql &> /dev/null && grep -q 'mysql' .env 2>/dev/null; then
run_timed_benchmark "MySQL connection test" "timeout 10s mysql --execute='SELECT 1;'" 15
fi
else
report_benchmark "SKIP" "Database benchmarks" "No database configuration found"
fi
# 7. Load Testing (if tools available)
echo "🔥 Load Testing" >&2
if command -v hyperfine &> /dev/null; then
# Hyperfine command benchmarks
if [ -f "package.json" ]; then
if jq -e '.scripts.start' package.json >/dev/null 2>&1; then
run_timed_benchmark "Command timing analysis" "hyperfine --warmup 1 'npm run start --version' 'npm run build --help'" 30
fi
fi
else
report_benchmark "SKIP" "Hyperfine benchmarks" "Hyperfine not installed"
fi
if command -v ab &> /dev/null; then
# Apache Bench (if server is running)
if curl -s http://localhost:3000 >/dev/null 2>&1; then
run_timed_benchmark "Apache Bench load test" "ab -n 100 -c 10 http://localhost:3000/" 60
fi
else
report_benchmark "SKIP" "Apache Bench" "ab not installed"
fi
# 8. Historical Comparison
echo "📈 Historical Performance Analysis" >&2
# Find previous benchmark reports
PREVIOUS_REPORTS=($(ls -t "$BENCHMARK_RESULTS_DIR"/benchmark-*.json 2>/dev/null | head -5))
if [ ${#PREVIOUS_REPORTS[@]} -gt 1 ]; then
LATEST_PREVIOUS="${PREVIOUS_REPORTS[1]}"
echo " 📊 Comparing with previous run: $(basename "$LATEST_PREVIOUS")" >&2
if [ -f "$LATEST_PREVIOUS" ] && command -v jq &> /dev/null; then
PREV_DURATION=$(jq -r '.total_duration // 0' "$LATEST_PREVIOUS" 2>/dev/null || echo "0")
if [ "$PREV_DURATION" -gt 0 ] && [ "$TOTAL_DURATION" -gt 0 ]; then
DURATION_DIFF=$((TOTAL_DURATION - PREV_DURATION))
PERCENT_CHANGE=$(echo "scale=1; $DURATION_DIFF * 100 / $PREV_DURATION" | bc -l 2>/dev/null || echo "0")
if [ "$DURATION_DIFF" -gt 0 ]; then
echo " ⬆️ Performance regression: +${PERCENT_CHANGE}% slower" >&2
elif [ "$DURATION_DIFF" -lt 0 ]; then
echo " ⬇️ Performance improvement: ${PERCENT_CHANGE#-}% faster" >&2
else
echo " ➡️ Performance unchanged" >&2
fi
fi
fi
else
echo " 📋 No previous benchmarks found for comparison" >&2
fi
# Complete JSON report
END_TIME=$(date +%s)
SESSION_DURATION=$((END_TIME - START_TIME))
cat >> "$REPORT_FILE" << EOF
],
"summary": {
"benchmarks_run": $BENCHMARKS_RUN,
"benchmarks_passed": $BENCHMARKS_PASSED,
"benchmarks_failed": $BENCHMARKS_FAILED,
"total_duration": $TOTAL_DURATION,
"session_duration": $SESSION_DURATION
},
"project_types": [$(printf '"%s",' "${PROJECT_TYPES[@]}" | sed 's/,$//')]
}
EOF
# 9. Generate Final Report
echo "" >&2
echo "📋 Performance Benchmark Summary" >&2
echo "================================" >&2
echo " 🏃 Benchmarks run: $BENCHMARKS_RUN" >&2
echo " ✅ Passed: $BENCHMARKS_PASSED" >&2
echo " ❌ Failed: $BENCHMARKS_FAILED" >&2
echo " ⏱️ Total benchmark time: ${TOTAL_DURATION}s" >&2
echo " 📊 Session duration: ${SESSION_DURATION}s" >&2
echo " 📄 Report saved: $REPORT_FILE" >&2
# Performance assessment
if [ "$BENCHMARKS_FAILED" -eq 0 ] && [ "$BENCHMARKS_PASSED" -gt 0 ]; then
echo " 🎉 Status: All benchmarks passed" >&2
elif [ "$BENCHMARKS_FAILED" -gt 0 ]; then
echo " ⚠️ Status: Some benchmarks failed" >&2
elif [ "$BENCHMARKS_RUN" -eq 0 ]; then
echo " ℹ️ Status: No benchmarks configured" >&2
else
echo " ❓ Status: Mixed results" >&2
fi
echo "" >&2
echo "💡 Performance Optimization Tips:" >&2
echo " • Run benchmarks regularly to catch regressions early" >&2
echo " • Set up CI/CD performance gates" >&2
echo " • Monitor Core Web Vitals for web applications" >&2
echo " • Profile memory usage and optimize bottlenecks" >&2
echo " • Use caching strategies to improve response times" >&2
echo " • Consider lazy loading and code splitting" >&2
echo "⚡ Performance benchmark report complete" >&2
exit 0{
"hooks": {
"stop": {
"script": "./.claude/hooks/performance-benchmark-report.sh",
"timeout": 120000
}
}
}.claude/settings.local.json~/.claude/settings.json.claude/settings.json{
"hooks": {
"stop": {
"script": "./.claude/hooks/performance-benchmark-report.sh",
"timeout": 120000
}
}
}
#!/usr/bin/env bash
# Performance Benchmark Report Hook
# Runs comprehensive performance benchmarks when the session ends
echo "⚡ Performance Benchmark Report" >&2
echo "=============================" >&2
# Initialize benchmark tracking
BENCHMARKS_RUN=0
BENCHMARKS_PASSED=0
BENCHMARKS_FAILED=0
TOTAL_DURATION=0
START_TIME=$(date +%s)
BENCHMARK_RESULTS_DIR=".performance-reports"
TIMESTAMP=$(date +"%Y-%m-%d-%H-%M-%S")
REPORT_FILE="$BENCHMARK_RESULTS_DIR/benchmark-$TIMESTAMP.json"
# Create benchmark results directory
mkdir -p "$BENCHMARK_RESULTS_DIR"
# Function to report benchmark results
report_benchmark() {
local status="$1"
local name="$2"
local duration="$3"
local details="$4"
BENCHMARKS_RUN=$((BENCHMARKS_RUN + 1))
case "$status" in
"PASS")
echo "✅ PASS: $name (${duration}s)" >&2
BENCHMARKS_PASSED=$((BENCHMARKS_PASSED + 1))
;;
"FAIL")
echo "❌ FAIL: $name (${duration}s)" >&2
BENCHMARKS_FAILED=$((BENCHMARKS_FAILED + 1))
;;
"SKIP")
echo "⏭️ SKIP: $name - $details" >&2
;;
"INFO")
echo "ℹ️ INFO: $name" >&2
;;
esac
if [ -n "$duration" ] && [ "$duration" != "0" ]; then
TOTAL_DURATION=$((TOTAL_DURATION + duration))
fi
}
# Function to run command with timing
run_timed_benchmark() {
local name="$1"
local command="$2"
local timeout_seconds="${3:-60}"
echo " 🏃 Running: $name..." >&2
local start_time=$(date +%s)
local output_file="/tmp/benchmark_${name//[^a-zA-Z0-9]/_}_$$"
if timeout "${timeout_seconds}s" bash -c "$command" > "$output_file" 2>&1; then
local end_time=$(date +%s)
local duration=$((end_time - start_time))
report_benchmark "PASS" "$name" "$duration"
# Show brief output
if [ -s "$output_file" ]; then
echo " 📊 Results:" >&2
head -5 "$output_file" | while read line; do
echo " $line" >&2
done
fi
else
local end_time=$(date +%s)
local duration=$((end_time - start_time))
report_benchmark "FAIL" "$name" "$duration"
# Show error output
if [ -s "$output_file" ]; then
echo " ❌ Error:" >&2
tail -3 "$output_file" | while read line; do
echo " $line" >&2
done
fi
fi
rm -f "$output_file"
}
# Function to detect project type and language
detect_project_type() {
local project_types=()
[ -f "package.json" ] && project_types+=("nodejs")
[ -f "requirements.txt" ] || [ -f "pyproject.toml" ] && project_types+=("python")
[ -f "go.mod" ] && project_types+=("go")
[ -f "Cargo.toml" ] && project_types+=("rust")
[ -f "composer.json" ] && project_types+=("php")
[ -f "Gemfile" ] && project_types+=("ruby")
[ -f "pom.xml" ] || [ -f "build.gradle" ] && project_types+=("java")
echo "${project_types[@]}"
}
# Initialize JSON report
cat > "$REPORT_FILE" << EOF
{
"timestamp": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
"session_id": "$(uuidgen 2>/dev/null || echo "session-$TIMESTAMP")",
"project_path": "$(pwd)",
"project_name": "$(basename "$(pwd)")",
"benchmarks": [
EOF
# Detect project types
PROJECT_TYPES=($(detect_project_type))
if [ ${#PROJECT_TYPES[@]} -eq 0 ]; then
report_benchmark "INFO" "No recognized project structure found"
else
echo " 📊 Detected project types: ${PROJECT_TYPES[*]}" >&2
fi
# 1. Node.js Benchmarks
if [[ " ${PROJECT_TYPES[*]} " =~ " nodejs " ]]; then
echo "📦 Node.js Performance Benchmarks" >&2
# Check for benchmark scripts in package.json
if [ -f "package.json" ]; then
BENCHMARK_SCRIPTS=$(jq -r '.scripts | to_entries[] | select(.key | test("benchmark|perf")) | .key' package.json 2>/dev/null || echo "")
if [ -n "$BENCHMARK_SCRIPTS" ]; then
echo "$BENCHMARK_SCRIPTS" | while read script; do
run_timed_benchmark "npm run $script" "npm run $script" 180
done
else
report_benchmark "SKIP" "Node.js benchmarks" "No benchmark scripts found in package.json"
fi
# Bundle size analysis
if command -v npx &> /dev/null; then
if [ -f "dist/" ] || [ -f "build/" ]; then
run_timed_benchmark "Bundle size analysis" "npx bundlesize" 60
fi
# Build performance
if jq -e '.scripts.build' package.json >/dev/null 2>&1; then
run_timed_benchmark "Build performance" "npm run build" 300
fi
# Test performance
if jq -e '.scripts.test' package.json >/dev/null 2>&1; then
run_timed_benchmark "Test suite performance" "npm test" 180
fi
fi
fi
fi
# 2. Python Benchmarks
if [[ " ${PROJECT_TYPES[*]} " =~ " python " ]]; then
echo "🐍 Python Performance Benchmarks" >&2
# pytest-benchmark
if command -v pytest &> /dev/null && ([ -f "pytest.ini" ] || [ -f "pyproject.toml" ]); then
run_timed_benchmark "pytest benchmarks" "pytest --benchmark-only --benchmark-json=/tmp/pytest_benchmark.json" 300
fi
# Python timeit benchmarks
if [ -f "benchmark.py" ]; then
run_timed_benchmark "Python benchmark.py" "python benchmark.py" 120
fi
# Memory profiling
if command -v python &> /dev/null && command -v pip &> /dev/null; then
run_timed_benchmark "Memory profiling" "python -c 'import psutil; print(f\"Memory usage: {psutil.virtual_memory().percent}%\")'" 10
fi
fi
# 3. Go Benchmarks
if [[ " ${PROJECT_TYPES[*]} " =~ " go " ]]; then
echo "🐹 Go Performance Benchmarks" >&2
if command -v go &> /dev/null; then
# Go test benchmarks
run_timed_benchmark "Go benchmarks" "go test -bench=. -benchmem" 180
# Build performance
run_timed_benchmark "Go build performance" "go build -o /tmp/go_build_test" 60
# Clean up
rm -f /tmp/go_build_test
fi
fi
# 4. Rust Benchmarks
if [[ " ${PROJECT_TYPES[*]} " =~ " rust " ]]; then
echo "🦀 Rust Performance Benchmarks" >&2
if command -v cargo &> /dev/null; then
# Cargo bench
run_timed_benchmark "Cargo benchmarks" "cargo bench" 300
# Build performance
run_timed_benchmark "Cargo build performance" "cargo build --release" 180
# Test performance
run_timed_benchmark "Cargo test performance" "cargo test" 120
fi
fi
# 5. Web Performance Benchmarks
echo "🌐 Web Performance Analysis" >&2
# Check if this looks like a web project
WEB_PROJECT=false
if [ -f "package.json" ] && grep -q '"next"\\|"react"\\|"vue"\\|"angular"\\|"express"\\|"koa"' package.json; then
WEB_PROJECT=true
elif [ -f "index.html" ] || [ -d "public" ] || [ -d "static" ]; then
WEB_PROJECT=true
fi
if [ "$WEB_PROJECT" = true ]; then
# Lighthouse audit (if available)
if command -v lighthouse &> /dev/null; then
# Check for running dev server
if curl -s http://localhost:3000 >/dev/null 2>&1; then
run_timed_benchmark "Lighthouse audit (localhost:3000)" "lighthouse http://localhost:3000 --output json --quiet --chrome-flags='--headless' --no-sandbox" 120
elif curl -s http://localhost:8080 >/dev/null 2>&1; then
run_timed_benchmark "Lighthouse audit (localhost:8080)" "lighthouse http://localhost:8080 --output json --quiet --chrome-flags='--headless' --no-sandbox" 120
else
report_benchmark "SKIP" "Lighthouse audit" "No local server detected"
fi
else
report_benchmark "SKIP" "Lighthouse audit" "Lighthouse not installed"
fi
# Bundle analyzer (if available)
if command -v npx &> /dev/null && [ -f "package.json" ]; then
if [ -d "dist" ] || [ -d "build" ] || [ -d ".next" ]; then
run_timed_benchmark "Bundle analysis" "npx webpack-bundle-analyzer --help >/dev/null && echo 'Bundle analyzer available'" 10
fi
fi
else
report_benchmark "SKIP" "Web performance" "Not a web project"
fi
# 6. Database Benchmarks
echo "🗄️ Database Performance Analysis" >&2
# Check for database connections
if [ -f ".env" ] && grep -q 'DATABASE_URL\\|DB_' .env; then
report_benchmark "INFO" "Database configuration detected"
# Simple connection test
if command -v psql &> /dev/null && grep -q 'postgres' .env 2>/dev/null; then
run_timed_benchmark "PostgreSQL connection test" "timeout 10s psql \"$(grep DATABASE_URL .env | cut -d'=' -f2)\" -c 'SELECT 1;'" 15
fi
if command -v mysql &> /dev/null && grep -q 'mysql' .env 2>/dev/null; then
run_timed_benchmark "MySQL connection test" "timeout 10s mysql --execute='SELECT 1;'" 15
fi
else
report_benchmark "SKIP" "Database benchmarks" "No database configuration found"
fi
# 7. Load Testing (if tools available)
echo "🔥 Load Testing" >&2
if command -v hyperfine &> /dev/null; then
# Hyperfine command benchmarks
if [ -f "package.json" ]; then
if jq -e '.scripts.start' package.json >/dev/null 2>&1; then
run_timed_benchmark "Command timing analysis" "hyperfine --warmup 1 'npm run start --version' 'npm run build --help'" 30
fi
fi
else
report_benchmark "SKIP" "Hyperfine benchmarks" "Hyperfine not installed"
fi
if command -v ab &> /dev/null; then
# Apache Bench (if server is running)
if curl -s http://localhost:3000 >/dev/null 2>&1; then
run_timed_benchmark "Apache Bench load test" "ab -n 100 -c 10 http://localhost:3000/" 60
fi
else
report_benchmark "SKIP" "Apache Bench" "ab not installed"
fi
# 8. Historical Comparison
echo "📈 Historical Performance Analysis" >&2
# Find previous benchmark reports
PREVIOUS_REPORTS=($(ls -t "$BENCHMARK_RESULTS_DIR"/benchmark-*.json 2>/dev/null | head -5))
if [ ${#PREVIOUS_REPORTS[@]} -gt 1 ]; then
LATEST_PREVIOUS="${PREVIOUS_REPORTS[1]}"
echo " 📊 Comparing with previous run: $(basename "$LATEST_PREVIOUS")" >&2
if [ -f "$LATEST_PREVIOUS" ] && command -v jq &> /dev/null; then
PREV_DURATION=$(jq -r '.total_duration // 0' "$LATEST_PREVIOUS" 2>/dev/null || echo "0")
if [ "$PREV_DURATION" -gt 0 ] && [ "$TOTAL_DURATION" -gt 0 ]; then
DURATION_DIFF=$((TOTAL_DURATION - PREV_DURATION))
PERCENT_CHANGE=$(echo "scale=1; $DURATION_DIFF * 100 / $PREV_DURATION" | bc -l 2>/dev/null || echo "0")
if [ "$DURATION_DIFF" -gt 0 ]; then
echo " ⬆️ Performance regression: +${PERCENT_CHANGE}% slower" >&2
elif [ "$DURATION_DIFF" -lt 0 ]; then
echo " ⬇️ Performance improvement: ${PERCENT_CHANGE#-}% faster" >&2
else
echo " ➡️ Performance unchanged" >&2
fi
fi
fi
else
echo " 📋 No previous benchmarks found for comparison" >&2
fi
# Complete JSON report
END_TIME=$(date +%s)
SESSION_DURATION=$((END_TIME - START_TIME))
cat >> "$REPORT_FILE" << EOF
],
"summary": {
"benchmarks_run": $BENCHMARKS_RUN,
"benchmarks_passed": $BENCHMARKS_PASSED,
"benchmarks_failed": $BENCHMARKS_FAILED,
"total_duration": $TOTAL_DURATION,
"session_duration": $SESSION_DURATION
},
"project_types": [$(printf '"%s",' "${PROJECT_TYPES[@]}" | sed 's/,$//')]
}
EOF
# 9. Generate Final Report
echo "" >&2
echo "📋 Performance Benchmark Summary" >&2
echo "================================" >&2
echo " 🏃 Benchmarks run: $BENCHMARKS_RUN" >&2
echo " ✅ Passed: $BENCHMARKS_PASSED" >&2
echo " ❌ Failed: $BENCHMARKS_FAILED" >&2
echo " ⏱️ Total benchmark time: ${TOTAL_DURATION}s" >&2
echo " 📊 Session duration: ${SESSION_DURATION}s" >&2
echo " 📄 Report saved: $REPORT_FILE" >&2
# Performance assessment
if [ "$BENCHMARKS_FAILED" -eq 0 ] && [ "$BENCHMARKS_PASSED" -gt 0 ]; then
echo " 🎉 Status: All benchmarks passed" >&2
elif [ "$BENCHMARKS_FAILED" -gt 0 ]; then
echo " ⚠️ Status: Some benchmarks failed" >&2
elif [ "$BENCHMARKS_RUN" -eq 0 ]; then
echo " ℹ️ Status: No benchmarks configured" >&2
else
echo " ❓ Status: Mixed results" >&2
fi
echo "" >&2
echo "💡 Performance Optimization Tips:" >&2
echo " • Run benchmarks regularly to catch regressions early" >&2
echo " • Set up CI/CD performance gates" >&2
echo " • Monitor Core Web Vitals for web applications" >&2
echo " • Profile memory usage and optimize bottlenecks" >&2
echo " • Use caching strategies to improve response times" >&2
echo " • Consider lazy loading and code splitting" >&2
echo "⚡ Performance benchmark report complete" >&2
exit 0
Complete hook script that performs performance benchmarking when session ends
#!/usr/bin/env bash
echo "⚡ Performance Benchmark Report" >&2
BENCHMARK_RESULTS_DIR=".performance-reports"
mkdir -p "$BENCHMARK_RESULTS_DIR"
TIMESTAMP=$(date +"%Y-%m-%d-%H-%M-%S")
REPORT_FILE="$BENCHMARK_RESULTS_DIR/benchmark-$TIMESTAMP.json"
if [ -f "package.json" ]; then
BENCHMARK_SCRIPTS=$(jq -r '.scripts | to_entries[] | select(.key | test("benchmark|perf")) | .key' package.json 2>/dev/null || echo "")
if [ -n "$BENCHMARK_SCRIPTS" ]; then
echo "$BENCHMARK_SCRIPTS" | while read script; do
echo "🏃 Running: npm run $script" >&2
START_TIME=$(date +%s)
if npm run "$script" >/dev/null 2>&1; then
END_TIME=$(date +%s)
DURATION=$((END_TIME - START_TIME))
echo "✅ PASS: npm run $script (${DURATION}s)" >&2
else
echo "❌ FAIL: npm run $script" >&2
fi
done
fi
fi
echo "📄 Report saved: $REPORT_FILE" >&2
exit 0
Enhanced hook script for Lighthouse web performance auditing with Core Web Vitals
#!/usr/bin/env bash
if [ -f "package.json" ]; then
if command -v lighthouse &> /dev/null; then
if curl -s http://localhost:3000 >/dev/null 2>&1; then
echo "🌐 Running Lighthouse audit..." >&2
START_TIME=$(date +%s)
if lighthouse http://localhost:3000 --output json --quiet --chrome-flags='--headless --no-sandbox' > /tmp/lighthouse.json 2>&1; then
END_TIME=$(date +%s)
DURATION=$((END_TIME - START_TIME))
PERFORMANCE_SCORE=$(jq -r '.categories.performance.score * 100' /tmp/lighthouse.json 2>/dev/null || echo "0")
LCP=$(jq -r '.audits["largest-contentful-paint"].numericValue' /tmp/lighthouse.json 2>/dev/null || echo "0")
CLS=$(jq -r '.audits["cumulative-layout-shift"].numericValue' /tmp/lighthouse.json 2>/dev/null || echo "0")
echo "✅ Lighthouse audit completed (${DURATION}s)" >&2
echo " 📊 Performance Score: $PERFORMANCE_SCORE" >&2
echo " 📊 LCP: ${LCP}ms" >&2
echo " 📊 CLS: $CLS" >&2
fi
rm -f /tmp/lighthouse.json
fi
fi
fi
exit 0
Enhanced hook script for Go performance benchmarking with go test -bench
#!/usr/bin/env bash
if [ -f "go.mod" ] && command -v go &> /dev/null; then
echo "🐹 Running Go benchmarks..." >&2
START_TIME=$(date +%s)
BENCH_OUTPUT="/tmp/go_bench_$$"
if go test -bench=. -benchmem > "$BENCH_OUTPUT" 2>&1; then
END_TIME=$(date +%s)
DURATION=$((END_TIME - START_TIME))
BENCH_COUNT=$(grep -c '^Benchmark' "$BENCH_OUTPUT" 2>/dev/null || echo "0")
echo "✅ Go benchmarks completed (${DURATION}s)" >&2
echo " 📊 Benchmarks run: $BENCH_COUNT" >&2
head -10 "$BENCH_OUTPUT" | while read line; do
echo " $line" >&2
done
else
echo "❌ Go benchmarks failed" >&2
fi
rm -f "$BENCH_OUTPUT"
fi
exit 0
Enhanced hook script for historical benchmark comparison and trend analysis
#!/usr/bin/env bash
BENCHMARK_RESULTS_DIR=".performance-reports"
PREVIOUS_REPORTS=($(ls -t "$BENCHMARK_RESULTS_DIR"/benchmark-*.json 2>/dev/null | head -2))
if [ ${#PREVIOUS_REPORTS[@]} -gt 1 ]; then
LATEST_PREVIOUS="${PREVIOUS_REPORTS[1]}"
CURRENT_REPORT="${PREVIOUS_REPORTS[0]}"
if [ -f "$LATEST_PREVIOUS" ] && [ -f "$CURRENT_REPORT" ] && command -v jq &> /dev/null; then
PREV_DURATION=$(jq -r '.summary.total_duration // 0' "$LATEST_PREVIOUS" 2>/dev/null || echo "0")
CURR_DURATION=$(jq -r '.summary.total_duration // 0' "$CURRENT_REPORT" 2>/dev/null || echo "0")
if [ "$PREV_DURATION" -gt 0 ] && [ "$CURR_DURATION" -gt 0 ]; then
DURATION_DIFF=$((CURR_DURATION - PREV_DURATION))
PERCENT_CHANGE=$(echo "scale=1; $DURATION_DIFF * 100 / $PREV_DURATION" | bc -l 2>/dev/null || echo "0")
echo "📈 Performance Comparison:" >&2
echo " Previous: ${PREV_DURATION}s" >&2
echo " Current: ${CURR_DURATION}s" >&2
if [ "$DURATION_DIFF" -gt 0 ]; then
echo " ⬆️ Regression: +${PERCENT_CHANGE}% slower" >&2
elif [ "$DURATION_DIFF" -lt 0 ]; then
echo " ⬇️ Improvement: ${PERCENT_CHANGE#-}% faster" >&2
else
echo " ➡️ Unchanged" >&2
fi
fi
fi
fi
exit 0
Increase timeout in hookConfig: timeout: 300000 for 5 minutes. Reduce benchmark scope by skipping slow tests. Use timeout 120s wrapper around individual benchmark commands to prevent single test blocking. Verify benchmark duration. Test with various timeout values.
Check script existence: jq -e '.scripts.benchmark' package.json before execution. Add fallback: if ! jq -e '.scripts.benchmark' package.json; then echo 'No benchmark script'; exit 0; fi. Skip gracefully instead of failing. Verify package.json structure. Test with various script names.
Install Chrome/Chromium: brew install chromium on macOS or apt-get install chromium-browser on Linux. Set CHROME_PATH environment variable. Use --chrome-flags='--headless --no-sandbox' for CI environments. Verify Chrome installation. Test with various Chrome configurations.
Validate JSON before parsing: jq empty "$REPORT_FILE" 2>/dev/null || continue. Handle malformed reports gracefully. Add schema version field to new reports: {"schema_version": "1.0", ...}. Verify JSON structure. Test with various report formats.
Check exit status context if available. Add conditional execution: [ -f .benchmark-enabled ] || exit 0. Create .benchmark-enabled flag only when user explicitly requests benchmarking to avoid unnecessary runs. Verify hook execution conditions. Test with various session states.
Verify Go test files exist: find . -name '*_test.go'. Check go.mod location. Ensure benchmark functions use Benchmark prefix: func BenchmarkFunction(b *testing.B). Verify Go project structure. Test with various Go test configurations.
Install pytest-benchmark: pip install pytest-benchmark. Verify pytest installation: pytest --version. Check pytest.ini or pyproject.toml configuration. Ensure benchmark tests use @pytest.mark.benchmark decorator. Verify Python environment. Test with various pytest configurations.
Install webpack-bundle-analyzer: npm install --save-dev webpack-bundle-analyzer. Verify webpack configuration. Check for dist/ or build/ directories. Ensure build is completed before analysis. Verify bundle analyzer configuration. Test with various webpack setups.
Show that Performance Benchmark Report - Hooks is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.
[](https://heyclau.de/entry/hooks/performance-benchmark-report)Performance Benchmark Report - Hooks side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
| Field | Runs performance benchmarks and generates comparison report when session ends. Open dossier | Monitors application performance metrics, identifies bottlenecks, and provides optimization recommendations. Open dossier | Collects and reports detailed metrics about the coding session when Claude stops. Open dossier | Generates a comprehensive test coverage report when the coding session ends. Open dossier |
|---|---|---|---|---|
| Next steps | ||||
| Trust | ||||
| Review status | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed |
| Package trust | Package not verified | Package not verified | Package not verified | Package not verified |
| Source provenance | Source-backed | Source-backed | Source-backed | Source-backed |
| Submitter | — | — | — | — |
| Install risk | Review first | Review first | Review first | Review first |
| Notes | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ |
| Brand | — | — | — | — |
| Category | hooks | hooks | hooks | hooks |
| Source | source-backed | source-backed | source-backed | source-backed |
| Author | JSONbored | JSONbored | JSONbored | JSONbored |
| Added | 2025-09-19 | 2025-09-16 | 2025-09-19 | 2025-09-19 |
| Platforms | Claude Code | Claude Code | Claude Code | Claude Code |
| Source repo | — | — | — | — |
| Safety notes | ✓Runs as part of an automated hook or local workflow; test on a disposable branch before enabling it on write or blocking paths. Review generated reports, file edits, benchmark output, or shell commands before treating hook output as a merge or release gate. | ✓Runs as part of an automated hook or local workflow; test on a disposable branch before enabling it on write or blocking paths. Review generated reports, file edits, benchmark output, or shell commands before treating hook output as a merge or release gate. | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. |
| Privacy notes | ✓Hook inputs and reports can include repository paths, markdown content, benchmark results, lint findings, environment details, or CI logs. Redact private URLs, tokens, customer data, and proprietary file contents before publishing hook output. | ✓Hook inputs and reports can include repository paths, markdown content, benchmark results, lint findings, environment details, or CI logs. Redact private URLs, tokens, customer data, and proprietary file contents before publishing hook output. | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. |
| Prerequisites | — none listed | — none listed | — none listed | — none listed |
| Install | | | | |
| Config | | | | |
| Citations | ||||
| Claim | Unclaimed | Unclaimed | Unclaimed | Unclaimed |
Source-backed guides for putting this to work.
Control MCP tool output size with env limits, annotations, and tool search to protect Claude Code context.
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.