Notify Before Watcher
Streamline your workflow with this show, notification, before, bash. Includes structured workflows, validation checks, and reusable patterns for pre tool.
Notify Before Watcher
Displays a notification before any Bash command execution, providing visibility into when system commands are about to run during Claude Code sessions.
When to Use This Hook
Attach this hook when you need to:
- Maintain awareness of every shell command Claude executes for security auditing
- Create a log trail of command execution timing for compliance or debugging
- Provide a visual checkpoint before potentially impactful system commands run
Consider alternatives when:
- You have comprehensive logging at the shell level (e.g., auditd or shell history logging)
- The notification noise outweighs the security benefit for your workflow
Quick Start
Configuration
name: notify-before-watcher type: hook trigger: PreToolUse category: pre-tool
Example Trigger
# Hook triggers before any Bash command execution claude> Run npm install # Notification appears before the command runs
Example Output
About to run bash command...
Command: npm install
Working directory: /home/user/project
Timestamp: 2026-03-15T10:23:45Z
Core Concepts
Notification Scope Overview
| Aspect | Details |
|---|---|
| Trigger | Every Bash tool invocation |
| Timing | Pre-execution (before command runs) |
| Output | Simple echo notification to stdout |
| Blocking | Non-blocking, does not prevent execution |
| Overhead | Negligible (single echo command) |
Notification Workflow
Bash Tool Invoked
|
Echo Notification
|
Command Executes
|
Output Returned
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
matcher | string | "Bash" | Tool type that triggers the notification |
show_command | boolean | false | Include the actual command in the notification |
show_timestamp | boolean | false | Add ISO timestamp to the notification |
show_directory | boolean | false | Show working directory in notification |
log_to_file | string | "" | Optional file path to append notifications |
Best Practices
-
Keep Notifications Minimal - The default single-line notification adds awareness without clutter. Only enable extra details (command, timestamp, directory) when actively auditing or debugging.
-
Log to File for Audit Trails - For compliance environments, configure
log_to_fileto append every command notification to a persistent log. This creates an auditable record independent of terminal scrollback. -
Combine with Dangerous Command Blocker - Use the notification hook alongside a command blocker for a two-layer defense: notification gives visibility, blocker prevents harmful commands. Together they provide awareness and protection.
-
Extend to Other Tool Types - While Bash is the primary security concern, consider adding matchers for
WriteandEditto see all file system modifications, not just command executions. -
Use Color Coding for Severity - Enhance the notification with ANSI color codes to distinguish routine commands (green) from potentially impactful ones (yellow for installs, red for deletions).
Common Issues
-
Notification Fatigue - In active sessions, dozens of Bash invocations create repetitive notifications. Use
silent_passor filter to only notify on commands matching specific patterns. -
Terminal Buffer Pollution - Excessive notifications push useful output out of the visible terminal buffer. Keep messages to a single line and consider a compact format for high-frequency sessions.
-
Missing Command Context - The default notification does not show what command is about to run. Enable
show_commandto make the notification actionable rather than just informational.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Pre-Commit Security Scanner
Pre-commit hook that scans staged files for hardcoded secrets, API keys, passwords, and sensitive data patterns before allowing commits.
Agents Md Watcher
Streamline your workflow with this automatically, loads, agents, configuration. Includes structured workflows, validation checks, and reusable patterns for automation.
Automated Build Inspector
Boost productivity using this automatically, trigger, build, processes. Includes structured workflows, validation checks, and reusable patterns for automation.