Claude Code Hooks Workflow
An interactive flowchart visualizing how Claude Code hooks trigger Touch Bar status updates on your MacBook Pro.
Overview
This diagram illustrates the beautiful integration between Claude Code hooks and the MacBook Pro Touch Bar notification system. Watch how your prompt flows through the system, triggering colorful status updates that keep you informed at a glance!
Workflow Steps
- User sends prompt - You type your request in Claude Code CLI
- Claude Code processes request - Claude analyzes what you need
- Tool use needed? - Decision point: does Claude need to use tools?
- Yes path (Blue status):
- PreToolUse Hook fires - Hook triggers before tool execution
- Script writes JSON with BLUE status - Touch Bar turns blue
- No path (Green status):
- Claude responds directly - Text response without tools
- Stop Hook fires - Hook triggers when response completes
- Script writes JSON with GREEN status - Touch Bar turns green
- BetterTouchTool reads file - BTT polls the status file every second
- Touch Bar displays status! - You see the colorful indicator
Color Semantics
| Color | Meaning | Hook |
|---|---|---|
| Blue | Claude is working (tool in use) | PreToolUse |
| Green | Claude is ready for your next prompt | Stop |
Key Concepts
- Claude Code Hooks - Shell commands that execute on specific events
- PreToolUse Hook - Fires before any tool (Bash, Read, Write, etc.) executes
- Stop Hook - Fires when Claude finishes responding
- JSON Status - Color-coded status written to temp file
- BetterTouchTool - macOS app that displays status on Touch Bar
How Hooks Work
Hooks are configured in ~/.claude/settings.json:
{
"hooks": {
"PreToolUse": [{
"matcher": "",
"hooks": [{"type": "command", "command": "/path/to/script.sh running"}]
}],
"Stop": [{
"matcher": "",
"hooks": [{"type": "command", "command": "/path/to/script.sh prompt"}]
}]
}
}
Lesson Plan
Learning Objectives
By studying this workflow, you will understand:
- How Claude Code hooks provide extensibility points
- The flow of events when Claude processes a request
- How file-based IPC enables Touch Bar integration
- The difference between tool-using and direct responses
Activities
- Trace the Flow: Follow a prompt through both paths (with and without tools)
- Identify Hooks: List the two hooks used and when they fire
- Color Mapping: Explain why blue indicates "working" and green indicates "ready"
Assessment Questions
- What hook fires when Claude starts using the Bash tool?
- What file does the script write to?
- How often does BetterTouchTool check for updates?
- What determines whether the flow takes the "Yes" or "No" path?
Related Resources
- MacBook Touch Bar Status Documentation
- Claude Code Hooks Documentation
- BetterTouchTool Documentation
References
- Anthropic. (2025). Claude Code Hooks. https://docs.anthropic.com/en/docs/claude-code/hooks
- folivora. (2025). BetterTouchTool Documentation. https://docs.folivora.ai/