by who96
Single-file bridge: talk to Claude Code CLI from Discord.
# Add to your Claude Code skills
git clone https://github.com/who96/claude_bridge_discordSingle-file bridge that connects one Discord channel to one Codex CLI process.
This repository keeps command compatibility with the previous Claude bridge:
/new /status /connect /handoff /help.
CHANNEL_IDDiscord message -> bridge.py -> codex exec/resume --json -> parse JSON events -> Discord reply
Bridge state:
~/.codex-discord-bridge/~/.codex-discord-bridge/session.json
thread_idsession_id~/.codex-discord-bridge/handoffs/codex exec --json --skip-git-repo-check [--dangerously-bypass-approvals-and-sandbox] [-m MODEL] "<prompt>"codex exec resume --json --skip-git-repo-check [--dangerously-bypass-approvals-and-sandbox] [-m MODEL] <thread_id> "<prompt>"thread.started.thread_id as authoritative thread IDitem.completed.item.type=="agent_message" text as reply bodyNo comments yet. Be the first to share your thoughts!
/connect safety:
/connect <thread_id> is strict.thread.started.thread_id, bridge treats it as failure and blocks auto-fallback.Implicit fallback:
| Variable | Required | Default | Description |
|---|---|---|---|
| DISCORD_TOKEN | Yes | — | Discord bot token |
| CHANNEL_ID | Yes | — | Discord channel ID |
| CODEX_BIN | No | codex | Codex CLI binary path |
| CODEX_MODEL | No | empty | Optional model override |
| CODEX_TIMEOUT | No | 300 | Max seconds per Codex call |
| CODEX_CWD | No | $HOME | Working directory for Codex call |
| CODEX_FULL_ACCESS | No | 0 | 1 enables --dangerously-bypass-approvals-and-sandbox |
| SELFTEST_ON_START | No | 0 | 1 runs startup selftest |
Compatibility fallback (for smooth migration):
CLAUDE_CWD can still be used if CODEX_CWD is not setCLAUDE_TIMEOUT can still be used if CODEX_TIMEOUT is not set| Command | Behavior |
|---|---|
| /new | Clear current thread; next message creates a new thread |
| /status | Show current thread, cwd, timeout, backend |
| /connect [thread-id] | Bind explicit thread (no arg = reset) |
| /handoff | Summarize old thread -> coldstart new thread; rollback old thread if new bootstrap fails |
| /help | Show command help |
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
DISCORD_TOKEN="xxx" \
CHANNEL_ID="1234567890" \
CODEX_FULL_ACCESS="1" \
.venv/bin/python3 bridge.py
Keep old example for r...