CCNotify icon indicating copy to clipboard operation
CCNotify copied to clipboard

Implement smart notification filtering to reduce notification fatigue

Open Helmi opened this issue 1 year ago • 0 comments

Description

Currently ccnotify sends notifications for every bash command execution, causing significant notification fatigue. The current logic at notify.py:768 states "Notify for all Bash commands" which defeats the purpose of an intelligent notification system.

Context

  • Project area: Core notification filtering logic in src/ccnotify/notify.py:756-884
  • Complexity assessment: 5/10 (moderate logic changes, path analysis needed)
  • Current behavior: All bash commands trigger notifications
  • Problem: Notification fatigue from routine operations like ls, cat, pwd, echo, etc.

Technical Details

Affected files:

  • src/ccnotify/notify.py:756-884 - Main PreToolUse filtering logic that needs modification
  • Potentially config system for customizable command whitelist

Current filtering logic:

# Lines 762-863: Currently notifies for ALL bash commands
if tool_name == "Bash":
    # Notify for all Bash commands  <- THIS IS THE PROBLEM

Requirements

Core Approach: Minimal Whitelist + Path-Based Filtering

  1. Minimal whitelist approach - Only truly dangerous commands should trigger notifications:

    • rm, sudo, chmod, chown, mv (file operations with potential for damage)
    • Exclude routine commands: ls, cat, pwd, echo, grep, find, git status, etc.
    • Exclude even moderately risky but common commands: cp, curl, wget, docker
  2. Path-based filtering - Commands targeting files outside the current project directory should trigger notifications regardless of command type

  3. Simplicity - Keep the logic straightforward and predictable

Implementation Steps

  • [ ] Create minimal dangerous command whitelist in filtering logic
  • [ ] Implement path analysis to detect when commands target files outside project directory
  • [ ] Modify PreToolUse handler filtering logic (notify.py:762-863)
  • [ ] Add configuration option for customizable whitelist (optional enhancement)
  • [ ] CRITICAL: Local testing - Test extensively with real Claude Code usage before any commit
  • [ ] Update any relevant documentation about filtering behavior

Acceptance Criteria

  • [ ] Only dangerous commands (rm, sudo, chmod, chown, mv) trigger notifications by default
  • [ ] Commands targeting files outside current project directory trigger notifications
  • [ ] Significant reduction in notification volume during typical Claude Code sessions
  • [ ] Local testing demonstrates proper filtering without missing important events
  • [ ] All existing tests pass
  • [ ] No false negatives for truly dangerous operations

Testing Requirements

MUST complete local testing before any GitHub push:

  • Test with typical Claude Code development sessions
  • Verify dangerous commands still trigger notifications
  • Verify routine commands are filtered out
  • Test path-based filtering with commands targeting system files
  • Measure notification volume reduction

Helmi avatar Sep 15 '25 08:09 Helmi