Discord Bridge for Autonomous Claude Code Sessions

A developer has built a Discord bridge for autonomous Claude Code sessions to solve the pull-based limitation where Claude only acts when tools fire or CLI input is sent. The system enables real-time two-way chat via WebSocket with local file queueing and push notifications on stop/error events.
Architecture
Inbound flow: Discord → WebSocket → bridge.js → discord-inbox.jsonl → PostToolUse hook → Claude
Outbound flow: Claude → Discord MCP → #claude-code-chat → phone push notification
Components
- bridge.js (~50 lines, discord.js v14): Persistent WebSocket to Discord gateway that listens to a dedicated channel and writes messages as JSONL to a local inbox file with zero API polling.
- PostToolUse hook: Reads local inbox on every tool call with no network calls or throttling — just a file read that takes microseconds versus the 2-minute polling interval used previously.
- PreToolUse hook: Auto-starts the bridge on first tool call of every session, silently doing nothing if already running.
- Outbound webhook: Sends structured STATUS updates on Stop/Error events with per-session named threads auto-created via Discord's thread_name parameter (requires ?wait=true to get channel_id back — default returns 204 empty).
Key Design Decisions
The main architectural shift was using a local file queue over API polling. JSONL with atomic truncation prevents race conditions. The bridge is session-agnostic — Discord history persists across crashes and restarts, allowing multiple agents to share the same channel.
Limitations
Permission approval prompts (1/2/3) still require terminal input since Claude is idle at that point and tools aren't firing. This works for redirecting mid-active-run but not for answering stopped prompts.
Testing Results
Tested on 27K lines analyzed overnight across two parallel sessions, finding 15 bugs and delivering a 6-month roadmap at 5:42 AM. Setup requires three bash files and approximately twenty minutes.
📖 Read the full source: r/LocalLLaMA
👀 See Also

MCP Server Tracks Known Bugs in Dev Tools to Improve LLM Recommendations
nanmesh-mcp is an MCP server that crawls GitHub Issues, Stack Overflow, and Reddit to track real problems in 57 development tools, providing LLMs with current bug data before making library recommendations.

Sentrial: Production Monitoring for AI Agents
Sentrial is a monitoring tool that automatically detects failure patterns in AI products including loops, hallucinations, tool misuse, and user frustrations. It diagnoses root causes by analyzing conversation patterns, model outputs, and tool interactions.

Homebutler: OpenClaw Skill for Homelab Management via Telegram
Homebutler is a single Go binary (~13MB, zero dependencies) that works as an OpenClaw skill to manage homelabs from Telegram chat. It monitors servers, restarts Docker containers, wakes machines, scans networks, and alerts on resource spikes without SSH sessions or dashboard logins.

Mia: Local AI Workspace Daemon with Native Android App and P2P Streaming
Mia is a daemon that runs on your machine and pairs with a native Android app over P2P, allowing you to kick off and monitor long-running AI coding tasks from your phone. It supports OpenCode, Claude Code, Gemini CLI, and Codex agents, streaming output directly to your device in real time.