Daniel Lyons' Notes

Claude Code Now Speaks + Sends Mobile Notifications (ntfy) via Hooks - Here’s the Setup!

Description

🛠️ Get EVERYTHING from this video from my Claude Code Builder Pack ► https://rebrand.ly/cd65f2(Includes voice + mobile notification hooks, lesson plan, dem...

My Notes

00:00 Introduction to Claude Code Hooks

  • Episode focuses on getting the best out of Claude Code
  • Demonstrates Claude's permission system for file edits
  • Common issue: Claude Code gets stuck waiting for permission when running in background

00:55 Tutorial Overview

  • Building notification systems using Claude Code's hook system
  • Two notification types:
    • Desktop audio notifications
    • Phone push notifications
  • All resources available in description (Claude Code Builder Pack)

01:50 Live Demonstration

  • Demo app shown running in sidebar (React app)
  • Claude analyzes folder structure and provides voice notification when task completes
  • Notifications appear on both desktop and phone simultaneously

02:24 How Hook Events Work

  • When Claude performs an action, a hook event is fired
  • Events can be matched against configuration file rules
  • Custom commands execute based on matched events
  • Two notification systems demonstrated:
    • Voice notifications (audio feedback)
    • Desktop/phone push notifications

03:15 Context-Aware Notifications

  • System provides context about file types being read
  • Example: Specifies "reading a README file" rather than generic "reading a file"
  • Allows for more intelligent and specific notifications

03:32 Interactive Example: Adding Gradient

  • User requests gradient styling for cars in UI
  • Claude enters plan mode (Shift+Enter) to think through changes
  • System requires user approval before proceeding with edits
  • Different notification type for permission requests vs. task completion
04:00 Permission Approval Flow
  • Claude shows plan for modifications (TypeScript and TSX files)
  • User approves and auto-accepts edits
  • Hook system catches different event types and handles them differently
  • Voice notification changes based on event type (informational vs. requiring action)
04:45 Task Completion Notifications
  • System announces TypeScript modifications in progress
  • Updates to-do list as different events occur
  • Final notification when code update completes
  • Phone receives corresponding push notifications

05:19 Key Takeaways

  • Hook system enables voice and push notifications
  • Understanding hooks allows extension to other use cases:
    • Type checking
    • Pre-commit hooks
    • Workflow acceleration
  • Notification system is practical example of hook capabilities

05:52 Available Resources

  • Demo app included
  • Push notification system code
  • Voice activation system code
  • Full lesson plan with diagrams:
    • Hook event flow diagram
    • Architecture diagram
    • Context-aware system diagram
  • Access via Insiders Club or Claude Code Builder Pack

06:59 Tutorial Approach

  • Focus on architecture and concepts rather than code details
  • Code can be easily generated using Claude itself
  • Main learning: understanding Claude hooks and their architecture
  • Two notification systems covered in detail

07:31 Voice Notification System Benefits

  • Provides audio feedback for Claude Code events during execution
  • Alerts when task is waiting for user input
  • Alerts when task completes
  • Useful when switching between tabs or leaving Claude Code running in background

07:48 Push Notification System Benefits

  • Sends event notifications to phone
  • Useful when audio is unavailable or headphones are out
  • Combined with voice notifications covers both audio and visual feedback

08:22 System Architecture Highlights

  • Context-aware intelligence in hook handling
  • Specific file type identification (Python file, markdown file, etc.)
  • Distinguishes between different actions (git commands, file reads, etc.)
  • Provides variation in voice narration
  • Enables fine-grained control over which notifications to receive

09:11 Claude Hooks Documentation

  • Claude documentation provides good reference material: Hooks reference - Claude Code Docs
  • Several main hook events available for listening
  • Events tie into Claude's actions

09:29 Pre-Tool Use Event

  • Fires before Claude uses a tool to perform action
  • Works with file edits and file reads
  • Use cases:
    • Prevent writes to particular files/folders
    • Add restrictions to specific locations

09:44 Post-Tool Use Event

  • Fires after event has occurred
  • Enables post-processing actions:
    • Formatting
    • Linting
    • Spell checking

10:00 Stop and Notification Events

  • Stop event: Fires when Claude completes a task
    • Sends completion notification
  • Notification event: Provides context about why Claude paused
    • Examples: Permission needed, file edit required
    • More detailed than stop event

10:43 Hook Event Flow and Configuration

10:43 Hook Event Flow

  • Claude performs action → Hook event fires
  • Event matched against configuration file
  • Matching triggers specified action (e.g., play notification sound)
  • Configuration file specifies: event type, tool match, command to run

11:16 Configuration File Structure

  • Located in .claude folder as settings.json
  • Defines hook handling preferences
  • Specifies which events to listen for
11:31 Hook Configuration Details
  • Hooks section contains event listeners: stop, pre-tool-use, notification
  • Two handlers configured:
    • Voice notifications handler
    • Push notifications handler
  • Pre-tool-use: voice notifications only (avoid notification overload)
  • Stop/notification events: both voice and push notifications
11:42 Handler Architecture
  • Single Python file handles all hooks for each system
  • Same Python file used across different hook types
  • Simplifies management compared to separate handlers per hook
12:24 Handler Organization Options
  • Can create specific handlers for each hook type
  • Can create handlers for specific tool matches
  • Recommended approach: single file per system
  • Simpler and more maintainable

12:52 System Architecture Overview

12:52 Architecture Components

  • Claude Code runs and fires hook events
  • Two handlers process events:
    • Voice notifications handler
    • Push notifications handler
  • Single handler manages all event combinations
  • Similar structure for both systems

13:08 Handler Components

  • Python handler file
  • Mapping JSON file:
    • Maps events to sounds (voice) or notifications (push)
    • Provides audio feedback or push notifications

13:32 Voice Notification System

13:32 Voice Notification Structure

  • Handler file: handler.py
  • Mapping file: sound_mapping.json
  • Maps hook events to sound files:
    • Stop events
    • Notification events
    • Pre-tool-use events

13:49 Sound Mapping Features

  • Multiple sound files per event for variation
  • Randomly switches between sounds to avoid repetition
  • Maps to specific tools (code edit, search, etc.)
  • Maps to file extensions (Python files, etc.)
  • Maps to specific file names (README files)
14:04 Context-Specific Audio
  • Different audio for different file types
  • Example: Different sounds for Python vs. other files
  • File extension-based selection
  • Specific file name matching for unique files
14:33 Voice Customization
  • Settings file specifies which voice to use
  • Example voices: Alfred (Batman), others available
  • Can create custom voice folders (e.g., Jarvis from Iron Man)
  • Swap voice folders to change entire notification voice

15:22 Push Notification System

15:22 Push Notification System Structure

  • Similar structure to voice notifications
  • Single handler file and mapping file
  • Maps events to notification titles and messages instead of sounds

15:33 Push Notification Mapping

  • Stop events
  • Notification events
  • Pre-tool-use events
  • Specific tool-based messages
  • Contextual patterns based on file operations and extensions

16:18 Managing Dependencies with UV

16:18 Python Dependencies in Hooks

  • Challenge: Managing external dependencies in hook scripts
  • Examples: httpx library, sound libraries
  • Solution: Use uv (UV package manager)

16:29 UV Package Manager

  • Extremely fast Python package manager
  • Executes scripts in isolated environment
  • No need for requirements.txt or pyproject.toml
  • Dependencies specified directly in Python file
16:40 UV Usage
  • Settings file uses uv run instead of python
  • Automatically creates isolated environment
  • Installs specified dependencies
  • Executes script with correct Python version
17:05 Dependency Specification
  • Python version specified at top of file (e.g., 3.13)
  • Dependencies listed (e.g., httpx)
  • UV spins up virtual environment with specified versions
  • No local machine dependency management needed

17:35 Voice Notification Dependencies

  • Uses Pygame library for audio playback
  • Chosen for cross-platform compatibility (Windows, Linux, Mac)
  • Provides reliable sound playback across systems
  • Alternative pure audio libraries could be used
17:46 Audio Playback Challenges
  • Native OS capabilities difficult to implement reliably
  • Issues with Windows, WSL, and Mac compatibility
  • Pygame provides unified solution
  • Works consistently across platforms

18:29 Ntfy.sh Push Notification Service

18:29 Ntfy.sh Overview

  • Simple and powerful service for push notifications
  • Uses topic-based messaging system
  • Send messages to topic name
  • Subscribe to topic on device to receive messages

18:41 Topic System

  • Messages sent to topic names
  • Subscribers receive messages from subscribed topics
  • Default behavior: public topics
  • Anyone can publish/subscribe to public topics
18:54 Topic Configuration
  • Settings file specifies topic to subscribe to
  • Can view all notifications sent to topic via URL
  • Public by default - anyone can see messages
19:12 Security Consideration
  • All notifications are public
  • Random hash added to topic name for privacy
  • Reduces chance of accidental discovery
  • Generic topic names (e.g., "claude-code-notifications") receive other users' messages
19:25 Public Topic Example
  • Generic topics show notifications from multiple users
  • Other people publish to same endpoints
  • Subscribing to generic topics receives all users' notifications
  • Hash suffix prevents this issue
19:37 Topic Privacy Strategy
  • Random hash makes topic unique
  • Low chance of collision with other publishers
  • Good for testing purposes
  • Balances privacy with simplicity

19:49 Push Notification Function

  • Takes topic, title, and message as parameters
  • Sends to ntfy.sh server
  • Optional parameters: text, priority
  • Uses httpx client library for HTTP requests

20:02 Notification Delivery

  • Function sends notification with correct HTTP headers
  • Phone app receives notifications
  • User subscribes to topic in phone app
  • Continues receiving notifications for subscribed topic

20:21 System Summary and Extensibility

20:21 System Summary

  • Straightforward yet powerful architecture
  • Hook event triggers system
  • Tool type checked for context
  • Secondary filtering provides additional context
  • Variation selection or push notification sent

20:35 Hook Event Processing Flow

  • Receive hook event
  • Check tool type
  • Apply secondary filter for context
  • Select variation or notification to send
  • Deliver to user

20:48 Extensibility

  • Main learning: understanding hooks and handling them
  • Can integrate system into own workflow
  • Enables creative and fun extensions
  • Foundation for other hook-based automations

21:13 Resources and Conclusion

21:13 Project Availability

  • Entire project available for download
  • Includes:
    • Settings configuration
    • Voice notification system handlers
    • Push notification system handlers
    • All audio files
    • Complete lesson plan with diagrams
  • Available via Claude Code Builder Pack (link in description)

21:24 Builder Pack Contents

  • Code and scripts from current episode
  • Configuration files from previous 3 episodes
  • Free version available in AI-oriented Insiders Club
  • Link provided in description

21:33 Related Content

  • Previous video: Using Claude Code with any model for reduced costs and faster speeds
  • Recommended viewing

21:49 Call to Action

  • Like the video
  • Subscribe to channel
  • Turn on notifications for new content
Claude Code Now Speaks + Sends Mobile Notifications (ntfy) via Hooks - Here’s the Setup!
Interactive graph
On this page
Description
My Notes
00:00 Introduction to Claude Code Hooks
00:55 Tutorial Overview
01:50 Live Demonstration
02:24 How Hook Events Work
03:15 Context-Aware Notifications
03:32 Interactive Example: Adding Gradient
04:00 Permission Approval Flow
04:45 Task Completion Notifications
05:19 Key Takeaways
05:52 Available Resources
06:59 Tutorial Approach
07:31 Voice Notification System Benefits
07:48 Push Notification System Benefits
08:22 System Architecture Highlights
09:11 Claude Hooks Documentation
09:29 Pre-Tool Use Event
09:44 Post-Tool Use Event
10:00 Stop and Notification Events
10:43 Hook Event Flow and Configuration
10:43 Hook Event Flow
11:16 Configuration File Structure
11:31 Hook Configuration Details
11:42 Handler Architecture
12:24 Handler Organization Options
12:52 System Architecture Overview
12:52 Architecture Components
13:08 Handler Components
13:32 Voice Notification System
13:32 Voice Notification Structure
13:49 Sound Mapping Features
14:04 Context-Specific Audio
14:33 Voice Customization
15:22 Push Notification System
15:22 Push Notification System Structure
15:33 Push Notification Mapping
16:18 Managing Dependencies with UV
16:18 Python Dependencies in Hooks
16:29 UV Package Manager
16:40 UV Usage
17:05 Dependency Specification
17:35 Voice Notification Dependencies
17:46 Audio Playback Challenges
18:29 Ntfy.sh Push Notification Service
18:29 Ntfy.sh Overview
18:41 Topic System
18:54 Topic Configuration
19:12 Security Consideration
19:25 Public Topic Example
19:37 Topic Privacy Strategy
19:49 Push Notification Function
20:02 Notification Delivery
20:21 System Summary and Extensibility
20:21 System Summary
20:35 Hook Event Processing Flow
20:48 Extensibility
21:13 Resources and Conclusion
21:13 Project Availability
21:24 Builder Pack Contents
21:33 Related Content
21:49 Call to Action