A Discord bot that lets users interact with Claude Code directly in Discord threads.
- TypeScript (strict mode)
- discord.js v14
- @anthropic-ai/claude-agent-sdk
- Node.js 20+
- pnpm as package manager
src/index.ts— Bot entry point, Discord client setupsrc/commands/— Slash command handlerscode.ts—/code <prompt>— Start a coding task in a new threadask.ts—/ask <question>— Ask Claude a question (no file tools)
src/agent/— Claude Agent SDK integrationsession.ts— Manages agent sessions, wraps query() with streamingtools.ts— Tool configuration and allowed tools presets
src/discord/— Discord utilitiesstream.ts— Stream agent output to Discord (edit messages in chunks)thread.ts— Thread creation and management
src/config.ts— Environment config (DISCORD_TOKEN, ANTHROPIC_API_KEY, etc.)
- When user runs
/code <prompt>, bot creates a thread and streams Claude's work there - Agent output is streamed — bot edits its message every ~1s with new content
- Tool usage (file reads, edits, bash commands) shown as formatted blocks
- Support
/askfor quick questions without file system tools - Error handling: timeouts, rate limits, graceful shutdown
- Store secrets and runtime config in
~/.agent-inbox/config.jsonl
- ESM modules
- Strict TypeScript
- No classes unless necessary, prefer functions
- Use async/await, no callbacks
- Minimal dependencies
- No comments that just restate the code
- pnpm init, install deps
- tsconfig.json with strict mode, ESM
~/.agent-inbox/config.jsonlwith required records- .gitignore for node_modules, dist