Cc Tg Watchdog — Development skill for Claude Code
Claude Code + Telegram watchdog script for 24/7 VPS uptime.
How to install Cc Tg Watchdog
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open kittenshome/cc-tg-watchdog and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
What Cc Tg Watchdog does
Claude Code + Telegram watchdog script for 24/7 VPS uptime.
Alternatives in Development
- Telegram — Show Telegram bot status and manage global session 1.3k ★
- Agentlas Connect — Connect Agentlas agents or teams to Telegram 1.1k ★
- Claude Telegram Relay — Minimal pattern for running Claude Code as an always-on Telegram bot 326 ★
README
Claude Code Telegram 看门狗脚本
一套在 Linux VPS 上守护 Claude Code + Telegram 长驻会话的实用脚本:异常重启、上下文自动换气、漏回消息恢复,以及登录凭证刷新尝试。
[!IMPORTANT] 这是个人环境中长期运行后整理出的脚本,不是 Anthropic/Telegram 官方组件,也不能保证 100% 不丢消息。默认阈值、界面文案和进程特征可能随 Claude Code 或插件版本变化,请先在测试 bot 上验证。
解决什么问题
在 VPS 上跑 `claude --channels plugin:telegram@claude-plugins-official`,迟早会遇到:
- tmux 进程悄悄死掉
- 撞上额度弹窗卡住不动
- Telegram 的 Bun 进程断连
- API 凭证过期,401 死循环
- 上下文窗口越来越大,每句话烧一大把 token
- 换气/重启那一刻刚好来了消息,没人回
这套脚本针对以上故障做自动检测和恢复;实际效果取决于 Claude Code、Telegram 插件版本和你的 VPS 环境。
架构
crontab(每3分钟)
|
v
tgbot-watchdog.sh ── 检查健康 ── 正常?跳过
| |
|(出问题了) |
v |
tgbot.sh ── 杀旧进程 |
| ── 补回漏掉的消息 |
| ── 刷新凭证 |
| ── 启动新 tmux 会话 |
| ── 验证 Telegram 连接 |
v |
claude --channels plugin:telegram <-+
(跑在 tmux "tgbot" 里)
快速开始
前置条件
- 一台 VPS,装好 Claude Code CLI 并登录
- Telegram 插件(
plugin:telegram@claude-plugins-official) tmuxpython3、flock、timeout、ss(常见 Debian/Ubuntu 可分别由python3、util-linux、coreutils、iproute2提供)- 已在 Claude Code Telegram 插件中安全配置 bot token
强烈建议 Telegram 单独使用一个 `CLAUDE_CONFIG_DIR`,避免看门狗读到普通 Claude Code 项目的会话,或重启错误的频道实例。不要把 `.credentials.json`、bot token、OAuth token、会话 JSONL、日志或真实记忆补丁提交到仓库。
1. 复制脚本
cp watchdog.sh ~/tgbot-watchdog.sh
cp start.sh ~/tgbot.sh
cp orphan-recovery.py ~/tgbot-orphan.py
chmod +x ~/tgbot-watchdog.sh ~/tgbot.sh
2. 配置
编辑 `tgbot.sh` 和 `tgbot-watchdog.sh`,确保两边使用相同配置。下面是 root 用户示例;非 root 用户请使用自己的 `$HOME`:
# 建议 Telegram 使用独立配置目录(.credentials.json 所在位置)
CLAUDE_CONFIG_DIR="${CLAUDE_CONFIG_DIR:-$HOME/.claude-tgbot}"
# tmux 会话名
SESSION_NAME="tgbot"
# 使用的模型
MODEL="claude-sonnet-4-6"
如果 Claude 会话不是从 `$HOME` 启动,还要在两个脚本中显式设置该会话的 JSONL 目录:
PROJECT_DIR="/path/to/claude-config/projects/"
脚本不会替你生成 Telegram bot
Related Skills
Telegram MCP Kit
Connect Claude (or any MCP client) to your own Telegram in ~15 minutes: setup prompt for Claude Code/Codex, pr
Telegramcode
OpenCode and Claude Code coding agents in Telegram: run on your own machine or VPS, drive by voice or text fro
Agent Lifecycle Ops
Unified start/stop/status/check/logs/tail/strategy interface for any systemd-managed OneFlow agent. Auto-heals
Claude Code API Watchdog
Auto-recover Claude Code sessions stuck on transient API errors. Outer-loop watchdog for unattended tmux Claud
Lord Claude
Five Claude Code skills that delegate sub-tasks to rival CLIs — Codex, Gemini (via Antigravity), Grok, and Com
Claude Remote Watchdog
Auto-detect and fix dead Claude Code Remote Control sessions in tmux
Related Agents
Deploy
Deploy to target platform — Vercel, Netlify, Fly.io, AWS, VPS. Pre-deploy verification + security gates. Tests
Sysops
VPS maintenance agent. Use when the user asks about server status, wants to check their deployments, apply OS
Agency Incident Commander
Production incident management — SEV1-4 framework, blameless post-mortems, on-call process. Use při Flash VPS