Dedupe Repeated Idle-Prompt Notifications

A session waiting on an unanswered permission prompt can generate the same idle notification repeatedly — noisy rather than useful. This surfaces the first one and silently counts the rest, so whoever's watching isn't trained to tune the whole category out.

Notification & Escalation Routing Event: Notification Claude Code Open source · Free

1. Save this as the hook script

#!/usr/bin/env python3
"""Notification hook — surfaces the first idle_prompt notification per
session, counts the rest silently. Wire with matcher "idle_prompt"."""
import json, sys
from pathlib import Path

data = json.load(sys.stdin)
session_id = data.get("session_id", "unknown")
counter_path = Path(data.get("cwd", ".")) / ".claude" / f"idle_notif_count_{session_id}.txt"

count = int(counter_path.read_text()) + 1 if counter_path.exists() else 1
counter_path.parent.mkdir(parents=True, exist_ok=True)
counter_path.write_text(str(count))

if count == 1:
    print("NOTICE: session is idle, waiting on a permission prompt.", file=sys.stderr)

sys.exit(0)

Save to a path inside your project, e.g. .claude/hooks/dedupe-idle-prompt-notifications.sh, then chmod +x it.

2. Wire it into .claude/settings.json

{
  "hooks": {
    "Notification": [
      {
        "matcher": "idle_prompt",
        "hooks": [
          {"type": "command", "command": "python3 .claude/hooks/dedupe-idle-prompt-notifications.py"}
        ]
      }
    ]
  }
}

Before you use this

A hook runs with your local shell's permissions — review the script above before adding it, the same way you'd review any script you didn't write yourself. See our guide on hook security risks for the specific CVEs this category of feature has already produced.

Related hooks

← All hooks
FEEDBACK