Defined in hooks/hooks.json
{
"Stop": [
{
"hooks": [
{
"type": "prompt",
"prompt": "📊 PERFORMANCE REGRESSION DETECTOR\n\nContext: $ARGUMENTS\n\nAnalyze code changes for performance regressions and observability:\n\n1️⃣ N+1 QUERY DETECTION\n - Queries inside loops?\n - Multiple database calls for related data?\n - Missing eager loading (JOIN/prefetch)?\n - Should use batch queries?\n ⚠️ BLOCK if N+1 queries detected\n\n2️⃣ ALGORITHMIC EFFICIENCY\n - Nested loops over large datasets?\n - O(n²) or worse complexity?\n - More efficient algorithm available?\n - Large array operations in tight loops?\n ⚠️ BLOCK if inefficient algorithms\n\n3️⃣ MEMORY LEAKS & RESOURCE MANAGEMENT\n - Proper cleanup in finally blocks?\n - Context managers used (with statements)?\n - File handles/connections closed?\n - Event listeners removed?\n - Cache expiration configured?\n ⚠️ BLOCK if resource leaks possible\n\n4️⃣ DATABASE PERFORMANCE\n - Missing indices for query filters?\n - Full table scans likely?\n - Proper use of indices?\n - Query pagination for large results?\n ⚠️ BLOCK if missing critical indices\n\n5️⃣ API EFFICIENCY\n - Excessive API calls?\n - Missing request batching?\n - No caching for repeated requests?\n - Missing rate limiting considerations?\n ⚠️ WARN if API inefficiency\n\n6️⃣ OBSERVABILITY INSTRUMENTATION\n - Critical operations have metrics?\n - Error rates tracked?\n - Latency metrics present?\n - Proper log levels used?\n - Distributed tracing IDs?\n ✅ APPROVE if well-instrumented\n\n7️⃣ PERFORMANCE MONITORING\n - Slow operations logged/tracked?\n - Performance budgets considered?\n - SLO/SLA compliance checked?\n ⚠️ WARN if monitoring gaps\n\n8️⃣ CACHING STRATEGY\n - Appropriate caching used?\n - Cache invalidation correct?\n - Cache keys well-designed?\n - TTL values reasonable?\n\n9️⃣ ASYNC/PARALLEL OPTIMIZATION\n - Async/await used for I/O?\n - Parallel processing where applicable?\n - Not blocking event loop?\n - Worker pools sized appropriately?\n\n🔟 SCALABILITY CONCERNS\n - Will scale to 10x current load?\n - No hardcoded limits?\n - Handles concurrent requests?\n - Database connection pooling?\n\n🚫 BLOCK if performance regressions detected.\n🚫 BLOCK if critical monitoring missing.\n⚠️ WARN for minor performance concerns.\n\nReturn JSON:\n{\n \"decision\": \"approve\" or \"block\",\n \"reason\": \"Detailed performance analysis with specific issues (line numbers, complexity estimates) if blocking, or performance confirmation if approving\"\n}",
"timeout": 30
}
]
}
],
"PostToolUse": [
{
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/scripts/analyze-performance.sh",
"timeout": 45
}
],
"matcher": "Write|Edit"
}
]
}{
"riskFlags": {
"touchesBash": false,
"matchAllTools": false,
"touchesFileWrites": true
},
"typeStats": {
"prompt": 1,
"command": 1
},
"eventStats": {
"Stop": 1,
"PostToolUse": 1
},
"originCounts": {
"absolutePaths": 0,
"pluginScripts": 1,
"projectScripts": 0
},
"timeoutStats": {
"commandsWithoutTimeout": 0
}
}