forked from
danielmorrisey.com/claude-bot
A simple Claude AI Bot that uses the Claude API
@madebydanny.uk / claude-bot#
Bluesky Claude Bot (Python)#
A Python-based Bluesky bot that listens for mentions of @claude.altq.net and responds using the Claude API.
WORKS FOR altq.net PDS ONLY#
PLEASE EDIT CODE TO WORK WITH YOUR PDS
Features#
- Listens for mentions on Bluesky
- Uses Claude API (Claude Sonnet 4.5) to generate responses
- Automatically replies to mentions
- Handles long responses by splitting into thread replies
- Tracks processed posts to avoid duplicates
- Uses your custom prompt template for Claude responses
Setup#
1. Install Dependencies#
cd bot-python
pip install -r requirements.txt
Or if you prefer using a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
2. Configure Environment Variables#
Copy the example environment file and fill in your credentials:
cp .env.example .env
Edit .env and add:
BLUESKY_HANDLE: Your Bluesky handle (e.g.,claude.altq.net)BLUESKY_PASSWORD: Your Bluesky app password (create one at https://bsky.app/settings/app-passwords)ANTHROPIC_API_KEY: Your Anthropic API key (get one at https://console.anthropic.com/)BOT_HANDLE: The handle the bot listens for (default:claude.altq.net)
⚠️ Security Warning: Never commit your .env file to git! The .env.example file should only contain placeholder values.
3. Create a Bluesky App Password#
- Go to https://bsky.app/settings/app-passwords
- Create a new app password
- Use this password in the
BLUESKY_PASSWORDenvironment variable
4. Run the Bot#
python bot.py
The bot will:
- Log in to Bluesky
- Start polling for mentions every 10 seconds
- Respond to any mentions of
@claude.altq.net(or your configuredBOT_HANDLE)
How It Works#
- The bot logs into Bluesky using your credentials
- It polls for notifications every 10 seconds
- When it finds a mention of
@claude.altq.net, it:- Extracts the question from the post
- Sends it to the Claude API with your custom prompt
- Posts the response as a reply
- Long responses are automatically split into thread replies
Claude Prompt#
The bot uses a custom prompt that instructs Claude to:
- Keep responses short and concise (1-2 sentences)
- Write in a casual, friendly tone
- Stay on topic
- Avoid controversial or inappropriate content
- Write suitable for direct posting on Bluesky
You can modify the prompt in the get_claude_response() function in bot.py.
Troubleshooting#
Bot not responding to mentions#
- Check that your credentials are correct in
.env - Verify the bot is running and check console logs
- Make sure
BOT_HANDLEmatches the handle people are mentioning - Check that your Bluesky account has permission to post replies
API Errors#
- Verify your Anthropic API key is correct and has credits
- Check that your Bluesky app password is valid
- Ensure your Bluesky account is in good standing
Import Errors#
- Make sure all dependencies are installed:
pip install -r requirements.txt - Check that you're using Python 3.8 or higher
Production Deployment#
For production, consider:
- Using a process manager like
systemd,supervisor, orpm2 - Setting up monitoring and logging
- Running on a cloud service (AWS, Heroku, Fly.io, etc.)
- Setting up environment variables securely
- Using a virtual environment
License#
MIT