Contrôlez Claude Code CLI directement depuis Telegram - Un bot Telegram qui donne accès complet à Claude Code avec tous ses outils (Read, Write, Edit, Bash, Git, etc.)
Envoyez des messages à votre bot Telegram et Claude Code exécute les tâches :
- 📖 Lire/modifier du code
- 🔧 Exécuter des commandes (tests, build, git)
- 🌐 Faire des recherches web
- ✍️ Créer/éditer des fichiers
- 💬 Poser des questions interactives
- ⚡ Animations en temps réel (typing indicator ●●●)
Architecture : CLI subprocess (comme richardatct) avec streaming complet des outils.
- GCP Account (free tier OK)
- Token Telegram : Créez un bot via @BotFather
- Claude CLI : Compte Anthropic (console)
- Votre Telegram ID : Obtenez-le via @userinfobot
# Clone ce repo
git clone https://github.com/stebou/claude-code-telegram-gcp.git
cd claude-code-telegram-gcp
# Créer la VM (e2-small, 2GB RAM, 30GB disk)
gcloud compute instances create telegram-bot-vm \
--zone=us-central1-a \
--machine-type=e2-small \
--image-family=ubuntu-2204-lts \
--image-project=ubuntu-os-cloud \
--boot-disk-size=30GB# SSH dans la VM
gcloud compute ssh telegram-bot-vm --zone=us-central1-a
# Installer dépendances
sudo apt-get update
sudo apt-get install -y python3.11 python3.11-venv git tmux
# Installer Poetry
curl -sSL https://install.python-poetry.org | python3 -
export PATH="$HOME/.local/bin:$PATH"
# Installer Claude CLI
npm install -g @anthropic-ai/claude
# Cloner le bot
mkdir -p ~/telegram-bot
cd ~/telegram-bot
git clone https://github.com/stebou/claude-code-telegram-gcp.git
cd claude-code-telegram-gcp/bot
# Installer dépendances Python
poetry install# Créer .env
cd ~/telegram-bot/claude-code-telegram-gcp/bot
cp .env.example .env
nano .envRemplissez :
TELEGRAM_BOT_TOKEN=votre_token_botfather
TELEGRAM_BOT_USERNAME=votre_bot_username
ALLOWED_USERS=[votre_telegram_id]
APPROVED_DIRECTORY=/home/votre_user/telegram-bot/votre_repoAuthentifier Claude :
claude auth login
# Suivez le lien dans votre navigateur# Créer script de démarrage
cat > ~/telegram-bot/start-bot.sh << 'EOF'
#!/bin/bash
tmux kill-session -t telegram-bot 2>/dev/null
tmux new-session -d -s telegram-bot
tmux send-keys -t telegram-bot "cd ~/telegram-bot/claude-code-telegram-gcp/bot" C-m
tmux send-keys -t telegram-bot 'export PATH="/home/$USER/.local/bin:$PATH"' C-m
tmux send-keys -t telegram-bot 'echo "🤖 Démarrage Telegram Bot..."' C-m
tmux send-keys -t telegram-bot "poetry run python -m src.main" C-m
echo "✅ Bot démarré dans tmux session 'telegram-bot'"
echo "Pour voir les logs: tmux attach -t telegram-bot"
echo "Pour détacher: Ctrl+B puis D"
EOF
chmod +x ~/telegram-bot/start-bot.sh
# Démarrer le bot
~/telegram-bot/start-bot.sh- Ouvrez Telegram
- Cherchez votre bot
- Envoyez
/start - Testez : "Liste tous les fichiers Python du projet"
✅ C'est tout ! Le bot est opérationnel.
- 📖 Read - Lit n'importe quel fichier
- ✍️ Write - Crée de nouveaux fichiers
- ✏️ Edit - Modifie du code existant
- 🔧 Bash - Exécute des commandes shell
- 🔍 Glob - Trouve des fichiers par pattern
- 🔎 Grep - Cherche dans le code
- 🌐 WebSearch - Recherche web
- 📋 TodoWrite - Gère des listes de tâches
- 🎯 Task - Lance des tâches multi-étapes
- 💬 AskUserQuestion - Pose des questions
- ⚡ Skill - Exécute des skills personnalisés
- 🔨 SlashCommand - Commandes custom
Le bot affiche :
- ✅ Animation "typing" (●●●) pendant le traitement
- 🔧 Outils utilisés en temps réel
- 🤖 Réflexions de Claude
- ✨ Résultats au fur et à mesure
Vous: "Ajoute une fonction de login avec JWT"
Bot: 🔧 Read
📖 Lecture de auth/
Bot: 🔧 Write
✍️ Création de auth/jwt_handler.py
Bot: 🔧 Edit
✏️ Mise à jour de main.py
Bot: 🔧 Bash
🧪 pytest tests/test_auth.py -v
✅ Tests OK
Bot: 🔧 Bash
📤 git commit -m "feat: Add JWT auth"
🚀 git push origin main
✅ Feature complète et déployée !
# Attacher à tmux
tmux attach -t telegram-bot
# Détacher: Ctrl+B puis D
# Ou depuis votre machine locale
gcloud compute ssh telegram-bot-vm --zone=us-central1-a \
--command="tmux capture-pane -t telegram-bot -p | tail -50"ssh telegram-bot-vm
~/telegram-bot/start-bot.shssh telegram-bot-vm
cd ~/telegram-bot/claude-code-telegram-gcp
git pull
poetry install
~/telegram-bot/start-bot.sh# Arrêter
gcloud compute instances stop telegram-bot-vm --zone=us-central1-a
# Redémarrer
gcloud compute instances start telegram-bot-vm --zone=us-central1-a
gcloud compute ssh telegram-bot-vm --zone=us-central1-a \
--command="~/telegram-bot/start-bot.sh"- VM e2-small : ~$12/mois (2GB RAM, recommandé)
- Disk 30GB : ~$1/mois
- Claude API : Variable selon usage
- Total : ~$15-20/mois
- ✅ Sandbox : Accès limité à
APPROVED_DIRECTORY - ✅ Whitelist : Seuls les users dans
ALLOWED_USERS - ✅ Rate limiting : Protection DoS
- ✅ Commandes bloquées :
rm -rf /,sudo, etc.
# Telegram
TELEGRAM_BOT_TOKEN=123456:ABC-DEF
TELEGRAM_BOT_USERNAME=my_bot
# Sécurité
ALLOWED_USERS=[1136600499]
APPROVED_DIRECTORY=/home/user/telegram-bot/repo
# Claude
USE_SDK=false
CLAUDE_MAX_TURNS=10
CLAUDE_MAX_COST_PER_USER=10.0
CLAUDE_TIMEOUT_SECONDS=900
CLAUDE_ALLOWED_TOOLS=["Read","Write","Edit","Bash","Glob","Grep","Task","WebFetch","WebSearch","TodoWrite","Skill","SlashCommand","AskUserQuestion"]
# Rate Limiting
RATE_LIMIT_REQUESTS=10
RATE_LIMIT_WINDOW=60
# Features
ENABLE_FILE_UPLOADS=true
DEBUG=false
LOG_LEVEL=INFOAjoutez à ~/.ssh/config :
Host telegram-bot-vm
HostName YOUR_VM_IP
User YOUR_USERNAME
IdentityFile ~/.ssh/google_compute_engine
ServerAliveInterval 60
TCPKeepAlive yes
Puis dans VSCode :
- Installer extension "Remote - SSH"
- F1 → "Remote-SSH: Connect to Host"
- Sélectionner
telegram-bot-vm
# Vérifier si le bot tourne
ssh telegram-bot-vm
tmux attach -t telegram-bot
# Vérifier Claude auth
claude auth status
# Vérifier .env
cat ~/telegram-bot/claude-code-telegram-gcp/bot/.envVotre .env est mal formaté. Utilisez des JSON arrays :
❌ Incorrect :
ALLOWED_USERS=123456
CLAUDE_ALLOWED_TOOLS=Read,Write✅ Correct :
ALLOWED_USERS=[123456]
CLAUDE_ALLOWED_TOOLS=["Read","Write"]Upgradez vers e2-medium (4GB RAM) :
gcloud compute instances stop telegram-bot-vm --zone=us-central1-a
gcloud compute instances set-machine-type telegram-bot-vm \
--zone=us-central1-a \
--machine-type=e2-medium
gcloud compute instances start telegram-bot-vm --zone=us-central1-aArchitecture basée sur RichardAtCT/claude-code-telegram.
Améliorations :
- ✅ CLI subprocess au lieu de SDK
- ✅ Streaming complet des outils
- ✅ Animation typing indicator (●●●)
- ✅ Fix throttling sur 2nd+ messages
- ✅ Parsing stream-json corrigé
- ✅ Configuration Pydantic
- ✅ Documentation GCP complète
MIT License
- GitHub : Issues
- Repo Original : richardatct
⚡ Déployé en < 5 min | 💰 ~$15/mois | 🚀 Production-ready