coding by Ryan Caldwell

Run Claude Code From Discord With a Bot Bridge

An open-source Discord bot runs Claude Code from chat channels, with sandboxing, role-based access, MCP management, and Git branch organization.

Run Claude Code From Discord With a Bot Bridge

An open-source project called claude-code-discord lets developers operate the Claude Code CLI through Discord channels instead of a local terminal. The bot connects a self-hosted Claude Code instance to the Discord API, so commands and responses move through chat. The repository is available at https://github.com/zebbern/claude-code-discord.

How the Bridge Works

The bot is built on the @anthropic-ai/claude-agent-sdk and exposes Claude Code through Discord slash commands. According to the project, it ships with more than 45 slash commands covering coding sessions, shell access, Git operations, and worktree management.

A central idea is “thread-per-session.” Each conversation started with the /claude-thread command gets its own Discord thread with a custom name, which keeps separate tasks from blending into one channel. The project also maps Git branches to channels and categories so feature work stays organized by branch.

The recommended setup uses Docker. After cloning the repository, a developer copies the example environment file, fills in a Discord bot token and application ID, and starts the container with docker compose. An Anthropic API key is optional and, when present, enables dynamic model discovery that refreshes on a schedule. Model selection happens from chat as well, using settings commands to switch between Claude models.

Local Hosting and Access Control

The project is designed around keeping code and credentials on the operator’s own infrastructure. The documentation describes hosting locally on a virtual machine, in Docker, or in the cloud, while exposing only a controlled interface through Discord. This means API keys and source files stay on the operator’s machine rather than a third-party service.

Access control is role-based. Operators can restrict destructive commands such as /shell, /git, and worktree operations to specific Discord roles or user IDs, configured through environment variables. When Claude wants to use a tool that has not been approved, the bot can present interactive Allow and Deny buttons. Claude can also ask clarifying questions mid-session through Discord buttons rather than failing silently.

For containment, the project relies on the SDK sandbox, which it describes as supporting network rules, filesystem access control lists, and excluded commands. These boundaries limit what a chat-triggered session can reach on the host.

Collaboration and Oversight Features

Because the interface lives in Discord, a team can run commands and review results in a space they already use. The project frames this as centralized collaboration, where the channel history doubles as an audit trail showing who ran what and when.

The bot includes mid-session controls that do not require restarting a task. Operators can interrupt a run, change the model, change permissions, stop a task, or rewind. It also supports MCP server management from inside a session, allowing operators to view status, toggle servers, and reconnect them while work continues. A hooks system provides passive callbacks for tool use, notifications, and task completion, giving observability into what a session is doing.

One more feature is channel monitoring. The bot can watch a designated channel for messages from other bots, webhooks, or users, and automatically open a thread to investigate an alert. Combined with mentions that notify an operator when a task finishes, the design points toward running Claude Code on remote infrastructure while staying informed through chat.

Source: github.com