To get a notification when the Codex CLI finishes, add a Stop hook to ~/.codex/hooks.json that runs your system's notification command, then trust it once with /hooks. Stop fires the moment a turn ends. For "Codex wants my approval", add a PermissionRequest hook that does the same: it fires as soon as Codex is about to ask. Both work on Mac, Windows and Linux, and a tool such as Notifier for Codex can send the same alerts to your phone and let you answer from there.
01What Codex does on its own
Codex already has a built-in alert. With the default settings, when a turn completes or an approval is waiting and your terminal window is not focused, Codex sends a desktop notification in terminals that understand the OSC 9 escape sequence (Ghostty, iTerm2, Kitty, Warp and WezTerm). Everywhere else, including Apple Terminal, Windows Terminal, the VS Code terminal and most Linux terminals, it falls back to the terminal bell, which may make a sound, flash or do nothing, depending on the terminal.
The settings live under [tui] in ~/.codex/config.toml, and the built-in notifications guide explains each one. If the bell is not enough, or you want a notification in any terminal, use a hook.
02The two hooks you need
Hooks are commands that Codex runs at fixed points in a session. Two of them matter here:
StopWhen a turn ends and Codex hands control back to you"Codex has finished"PermissionRequestWhen Codex is about to ask you to approve a command, a patch or a tool call"Codex needs approval"Codex has no separate "Notification" event, so these two cover both moments. Both fire straight away. For how hooks work in general (events, matchers, files, trust), see Codex hooks explained.
03A working setup on macOS
Open ~/.codex/hooks.json (create it if it doesn't exist) and add this. If the file already has a hooks object, add Stop and PermissionRequest as keys inside it rather than replacing it.
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Codex has finished\" with title \"Codex\"' >/dev/null"
}
]
}
],
"PermissionRequest": [
{
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Codex wants your approval\" with title \"Codex\"' >/dev/null"
}
]
}
]
}
}
Two details matter:
- Print nothing. Codex expects a
Stophook to print either nothing or JSON. Plain text on stdout is treated as invalid output, so the>/dev/nullkeeps the hook quiet. - Make no decision. A
PermissionRequesthook that prints nothing leaves the approval prompt exactly as it was. It only tells you the prompt is there.
If nothing appears, macOS may be blocking Script Editor, which osascript uses to show notifications. Run osascript -e 'display notification "test"' once in Terminal, then open System Settings > Notifications, find Script Editor and turn on Allow Notifications. More options are in the macOS guide.
04Trust the hooks
Codex does not run a new or changed hook until you have reviewed and trusted it. Start codex, and if it warns that hooks need review, type /hooks, check the two entries and trust them. Codex records trust against the exact hook definition, so every time you edit a command, you trust it again.
05The same setup on Linux and Windows
Keep the JSON shape above and swap the command strings.
Linux (needs a desktop notification daemon, so not on a headless server):
"command": "notify-send 'Codex' 'Codex has finished'"
If notify-send is missing, install libnotify-bin on Debian and Ubuntu, or your distribution's equivalent. For servers, see notifications over SSH.
Windows. The hooks file is %USERPROFILE%\.codex\hooks.json. The BurntToast PowerShell module gives a proper toast (install it once with Install-Module BurntToast -Scope CurrentUser):
"command": "powershell -NoProfile -Command \"New-BurntToastNotification -Text 'Codex','Codex has finished'\""
The Windows guide covers WSL and options with nothing to install.
06Or use the notify setting
Codex also has an older, simpler mechanism: notify in ~/.codex/config.toml runs a program of your choice each time a turn completes, passing it a JSON description of the turn. It only covers "finished" (not approvals), cannot answer anything, and needs no trust step. The notify guide has a ready-made script. Use it if you only want "done" alerts; use hooks if you also want "needs approval".
07Check that it works
- Run
/hooksin Codex and confirm both hooks are listed and trusted. - Ask Codex something short. When the turn ends, the "finished" notification should appear.
- Ask for something that needs approval, such as a command that uses the network. The approval notification appears as the prompt does.
If nothing happens, check hooks.json is valid JSON (no trailing commas, no comments) and run the command by hand in a terminal. The troubleshooting checklist covers the rest.
08Getting the alert on your phone
A desktop notification only helps while you are at the desk. Once you walk away, you need the alert somewhere else. There are three common routes:
- A push service you run yourself, such as ntfy, called with
curlfrom the same hooks. See the ntfy guide. - A chat webhook for Telegram, Slack or Discord. See the chat webhooks guide.
- Notifier for Codex, which installs the hooks for you and lets you answer from the phone.
The do-it-yourself routes are a fine answer if all you want is a ping. Their limit is that they are one-way: you find out Codex is waiting, then you still have to get back to the keyboard to approve anything.
Notifier for Codex is an independent tool (not made by or affiliated with OpenAI) with two parts: codex-notifier, a free command line tool for Mac, Windows and Linux, and apps for iPhone and Android. Install it with one line:
curl -fsSL https://notifierforcodex.com/install.sh | sh
On Windows, use irm https://notifierforcodex.com/install.ps1 | iex in PowerShell (Windows support is in beta). Homebrew and npx @touchtap/codex-notifier are on the codex-notifier page.
Its first codex-notifier pair (the Mac and Linux install line runs it for you) adds six hook entries to ~/.codex/hooks.json, each running codex-notifier hook, and marks them trusted in ~/.codex/config.toml, so there is no /hooks step. The rest of both files stays as it was, with a one-time backup beside each. With no phone at all, codex-notifier shows a desktop notification on the computer when Codex finishes, wants approval or asks a question. That part is free and needs no network.
Pair a phone and you also get:
- a "Codex has finished" push the moment a turn ends;
- approvals for commands and patches, which you approve or reject (with a note, if you like) from the phone;
- Codex's questions, answered by picking or typing an answer;
- a box to send Codex its next instruction right after it finishes.
If you typed in the last 30 seconds, nothing waits for the phone and the terminal asks as usual. The apps need a subscription or a one-off purchase; see pricing. Pairing a phone walks through the setup.
09FAQ
Does the Stop hook fire after every message, or only when the whole task is done?
After every turn. Codex doesn't know when your overall task is finished, only when it has handed control back to you. In a long back-and-forth you get one alert per reply. If that is too many, add a check to your script, for example only notify when the turn took longer than a minute.
Why does my Stop hook break with "invalid output"?
Codex expects a Stop hook to print nothing or a JSON object. If your command prints text (as curl does with a response body), Codex treats it as invalid. Redirect the output with >/dev/null on Mac and Linux, or | Out-Null in PowerShell.
I added the hook but nothing happens. Why?
The most common reason is trust. Codex skips new or changed hooks until you review them in /hooks. The second is a JSON mistake in hooks.json. The third is the operating system hiding the notification. The checklist goes through each.
Do hooks work with codex exec?
Yes. Hooks belong to Codex itself, so they also run for non-interactive codex exec runs, which makes a Stop hook a handy "the script is done" signal. codex exec doesn't ask for approval by default, so a PermissionRequest hook rarely fires there.
Does this work in the VS Code terminal?
Yes, if you run codex in that terminal. Hooks run from Codex, not from the terminal, so they work in any terminal. The built-in OSC 9 alert is what depends on the terminal. See Codex notifications in VS Code.
Can I get notified on my phone without installing anything on it?
Partly. A hook that posts to a chat webhook can reach an app you already have. It can only tell you something happened. To approve or answer from the phone, you need something that sends your reply back to the hook, which is what Notifier for Codex's apps do.