A powerful Telegram bot that provides remote access to Claude Code, enabling developers to interact with their projects from anywhere. Transform your phone into a development terminal with full Claude AI assistance, project navigation, and session persistence.
This bot bridges Telegram and Claude Code, allowing you to:
- π¬ Chat with Claude about your code projects through Telegram
- π Navigate directories and manage files remotely
- π Maintain context across conversations with session persistence
- π± Code on the go from any device with Telegram
- π‘οΈ Stay secure with built-in authentication and sandboxing
Perfect for code reviews on mobile, quick fixes while traveling, or getting AI assistance when away from your development machine.
You: cd my-project
Bot: π Changed to: my-project/
You: ls
Bot: π src/
π tests/
π README.md
π package.json
You: Can you help me add error handling to src/api.py?
Bot: π€ I'll help you add robust error handling to your API...
[Claude analyzes your code and suggests improvements]
This project is actively being developed. Here's the current status of features:
- Full Telegram bot functionality with advanced command handling
- Directory navigation (
cd,ls,pwd) with project switching - Multi-layer authentication (whitelist + optional token-based)
- Advanced rate limiting with token bucket algorithm
- Complete Claude integration with SDK/CLI support
- β¨ Enhanced file upload handling with archive extraction
- β¨ Git integration with safe repository operations
- β¨ Quick actions system with context-aware buttons
- β¨ Session export in Markdown, HTML, and JSON formats
- β¨ Image/screenshot upload with smart analysis prompts
- β¨ Conversation enhancements with follow-up suggestions
- SQLite database persistence with migrations
- Comprehensive usage and cost tracking
- Session management with persistence
- Audit logging and security event tracking
- π¦ Archive Analysis: Upload ZIP/TAR files for comprehensive project analysis
- π Git Operations: View status, diffs, logs, and commit history
- β‘ Quick Actions: Context-aware buttons for tests, linting, formatting, etc.
- π€ Session Export: Download conversation history in multiple formats
- πΌοΈ Image Support: Upload screenshots and diagrams for analysis
- π‘ Smart Suggestions: AI-powered follow-up action recommendations
- True streaming responses with real-time updates
- Claude vision API integration for full image analysis
- Custom quick actions configuration
- Advanced Git operations (when security permits)
- Plugin system for third-party extensions
- Multi-language code execution
- Webhook support for CI/CD integration
- Full Claude Code Access: Complete integration with Claude's powerful coding assistant
- Session Persistence: Maintain conversation context with SQLite database storage
- SDK & CLI Support: Works with both Anthropic Python SDK and Claude CLI
- Error Recovery: Intelligent error handling with helpful suggestions and retry logic
- Tool Support: Access to Claude's full toolkit including file operations, code analysis, and more
- Directory Navigation:
cd,ls,pwdcommands just like a real terminal - File Management: Upload files, archives, and images for Claude to analyze
- Git Integration: View repository status, diffs, and commit history
- Project Switching: Easy navigation between different codebases with context preservation
- Command History: Full session tracking with export capabilities
- Multi-Layer Authentication: Whitelist-based and optional token authentication
- Directory Isolation: Strict sandboxing to approved project directories
- Rate Limiting: Token bucket algorithm with request and cost-based limits
- Comprehensive Audit Logging: Complete tracking of all user actions and security events
- Input Validation: Protection against injection attacks, path traversal, and zip bombs
- Quick Actions: Context-aware buttons for tests, linting, formatting, and more
- Session Management: Start, continue, end, export, and monitor Claude sessions
- Usage Analytics: Detailed cost tracking, usage patterns, and system statistics
- Responsive Design: Clean, mobile-friendly interface with inline keyboards
- Smart Follow-ups: AI-powered suggestions for next actions based on context
- Python 3.9+ - Download here
- Poetry - Modern Python dependency management
- Claude Code CLI - Install from here
- Telegram Bot Token - Get one from @BotFather
- Message @BotFather on Telegram
- Send
/newbotand follow the prompts - Save your bot token (it looks like
1234567890:ABC...) - Note your bot username (e.g.,
my_claude_bot)
Choose one of these authentication methods:
Option 1: Use existing Claude CLI login (Recommended)
# Install Claude CLI
# Follow instructions at https://claude.ai/code
# Authenticate with Claude
claude
# follow the prompts to authenticate
# The bot will automatically use your CLI credentialsOption 2: Use API key directly
# Get your API key from https://console.anthropic.com/
# You'll add this to your .env file in the next step# Clone the repository
git clone https://github.com/yourusername/claude-code-telegram.git
cd claude-code-telegram
# Install Poetry (if needed)
curl -sSL https://install.python-poetry.org | python3 -
# Install dependencies
make dev# Copy the example configuration
cp .env.example .env
# Edit with your settings
nano .envMinimum required configuration:
TELEGRAM_BOT_TOKEN=1234567890:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
TELEGRAM_BOT_USERNAME=my_claude_bot
APPROVED_DIRECTORY=/Users/yourname/projects
ALLOWED_USERS=123456789 # Your Telegram user ID# Start in debug mode
make run-debug
# Or for production
make runπ That's it! Message your bot on Telegram to get started.
π Detailed Setup Guide: For comprehensive setup instructions including authentication options and troubleshooting, see docs/setup.md
Once your bot is running, you can use these commands in Telegram:
/ls # List files in current directory
/cd myproject # Change to project directory
/pwd # Show current directory
/projects # Show available projects
/new # Start a new Claude session
/continue [message] # Continue previous session (optionally with message)
/end # End current session
/status # Show session status and usage
/export # Export session (choose format: Markdown, HTML, JSON)
/git # Show git repository info (status, diff, log)
/actions # Show context-aware quick actions
/start # Welcome message and setup
/help # Show all available commands
Just send any message to interact with Claude about your code:
You: "Analyze this Python function for potential bugs"
You: "Help me optimize this database query"
You: "Create a React component for user authentication"
You: "Explain what this code does"
Upload files: Simply send files to Telegram and Claude will analyze them.
Supported operations:
- Single files: Code files, configs, documents - Claude analyzes content
- Archives: ZIP/TAR files - Extracts and analyzes project structure
- Images: Screenshots, diagrams, UI mockups - Smart prompt generation
- Multiple files: Send several files for batch analysis
Supported file types: .py, .js, .ts, .jsx, .tsx, .java, .cpp, .c, .go, .rs, .rb, .php, .swift, .kt, .scala, .sql, .json, .xml, .html, .css, .md, .txt, .yaml, .toml, .zip, .tar, .tar.gz, .png, .jpg, .jpeg, .gif, .webp, and more.
1. You: /cd my-web-app
Bot: π Changed to: my-web-app/
2. You: /ls
Bot: π src/
π components/
π package.json
π README.md
3. You: "Can you help me add TypeScript to this project?"
Bot: π€ I'll help you migrate to TypeScript! Let me analyze your project structure...
[Claude provides detailed migration steps]
4. You: /status
Bot: π Session Status
π Directory: my-web-app/
π€ Claude Session: β
Active
π° Usage: $0.15 / $10.00 (2%)
You: [Upload project.zip]
Bot: π¦ Analyzing archive: project.zip
Project Structure:
π src/
π main.py (2.3KB)
π utils.py (1.1KB)
π tests/
π test_main.py (3.2KB)
π requirements.txt (245B)
Language: Python
Frameworks: pytest detected
Entry point: src/main.py
π€ I've analyzed your Python project. It appears to be...
You: /git
Bot: π Git Repository Status
πΏ Branch: feature/new-api
π Changes: 3 files modified
π Behind main: 2 commits
Recent commits:
β’ abc123 - Add API endpoint (2 hours ago)
β’ def456 - Update dependencies (1 day ago)
[View Diff] [Show Log] [See Changes]
You: /actions
Bot: π Available Quick Actions
Based on your project context:
[π§ͺ Run Tests] [π¦ Install Deps]
[π¨ Format Code] [π Run Linter]
[π Add Docs] [π§ Refactor]
You: /export
Bot: π€ Export Session
Choose format:
[π Markdown] [π HTML] [π JSON]
You: [Click Markdown]
Bot: β
Session exported!
π claude_session_abc123.md (15.2KB)
[Downloads as file in Telegram]
The bot provides helpful buttons for common tasks:
- π§ͺ Test - Run your test suite
- π¦ Install - Install dependencies
- π¨ Format - Format your code
- π Find TODOs - Locate TODO comments
- π¨ Build - Build your project
- π Git Status - Check git status
# Telegram Bot Configuration
TELEGRAM_BOT_TOKEN=1234567890:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
TELEGRAM_BOT_USERNAME=my_claude_bot
# Security - Base directory for project access (absolute path)
APPROVED_DIRECTORY=/Users/yourname/projects
# User Access Control
ALLOWED_USERS=123456789,987654321 # Your Telegram user ID(s)# Claude Settings
USE_SDK=true # Use Python SDK (default) or CLI subprocess
ANTHROPIC_API_KEY=sk-ant-api03-... # Optional: API key for SDK (if not using CLI auth)
CLAUDE_MAX_COST_PER_USER=10.0 # Max cost per user in USD
CLAUDE_TIMEOUT_SECONDS=300 # Timeout for operations
CLAUDE_ALLOWED_TOOLS="Read,Write,Edit,Bash,Glob,Grep,LS,Task,MultiEdit,NotebookRead,NotebookEdit,WebFetch,TodoRead,TodoWrite,WebSearch"
# Rate Limiting
RATE_LIMIT_REQUESTS=10 # Requests per window
RATE_LIMIT_WINDOW=60 # Window in seconds
# Features
ENABLE_GIT_INTEGRATION=true
ENABLE_FILE_UPLOADS=true
ENABLE_QUICK_ACTIONS=true
# Development
DEBUG=false
LOG_LEVEL=INFOπ Full configuration reference: See
.env.examplefor all available options with detailed descriptions.
To get your Telegram user ID for the ALLOWED_USERS setting:
- Message @userinfobot on Telegram
- It will reply with your user ID number
- Add this number to your
ALLOWED_USERSsetting
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 for error messages
"Permission denied" errors:
- β
Verify
APPROVED_DIRECTORYpath exists and is readable - β Ensure the bot process has file system permissions
- β Check that paths don't contain special characters
Claude integration not working:
If using SDK mode (USE_SDK=true, which is default):
- β
Check CLI authentication:
claude auth status - β
If no CLI auth, verify
ANTHROPIC_API_KEYis set in .env - β Ensure API key has sufficient credits
- β Check logs for "SDK initialization" messages
If using CLI mode (USE_SDK=false):
- β
Verify Claude CLI is installed:
claude --version - β
Check CLI authentication:
claude auth status - β Ensure CLI has sufficient credits
General troubleshooting:
- β
Verify
CLAUDE_ALLOWED_TOOLSincludes necessary tools - β
Check
CLAUDE_TIMEOUT_SECONDSisn't too low - β
Monitor usage with
/statuscommand
High usage costs:
- β
Adjust
CLAUDE_MAX_COST_PER_USERto set spending limits - β
Monitor usage with
/statuscommand - β Use shorter, more focused requests
- β
End sessions when done with
/end
- π Documentation: Check this README and
.env.example - π Bug Reports: Open an issue
- π¬ Discussions: GitHub Discussions
- π Security: See SECURITY.md for reporting security issues
This bot implements enterprise-grade security:
- π Access Control: Whitelist-based user authentication
- π Directory Isolation: Strict sandboxing to approved directories
- β±οΈ Rate Limiting: Request and cost-based limits prevent abuse
- π‘οΈ Input Validation: Protection against injection attacks
- π Audit Logging: Complete tracking of all user actions
- π Secure Defaults: Principle of least privilege throughout
For security issues, see SECURITY.md.
We welcome contributions! Here's how to get started:
# Fork and clone the repository
git clone https://github.com/yourusername/claude-code-telegram.git
cd claude-code-telegram
# Install development dependencies
make dev
# Run tests to verify setup
make testmake help # Show all available commands
make test # Run tests with coverage
make lint # Run code quality checks
make format # Auto-format code
make run-debug # Run bot in debug mode- π΄ Fork the repository
- πΏ Create a feature branch:
git checkout -b feature/amazing-feature - β¨ Make your changes with tests
- β
Test your changes:
make test && make lint - π Commit your changes:
git commit -m 'Add amazing feature' - π Push to the branch:
git push origin feature/amazing-feature - π― Submit a Pull Request
- Python 3.9+ with type hints
- Black formatting (88 char line length)
- pytest for testing with >85% coverage
- mypy for static type checking
- Conventional commits for commit messages
This project is licensed under the MIT License - see the LICENSE file for details.
If you find this project useful, please consider giving it a star! β
- Claude by Anthropic for the amazing AI capabilities
- python-telegram-bot for the excellent Telegram integration
- All contributors who help make this project better
Made with β€οΈ for developers who code on the go