You give Claude Code a task that should take ten minutes. You switch to the browser, answer two messages, read an article, and forty minutes later you look back at the terminal. The agent finished after eight. Or it stopped after one, waiting for you to approve a command.
A notification fixes both. Claude Code and Codex can each send one, but what you get by default depends on your terminal, and the usual recipes stop working as soon as the agent runs over SSH or inside a container. Below are the built-in settings, hooks that work anywhere, a ping on your phone, and what Sessionboxer sends. The details come from the Claude Code terminal docs, the hooks reference and the Codex advanced configuration, read on November 28, 2026.
What Claude Code does out of the box
When Claude finishes a task or pauses for a permission prompt, and you seem to be away from the terminal, Claude Code fires a notification event. What reaches you depends on the terminal:
- Ghostty, Kitty and iTerm2 show a desktop notification. iTerm2 does so only after you turn on its alerts: Settings → Profiles → Terminal, tick "Notification Center Alerts", then enable "Send escape sequence-generated alerts" under Filter Alerts.
- Apple Terminal gets a silent bell character at most, and only with "Audible bell" off in its profile.
- Every other terminal gets nothing. The docs name Warp and the VS Code integrated terminal.
If yours is in the last group, the smallest fix is one line in ~/.claude/settings.json:
{ "preferredNotifChannel": "terminal_bell" }
Claude Code then prints the bell character whatever the terminal. Whether that becomes a sound, a flashing tab or a bounce in the Dock is the terminal's choice.
Inside tmux, notifications do not reach the outer terminal until you add set -g allow-passthrough on to ~/.tmux.conf and restart Claude Code. Even then, a pane in a window you are not viewing sends none.
Hooks: run your own command
For anything more than a bell, use a hook. Two events matter here.
Notification runs when Claude Code sends a notification, and its matcher picks the type. The useful ones are permission_prompt, when a permission prompt has waited about six seconds, and idle_prompt, when Claude finished about 60 seconds ago and you have not typed since. Both use the same timing as the desktop notification, so in a terminal session they only fire when you look away. The hook still runs if you set preferredNotifChannel to notifications_disabled.
Stop runs every time the main agent finishes responding. It does not run when you interrupt it, and an API error fires StopFailure instead. Its input includes last_assistant_message, the text of Claude's final reply, which makes a good notification body.
The hooks guide has a desktop command for each system. On Linux:
{
"hooks": {
"Notification": [
{
"matcher": "",
"hooks": [
{ "type": "command", "command": "notify-send 'Claude Code' 'Claude Code needs your attention'" }
]
}
]
}
}
On macOS the guide uses osascript -e 'display notification ...' and warns that it fails silently until Script Editor is allowed to send notifications in System Settings. Type /hooks in Claude Code to check that yours loaded.
Use idle_prompt if you only want to hear about it once you have wandered off. Use Stop if you want a ping after every turn, even while you sit there.
Over SSH and in Docker, desktop commands go nowhere
A hook runs on the machine where Claude Code runs. On a VPS, in a dev container or in a Docker box, notify-send has nobody to talk to. The hooks guide says as much: it needs a notification daemon, "which headless servers, SSH sessions, and most containers don't have."
There are two ways around it. If you connect from Ghostty, Kitty or iTerm2 and are not inside tmux, leave preferredNotifChannel at its default, "auto", and from Claude Code 2.1.326 the notification travels back over SSH to your terminal. Older versions need the terminal's name in that setting instead.
Otherwise, send the notification over the network. ntfy is a simple choice: you publish a message with one HTTP POST and read it in the ntfy phone app or a browser. This Stop hook sends the first 200 characters of Claude's last reply:
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "jq -r '.last_assistant_message // \"Claude Code is done\"' | head -c 200 | curl -s -d @- https://ntfy.sh/pick-a-long-random-topic"
}
]
}
]
}
}
The machine needs jq and curl. Two cautions. ntfy has no sign-up, so its docs say the topic name is essentially a password; pick one nobody will guess. And this sends part of the agent's reply to someone else's server. If the reply might contain code or names you would rather keep, send a fixed string, or run ntfy yourself.
Codex: tui.notifications and notify
Codex has two settings, both in ~/.codex/config.toml.
tui.notifications is built into the terminal UI. It takes true or a list of event types such as agent-turn-complete and approval-requested. tui.notification_method is auto, osc9 or bel; with auto, Codex sends an OSC 9 escape sequence when the terminal seems to support it and falls back to the bell. tui.notification_condition is unfocused by default; set it to always to be told even while you watch.
[tui]
notifications = ["agent-turn-complete", "approval-requested"]
notification_method = "bel"
notify runs a program of your own on agent-turn-complete, currently the only event it supports. Codex passes it one argument: a JSON object with type, thread-id, turn-id, cwd, input-messages and last-assistant-message. The same ntfy idea, as a top-level key (put it above any [table] header in the file, or TOML reads it as part of that table):
notify = ["bash", "-c", "printf '%s' \"$1\" | jq -r '.\"last-assistant-message\" // \"Codex is done\"' | head -c 200 | curl -s -d @- https://ntfy.sh/pick-a-long-random-topic", "codex-notify"]
It has to be your user config. Codex ignores notify in a project's .codex/config.toml and prints a warning, so a repository you clone cannot set one for you.
What Sessionboxer sends
We build Sessionboxer, so this section is about our own product. Each session runs in its own Docker container, and the agent inside runs without permission prompts because the container is the boundary. There is no approval to wait for, so the only question is whether the turn is over.
The Control Plane answers that with Web Push to the browsers you paired, with no hooks in the box. In Global settings → Devices and remote access, turn on Notify this device when a turn ends or a pull request gets feedback. You then get a push when an agent's turn ends, with the first line of its last message, and when a pull request you follow gets new comments or reviews or a check fails. Tapping it opens the session or the PR. A device that has the page on screen gets no push, since it sees the change live. Send a test notification checks the whole path.
The agent can also notify you on purpose. Every box has a built-in sessionboxer MCP server, and sending you a notification is one of the things the agent can do through it, so "notify me when the migration passes" is a prompt that works.
The limits, from the phone chapter of the guide:
- Web Push needs HTTPS, which you get from one of the tunnels or your own address.
- On an iPhone the app has to be added to the Home Screen first, on iOS 16.4 or later.
- Messages pass through the browser vendor's push relay as ciphertext.
- The Control Plane has to be running. If it lives on a laptop that goes to sleep, nothing runs and nothing is sent. A home server or a VPS avoids that.
Which one to set up
| Where the agent runs | What to set |
|---|---|
| Your machine, in Ghostty, Kitty or iTerm2 | Nothing for Claude Code; tui.notifications for Codex |
| Your machine, in the VS Code terminal or Warp | preferredNotifChannel: "terminal_bell" or a Notification hook |
| Over SSH from Ghostty, Kitty or iTerm2, no tmux | Leave "auto" (Claude Code 2.1.326 or later) |
| A container, a VPS, or SSH with tmux | A Stop hook or notify that posts to ntfy |
| Sessionboxer | Web Push, turned on once per device |
If you want to answer as well as be told, from the same phone, our post on steering agents from a phone compares the ways to do that.