Telegram gateway for Claude Code CLI - control Claude remotely via Telegram
Project description
Claude Gateway
A Telegram bot that lets you remotely control Claude Code CLI from your phone. Designed to run on a Raspberry Pi or any Linux server, it forwards your Telegram messages to Claude Code and streams responses back in real time.
Telegram <──> claude-gateway <──> Claude Code CLI
Dashboard: A web dashboard for browser-based access is included but is still a work in progress.
Features
- Send messages to Claude Code from Telegram from anywhere
- Conversations carry context automatically (uses
--continuebetween messages) - Switch between projects with
/projector an inline keyboard - Create new project directories with
/newproject - Upload images directly to your current project folder
- Cancel running Claude operations with
/stop - Start a remote-control session with
/remote— opens aclaude.aibrowser link so you can take over from your phone - Chat ID whitelist keeps the bot private
- Interactive setup wizard (
claude-gateway setup) - Optional systemd service for auto-start on boot
- Code blocks in responses — code in Claude's output is automatically formatted as Telegram code blocks for easy reading and one-tap copying
Prerequisites
-
Claude Code CLI installed and authenticated on the host machine:
npm install -g @anthropic-ai/claude-code claude --version
-
Python 3.11+ on the host machine.
-
A Telegram bot token — create one via @BotFather on Telegram (
/newbot). -
Your Telegram chat ID — you can find it by messaging @userinfobot or by starting the bot without a whitelist and reading the ID from the unauthorized message.
Installation
Recommended: pipx (isolated environment)
pipx install claude-gateway
Alternative: pip
pip install claude-gateway
From source
git clone https://github.com/yourusername/claude-gateway.git
cd claude-gateway
pip install -e .
Setup
Run the interactive wizard after installation:
claude-gateway setup
The wizard will ask for:
| Setting | Description |
|---|---|
| Bot token | The token from @BotFather |
| Allowed chat IDs | Comma-separated Telegram chat IDs that can use the bot |
| Default project path | Directory Claude opens in for each new session |
| Project search dirs | Comma-separated dirs scanned for the /project command |
| New project dir | Where /newproject creates folders |
| Dashboard host/port | Optional, defaults to 0.0.0.0:3000 |
Configuration is saved to ~/.config/claude-gateway/config.env.
Getting your chat ID
If you're not sure of your chat ID, start the bot without setting one, send any message, and the bot will reply with your ID. Then re-run claude-gateway setup and add it.
Running the bot
claude-gateway start
The bot will connect to Telegram and start listening for messages.
Bot commands
| Command | Description |
|---|---|
/start |
Welcome message and current project |
/help |
Show all commands |
/new |
Start a fresh Claude conversation |
/project |
Show project picker (inline keyboard) |
/project <name> |
Switch to a named project |
/newproject <name> |
Create a new project directory and switch to it |
/status |
Show current session info |
/stop |
Cancel the current Claude operation |
/remote |
Start a remote-control session and get a claude.ai URL |
/stopremote |
Stop the active remote-control session |
Any other message is forwarded directly to Claude Code.
Configuration reference
All settings can be set via environment variables or in ~/.config/claude-gateway/config.env:
# Required
TELEGRAM_BOT_TOKEN=your_bot_token_here
# Security: comma-separated chat IDs allowed to use the bot
ALLOWED_CHAT_IDS=123456789,987654321
# Project directories
DEFAULT_PROJECT_PATH=/home/user/projects
PROJECT_SEARCH_DIRS=/home/user/projects,/mnt/ssd/projects
NEW_PROJECT_DIR=/home/user/projects
# Dashboard (optional, work in progress)
DASHBOARD_HOST=0.0.0.0
DASHBOARD_PORT=3000
# Data storage for the dashboard agent store
DATA_DIR=/home/user/.local/share/claude-gateway
Environment variables always take precedence over the config file. A .env file in the current working directory takes precedence over ~/.config/claude-gateway/config.env.
Running as a systemd service
Generate service files with:
claude-gateway systemd
This creates claude-gateway.service and claude-dashboard.service in the current directory. Install them:
sudo cp claude-gateway.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now claude-gateway
Check status and logs:
sudo systemctl status claude-gateway
journalctl -u claude-gateway -f
Dashboard (Work in Progress)
A web dashboard is included that provides browser-based access to Claude via agents. It is currently a work in progress and may have rough edges.
To start it:
claude-gateway dashboard
Then open http://localhost:3000 in your browser.
The dashboard exposes a REST + WebSocket API (/api/*) and a React frontend (if the frontend has been built). The frontend source is in the frontend/ directory.
Security
- Chat ID whitelist: Only configured chat IDs can interact with the bot. Anyone else receives an unauthorized message showing their chat ID.
- Path validation: The bot blocks access to sensitive system directories (
/etc,/root,/var,/usr,/bin,/sbin,/boot). --dangerously-skip-permissions: Claude Code runs without interactive permission prompts since there is no TTY. Access control is delegated to the Telegram whitelist and path validation.- Config file permissions: The setup wizard creates
~/.config/claude-gateway/config.envwith mode0600(owner read/write only).
Project structure
claude_gateway/
├── cli.py # CLI entry point (setup, start, dashboard, systemd)
├── config.py # Configuration loading
├── gateway.py # Telegram bot handlers
├── claude_runner.py # Claude Code process manager
├── dashboard.py # FastAPI dashboard (WIP)
├── agent_store.py # JSON persistence for dashboard agents
└── models.py # Pydantic data models
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claude_gateway-0.2.0.tar.gz.
File metadata
- Download URL: claude_gateway-0.2.0.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d67717b43e6ab26d248600e425683224959c55cb4990e84b5e2ee9c585cea3e4
|
|
| MD5 |
21db1ab20c35edce1c818a5b9f669135
|
|
| BLAKE2b-256 |
9bc77cb7bde2e9dfec0fc120bb4cbc026c0f73bc86dcf3b9d668c312a6750125
|
Provenance
The following attestation bundles were made for claude_gateway-0.2.0.tar.gz:
Publisher:
publish.yml on gieldid/claude_gateway
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claude_gateway-0.2.0.tar.gz -
Subject digest:
d67717b43e6ab26d248600e425683224959c55cb4990e84b5e2ee9c585cea3e4 - Sigstore transparency entry: 1050763028
- Sigstore integration time:
-
Permalink:
gieldid/claude_gateway@5bd6f7ff9ceaf919fa3567dff5d9f796fe199263 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/gieldid
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5bd6f7ff9ceaf919fa3567dff5d9f796fe199263 -
Trigger Event:
release
-
Statement type:
File details
Details for the file claude_gateway-0.2.0-py3-none-any.whl.
File metadata
- Download URL: claude_gateway-0.2.0-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
753462c5a1dc7e89c076e90438c8a9805fbf01b0682f9e2f11780d42088cdd0d
|
|
| MD5 |
7a3ea4acee57648aa9c18304e760059b
|
|
| BLAKE2b-256 |
522d2bc9485af4d0d38e39c05ac6de441f1050c0353d4d67204eacac0cbbe076
|
Provenance
The following attestation bundles were made for claude_gateway-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on gieldid/claude_gateway
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claude_gateway-0.2.0-py3-none-any.whl -
Subject digest:
753462c5a1dc7e89c076e90438c8a9805fbf01b0682f9e2f11780d42088cdd0d - Sigstore transparency entry: 1050763081
- Sigstore integration time:
-
Permalink:
gieldid/claude_gateway@5bd6f7ff9ceaf919fa3567dff5d9f796fe199263 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/gieldid
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5bd6f7ff9ceaf919fa3567dff5d9f796fe199263 -
Trigger Event:
release
-
Statement type: