Skip to main content
hook

notify-before-bash — Claude Code hook: what it does, how to install

Prints a terminal notice before Claude Code executes any Bash command. Useful for keeping an eye on shell activity during coding sessions.

Install into Claude Code · claude-code-templates All methods and platforms ↓
npx claude-code-templates@latest --hook pre-tool/notify-before-bash
Open on GitHub

What notify-before-bash does

This hook hooks into the PreToolUse event for the Bash tool. Every time Claude prepares to run a terminal instruction, it prints 🔔 About to run bash command... to stdout.

The action runs a plain shell echo configured directly in JSON. Because it depends on nothing outside your existing environment, setup takes only a few seconds.

The hook merely prints a message to your screen without parsing arguments or halting execution.

What it helps with

  • spot shell command attempts before they run
  • keep track of Claude Code accessing the operating system terminal
  • monitor command executions visually during automated workflows

Example prompts for the agent

  • Run the test suite with npm test
  • Check current disk usage in this directory

How to install notify-before-bash

1claude-code-templates

npx claude-code-templates@latest --hook pre-tool/notify-before-bash

2Manually: put the files in place

.claude/settings.json

The hooks block: event (PreToolUse, PostToolUse, Stop…) → command. Personal ones go to ~/.claude/settings.json

Step by step, with commands for each platform: Claude Code hooks: what they are, where to configure them, how to block a risky command

Questions about notify-before-bash

How to install notify-before-bash in Claude Code?

Run npx claude-code-templates@latest --hook pre-tool/notify-before-bash or insert the hook settings directly into .claude/settings.json.

What does notify-before-bash do?

It intercepts the PreToolUse event for Bash and echoes an alert line right before Claude executes the command.

Does notify-before-bash block dangerous operations?

No, it only prints a notification string and does not inspect or abort command execution.

Source text

notify-before-bash.json · MIT
{
  "description": "Show notification before any Bash command execution for security awareness. This hook displays a simple echo message '🔔 About to run bash command...' before Claude executes any bash command, giving you visibility into when system commands are about to run. Useful for monitoring and auditing command execution.",
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "echo '🔔 About to run bash command...'"
          }
        ]
      }
    ]
  }
}

© davila7 · MIT · davila7/claude-code-templates

Similar hooks

All hooks for Security →

From the same set804

The whole set →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor