Defined in hooks/hooks.json
{
"Stop": [
{
"hooks": [
{
"type": "prompt",
"prompt": "🌐 BROWSER AUTOMATION FINAL CHECK\n\nContext: $ARGUMENTS\n\nPerform final validation of browser automation changes:\n\n✅ CONFIRM:\n1. All browser resources cleaned up properly\n2. No resource leaks (browser processes, contexts)\n3. Error handling comprehensive\n4. Tests are reliable (not flaky)\n5. Safe navigation only (trusted domains)\n6. No hardcoded credentials\n7. Proper wait strategies used (no sleep())\n8. Selectors are stable and maintainable\n\n❌ BLOCK if:\n- Resource cleanup missing (browser.close(), context.close())\n- Unsafe navigation detected\n- Hardcoded credentials found\n- Using time.sleep() or setTimeout() instead of proper waits\n- Tests are flaky or have race conditions\n- Error handling inadequate\n\n💡 For non-browser-automation work, approve immediately.\n\nReturn JSON:\n{\n \"decision\": \"approve\" or \"block\",\n \"reason\": \"Browser automation quality summary with any issues or approval confirmation\"\n}",
"timeout": 30
}
]
}
],
"PreToolUse": [
{
"hooks": [
{
"type": "prompt",
"prompt": "🌐 BROWSER AUTOMATION SAFETY VALIDATOR\n\nContext: $ARGUMENTS\n\nYou are validating browser automation code for safety and reliability. Be thorough - unsafe automation can cause security issues or flaky tests.\n\n1️⃣ SAFE NAVIGATION\n - Only navigating to trusted domains?\n - No user-controlled URLs without validation?\n - HTTPS used for sensitive operations?\n - No navigation to malicious/suspicious sites?\n ⚠️ BLOCK if unsafe navigation detected\n\n2️⃣ RESOURCE CLEANUP\n - Browser instances properly closed?\n - Context cleanup in finally blocks?\n - Page.close() called when done?\n - No leaked browser processes?\n - Proper use of context managers (async with)?\n ⚠️ BLOCK if resource leaks possible\n\n3️⃣ ERROR HANDLING\n - Timeouts configured appropriately?\n - Network errors handled gracefully?\n - Element not found exceptions caught?\n - Screenshots on failure for debugging?\n - Retry logic for flaky operations?\n ⚠️ BLOCK if error handling inadequate\n\n4️⃣ WAIT STRATEGIES\n - Explicit waits used (not sleep())?\n - Wait for elements to be visible/clickable?\n - Network idle waits for dynamic content?\n - Reasonable timeout values (not too long)?\n - No arbitrary time.sleep() or setTimeout()?\n ⚠️ BLOCK if using sleep() instead of proper waits\n\n5️⃣ SELECTOR QUALITY\n - Stable selectors used (not fragile CSS)?\n - Data attributes for test selectors?\n - No absolute XPath (prefer relative)?\n - Selectors documented/named clearly?\n ⚠️ WARN if selectors are brittle\n\n6️⃣ DATA SECURITY\n - No hardcoded credentials?\n - Sensitive data from environment variables?\n - No logging of passwords/tokens?\n - Screenshot sanitization for sensitive data?\n ⚠️ BLOCK if credentials hardcoded\n\n7️⃣ PERFORMANCE\n - Headless mode for CI/tests?\n - Appropriate viewport sizes?\n - Resource blocking for faster tests (images, fonts)?\n - Parallel execution considered?\n - No unnecessary page loads?\n\n8️⃣ RELIABILITY\n - Tests isolated (no shared state)?\n - Fresh browser context per test?\n - Network mocking for external APIs?\n - No race conditions?\n - Deterministic test data?\n ⚠️ BLOCK if tests are flaky\n\n9️⃣ ACCESSIBILITY\n - Using semantic selectors when possible?\n - ARIA labels for element selection?\n - Accessibility testing included?\n - Screen reader compatibility considered?\n\n🔟 FRAMEWORK BEST PRACTICES\n - Playwright/Selenium/Puppeteer used correctly?\n - Page Object Model pattern followed?\n - Helper functions for common actions?\n - Configuration externalized?\n\n🚫 BLOCK if unsafe navigation or credential issues.\n🚫 BLOCK if resource cleanup missing.\n🚫 BLOCK if using sleep() instead of proper waits.\n\nReturn JSON:\n{\n \"decision\": \"approve\" or \"block\",\n \"reason\": \"Detailed browser automation safety assessment with specific issues if blocking, or safety confirmation if approving\"\n}",
"timeout": 30
}
],
"matcher": "Write|Edit"
}
]
}{
"riskFlags": {
"touchesBash": false,
"matchAllTools": false,
"touchesFileWrites": true
},
"typeStats": {
"prompt": 2
},
"eventStats": {
"Stop": 1,
"PreToolUse": 1
},
"originCounts": {
"absolutePaths": 0,
"pluginScripts": 0,
"projectScripts": 0
},
"timeoutStats": {
"commandsWithoutTimeout": 0
}
}