forked from
danielmorrisey.com/claude-bot
A simple Claude AI Bot that uses the Claude API
1# @madebydanny.uk / claude-bot
2
3# Bluesky Claude Bot (Python)
4
5A Python-based Bluesky bot that listens for mentions of `@claude.altq.net` and responds using the Claude API.
6
7# WORKS FOR altq.net PDS ONLY
8**PLEASE EDIT CODE TO WORK WITH YOUR PDS**
9
10## Features
11
12- Listens for mentions on Bluesky
13- Uses Claude API (Claude Sonnet 4.5) to generate responses
14- Automatically replies to mentions
15- Handles long responses by splitting into thread replies
16- Tracks processed posts to avoid duplicates
17- Uses your custom prompt template for Claude responses
18
19## Setup
20
21### 1. Install Dependencies
22
23```bash
24cd bot-python
25pip install -r requirements.txt
26```
27
28Or if you prefer using a virtual environment:
29
30```bash
31python -m venv venv
32source venv/bin/activate # On Windows: venv\Scripts\activate
33pip install -r requirements.txt
34```
35
36### 2. Configure Environment Variables
37
38Copy the example environment file and fill in your credentials:
39
40```bash
41cp .env.example .env
42```
43
44Edit `.env` and add:
45- `BLUESKY_HANDLE`: Your Bluesky handle (e.g., `claude.altq.net`)
46- `BLUESKY_PASSWORD`: Your Bluesky app password (create one at https://bsky.app/settings/app-passwords)
47- `ANTHROPIC_API_KEY`: Your Anthropic API key (get one at https://console.anthropic.com/)
48- `BOT_HANDLE`: The handle the bot listens for (default: `claude.altq.net`)
49
50**⚠️ Security Warning:** Never commit your `.env` file to git! The `.env.example` file should only contain placeholder values.
51
52### 3. Create a Bluesky App Password
53
541. Go to https://bsky.app/settings/app-passwords
552. Create a new app password
563. Use this password in the `BLUESKY_PASSWORD` environment variable
57
58### 4. Run the Bot
59
60```bash
61python bot.py
62```
63
64The bot will:
651. Log in to Bluesky
662. Start polling for mentions every 10 seconds
673. Respond to any mentions of `@claude.altq.net` (or your configured `BOT_HANDLE`)
68
69## How It Works
70
711. The bot logs into Bluesky using your credentials
722. It polls for notifications every 10 seconds
733. When it finds a mention of `@claude.altq.net`, it:
74 - Extracts the question from the post
75 - Sends it to the Claude API with your custom prompt
76 - Posts the response as a reply
774. Long responses are automatically split into thread replies
78
79## Claude Prompt
80
81The bot uses a custom prompt that instructs Claude to:
82- Keep responses short and concise (1-2 sentences)
83- Write in a casual, friendly tone
84- Stay on topic
85- Avoid controversial or inappropriate content
86- Write suitable for direct posting on Bluesky
87
88You can modify the prompt in the `get_claude_response()` function in `bot.py`.
89
90## Troubleshooting
91
92### Bot not responding to mentions
93
94- Check that your credentials are correct in `.env`
95- Verify the bot is running and check console logs
96- Make sure `BOT_HANDLE` matches the handle people are mentioning
97- Check that your Bluesky account has permission to post replies
98
99### API Errors
100
101- Verify your Anthropic API key is correct and has credits
102- Check that your Bluesky app password is valid
103- Ensure your Bluesky account is in good standing
104
105### Import Errors
106
107- Make sure all dependencies are installed: `pip install -r requirements.txt`
108- Check that you're using Python 3.8 or higher
109
110## Production Deployment
111
112For production, consider:
113- Using a process manager like `systemd`, `supervisor`, or `pm2`
114- Setting up monitoring and logging
115- Running on a cloud service (AWS, Heroku, Fly.io, etc.)
116- Setting up environment variables securely
117- Using a virtual environment
118
119## License
120
121MIT
122