claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Feature: Sound notifications

Open Heilemann opened this issue 7 months ago • 15 comments

Windsurf has a feature you can enable to have it play a ding sound when it's done thinking and it's the user's turn. This is great, especially if it's easy to turn on and off, and even more so now that Opus allows for very long turns (I'm currently 1091 seconds into a run right now), so I know when to turn my attention back to it.

Heilemann avatar May 24 '25 13:05 Heilemann

the same for VScode. terminal in vscode not playing a sound when Claude Code done with something despite me turning alert sounds on. it works in regular (non-vscode terminal though).

Image

mehdifanai avatar May 25 '25 04:05 mehdifanai

For me it does not work either in vscode or in native MacOS terminal. Tried both "auto", "terminal_bell" and even claude config set --global preferredNotifChannel "\a" claude config set --global preferredNotifChannel "afplay /System/Library/Sounds/Ping.aiff"

SKALO-SE avatar May 25 '25 07:05 SKALO-SE

yeah and plz also support email / text notification if possible

onjas-6 avatar May 25 '25 09:05 onjas-6

Could we add an option to execute a user-defined script when a task completes or needs confirmation? This would let developers create personalized notifications (e.g., email, SMS).

Currently, relying solely on terminal alerts presents challenges. They can be cumbersome to configure, sometimes don't work reliably, and can also be disruptive. For instance, if a user customizes the alert sound to be louder, it might trigger frequently for minor errors (like typos), causing unnecessary noise.

Script execution would offer greater flexibility, bypassing these limitations and giving users better control over their notification preferences.

arrrggghhh avatar May 27 '25 11:05 arrrggghhh

I'd like to second @arrrggghhh's proposal here, running a bash command or similar would be much more flexible.

smythp avatar Jun 02 '25 16:06 smythp

Second this, the bell feature isn't working for me on Kubuntu 24's native terminal, when e.g. printf '\a' makes a bell sound just fine.

Datamine avatar Jun 03 '25 05:06 Datamine

I got it working in MacOS and vscode. vscode: "accessibility.signals.terminalBell": { "sound": "on" "terminal.integrated.enableVisualBell": true

Claude Code config set to terminal_bell

SKALO-SE avatar Jun 06 '25 13:06 SKALO-SE

I managed to get it working using @SKALO-SE's method. Thank you so much! However, I can't forget the exciting notification sound from RooCode. I'd be really happy if more fun sounds could be implemented in the future.

km-tr avatar Jun 12 '25 15:06 km-tr

Older similar issue: https://github.com/anthropics/claude-code/issues/104

MartinKavik avatar Jun 15 '25 10:06 MartinKavik

terminal_bell setting does not ever cause a notification to be emitted even though running echo -e "\a" from bash mode within claude code in same context works fine.

dwymark-celestron avatar Jun 17 '25 21:06 dwymark-celestron

Running echo -e "\a" in WSL2 on Windows works. After launching claude in the same window it does not anymore. Is a fix planned?

anose001 avatar Jun 19 '25 05:06 anose001

Would love to be able to customize the sound, any idea on how to do that?

McGowanC avatar Jun 23 '25 17:06 McGowanC

Does anyone here know if we can use this notification channel to call an mcp tool? Ideally, I'd like to setup such that when a task is complete, a slack message is sent, via mcp.

PastaPastaPasta avatar Jun 25 '25 18:06 PastaPastaPasta

If they introduced the "run arbitrary commad" concept, you could do this. As it stands, no.

smythp avatar Jun 25 '25 21:06 smythp

@PastaPastaPasta you can do it instructing Claude in CLAUDE.md to perform a command ALWAYS after it finishes however this will burn some ammount of tokens.

lcarrasco avatar Jun 26 '25 20:06 lcarrasco

This would really improve my workflow if possible to fix!

  • On WezTerm, [email protected]
  • Manual echo -e "\a" triggers a bell sound
  • Setting claude config set --global preferredNotifChannel terminal_bell doesn't trigger on Claude complete
    • (FWIW, setting the terminal_bell option in the /config UI doesn't fix it either)

zazer0 avatar Jul 02 '25 12:07 zazer0

Sounds like this ticket can be closed because you can handle it with hooks, no? https://docs.anthropic.com/en/docs/claude-code/hooks#notification-2

kylemh avatar Jul 02 '25 13:07 kylemh

I think there should still be a feature here and they can use hooks under the hood? Plus none of the included options work (or only flakily in specific circumstances). If they want to rip out this feature entirely, then fine, close the issue, but that work hasn't been done.

smythp avatar Jul 03 '25 15:07 smythp

+1 towards solving this with hooks. Currently experimenting with:

"Stop": [
  {
    "matcher": "",
    "hooks": [
      {
        "type": "command",
        "command": "afplay /System/Library/Sounds/Glass.aiff"
      }
    ]
  }
],
"Notification": [
  {
    "matcher": "",
    "hooks": [
      {
        "type": "command",
        "command": "afplay /System/Library/Sounds/Submarine.aiff"
      }
    ]
  }
]

alex-orlovskyi avatar Jul 06 '25 12:07 alex-orlovskyi

Here is how I got it working.

First step: deciding on a notification command

First, you need to know the command you want to run in order to receive a notification.

It could be a cURL request to ntfy.sh, or a command that shows a notification on your laptop.

For my use case, I decided to show a notification on my laptop.

Here is my command:

notify-send --app-name="Claude Code" --icon /home/clouedoc/Pictures/claude.png --urgency normal "Claude Code" "Needs your attention"

Do note that notify-send is specific to Linux (as far as I know).

I downloaded an icon of Claude to illustrate my notification :-)

Second step: setting up the hooks

  1. Open Claude code
  2. Type /hooks
  3. Add a hook on the "Stop" hook, set the command that you picked (or copy mine above). Same with the "Notification" hook. Save them as user configuration
  4. Done!

Here is how it looks on my system (with Mako as a notification daemon):

Image

clouedoc avatar Jul 07 '25 04:07 clouedoc

Just created similar workaround to @clouedoc with https://github.com/julienXX/terminal-notifier

    "Stop": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "terminal-notifier -group 'PROJECT_NAME' -title 'Claude Code Stopped' -subtitle \"Event: $CLAUDE_EVENT_TYPE\" -message \"Last tool: ${CLAUDE_TOOL_NAME:-N/A} | Files: $(echo \"$CLAUDE_FILE_PATHS\" | wc -w | tr -d ' ')\" -sound Glass"
          }
        ]
      }
    ]

Appears on mac like this:

Image

alex-orlovskyi avatar Jul 07 '25 15:07 alex-orlovskyi

Thanks for the hint with terminal-notifier, @clouedoc!

I use this for managing the hook via nix + home-manager:

".claude/settings.json".text = builtins.toJSON {
  hooks = {
    Stop = [
      {
        matcher = ".*";
        hooks = [
          {
            type = "command";
            command = ''${pkgs.terminal-notifier}/bin/terminal-notifier -title "Claude Code" -message "Task completed""'';
          }
        ];
      }
    ];
  };
};

felixzieger avatar Jul 18 '25 13:07 felixzieger

the bell notification is working for me using WSL devcontainers. You need to adjust the vscode settings, add the claude notification bell setting, and then you need to NOT be focused on the claude code window when it completes.

vscode settings:

"terminal.integrated.enableVisualBell": true,
  "accessibility.signals.terminalBell": {
    "sound": "on",
    "announcement": "auto",
  },

Edit: at the same time I did the above, I also added a Stop hook .py script that (attempts) to output the user's latest prompts. So if just changing the above settings doesn't work, maybe also add a hook.

jasonswearingen avatar Jul 23 '25 02:07 jasonswearingen

Thank you for the suggestion! You can either use preferredNotifChannel (https://docs.anthropic.com/en/docs/claude-code/settings) or hooks (https://docs.anthropic.com/en/docs/claude-code/hooks) to set up sound notifications

levpopov avatar Aug 22 '25 18:08 levpopov

guys, which hook is for the decision box that asks user to choose whether to accept edit or reject? the accessibility sound terminal bell is delayed about 3 seconds after the box appears, which is not ideal. I tried pretooluse and notification hooks, but they are not working,

tytung2020 avatar Aug 26 '25 14:08 tytung2020

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Sep 03 '25 14:09 github-actions[bot]