Last active
July 29, 2025 04:57
-
-
Save dachi023/9b0c834925b10355c253e8fb3ce3ee15 to your computer and use it in GitHub Desktop.
Claude CodeのStop hookで完了時のメッセージを読み上げる
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -euo pipefail | |
| input=$(cat) | |
| [[ $(echo "$input" | jq -r '.stop_hook_active') == "true" ]] && exit 0 | |
| text=$(python3 -c " | |
| import json | |
| with open('$(echo "$input" | jq -r '.transcript_path')') as f: | |
| for entry in reversed([json.loads(l) for l in f if l.strip()]): | |
| if (msg := entry.get('message', {})).get('role') == 'assistant': | |
| if texts := [c['text'] for c in msg.get('content', []) if c.get('type') == 'text']: | |
| print(' '.join(texts)[:300]); break | |
| " 2>/dev/null || echo "No message") | |
| say "$text" && afplay /System/Library/Sounds/Glass.aiff 2>/dev/null & |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "hooks": { | |
| "Stop": [ | |
| { | |
| "matcher": "", | |
| "hooks": [ | |
| { | |
| "type": "command", | |
| "command": "/Users/myuser/.claude/hooks/say-output.sh" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment