Control Claude Code AI directly from Telegram β code, review, and deploy from anywhere
Features β’ Quick Start β’ Deploy β’ Architecture β’ Configuration
Claude Code Telegram transforms your Telegram into a powerful AI coding assistant. It's a bridge between Claude Code (Anthropic's official CLI for Claude) and Telegram, allowing you to:
- π» Write code using natural language from your phone
- π Review and debug code on the go
- π Manage projects across multiple repositories
- β Approve AI actions with Human-in-the-Loop (HITL) controls
- π Deploy changes without touching your computer
Think of it as having Claude Code in your pocket, accessible anywhere via Telegram.
| Feature | Description |
|---|---|
| π¬ Natural Language | Just describe what you want β Claude writes the code |
| π Streaming Responses | See AI responses in real-time as they're generated |
| π Context Awareness | Maintains conversation history per project |
| π― Multi-Model Support | Works with Claude Sonnet, Opus, and Haiku |
| Feature | Description |
|---|---|
| β Tool Approval | Approve or deny file changes, commands before execution |
| β‘ YOLO Mode | Auto-approve all actions when you trust the AI |
| π Plan Review | Review implementation plans before Claude executes them |
| π Secure by Default | Nothing happens without your explicit consent |
| Feature | Description |
|---|---|
| ποΈ Multi-Project | Switch between different codebases seamlessly |
| π File Browser | Navigate and select projects via Telegram UI |
| πΎ Persistent Context | Each project maintains its own conversation history |
| π€ File Uploads | Send files directly to your project via Telegram |
| Feature | Description |
|---|---|
| π§© Official Plugins | Supports Claude Code plugins (commit, review, etc.) |
| π‘ MCP Integration | Telegram MCP server for Claude-initiated messages |
| π³ Docker Management | Control containers on your server |
| π System Monitoring | CPU, memory, disk metrics at a glance |
- π³ Docker & Docker Compose installed
- π€ Telegram bot token from @BotFather
- π Claude Code credentials (see below)
- π Your Telegram user ID (get it from @userinfobot)
Claude Code supports two authentication methods:
Uses your claude.ai subscription. No API costs β uses your existing Claude Pro/Team plan.
-
Install Claude Code CLI locally:
npm install -g @anthropic-ai/claude-code
-
Run and authenticate via browser:
claude # Opens browser for OAuth login to claude.ai -
Copy the credentials file to your project:
cp ~/.config/claude/config.json ./claude_config.json -
Mount it in
docker-compose.yml:volumes: - ./claude_config.json:/root/.config/claude/config.json:ro
Uses Anthropic API directly. Pay-per-use pricing.
ANTHROPIC_API_KEY=sk-ant-api03-xxxxxGet your API key from console.anthropic.com
Claude-compatible API with no regional restrictions.
ANTHROPIC_BASE_URL=https://open.bigmodel.cn/api/anthropic
ANTHROPIC_AUTH_TOKEN=your_zhipuai_tokenGet your token from open.bigmodel.cn
# Download and run the interactive deploy script
git clone https://github.com/Angusstone7/claude-code-telegram.git && \
cd claude-code-telegram && \
chmod +x deploy.sh && \
./deploy.shThe script will:
- β Check Docker installation
- β Prompt for your credentials interactively
- β
Create the
.envfile automatically - β Build and start the container
- β Show you next steps
# Clone, configure, and run β all in one command!
git clone https://github.com/Angusstone7/claude-code-telegram.git && \
cd claude-code-telegram && \
cp .env.example .env && \
echo "Now edit .env with your credentials, then run: docker-compose up -d --build"git clone https://github.com/Angusstone7/claude-code-telegram.git && cd claude-code-telegram && \
cat > .env << 'EOF'
TELEGRAM_TOKEN=your_bot_token_here
ANTHROPIC_API_KEY=sk-ant-your-key-here
ALLOWED_USER_ID=your_telegram_id_here
EOF
docker-compose up -d --buildJust replace:
your_bot_token_hereβ Your Telegram bot tokensk-ant-your-key-hereβ Your Anthropic API keyyour_telegram_id_hereβ Your Telegram user ID
π Click to expand detailed instructions
git clone https://github.com/Angusstone7/claude-code-telegram.git
cd claude-code-telegramcp .env.example .env# Required settings
TELEGRAM_TOKEN=123456789:ABCdefGHIjklMNOpqrsTUVwxyz
ANTHROPIC_API_KEY=sk-ant-api03-xxxxx
ALLOWED_USER_ID=123456789
# Optional: Multiple users (comma-separated)
# ALLOWED_USER_ID=123456789,987654321
# Optional: Use Claude Sonnet 4 (default) or other models
# ANTHROPIC_MODEL=claude-sonnet-4-20250514docker-compose up -d --builddocker-compose logs -f claude-botFind your bot and send /start π
| Command | Description |
|---|---|
/start |
π± Open main menu |
/yolo |
β‘ Toggle auto-approve mode |
/cancel |
π Cancel current AI task |
After /start, you'll see an inline keyboard with options:
βββββββββββββββββββββββββββββββββββ
β π¬ Chat with Claude Code β β Start coding session
βββββββββββββββββββββββββββββββββββ€
β π Projects β β Browse & switch projects
βββββββββββββββββββββββββββββββββββ€
β π€ Account β β Manage API credentials
βββββββββββββββββββββββββββββββββββ€
β βοΈ Settings β β Configure bot behavior
βββββββββββββββββββββββββββββββββββ
You: Create a Python function that validates email addresses
Claude: I'll create an email validation function for you.
π Creating file: utils/validators.py
ββββββββββββββββββββββββββββββββββββββ
β [β
Approve] [β Deny] [ποΈ View] β
ββββββββββββββββββββββββββββββββββββββ
You: [Clicks β
Approve]
Claude: β
Created utils/validators.py with email validation function.
The function uses regex pattern matching and handles edge cases...
When Claude wants to perform an action, you'll see approval buttons:
| Button | Action |
|---|---|
| β Approve | Allow Claude to proceed |
| β Deny | Block the action |
| ποΈ View | See what Claude wants to do |
| β‘ YOLO | Approve all future actions |
This project follows Domain-Driven Design (DDD) with clean architecture:
claude-code-telegram/
βββ π― domain/ # Core business logic
β βββ entities/ # User, Session, Project, Message
β βββ value_objects/ # UserId, Role, AIProviderConfig
β βββ repositories/ # Repository interfaces
β βββ services/ # Domain service contracts
β
βββ π¦ application/ # Use cases & orchestration
β βββ services/
β βββ bot_service.py # Main orchestration
β βββ project_service.py # Project management
β βββ context_service.py # Conversation context
β βββ account_service.py # Auth mode switching
β
βββ π§ infrastructure/ # External integrations
β βββ claude_code/
β β βββ sdk_service.py # Claude SDK (preferred)
β β βββ proxy_service.py # CLI fallback
β βββ persistence/ # SQLite repositories
β βββ messaging/ # AI service adapters
β
βββ π¨ presentation/ # Telegram interface
β βββ handlers/ # Message, callback, command handlers
β βββ keyboards/ # Inline keyboard builders
β βββ middleware/ # Auth middleware
β
βββ π telegram-mcp/ # MCP server (TypeScript)
β βββ src/index.ts # Telegram tools for Claude
β
βββ π§ͺ tests/ # Test suite (143+ tests)
| Mode | Description | When Used |
|---|---|---|
| SDK | Direct Python integration via claude-agent-sdk |
Primary (preferred) |
| CLI | Subprocess calls to claude CLI |
Fallback |
π§ Click to see all configuration options
| Variable | Description |
|---|---|
TELEGRAM_TOKEN |
Bot token from @BotFather |
ANTHROPIC_API_KEY |
API key (Anthropic or ZhipuAI) |
ALLOWED_USER_ID |
Telegram user ID(s), comma-separated |
| Variable | Default | Description |
|---|---|---|
ANTHROPIC_MODEL |
claude-sonnet-4-20250514 |
Default model |
ANTHROPIC_BASE_URL |
β | Custom API endpoint |
| Variable | Default | Description |
|---|---|---|
CLAUDE_WORKING_DIR |
/root/projects |
Default working directory |
CLAUDE_MAX_TURNS |
50 |
Max conversation turns |
CLAUDE_TIMEOUT |
600 |
Command timeout (seconds) |
CLAUDE_PERMISSION_MODE |
default |
default, auto, or never |
| Variable | Default | Description |
|---|---|---|
SSH_HOST |
host.docker.internal |
Host for SSH commands |
SSH_PORT |
22 |
SSH port |
LOG_LEVEL |
INFO |
Logging verbosity |
DEBUG |
false |
Enable debug mode |
| Host Path | Container Path | Purpose |
|---|---|---|
./data |
/app/data |
SQLite database |
./logs |
/app/logs |
Application logs |
./projects |
/root/projects |
Your code projects |
./claude_sessions |
/root/.claude |
Claude Code sessions |
./claude_config.json |
/root/.config/claude/config.json |
Claude Account credentials (optional) |
# Start the bot
docker-compose up -d --build
# View logs
docker-compose logs -f claude-bot
# Restart
docker-compose restart
# Stop
docker-compose down
# Update to latest version
git pull && docker-compose up -d --buildThe bot includes a Telegram MCP server that allows Claude to proactively send messages:
| Tool | Description |
|---|---|
send_message |
Send text notifications to Telegram |
send_file |
Send files with optional captions |
send_plan |
Create and send plan documents |
To rebuild after changes:
cd telegram-mcp && npm install && npm run build# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# or: venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Run locally
python main.py# All tests
pytest tests/
# With coverage
pytest tests/ --cov=. --cov-report=html
# Specific test file
pytest tests/unit/domain/test_ai_provider_config.py -v# Format code
black application/ domain/ infrastructure/ presentation/ shared/
# Type checking
mypy application/ domain/ infrastructure/ presentation/ shared/| Metric | Value |
|---|---|
| π Python LOC | ~28,100 |
| π Python Files | 112 |
| π§ͺ Unit Tests | 143+ |
| ποΈ Handlers LOC | ~9,000 |
| π MCP Server LOC | ~10,000 |
Access to the bot is controlled via ALLOWED_USER_ID environment variable:
# Single user (this user becomes admin)
ALLOWED_USER_ID=123456789
# Multiple users (first user is admin, others are regular users)
ALLOWED_USER_ID=123456789,987654321,555555555| Feature | Description |
|---|---|
| π Whitelist | Only users in ALLOWED_USER_ID can access the bot |
| π Auto Admin | First user in the list automatically gets admin role |
| π« Access Denied | Unauthorized users see their Telegram ID (for requesting access) |
If ALLOWED_USER_ID is empty, bot is open to everyone (warning logged) |
- β HITL Controls β Every AI action requires explicit approval
- β No Credentials in Code β All secrets via environment variables
- β SSH Key Auth β Secure server access (optional feature)
- β Role-Based Access β Admin, DevOps, User, ReadOnly roles
Bot doesn't respond
- Check logs:
docker-compose logs -f claude-bot - Verify
TELEGRAM_TOKENis correct - Ensure your user ID is in
ALLOWED_USER_ID
Claude Code not working
- Check if API key is valid
- Verify
ANTHROPIC_API_KEYis set - Look for SDK/CLI status in startup logs
Permission denied errors
chmod -R 755 ./data ./logs ./projectsContributions are welcome! Please:
- π΄ Fork the repository
- πΏ Create a feature branch (
git checkout -b feature/amazing-feature) - πΎ Commit your changes (
git commit -m 'Add amazing feature') - π€ Push to the branch (
git push origin feature/amazing-feature) - π Open a Pull Request
This project is licensed under the MIT License β see the LICENSE file for details.
Built with these amazing tools:
- Aiogram β Modern Telegram bot framework
- Claude Code β Anthropic's AI coding CLI
- Anthropic SDK β Claude API client
Made with β€οΈ for developers who code on the go