Guide
Get notified when Claude Code or Codex finishes
A coding agent that stops to ask for permission while you're in another window just sits there. Both Claude Code and Codex CLI can tell you when they finish or need input. Here is how to set that up for each, and what changes once you run several sessions at once.
Claude Code: the Notification and Stop hooks
Claude Code runs shell commands on hooks, set in
~/.claude/settings.json. Two of them matter here:
-
Notificationfires when Claude is waiting on you: a permission prompt that has waited about six seconds (matcherpermission_prompt), or about a minute of idle time after it answered (idle_prompt). An empty matcher fires on every type. -
Stopfires each time Claude finishes responding. That is the end of a turn, not necessarily of the whole task.
On macOS, this notifies you when Claude asks for permission and when it finishes a turn.
The permission_prompt matcher leaves out idle_prompt, which
would otherwise notify you a second time about a turn Stop already told you
had finished:
{
"hooks": {
"Notification": [
{
"matcher": "permission_prompt",
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Claude Code needs your attention\" with title \"Claude Code\"'"
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Claude Code finished\" with title \"Claude Code\"'"
}
]
}
]
}
}
On Linux, use notify-send 'Claude Code' 'Claude Code needs your attention' and
notify-send 'Claude Code' 'Claude Code finished' as the two commands instead. If your settings file already has a hooks object, add
these keys inside it rather than adding a second one. Run /hooks in Claude
Code to check they loaded. The
Claude Code hooks guide
has the Windows command and the other matchers.
Codex CLI: TUI notifications and notify
Codex can raise notifications itself from its terminal UI. In
~/.codex/config.toml:
[tui]
notifications = ["agent-turn-complete", "approval-requested"]
# Notify even while the terminal is focused (the default is only when it isn't)
notification_condition = "always"
These go out as terminal notifications (OSC 9, or a bell where the terminal doesn't
support it), so what you see depends on your terminal. For anything else, such as a
desktop notification, a sound or a message to your phone, the top-level
notify key runs a program of yours when a turn completes, with a JSON
argument that includes the working directory and Codex's last message:
notify = ["python3", "/Users/you/bin/codex-notify.py"]
Codex also has lifecycle hooks, including Stop, configured in
~/.codex/hooks.json. See
Codex's advanced configuration
for the details.
When one notification per agent stops being enough
With one session, any of the above works. With four agents in four worktrees, a few things get in the way:
- Which one? "Claude Code needs your attention" doesn't say which session, branch or project, and clicking it doesn't take you to that terminal.
- Every agent is set up differently. Claude Code, Codex, OpenCode and the rest each have their own config, and each needs its own notifier.
-
Remote machines. An agent running on an SSH host calls
notify-sendthere, not on the laptop you're looking at. - Nothing to come back to. A notification you missed is gone; nothing lists which sessions are still waiting.
How Komla handles it
Komla runs each agent in its own workspace, backed by a git worktree, and hooks into the agents itself, so you don't write any of the config above:
- Onboarding finds the agent CLIs you have installed and sets up notifications for each in one click, for Claude Code, Codex, Antigravity CLI and OpenCode, on this computer and on SSH hosts. Other agents can set themselves up with agent-led setup.
- A workspace whose agent finished, needs input or hit an error is badged in the sidebar, on its terminal tab and on the macOS dock. Hovering the badge shows the agent's message, and the dashboard inbox puts the workspaces that need you first.
- A sound plays once, and not at all when you're already looking at that terminal.
- With remote control (alpha), a paired phone can get a push notification when an agent needs input, finishes or fails, and tapping it opens that workspace.
To send these events somewhere else too, such as a desktop notification or a chat
message, Komla's ~/.komla/settings/hooks.json runs your command on
agent.done, agent.needs-input or agent.error for
every agent, with the workspace, branch, agent and message in environment variables:
{
"_version": 1,
"hooks": [
{
"id": "agent-needs-me",
"event": "agent.needs-input",
"runOn": "local",
"command": "~/bin/agent-alert.sh"
}
]
}
Here agent-alert.sh gets KOMLA_WORKSPACE_NAME,
KOMLA_BRANCH, KOMLA_AGENT and KOMLA_MESSAGE, and
"runOn": "local" runs it on this computer even for a workspace on an SSH
host. For scripts and builds that aren't agents, komla notify -- npm run build
runs a command and notifies you when it finishes or fails. See the
Komla CLI for more.
Best fit
If you run one agent at a time, the hooks above are all you need. Komla is for when several sessions run at once and you want one place that shows which of them are waiting for you.
Related guides
Run multiple AI coding agents with git worktrees, Codex CLI multiple sessions, and the Claude Code and Codex CLI pages.
Komla is free and open source for macOS, Windows and Linux. Download Komla or see the supported CLI coding agents.