Claude Code to Discord bridge - run Claude Code sessions through Discord.
- Per-user sessions: Each Discord user gets their own Claude Code session
- Real-time output: Claude Code output streams directly to Discord channels
- Status embed: Auto-updating pinned embed showing model, tokens, cost, and context usage
- Slash commands: Pass Claude Code commands through Discord (
/cc clear,/cc compact, etc.) - SDK-based: Uses official
@anthropic-ai/claude-codenpm package for reliable output
- Node.js 18+
- Discord bot token and application ID
- Anthropic API key OR users with Claude Max/Pro subscriptions
npm installcp .env.example .env
# Edit .env with your Discord bot token and app ID# Development (with hot reload)
npm run dev
# Production
npm run build
npm start| Command | Description |
|---|---|
/cc start |
Start a new Claude Code session |
/cc stop |
Stop your current session |
/cc login |
Authenticate with your Claude Max/Pro subscription |
/cc logout |
Remove your stored Claude credentials |
/cc clear |
Clear conversation history |
/cc compact |
Compact conversation to save context |
/cc model <name> |
Change the model |
/cc status |
Show session status |
Two authentication methods are supported:
-
Per-user OAuth (recommended): Users run
/cc loginand follow the DM instructions to authenticate with their own Claude Max/Pro subscription. -
Shared API key: Set
ANTHROPIC_API_KEYenvironment variable for all users to share.
Per-user OAuth takes priority if both are configured.
Once you start a session with /cc start:
- Any message you send in the channel goes directly to Claude Code
- Claude Code's output appears in the channel
- A pinned status embed shows current stats
- Use
/cc stopto end the session
Discord Bot (bot.ts)
↓
Session Manager (session.ts)
↓
Claude SDK Wrapper (claude.ts) ←→ Status Embed (embed.ts)
↓
@anthropic-ai/claude-code query()
| Variable | Required | Description |
|---|---|---|
DISCORD_BOT_TOKEN |
Yes | Discord bot token |
DISCORD_APP_ID |
Yes | Discord application ID |
ANTHROPIC_API_KEY |
No | Global API key (fallback) |
CODESMITH_CHANNEL_ID |
No | Restrict to specific channel |
CODESMITH_WORKSPACE_BASE |
No | Custom workspace directory |
CODESMITH_SESSION_TIMEOUT |
No | Session timeout in ms |
CODESMITH_DEFAULT_MODEL |
No | Default model name |
MIT