afk-claude-telegram-bridge
AFK Claude Telegram Bridge
Remote-control Claude Code sessions from your phone via Telegram when AFK (away from keyboard).
When to Use
- "set up telegram bridge" / "configure telegram AFK"
- "enable remote control" / "activate AFK mode"
- "I want to control Claude from my phone"
- Installing this skill on a new machine
What This Skill Does
Installs a complete Telegram β Claude Code bridge that allows you to:
- Approve/deny tool calls from Telegram inline keyboards
- Continue tasks by sending new instructions when Claude finishes
- Auto-approve read-only tools (Read, Glob, Grep, WebSearch, WebFetch)
- Multi-session support β up to 4 concurrent sessions (S1-S4)
- Minimal dependencies β Node.js with fp-ts only
Installation
Install via curl (recommended):
curl -fsSL https://raw.githubusercontent.com/gmotyl/afk-claude-telegram-bridge/main/install.sh | bash
Or from a local clone:
git clone https://github.com/gmotyl/afk-claude-telegram-bridge.git
cd afk-claude-telegram-bridge
npm install && npm run deploy
The installer downloads pre-built binaries from GitHub and handles everything:
- Copies hook.js, bridge.js, cli.js, hook.sh to
~/.claude/hooks/telegram-bridge/ - Installs
/afk,/back, and/afk-resetcommands to~/.claude/commands/ - Registers Stop, Notification, and PreToolUse hooks in
~/.claude/settings.json - Prompts for your bot token and auto-detects your Telegram group
Restart Claude Code after installation to load the new commands.
Prerequisites
Before running the installer, create a Telegram bot:
- Open Telegram -> search @BotFather -> send
/newbot - Name it "Claude Bridge" (or your preferred name)
- Copy the bot token
- Create a Telegram Group with Topics enabled
- Add the bot to the group as Administrator
- Send a message in the group (so the bot can detect it)
Usage
Activate AFK Mode
In any Claude Code session:
/afk
You'll see a confirmation on Telegram: "π‘ S1 β AFK Activated"
Deactivate AFK Mode
/back
From Telegram
When Claude needs approval for a tool call, you'll see:
π S1 β Permission Request
Tool: Bash
`npm install express`
[β
Approve] [β Deny]
When Claude finishes a task:
β
S1 β Task Complete
I've implemented the login form...
[π Let it stop]
Reply with text to send Claude a new instruction!
Multi-Session
With multiple sessions, prefix instructions:
S1: now add unit tests
S2: push to remote
File Structure
After installation:
~/.claude/hooks/telegram-bridge/
hook.sh β Bash wrapper (Claude Code calls this)
hook.js β Compiled hook entry point (Node.js)
bridge.js β Compiled Telegram daemon (Node.js)
config.json β Bot token, group ID, settings
state.json β Runtime state
daemon.log β Daemon log
ipc/ β Per-session IPC
~/.claude/commands/
afk.md β /afk command
back.md β /back command
afk-reset.md β /afk-reset command
Commands Reference
| Command | Description |
|---|---|
hook.sh --activate <session_id> [project] |
Activate AFK mode |
hook.sh --deactivate <session_id> |
Deactivate AFK mode |
hook.sh --reset |
Nuclear reset (kill daemons, clear state) |
hook.sh --status |
Show active sessions |
hook.sh --setup |
Configure bot token/chat_id |
hook.sh --help |
Show help |
Troubleshooting
- Daemon log:
cat ~/.claude/hooks/telegram-bridge/daemon.log - Status:
~/.claude/hooks/telegram-bridge/hook.sh --status - Manual start:
node ~/.claude/hooks/telegram-bridge/bridge.js - Kill daemon: Check PID in
state.json, thenkill <pid>
Dependencies
- Node.js 18+
- bash
- Telegram bot token
Changelog
See CHANGELOG.md for release history.
Credits
Originally built by Greg Motyl (@gmotyl).