Developers are turning to deterministic infrastructure over AI-driven actions for critical workflows. In a recent post on DEV.to, developer sora_uzu detailed a method to guarantee push notifications on iPhone whenever a Claude Code reply finishes. The solution abandons the built-in PushNotification tool in favor of a Python script triggered by Claude Code’s Stop hook, communicating with the ntfy.sh service. This shift addresses reliability issues highlighted in community discussions, where the AI fails to invoke tools consistently or slows down response times by attempting to manage external notifications.

The Problem With AI-Managed Notifications

Relying on the LLM to call a notification tool introduces latency and unpredictability. The author noted that the AI often forgot to send notifications despite explicit written rules, and the built-in tool suppressed alerts when the user was actively viewing the desktop screen. Furthermore, the overhead of calling a tool on every interaction degraded the responsiveness of the coding session. The lack of a native 'notify on finish' setting in Claude Code forced users to seek external workarounds that decouple the notification logic from the model’s reasoning process.

Architecture: Decoupling Core Logic From Hooks

The proposed architecture strictly separates the notification engine from the AI interface. A standalone Python script handles the HTTP POST request to ntfy.sh, sending a fixed, generic message to avoid leaking sensitive context like health or financial data. The Claude Code Stop hook acts merely as a thin entry point, passing the session ID to the script. This design ensures that if the user switches AI providers, the notification core remains functional, requiring only a minor adjustment to the hook configuration. The script is configured to always exit normally, preventing a failed notification from interrupting the coding workflow.

Implementation Details and Security

Implementation involves registering the script in .claude/settings.json under the Stop hooks array. The script reads a secret topic name from a git-ignored file, ensuring that only authorized devices can subscribe to the notification stream. By using the claude://code/{session-id} deep link format, tapping the notification on the iPhone directly opens the corresponding conversation in the Claude mobile app, provided Remote Control is enabled. The author emphasizes that the topic name must remain secret, as anyone possessing it can both receive and send messages to the channel.

Key Takeaways

  • Deterministic hooks outperform AI tool-calling for routine, time-sensitive tasks like notifications.
  • Decoupling notification logic into standalone scripts enhances portability across different AI coding assistants.
  • Using ntfy.sh with a secret topic provides a lightweight, self-hostable alternative to proprietary push services.
  • Security is maintained by sending only generic status messages and keeping the topic identifier private.

The Bottom Line

Stop asking the AI to remember to do chores; build the chores into the system. This pattern is the future of reliable agentic workflows.