Lightweight self-hosted Telegram manager for Claude Code CLI
Project description
tgcc - 用 Telegram 控制 Claude Code
English | 中文
用手机给 Claude Code 发消息,让它在你的电脑上写代码。
在 Telegram 发送指令 → tgcc 在本地调用 Claude Code CLI → 结果发回 Telegram
⚡ 3 步开始
# 1. 安装(PyPI)
uv tool install claude-code-tg
# 或装最新开发版:uv tool install "git+https://github.com/Ike-li/claude-code-tg.git"
# 2. 配置(快速向导,只问 3 个必填项;用 tgcc init --full 可配置全部选项)
tgcc init
# 3. 启动
tgcc start
然后在 Telegram 给你的 Bot 发消息就行了!
📋 需要准备什么?
- Python 3.11+
uv包管理器- Claude Code CLI(已认证登录)
- Telegram Bot Token(找 @BotFather 创建)
- 你的 Telegram User ID(找 @userinfobot 获取)
💡 为什么用 tgcc?
| 你的需求 | tgcc 给你 |
|---|---|
| 🏠 完全本地运行 | 不需要云服务器,Bot token 和代码都在你的机器上 |
| 📱 手机控制编程 | 通勤路上也能让 Claude 写代码,到家直接看结果 |
| 🎯 多项目管理 | 一台机器跑多个 Bot,每个对应不同项目目录 |
| 🔒 安全可见 | 日志自动脱敏,权限模式清晰显示,文件访问可控 |
| ⚙️ 灵活配置 | 每个对话可以单独设置模型/思考强度/权限模式 |
🎮 常用操作
Telegram 里的基础命令
/new - 开始新的 Claude 会话
/resume - 恢复本地的 Claude 会话
/stop - 停止当前执行
/status - 查看运行状态
/model opus - 切换到 Opus 模型
/effort max - 最大思考强度
本地管理多个 Bot
# 启动前自检配置
tgcc doctor --env prod.env
# 查看所有实例状态
tgcc status --all
# 批量启动 / 停止 / 重启
tgcc start-all
tgcc stop-all
tgcc restart-all
# 查看某个实例的日志
tgcc logs --env prod.env -f
📸 功能预览
📤 发送文件和图片
支持三种模式:
path- 传递本地文件路径给 Claude(推荐)copy-to-project- 复制附件到项目目录reject- 禁用文件上传
🎛️ 运行时控制
每个 Telegram 对话可以独立设置:
- 模型选择(Opus / Sonnet / Haiku)
- 思考强度(low → ultracode)
- 权限模式(bypassPermissions / default / plan)
所有设置在状态卡和日志中清晰可见。
📊 实时状态卡
运行中会显示可编辑的状态卡,包括:
- 当前执行的工具
- 已用时间
- 权限模式和思考强度
- Stop 按钮
完成后显示结果,带一键复制和重新执行按钮。
🔐 安全提醒
⚠️ 默认权限模式是 bypassPermissions,适合可信项目。如果项目目录不受你完全控制,启动前改成 default 或 plan。
✅ 推荐做法:
- 只把白名单用户加入
ALLOWED_USER_IDS .env文件设置为chmod 600(init 会自动做)- 定期检查日志,确保脱敏正常工作
- 不要把真实 token 提交到 git
详细安全模型见 Security Policy 和 Security Model。
📚 完整文档
- 快速开始: 5 分钟上手指南 - 最短路径
- 日常使用: 用户指南 - 所有配置选项和 Telegram 命令
- 遇到问题: 故障排查 - 按症状查找解决方案
- 长期运行: 运维指南 - 日志管理、升级、事故响应
- 架构设计: Architecture - 模块结构和设计决策
- 开发贡献: Contributing - 本地验证和 PR 流程
完整文档索引:Documentation Index
🚧 当前状态
这是 0.8.3 Alpha 版本(已打 tag v0.8.3):
✅ 已实现:文本对话、文件输入、多实例管理、会话恢复、权限模式、队列、日志脱敏、CI
✅ 已发布到 PyPI:uv tool install claude-code-tg
运行完整本地校验:
uv run python scripts/validate_local.py
🤝 贡献
欢迎贡献!提交 PR 前请:
uv sync --extra dev
uv run pytest --cov=claude_code_tg
uv run ruff check .
uv run --extra dev mypy
uv run ruff format --check .
📄 License
MIT License - 详见 LICENSE
🙋 获取帮助
- 问题和功能请求:GitHub Issues
- 安全漏洞:见 Security Policy
- 使用疑问:先查 Troubleshooting
⚡ Built with Claude Code | 🤖 Powered by Anthropic Claude | 💬 Delivered via Telegram
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_code_tg-0.8.3.tar.gz.
File metadata
- Download URL: claude_code_tg-0.8.3.tar.gz
- Upload date:
- Size: 243.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50e75579d7621ff16bd2443025d14b38587b007e4204f46d820922affd4a3eb3
|
|
| MD5 |
3b0f1bb054468dfa3a1e1e9f716a0962
|
|
| BLAKE2b-256 |
11355e6cddbbddeb971cf02e0fd91f70c343aa08f7ed08b4be6562e67bfda8d8
|
Provenance
The following attestation bundles were made for claude_code_tg-0.8.3.tar.gz:
Publisher:
release.yml on Ike-li/claude-code-tg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claude_code_tg-0.8.3.tar.gz -
Subject digest:
50e75579d7621ff16bd2443025d14b38587b007e4204f46d820922affd4a3eb3 - Sigstore transparency entry: 1732590582
- Sigstore integration time:
-
Permalink:
Ike-li/claude-code-tg@832ce63e14622b71daa8b731d08d34d566ccc728 -
Branch / Tag:
refs/tags/v0.8.3 - Owner: https://github.com/Ike-li
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@832ce63e14622b71daa8b731d08d34d566ccc728 -
Trigger Event:
push
-
Statement type:
File details
Details for the file claude_code_tg-0.8.3-py3-none-any.whl.
File metadata
- Download URL: claude_code_tg-0.8.3-py3-none-any.whl
- Upload date:
- Size: 96.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f85bc637bbb20dbdbb293853395a69c36f2713aa1d946b43efb77514e711eb8a
|
|
| MD5 |
8045b5d9a29a65d06dedda5c2e66a30d
|
|
| BLAKE2b-256 |
058ec1620180f85b7a5f7fd78b9806223422c86935dca4b2ed81cb91656ea6a6
|
Provenance
The following attestation bundles were made for claude_code_tg-0.8.3-py3-none-any.whl:
Publisher:
release.yml on Ike-li/claude-code-tg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claude_code_tg-0.8.3-py3-none-any.whl -
Subject digest:
f85bc637bbb20dbdbb293853395a69c36f2713aa1d946b43efb77514e711eb8a - Sigstore transparency entry: 1732590694
- Sigstore integration time:
-
Permalink:
Ike-li/claude-code-tg@832ce63e14622b71daa8b731d08d34d566ccc728 -
Branch / Tag:
refs/tags/v0.8.3 - Owner: https://github.com/Ike-li
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@832ce63e14622b71daa8b731d08d34d566ccc728 -
Trigger Event:
push
-
Statement type: