Skip to content

Add Claude Code CLI bridge#12

Open
sephxu wants to merge 1 commit into
anthropics:mainfrom
sephxu:cli-bridge
Open

Add Claude Code CLI bridge#12
sephxu wants to merge 1 commit into
anthropics:mainfrom
sephxu:cli-bridge

Conversation

@sephxu
Copy link
Copy Markdown

@sephxu sephxu commented Apr 30, 2026

Drives a Claude-* BLE device directly from Claude Code CLI, without the desktop app. Mirror-only: relays Notification events (the CLI's own "needs your attention" signal, fired when a tool call hits the user's permissions.ask list) to the device for a buzz + on-screen message.

Architecture:

Claude Code → hook.py → unix sock → daemon.py → BLE → device

  • daemon.py is long-running; maintains BLE link, accumulates session state, pushes snapshots, and signals "completed" briefly on each Notification (so existing firmware shows celebrate/attention pose).
  • hook.py is short-lived; Claude Code spawns one per hook event. It forwards a fire-and-forget message to the daemon. No PreToolUse interception, no decision round-trip — keeps tool-call latency at zero and avoids duplicating Claude Code's own permission DSL.

Single source of truth: Claude Code's permissions config (allow / ask / deny in settings.json) decides what gets prompted. The bridge does not have a separate policy file. Tuning what makes the device buzz means adjusting permissions.ask, not editing bridge config.

If the daemon is unreachable (not running, device disconnected) the hook silently no-ops so a dead daemon never blocks the terminal.

Drives a Claude-* BLE device directly from Claude Code CLI, without the
desktop app. Mirror-only: relays Notification events (the CLI's own
"needs your attention" signal, fired when a tool call hits the user's
permissions.ask list) to the device for a buzz + on-screen message.

Architecture:

  Claude Code → hook.py → unix sock → daemon.py → BLE → device

- daemon.py is long-running; maintains BLE link, accumulates session
  state, pushes snapshots, and signals "completed" briefly on each
  Notification (so existing firmware shows celebrate/attention pose).
- hook.py is short-lived; Claude Code spawns one per hook event. It
  forwards a fire-and-forget message to the daemon. No PreToolUse
  interception, no decision round-trip — keeps tool-call latency at
  zero and avoids duplicating Claude Code's own permission DSL.

Single source of truth: Claude Code's permissions config (allow / ask /
deny in settings.json) decides what gets prompted. The bridge does not
have a separate policy file. Tuning what makes the device buzz means
adjusting permissions.ask, not editing bridge config.

If the daemon is unreachable (not running, device disconnected) the
hook silently no-ops so a dead daemon never blocks the terminal.
@SnowWarri0r
Copy link
Copy Markdown

SnowWarri0r commented Apr 30, 2026

Heads-up to reviewers / folks landing here: there's a parallel community implementation, cc-buddy-bridge (MIT, Python, daily-driven for ~a week before this PR opened), with a different design philosophy. Sharing as prior art / alternative in case it's useful:

This PR (mirror-only) cc-buddy-bridge
Permission flow Notification mirrors the prompt PreToolUse round-trip; A/B buttons decide allow/deny
Tuning permissions.ask in settings Three-tier matcher (auto / ask / defer) + TOML override
Platform support macOS only (run-daemon.sh) macOS / Linux / Windows (all via bleak)
Install + autostart Manual JSON edit + manual run cc-buddy-bridge install [--service] — launchd / systemd / Task Scheduler
Statusline cc-buddy-bridge hud — composes with claude-hud
Assistant text on stick Stop hook (one-turn lag) JSONL tailer (~500 ms via watchfiles)
Folder push push-character over BLE w/ flow control
Tests / CI 98 tests, GH Actions matrix (Python 3.11 / 3.12 / 3.13)
Upstream firmware fixes #5 LittleFS auto-format (approved), #10 battery coulomb counter (pending)

Both designs are reasonable: mirror-only is simpler and avoids duplicating Claude Code's permission DSL; the round-trip variant is what unlocks defaultMode: bypassPermissions everywhere except the desk buddy — physical 2FA for the operations you flagged on permissions.ask.

Happy to upstream parts of cc-buddy-bridge under tools/ here if there's interest in a richer in-tree variant. Otherwise just leaving the link so the option is visible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants