# Get notified when your AI agent finishes or needs your approval

> Notification settings and hooks for Claude Code, Codex and Cursor on a Mac, with working config for a desktop alert when an agent stops or asks.

Each agent has its own way. Claude Code fires a `Notification` hook when it needs permission or goes idle, and a `Stop` hook when it finishes. Codex has a `notify` program for finished turns, built-in terminal notifications, and `PermissionRequest` and `Stop` hooks. Cursor has a `stop` hook, and its docs describe no built-in desktop notification. The simplest pattern on a Mac is a hook that calls `osascript` to show a notification.

## Claude Code

Add this to `~/.claude/settings.json` to get an alert when Claude asks permission or sits idle. The `Notification` matcher filters by type, and the docs list `permission_prompt`, `idle_prompt`, `agent_needs_input` and `agent_completed` among the values. Exit codes are ignored for this event, so a failed alert cannot change what Claude does.

```json
{
  "hooks": {
    "Notification": [
      {
        "matcher": "permission_prompt|idle_prompt",
        "hooks": [
          {
            "type": "command",
            "command": "osascript -e 'display notification \"Claude Code needs you\" with title \"Claude Code\"'"
          }
        ]
      }
    ]
  }
}
```

For a finished turn, add a `Stop` hook the same way. `Stop` has no matcher and fires every time Claude stops. Claude Code reloads settings while running, so edits apply to the open session. The docs show the shape of these hooks but no `osascript` example, so treat the command above as ours, and test it by running the `osascript` line alone first.

If you use background sessions, `claude agents` opens agent view. The docs say that while it is open, Claude Code sends a notification through your terminal notification channel when a background session needs input, finishes or fails, and fires the `Notification` hook with `agent_needs_input` or `agent_completed`. [Claude Code hooks](https://www.excellent.so/guides/claude-code-hooks)

## Codex

Three options, from simplest.

1. **Built-in terminal notifications.** In the `[tui]` table of `~/.codex/config.toml`, `notifications` turns them on or off or limits them to event types, `notification_method` takes `auto`, `osc9` or `bel`, and `notification_condition` takes `unfocused` or `always`.
2. **`notify`.** An array that runs a program when an event fires. Today only `agent-turn-complete` is supported, and the program gets one JSON argument with fields such as `cwd` and `last-assistant-message`.

```toml
notify = ["python3", "/Users/you/bin/notify.py"]
```

3. **Hooks.** `Stop` runs at the end of a turn. `PermissionRequest` runs when Codex is about to ask for approval, and if your hook declines to decide, the normal prompt continues. Hooks live in `$CODEX_HOME/hooks.json` (default `~/.codex`) or `.codex/hooks.json` in a trusted project, and a hook you have not reviewed and trusted is skipped. The docs include no notification example, so write a command hook that reads the JSON on stdin and calls `osascript`. [Codex hooks](https://www.excellent.so/guides/codex-hooks)

## Cursor

Cursor’s agent docs say nothing about notifications, so use a hook. The `stop` event fires when the agent loop ends, with a `status` of `completed`, `aborted` or `error`. Define it in `~/.cursor/hooks.json`:

```json
{
  "version": 1,
  "hooks": {
    "stop": [{ "command": "/Users/you/.cursor/hooks/notify.sh" }]
  }
}
```

The script can read the JSON and run `osascript`. Cursor’s docs describe no hook that fires when an approval prompt opens, so for approvals watch the app. [Cursor hooks](https://www.excellent.so/guides/cursor-hooks)

## Side by side

| | Finished | Needs approval | Needs a script |
| --- | --- | --- | --- |
| Claude Code | `Stop` hook, agent view | `Notification` with `permission_prompt` | Yes, for a desktop alert |
| Codex | `notify`, `[tui]` notifications, `Stop` hook | `PermissionRequest` hook | Only for custom alerts |
| Cursor | `stop` hook | No documented hook | Yes |

## Where Excellent fits

Excellent for Mac asks once to send you notifications. With Pro, it alerts you when an agent sends your email to a website, deletes a never-delete folder, force pushes main or leaves a key in a log, and when its check blocks or asks. It does not announce that an agent finished. Pro is US-only for now. [Pricing](https://www.excellent.so/pricing) · [Agent coverage](https://www.excellent.so/agents) · [Run the free scan](https://www.excellent.so/scan)

## Checklist

- [ ] Hook added for permission prompts in Claude Code.
- [ ] `notify` or `[tui]` notifications set in Codex, and any hook trusted.
- [ ] `stop` hook added in Cursor.
- [ ] macOS notifications allowed for the app that runs `osascript`.
- [ ] Triggered each alert once on purpose.

Checked against vendor documentation on November 25, 2026. [Claude Code hooks](https://code.claude.com/docs/en/hooks) · [Claude Code agent view](https://code.claude.com/docs/en/agent-view) · [Codex advanced config](https://learn.chatgpt.com/docs/config-file/config-advanced) · [Codex hooks](https://learn.chatgpt.com/docs/hooks) · [Cursor hooks](https://cursor.com/docs/hooks)

Source: https://www.excellent.so/guides/get-notified-when-ai-agent-finishes-or-needs-approval
