Claude Code Integration
Claude Code provides the most comprehensive hcom integration with automatic message delivery, PTY mode support, and subagent coordination.Message Delivery
Automatic: Messages are delivered automatically during normal Claude operation. No manual polling required. When messages arrive:- Mid-turn: Delivered at PostToolUse after any tool execution
- Idle: Delivered at Stop hook (vanilla mode) or via PTY injection (PTY mode)
- PTY mode: Messages injected at UserPromptSubmit when agent is idle
Hook Installation
Hooks are installed to~/.claude/settings.json (or $HCOM_DIR parent if set).
Automatic Install
Run Claude via hcom launcher:Manual Install
If you prefer to run Claude directly:Verify Installation
Launch Modes
PTY Mode (Recommended)
Launch with hcom for full integration:- Instant message delivery via terminal injection
- Terminal screen capture (
hcom term) - Automatic cleanup on kill (
hcom kill) - Fork and resume support
Vanilla Mode
Run Claude directly after installing hooks:- Messages delivered at Stop hook (when Claude goes idle)
- Waits up to
HCOM_TIMEOUTseconds (default: 86400) - No terminal screen capture
- Manual binding via
hcom startoutput marker
Headless Mode
Background execution without interactive terminal:- Run detached in background
- Messages delivered at Stop hook
- Managed via TUI (
hcom) - Auto-exit after timeout if no messages
Subagent Support
Claude Code’s Task tool spawns subagents that participate in hcom. How it works:- Parent Claude runs Task tool
- Subagent session starts (detected via
subagent-starthook) - Parent tracks subagent in
running_tasks - Subagent can send/receive hcom messages
- Parent delivers freeze-period messages when Task completes
- Connect to hcom with unique agent IDs
- Can message each other and other agents
- Are cleaned up when Task tool exits
Hook Types
Claude Code has 9 hook types:| Hook | When | Purpose |
|---|---|---|
| sessionstart | Session begins | Bind session, inject bootstrap |
| userpromptsubmit | User submits prompt | PTY message delivery |
| pre | Before tool execution | Status tracking |
| post | After tool execution | Message delivery, bootstrap fallback |
| poll | Agent goes idle | Non-PTY message polling |
| notify | Approval prompt | Status: blocked |
| subagent-start | Task tool spawns agent | Track subagent |
| subagent-stop | Subagent exits | Deliver messages, cleanup |
| sessionend | Session ends | Finalize, stop instance |
Configuration
Default Arguments
Timeout Settings
Auto-Approval
Enable auto-approval for safe hcom commands:Session Recovery
Claude Code supports session recovery after compaction: Automatic recovery:- Hook detects compaction (source=compact)
- Re-injects bootstrap if instance still bound
- Preserves hcom identity across compaction
Launch Examples
Single Agent
Multiple Agents
Fork and Resume
Advanced
Vanilla Binding
For vanilla Claude sessions, binding happens via transcript marker:- Run
hcom startinside Claude - Output contains
[hcom:instance-name]marker - Bash post hook detects marker in tool output
- Binds session to instance automatically
PTY Injection
PTY mode uses terminal control sequences for message delivery:- PTY wrapper monitors instance status
- When messages arrive, injects text into terminal
- Claude sees injected text as if user typed it
- Near-instant delivery without waiting for hooks
Bootstrap Injection
Bootstrap tells Claude about hcom on session start: Content:- Instance name and identity
- Available hcom commands
- Other active agents
- Relay status (if enabled)
- Custom notes (if configured)
- SessionStart (PTY mode)
- PostToolUse Bash (fallback for vanilla)
- UserPromptSubmit (rare fallback)
Troubleshooting
Messages not arriving
- Check Claude is idle:
hcom listshowslisteningstatus - Verify hooks installed:
hcom hooks status - Check recent events:
hcom events --last 5 - Try manual delivery:
hcom send @claude-instance -- test
Hooks not working
Subagents not connecting
- Parent must be PTY-launched:
hcom claude - Check parent status:
hcom listshows parent inactivestatus during Task - Subagent timeout: increase if tasks are slow
Reference
Hook configuration:~/.claude/settings.json
Settings path function:
- PTY mode: via process_id
- Vanilla: via transcript marker
- Fork: inherits parent binding
- 0: Success / no output
- 2: Message delivered (used internally)