RichardAtCT/claude-code-telegram
Claude Code Telegram Bot
A Telegram bot that gives you remote access to Claude Code. Chat naturally with Claude about your projects from anywhere – no terminal commands needed.
What is this?
This bot connects Telegram to Claude Code, providing a conversational AI interface for your codebase:
- Chat naturally – ask Claude to analyze, edit, or explain your code in plain language
- Maintain context across conversations with automatic session persistence per project
- Code on the go from any device with Telegram
- Receive proactive notifications from webhooks, scheduled jobs, and CI/CD events
- Stay secure with built-in authentication, directory sandboxing, and audit logging
Quick Start
Demo
|
|
1. Prerequisites
- Python 3.10+ – Download here
- Poetry – Modern Python dependency management
- Claude Code CLI – Install from here
- Telegram Bot Token – Get one from @BotFather
2. Install
|
|
3. Configure
|
|
Minimum required:
|
|
4. Run
|
|
Message your bot on Telegram to get started.
Detailed setup: See docs/setup.md for Claude authentication options and troubleshooting.
Modes
The bot supports two interaction modes:
Agentic Mode (Default)
The default conversational mode. Just talk to Claude naturally – no special commands required.
Commands: /start, /new, /status, /verbose, /repo
If ENABLE_PROJECT_THREADS=true: /sync_threads
|
|
Use /verbose 0|1|2 to control how much background activity is shown:
| Level | Shows |
|---|---|
| 0 (quiet) | Final response only (typing indicator stays active) |
| 1 (normal, default) | Tool names + reasoning snippets in real-time |
| 2 (detailed) | Tool names with inputs + longer reasoning text |
GitHub Workflow
Claude Code already knows how to use gh CLI and git. Authenticate on your server with gh auth login, then work with repos conversationally:
|
|
Use /repo to list cloned repos in your workspace, or /repo <name> to switch directories (sessions auto-resume).
Classic Mode
Set AGENTIC_MODE=false to enable the full 13-command terminal-like interface with directory navigation, inline keyboards, quick actions, git integration, and session export.
Commands: /start, /help, /new, /continue, /end, /status, /cd, /ls, /pwd, /projects, /export, /actions, /git
If ENABLE_PROJECT_THREADS=true: /sync_threads
|
|
Event-Driven Automation
Beyond direct chat, the bot can respond to external triggers:
- Webhooks – Receive GitHub events (push, PR, issues) and route them through Claude for automated summaries or code review
- Scheduler – Run recurring Claude tasks on a cron schedule (e.g., daily code health checks)
- Notifications – Deliver agent responses to configured Telegram chats
Enable with ENABLE_API_SERVER=true and ENABLE_SCHEDULER=true. See docs/setup.md for configuration.
Features
Working Features
-
Conversational agentic mode (default) with natural language interaction
-
Classic terminal-like mode with 13 commands and inline keyboards
-
Full Claude Code integration with SDK (primary) and CLI (fallback)
-
Automatic session persistence per user/project directory
-
Multi-layer authentication (whitelist + optional token-based)
-
Rate limiting with token bucket algorithm
-
Directory sandboxing with path traversal prevention
-
File upload handling with archive extraction
-
Image/screenshot upload with analysis
-
Git integration with safe repository operations
-
Quick actions system with context-aware buttons
-
Session export in Markdown, HTML, and JSON formats
-
SQLite persistence with migrations
-
Usage and cost tracking
-
Audit logging and security event tracking
-
Event bus for decoupled message routing
-
Webhook API server (GitHub HMAC-SHA256, generic Bearer token auth)
-
Job scheduler with cron expressions and persistent storage
-
Notification service with per-chat rate limiting
-
Tunable verbose output showing Claude’s tool usage and reasoning in real-time
-
Persistent typing indicator so users always know the bot is working
Planned Enhancements
- Plugin system for third-party extensions
Configuration
Required
|
|
Common Options
|
|
Agentic Platform
|
|
Project Threads Mode
|
|
In strict mode, only /start and /sync_threads work outside mapped project topics.
In private mode, /start auto-syncs project topics for your private bot chat.
To use topics with your bot, enable them in BotFather:
Bot Settings -> Threaded mode.
Full reference: See docs/configuration.md and
.env.example.
Finding Your Telegram User ID
Message @userinfobot on Telegram – it will reply with your user ID number.
Troubleshooting
Bot doesn’t respond:
- Check your
TELEGRAM_BOT_TOKENis correct - Verify your user ID is in
ALLOWED_USERS - Ensure Claude Code CLI is installed and accessible
- Check bot logs with
make run-debug
Claude integration not working:
- SDK mode (default): Check
claude auth statusor verifyANTHROPIC_API_KEY - CLI mode: Verify
claude --versionandclaude auth status - Check
CLAUDE_ALLOWED_TOOLSincludes necessary tools
High usage costs:
- Adjust
CLAUDE_MAX_COST_PER_USERto set spending limits - Monitor usage with
/status - Use shorter, more focused requests
Security
This bot implements defense-in-depth security:
- Access Control – Whitelist-based user authentication
- Directory Isolation – Sandboxing to approved directories
- Rate Limiting – Request and cost-based limits
- Input Validation – Injection and path traversal protection
- Webhook Authentication – GitHub HMAC-SHA256 and Bearer token verification
- Audit Logging – Complete tracking of all user actions
See SECURITY.md for details.
Development
|
|
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make changes with tests:
make test && make lint - Submit a Pull Request
Code standards: Python 3.10+, Black formatting (88 chars), type hints required, pytest with >85% coverage.
License
MIT License – see LICENSE.
Acknowledgments
- Claude by Anthropic
- python-telegram-bot