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:

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:

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:

Komla sidebar with workspace cards marked Done, Input and working, beside a Claude Code session

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.