Skip to main content

Lightweight self-hosted Telegram manager for Claude Code CLI

Project description

tgcc - 用 Telegram 控制 Claude Code

CI Python License: MIT Status: Alpha

English | 中文

用手机给 Claude Code 发消息,让它在你的电脑上写代码。

在 Telegram 发送指令 → tgcc 在本地调用 Claude Code CLI → 结果发回 Telegram

tgcc Telegram smoke demo


⚡ 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 发消息就行了!

📋 需要准备什么?

💡 为什么用 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,适合可信项目。如果项目目录不受你完全控制,启动前改成 defaultplan

推荐做法:

  • 只把白名单用户加入 ALLOWED_USER_IDS
  • .env 文件设置为 chmod 600(init 会自动做)
  • 定期检查日志,确保脱敏正常工作
  • 不要把真实 token 提交到 git

详细安全模型见 Security PolicySecurity Model


📚 完整文档

完整文档索引:Documentation Index


🚧 当前状态

这是 0.8.3 Alpha 版本(已打 tag v0.8.3):

已实现:文本对话、文件输入、多实例管理、会话恢复、权限模式、队列、日志脱敏、CI

已发布到 PyPIuv 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 .

详见 Contributing Guide


📄 License

MIT License - 详见 LICENSE


🙋 获取帮助


⚡ Built with Claude Code | 🤖 Powered by Anthropic Claude | 💬 Delivered via Telegram

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claude_code_tg-0.8.3.tar.gz (243.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claude_code_tg-0.8.3-py3-none-any.whl (96.3 kB view details)

Uploaded Python 3

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

Hashes for claude_code_tg-0.8.3.tar.gz
Algorithm Hash digest
SHA256 50e75579d7621ff16bd2443025d14b38587b007e4204f46d820922affd4a3eb3
MD5 3b0f1bb054468dfa3a1e1e9f716a0962
BLAKE2b-256 11355e6cddbbddeb971cf02e0fd91f70c343aa08f7ed08b4be6562e67bfda8d8

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for claude_code_tg-0.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f85bc637bbb20dbdbb293853395a69c36f2713aa1d946b43efb77514e711eb8a
MD5 8045b5d9a29a65d06dedda5c2e66a30d
BLAKE2b-256 058ec1620180f85b7a5f7fd78b9806223422c86935dca4b2ed81cb91656ea6a6

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page