How It Works
- Global hooks in
~/.claude/settings.jsonfire on every Claude Code event - Hook script
~/.claude/hooks/ravi-copilot.shreads the JSON, wraps it in an envelope, and publishes to NATS - Ravi triggers subscribe to
ravi.copilot.*topics and react - Mailbox injection — Ravi writes to CC’s inbox JSON to communicate back (CC must be in team mode)
Commands
Send message to CC session
List CC teams
NATS Topics
Payload Envelope
Trigger Examples
Alert on tool failure
Monitor new sessions
Monitor dangerous Bash commands
Notify on session end
Setup
- Install nats CLI:
nats --version(orbrew install nats-io/nats-tools/nats) - Daemon running:
ravi daemon status - Hook script executable:
ls -la ~/.claude/hooks/ravi-copilot.sh - Hooks registered:
cat ~/.claude/settings.json | grep -c "ravi-copilot.sh"(should show 14) - Test:
nats sub "ravi.copilot.>" --server nats://127.0.0.1:4222 - Open a CC session — events should appear in the subscriber
Key Files
Notes
- CC must be in team mode to receive messages from Ravi (inbox poller only runs with an active team)
- Hook script requires
jqandnatsin PATH — fails silently if missing - Publishes in background (
&) — never blocks CC - Triggers have anti-loop: events from trigger sessions are ignored