Cursor
Get notified when a Cursor agent run completes, is aborted, or fails. A Cursor stop hook in hooks.json that sends to Slack, Telegram, SMS, or email.
Cursor runs commands on agent events through hooks. The stop hook fires when an agent run ends and reports whether it completed, was aborted, or hit an error.
Cursor has no hook event for "waiting for approval": hooks like beforeShellExecution decide whether a command is allowed, they do not signal that you are needed. Use stop to know when to come back.
1. Create the hook script
#!/usr/bin/env bash
# Forwards the Cursor stop hook to Alphorn.
jq -c '{
title: ("Cursor - " + ((.workspace_roots[0] // "agent") | split("/") | last)),
message: ("Agent run " + (.status // "finished")),
priority: (if .status == "error" then 4 else 2 end),
tags: ["ai-agent", "cursor", (if .status == "error" then "error" else "completed" end)]
}' | curl -fsS --max-time 5 -X POST https://app.alphorn.dev/n/V1StGXR8_Z5jdHi6B-myT \
-H "Authorization: Bearer $ALPHORN_API_KEY" \
-H "Content-Type: application/json" \
-d @- > /dev/null
exit 0chmod +x ~/.cursor/hooks/alphorn-notify.shThe script prints nothing. Output from a stop hook is read by Cursor: a followup_message in it would be sent to the agent as your next message.
2. Register the hook
{
"version": 1,
"hooks": {
"stop": [{ "command": "./hooks/alphorn-notify.sh" }]
}
}User hooks run from ~/.cursor/, so ./hooks/alphorn-notify.sh points to the script above. To enable the hook for one project only, put the script and hooks.json in the project's .cursor/ folder and use "command": ".cursor/hooks/alphorn-notify.sh" (project hooks run from the project root). ALPHORN_API_KEY must be set in the environment Cursor runs in.
Event fields
| Field | Description |
|---|---|
status | completed, aborted, or error |
loop_count | Number of agent loop iterations |
workspace_roots | Open workspace folders |
conversation_id | Conversation the run belongs to |
See AI Agent Notifications for routing conventions and an AGENTS.md snippet (Cursor reads AGENTS.md) that lets the agent send notifications on its own.
OpenAI Codex CLI
Get notified when OpenAI Codex CLI finishes a turn or needs approval. Codex hooks (Stop, PermissionRequest) and the notify setting, sending to Slack or SMS.
Gemini CLI
Get notified when Gemini CLI finishes a response or needs tool permission. Gemini CLI hooks (AfterAgent, Notification) that send to Slack, Telegram, or SMS.