Add a completion notification to Claude Code
Claude Code hooks can run a local command at documented lifecycle events, which makes a completion notification possible. Start with a harmless test command and keep shell inputs, permissions and log contents tightly controlled.
Choose the right hook event
A completion notification can tell you when a long Claude Code interaction reaches a lifecycle event, so you do not need to watch the terminal continuously. Claude Code exposes hooks that run a configured command at documented events. Hook names and payloads can change, so begin with Anthropic’s current hooks reference for your installed version.
Test with a harmless command
Choose the event that matches your use case, such as a notification or task completion event, and configure a small local command in the project or user settings file as documented. First make the command print a harmless message to a log. Run a short session and confirm when it fires before connecting it to the operating system’s notification service.
Connect an operating-system alert
Keep the command simple and quote paths safely. Do not interpolate untrusted prompt text into a shell command. A hook can execute with your user permissions, so treat it like code: inspect the script, avoid downloading and executing remote content, and keep credentials out of arguments and logs.
Protect command inputs and logs
Operating systems expose different notification tools and permission prompts. Test on the machine where you will use it, and provide a silent fallback if notifications are disabled. If you run multiple sessions, include only non-sensitive context such as the project name; avoid putting prompts or file contents in notification text.
Treat alerts as convenience
A local alert can be missed, delayed or suppressed by focus settings, so it should not be the sole signal for a critical production workflow. Review hook output when debugging and remove the hook if it behaves unexpectedly. Use the official hooks documentation and the notifier project’s current README for exact configuration.
Official reference
Consult the official documentation for current instructions and applicable terms.
Author:AI Router
Link:https://www.airouter.me/blog/claude-code-notify
Non-commercial reuse with attribution (CC BY-NC-SA 4.0).