https://github.com/anandchowdhary/claude-code-slack-bot
๐ค Use Claude Code from a Slack bot, built on top of Claude Code Action
https://github.com/anandchowdhary/claude-code-slack-bot
claude claude-ai claude-code cloudflare-workers github-actions hono slack slack-bot
Last synced: 7 months ago
JSON representation
๐ค Use Claude Code from a Slack bot, built on top of Claude Code Action
- Host: GitHub
- URL: https://github.com/anandchowdhary/claude-code-slack-bot
- Owner: AnandChowdhary
- License: mit
- Created: 2025-07-14T10:13:02.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-07-17T09:21:59.000Z (7 months ago)
- Last Synced: 2025-07-21T15:06:43.423Z (7 months ago)
- Topics: claude, claude-ai, claude-code, cloudflare-workers, github-actions, hono, slack, slack-bot
- Language: TypeScript
- Homepage:
- Size: 109 KB
- Stars: 4
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ค Claude Code Slack integration
Seamlessly connect Slack with Claude Code to turn your team's feature requests and bug reports into GitHub issues with AI-powered implementation. Built with Cloudflare Workers, Hono, and TypeScript on top of [Claude Code Action](https://github.com/anthropics/claude-code-action).
## ๐ธ How it works
### 1. Request a feature in Slack
When you mention the bot, it acknowledges your request and creates a GitHub issue:

### 2. Get real-time progress updates
As Claude Code works on your request, you'll see progress updates in the Slack thread:

### 3. Behind the scenes
The bot creates a GitHub issue with full context from your Slack conversation:

## ๐ Setup instructions
### ๐ Prerequisites
- Claude Code Action installed in your repository
- Cloudflare account with Workers enabled
- Slack workspace with admin access
- GitHub repository with Claude Code configured
- GitHub personal access token with `repo` scope
- Node.js 18+ and npm/yarn
### 1. Clone and install
```bash
git clone https://github.com/your-org/claude-code-slack
cd claude-code-slack
npm install
```
### 2. Configure Slack app
1. Go to [api.slack.com/apps](https://api.slack.com/apps) and create a new app
2. Choose "From scratch" and select your workspace
3. Navigate to **OAuth & Permissions** and add these scopes:
**Bot token scopes:**
- `app_mentions:read` - Read messages that mention your app
- `chat:write` - Send messages as the bot
- `reactions:write` - Add emoji reactions
- `reactions:read` - View emoji reactions
- `channels:history` - View messages in public channels
- `groups:history` - View messages in private channels
- `im:history` - View messages in DMs
- `mpim:history` - View messages in group DMs
4. Install the app to your workspace and copy the **Bot user OAuth token**
### 3. Configure event subscriptions
1. In your Slack app settings, go to **Event Subscriptions**
2. Enable Events and add your Worker URL: `https://your-worker.workers.dev/slack/events`
3. Subscribe to these bot events:
- `app_mention` - When someone mentions your bot
- `message.channels` - Messages in public channels (for thread replies)
- `message.groups` - Messages in private channels (for thread replies)
- `message.im` - Direct messages
- `message.mpim` - Group direct messages
### 4. Set environment variables
Create a `.dev.vars` file for local development:
```env
SLACK_BOT_USER_OAUTH_TOKEN=xoxb-your-token
GITHUB_TOKEN=ghp_your_token
GITHUB_OWNER=your-org
GITHUB_REPO=your-repo
```
### 5. Configure Cloudflare resources
#### KV namespace
Create a KV namespace for storing issue-thread mappings:
```bash
wrangler kv:namespace create "KV"
```
#### Queue
Create a queue for handling progress checks:
```bash
wrangler queues create progress-checks
```
Update `wrangler.jsonc` with your resource IDs:
```json
{
"name": "claude-code-slack",
"kv_namespaces": [
{
"binding": "KV",
"id": "your-kv-namespace-id"
}
],
"queues": {
"producers": [{ "binding": "PROGRESS_QUEUE", "queue": "progress-checks" }],
"consumers": [{ "queue": "progress-checks" }]
}
}
```
### 6. Deploy to Cloudflare
```bash
# Deploy to production
npm run deploy
# Or for development
npm run dev
```
## โ๏ธ Configuration
### Environment variables
| Variable | Description | Required |
| ---------------------------- | ---------------------------------------------- | -------- |
| `SLACK_BOT_USER_OAUTH_TOKEN` | Slack bot OAuth token | โ
|
| `GITHUB_TOKEN` | GitHub personal access token with `repo` scope | โ
|
| `GITHUB_OWNER` | GitHub organization or username | โ
|
| `GITHUB_REPO` | GitHub repository name | โ
|
### KV storage
The bot uses Cloudflare KV to store:
- Issue-to-thread mappings (30-day TTL)
- Enables persistent connection between Slack threads and GitHub issues
### Queue system
Uses Cloudflare Queues to:
- Handle progress monitoring asynchronously
- Check for GitHub updates every 10 seconds
- Automatically stop monitoring after 30 minutes or when work is complete
## ๐งช Testing & debugging
### Debug mode
Add `[DEBUG]` to any message to see detailed information:
- Channel and thread details
- KV storage operations
- GitHub API calls
- Queue processing steps
Example:
```
@claude-bot [DEBUG] Can you help me fix the login button?
```
### Common issues
1. **Bot not responding**:
- Verify OAuth scopes include all required permissions
- Check event subscriptions are properly configured
- Ensure bot is added to the channel
2. **No GitHub issue created**:
- Confirm GitHub token has `repo` scope
- Verify GITHUB_OWNER and GITHUB_REPO are correct
- Check for API rate limits
3. **Progress updates not appearing**:
- Ensure queue is properly configured in wrangler.jsonc
- Check queue consumer is running
- Verify KV namespace is accessible
## ๐ง How it works
1. **User mentions bot** โ Bot adds ๐ reaction and creates GitHub issue
2. **Issue created** โ Claude Code starts working, queue monitors progress
3. **Progress updates** โ Every 10 seconds, check for new GitHub comments
4. **Updates posted** โ Convert GitHub markdown to Slack format and post
5. **Completion detected** โ When "[Create PR โ]" appears or 30 minutes pass, remove ๐
## ๐ License
[MIT](./LICENSE)