Version: 3.3.4 | Last Updated: 2025-12-22
This document is designed for AI assistants (Claude Code, Cursor, Copilot, etc.) to understand and help users install this project correctly.
Claude Code Audio Hooks provides audio notifications for Claude Code CLI events. When Claude completes tasks, triggers notifications, or needs authorization, users hear audio cues instead of constantly watching the terminal.
graph LR
A[Claude Code CLI] -->|Triggers Hook| B[Hook System]
B -->|Reads Config| C[user_preferences.json]
C -->|Selects Audio| D[Audio Files]
D -->|Plays via| E{Platform Player}
E -->|Windows| F[PowerShell MediaPlayer]
E -->|macOS| G[afplay]
E -->|Linux| H[mpg123/ffplay/aplay]
| Platform | Command |
|---|---|
| Windows (PowerShell) | .\scripts\install-windows.ps1 |
| Windows (Git Bash) | bash scripts/install-complete.sh |
| WSL | bash scripts/install-complete.sh |
| macOS | bash scripts/install-complete.sh |
| Linux | bash scripts/install-complete.sh |
Use this decision tree to determine the correct installation method:
flowchart TD
Start([User wants to install]) --> Q1{What OS?}
Q1 -->|Windows| Q2{Which shell?}
Q1 -->|macOS| MAC[Use: bash scripts/install-complete.sh]
Q1 -->|Linux| LINUX[Use: bash scripts/install-complete.sh]
Q2 -->|PowerShell/CMD| WIN_PS[Use: .\scripts\install-windows.ps1]
Q2 -->|Git Bash| WIN_GB[Use: bash scripts/install-complete.sh]
Q2 -->|WSL| WSL[Use: bash scripts/install-complete.sh]
Q2 -->|Cygwin| CYG[Use: bash scripts/install-complete.sh]
MAC --> CHECK[Check Python 3.6+]
LINUX --> CHECK
WIN_PS --> CHECK
WIN_GB --> CHECK
WSL --> CHECK
CYG --> CHECK
CHECK --> INSTALL[Run installer]
INSTALL --> RESTART[Restart Claude Code]
RESTART --> TEST[Test: claude 'What is 2+2?']
claude-code-audio-hooks/
├── CLAUDE.md # THIS FILE - AI assistant guide
├── README.md # User documentation
├── CHANGELOG.md # Version history
│
├── audio/
│ └── default/ # Audio files (9 MP3 files)
│ ├── notification.mp3 # Authorization requests
│ ├── task-complete.mp3 # Task completion (Stop)
│ ├── session-start.mp3 # Session begins
│ ├── session-end.mp3 # Session ends
│ ├── tool-start.mp3 # Before tool execution
│ ├── tool-end.mp3 # After tool execution
│ ├── user-prompt.mp3 # User submits prompt
│ ├── subagent-complete.mp3# Background task done
│ └── compact.mp3 # Context compaction
│
├── config/
│ ├── default_preferences.json # Default settings template
│ └── user_preferences.json # User's active settings
│
├── hooks/
│ ├── hook_runner.py # Main Python hook runner (Windows)
│ └── shared/
│ └── hook_config.sh # Shared bash functions (macOS/Linux)
│
├── scripts/
│ ├── install-complete.sh # Bash installer (all platforms)
│ ├── install-windows.ps1 # PowerShell installer (Windows)
│ ├── uninstall.sh # Uninstaller
│ ├── configure.sh # Configuration utility
│ ├── test-audio.sh # Audio testing tool
│ └── diagnose.py # Diagnostic tool
│
└── docs/ # Detailed documentation
├── ARCHITECTURE.md # System architecture
├── INSTALLATION_GUIDE.md # Detailed installation guide
└── TROUBLESHOOTING.md # Problem solving guide
graph TD
subgraph "Hook Events"
H1[Notification] -->|"Authorization needed"| A1[notification.mp3]
H2[Stop] -->|"Task completed"| A2[task-complete.mp3]
H3[SessionStart] -->|"Session begins"| A3[session-start.mp3]
H4[SessionEnd] -->|"Session ends"| A4[session-end.mp3]
H5[PreToolUse] -->|"Before tool"| A5[tool-start.mp3]
H6[PostToolUse] -->|"After tool"| A6[tool-end.mp3]
H7[UserPromptSubmit] -->|"User input"| A7[user-prompt.mp3]
H8[SubagentStop] -->|"Background done"| A8[subagent-complete.mp3]
H9[PreCompact] -->|"Compacting"| A9[compact.mp3]
end
| Hook | Trigger | Default Audio | Recommended |
|---|---|---|---|
Notification |
Authorization requests | notification.mp3 | Enable |
Stop |
Task completion | task-complete.mp3 | Enable |
SubagentStop |
Background task done | subagent-complete.mp3 | Enable |
SessionStart |
New session begins | session-start.mp3 | Optional |
SessionEnd |
Session closes | session-end.mp3 | Optional |
PreToolUse |
Before each tool | tool-start.mp3 | Disable (noisy) |
PostToolUse |
After each tool | tool-end.mp3 | Disable (noisy) |
UserPromptSubmit |
User sends message | user-prompt.mp3 | Optional |
PreCompact |
Context compaction | compact.mp3 | Optional |
- Claude Code CLI - Must be installed and working
- Python 3.6+ - Required for hook execution
| Platform | Audio Player | Notes |
|---|---|---|
| Windows | PowerShell MediaPlayer | Built-in, no install needed |
| macOS | afplay | Built-in, no install needed |
| Linux | mpg123, ffplay, or aplay | May need: sudo apt install mpg123 |
| WSL | PowerShell (via Windows) | Audio plays through Windows |
sequenceDiagram
participant User
participant Installer
participant Claude as ~/.claude/
participant Project as Project Dir
User->>Installer: Run install script
Installer->>Installer: Detect platform
Installer->>Installer: Check prerequisites
Installer->>Claude: Create hooks/ directory
Installer->>Claude: Copy hook_runner.py
Installer->>Claude: Save .project_path
Installer->>Claude: Configure settings.json
Installer->>Project: Create user_preferences.json
Installer->>User: Installation complete
User->>User: Restart Claude Code
User->>Claude: Test with "claude 'test'"
{
"hooks": {
"Notification": [{"hooks": [{"type": "command", "command": "py \"~/.claude/hooks/hook_runner.py\" notification"}]}],
"Stop": [{"hooks": [{"type": "command", "command": "py \"~/.claude/hooks/hook_runner.py\" stop"}]}],
// ... 7 more hooks
}
}Contains the absolute path to the project directory (Windows format on Windows):
D:/github_repository/claude-code-audio-hooks
{
"enabled_hooks": {
"notification": true,
"stop": true,
"subagent_stop": true,
"session_start": false,
"session_end": false,
"pretooluse": false,
"posttooluse": false,
"userpromptsubmit": false,
"precompact": false
},
"audio_settings": {
"theme": "default"
}
}# Bash/Zsh (Linux/macOS/Git Bash/WSL)
export CLAUDE_HOOKS_DEBUG=1
# PowerShell
$env:CLAUDE_HOOKS_DEBUG = "1"python scripts/diagnose.py -v --test-audio| Issue | Cause | Solution |
|---|---|---|
| No audio after install | Didn't restart Claude | Restart terminal/Claude Code |
| Path errors on Windows | Git Bash path format | Re-run installer (auto-converts) |
| WSL no audio | PowerShell not accessible | Check powershell.exe works |
| Linux no audio | No audio player | Install: sudo apt install mpg123 |
| "Invalid Settings" error | Old hooks format | Re-run installer for new format |
| Platform | Log Directory |
|---|---|
| Windows | %TEMP%\claude_audio_hooks_queue\logs\ |
| Linux/macOS | /tmp/claude_audio_hooks_queue/logs/ |
| WSL | /tmp/claude_audio_hooks_queue/logs/ |
When a user asks to install this project, follow these steps:
# Check OS
uname -s # Linux, Darwin (macOS), or MINGW*/MSYS* (Git Bash)
# Check for WSL
cat /proc/version 2>/dev/null | grep -i microsoft
# Check Python
python3 --version || python --version || py --versiongit clone https://github.com/ChanMeng666/claude-code-audio-hooks.git
cd claude-code-audio-hooksWindows PowerShell:
.\scripts\install-windows.ps1All other platforms (Git Bash, WSL, macOS, Linux):
bash scripts/install-complete.sh# Check hook runner installed
ls -la ~/.claude/hooks/hook_runner.py
# Check settings configured
cat ~/.claude/settings.json | grep hook_runner
# Check project path saved
cat ~/.claude/hooks/.project_pathInstruct user to:
- Restart Claude Code (close and reopen terminal)
- Run:
claude "What is 2+2?" - Listen for audio when response completes
| Version | Date | Key Changes |
|---|---|---|
| 3.3.4 | 2025-12-22 | Windows PowerShell installer, diagnostic tool, debug logging |
| 3.3.3 | 2025-11-07 | WSL audio fix, hooks format fix |
| 3.3.0 | 2025-11-06 | Non-interactive mode for all scripts |
| 3.0.0 | 2025-11-05 | Complete rewrite, Python hook runner |
- README.md - Full user documentation
- CHANGELOG.md - Detailed version history
- docs/ARCHITECTURE.md - System architecture details
- docs/INSTALLATION_GUIDE.md - Step-by-step installation
- docs/TROUBLESHOOTING.md - Problem solving guide
This document is optimized for AI assistant consumption. For human-readable documentation, see README.md.