How it works
Claude Code can trigger hooks at key lifecycle events:- session-start: When a new coding session begins
- notification: When Claude needs your attention (waiting for input, approval, etc.)
- stop: When the session ends
cmux claude-hook command connects these events to cmux’s notification system, workspace status indicators, and session tracking.
Setup
Verify cmux CLI is available
The If the command isn’t found, add cmux to your PATH:
cmux CLI is installed automatically with the cmux app. Check that it’s accessible:Configure Claude Code hooks
Create or edit
~/.claude/hooks.json to wire Claude lifecycle events to cmux:Claude Code will pipe event metadata as JSON to stdin when calling these hooks.
Session tracking
cmux tracks Claude Code sessions using theClaudeHookSessionStore mechanism. This associates each Claude session ID with a specific cmux workspace and surface.
How session tracking works
-
When
session-startfires, cmux stores the mapping: -
On subsequent
notificationevents, cmux looks up the session ID and routes notifications to the correct workspace/surface — even if you’ve switched tabs or windows. -
When
stopfires, cmux removes the session from the store and clears the status indicator.
~/.cmuxterm/claude-hook-sessions.json and pruned after 7 days of inactivity.
Command reference
session-start
Triggered when a Claude Code session begins. Sets the workspace status to “Running” with a bolt icon.notification
Triggered when Claude needs attention. Creates a notification and updates the workspace status to “Needs input” with a bell icon.stop
Triggered when a Claude Code session ends. Clears the workspace status indicator and removes the session from the store.Advanced usage
Multiple workspaces
If you run Claude Code in multiple workspaces, cmux automatically routes notifications to the correct workspace based on session ID.Custom hook scripts
You can wrap thecmux claude-hook command in a custom script for logging or additional automation:
~/.claude/my-hook.sh
hooks.json:
Environment variables
CMUX_SOCKET_PATH: Override the default socket path (default:/tmp/cmux.sock)CMUX_WORKSPACE_ID: Pre-set the target workspace IDCMUX_SURFACE_ID: Pre-set the target surface IDCMUX_CLAUDE_HOOK_STATE_PATH: Override session store location (default:~/.cmuxterm/claude-hook-sessions.json)
Troubleshooting
Notifications not appearing
Notifications not appearing
Check that cmux is running and the socket is accessible:Test the connection manually:If the socket doesn’t exist, launch cmux and try again.
Notifications appear in wrong workspace
Notifications appear in wrong workspace
The session store may have stale mappings. Clear it:Or explicitly target a workspace:
Hooks not firing
Hooks not firing
Verify your hooks.json syntax:Check Claude Code hook execution with a test script:
Related commands
cmux notify- Send custom notifications to any workspacecmux list-notifications- View all pending notifications- CLI Reference - Complete command reference