hooksSource-backedReview first Safety · Privacy ·
Performance Monitor - Hooks
Monitors application performance metrics, identifies bottlenecks, and provides optimization recommendations.
by JSONbored·added 2025-09-16·
Claude Code
HarnessClaude Code
Trigger:Stop
Review first — review before installing
Open the source and read safety notes before installing.
Schema details
- Install type
- cli
- Reading time
- 4 min
- Difficulty score
- 0
- Troubleshooting
- Yes
- Breaking changes
- No
Runtime and command metadata
- Trigger
- Stop
- Script language
- bash
Script body
#!/bin/bash
echo "🔍 Performance Monitor - Analyzing system performance..."
echo "📊 Monitoring Areas:"
echo " • Application Performance Metrics"
echo " • Database Performance"
echo " • Frontend Performance (Web Vitals)"
echo " • Infrastructure Monitoring"
if command -v node >/dev/null 2>&1; then
echo "✓ Node.js available for performance profiling"
fi
if command -v lighthouse >/dev/null 2>&1; then
echo "✓ Lighthouse available for web performance"
fi
if command -v artillery >/dev/null 2>&1; then
echo "✓ Artillery available for load testing"
fi
echo "💻 System Performance:"
if command -v free >/dev/null 2>&1; then
mem_usage=$(free | grep Mem | awk '{printf "%.2f", $3/$2 * 100.0}')
echo " Memory Usage: ${mem_usage}%"
fi
disk_usage=$(df / | tail -1 | awk '{print $5}' | sed 's/%//')
echo " Disk Usage: ${disk_usage}%"
echo "💡 Performance Recommendations:"
echo " • Implement response time tracking for API endpoints"
echo " • Set up Web Vitals monitoring for frontend performance"
echo " • Monitor database query performance"
echo " • Set up automated performance testing"
echo "🎯 Performance monitor analysis complete!"
exit 0Full copyable content
{
"hooks": {
"Stop": [
{
"matchers": [
"*"
],
"description": "Monitor performance metrics and provide optimization insights"
}
]
},
"scriptContent": "#!/bin/bash\n\necho \"🔍 Performance Monitor - Analyzing system performance...\"\n\n# Performance monitoring areas\necho \"📊 Monitoring Areas:\"\necho \" • Application Performance Metrics\"\necho \" • Database Performance\"\necho \" • Frontend Performance (Web Vitals)\"\necho \" • Infrastructure Monitoring\"\necho \" • Automated Performance Testing\"\n\n# Check if performance tools are available\ncommand -v node >/dev/null 2>&1 && echo \"✓ Node.js available for performance profiling\"\ncommand -v lighthouse >/dev/null 2>&1 && echo \"✓ Lighthouse available for web performance\"\ncommand -v artillery >/dev/null 2>&1 && echo \"✓ Artillery available for load testing\"\n\n# System performance check\necho \"\"\necho \"💻 System Performance:\"\n\n# Memory usage\nif command -v free >/dev/null 2>&1; then\n mem_usage=$(free | grep Mem | awk '{printf \"%.2f\", $3/$2 * 100.0}')\n echo \" Memory Usage: ${mem_usage}%\"\n if (( $(echo \"$mem_usage > 85\" | bc -l) 2>/dev/null )); then\n echo \" 🚨 High memory usage detected!\"\n fi\nfi\n\n# Disk usage\ndisk_usage=$(df / | tail -1 | awk '{print $5}' | sed 's/%//')\necho \" Disk Usage: ${disk_usage}%\"\nif (( disk_usage > 90 )); then\n echo \" 🚨 High disk usage detected!\"\nfi\n\n# Load average\nif command -v uptime >/dev/null 2>&1; then\n load_avg=$(uptime | awk -F'load average:' '{print $2}' | awk '{print $1}' | sed 's/,//')\n echo \" Load Average: $load_avg\"\nfi\n\n# Performance monitoring recommendations\necho \"\"\necho \"💡 Performance Recommendations:\"\necho \" • Implement response time tracking for API endpoints\"\necho \" • Set up Web Vitals monitoring for frontend performance\"\necho \" • Monitor database query performance\"\necho \" • Set up automated performance testing\"\necho \" • Configure performance alerts and thresholds\"\necho \" • Use profiling tools for bottleneck identification\"\necho \" • Implement performance budgets for builds\"\n\necho \"\"\necho \"📋 Next Steps:\"\necho \" 1. Set up performance monitoring dashboards\"\necho \" 2. Configure performance alerts\"\necho \" 3. Implement automated performance testing\"\necho \" 4. Review and optimize identified bottlenecks\"\n\necho \"\"\necho \"🎯 Performance monitor analysis complete!\"\necho \"📊 Use monitoring data to drive optimization decisions\"\n\nexit 0"
}About this resource
Features
- Application performance tracking including API response time tracking (endpoint response time measurement with millisecond precision, slow endpoint identification with threshold-based filtering, response time statistics with percentile analysis P50/P95/P99, average response time calculation), memory usage monitoring (memory consumption tracking with real-time monitoring, memory leak detection with growth pattern analysis, memory growth analysis with trend tracking), CPU usage monitoring (CPU utilization tracking with core-specific analysis, CPU bottleneck identification with process-specific tracking, process-specific CPU analysis with resource attribution), and application performance metrics (request throughput measurement, error rates tracking, latency percentiles with statistical analysis)
- Database query optimization including query performance analysis (slow query detection with threshold-based filtering and configurable thresholds, query execution time measurement with millisecond precision, query plan analysis with EXPLAIN integration), index recommendations (missing index detection with WHERE clause analysis, index usage analysis with index utilization tracking, index optimization suggestions with index creation recommendations), query optimization suggestions (query rewriting recommendations for better performance, batch query suggestions for N+1 query prevention, N+1 query detection with loop and query pattern matching), and database performance metrics (connection pool metrics monitoring, transaction metrics tracking, query cache metrics analysis)
- Frontend performance monitoring including Web Vitals tracking (Largest Contentful Paint LCP measurement with real-time tracking, First Input Delay FID measurement with interaction latency analysis, Cumulative Layout Shift CLS measurement with layout stability tracking, First Contentful Paint FCP measurement with initial render tracking, Time to Interactive TTI measurement with interactivity analysis), render blocking resource detection (CSS blocking resources with @import and detection, JavaScript blocking resources with
Content outline
- Features
- Use Cases
- Installation
- Config paths
- Requirements
- Hook Configuration
- Hook Script
- Examples
- Hook Configuration
- System Resource Monitoring
- Web Vitals Tracking with Lighthouse
- Bundle Size Analysis
- Troubleshooting
- Memory usage calculation fails on macOS systems
- bc command not found error on minimal systems
- Lighthouse or Artillery tools not detected
#performance#monitoring#optimization#metrics#automation
Source citations
Signals
Loading live community signals…
More like this, weekly
A short, calm digest of reviewed Claude resources. Unsubscribe any time.