A Telegram Bot for Claude
so I’ve been using Claude Code a lot lately and one thing that kept bugging me is that I can’t really talk to it when I’m away from my desk I mean it’s running in the terminal, doing its thing, but if it needs my approval for something it just sits there waiting and that’s when I thought - what if I could just talk to it through Telegram?
the CLI
I built tgbot - a minimal CLI for the Telegram Bot API it’s written in Go, zero dependencies, single binary, and it does exactly what you’d expect
# send a message
tgbot send --text "hello world"
# send a photo
tgbot media --type photo --file photo.jpg --caption "nice pic"
# fetch recent updates (this is the important one)
tgbot updates
# send a location
tgbot location --lat 51.5074 --lon -0.1278
all commands output JSON so you can pipe everything to jq and it plays nice with scripts
you install it by downloading the binary from the releases page or with go install:
go install github.com/dean/tgbot@latest
then just set two env vars - TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID - and you’re good to go
the skill
now the CLI by itself is cool but the real magic happens when you plug it into Claude Code as a skill
skills add deanshub/telegram -g
once installed Claude knows how to use tgbot - it can send you messages, check for updates, send media, locations, whatever you don’t need to explain the commands, it just knows
the approval hook
but here’s where it gets really interesting Claude Code has this hooks system where you can run scripts before tools execute so I wrote a hook that sends me a Telegram message every time Claude wants to do something potentially dangerous
it auto-approves safe stuff like reading files or searching code but when Claude wants to edit a file or run a bash command it sends me a message like:
Claude wants to run: Bash
npm install some-packageReply yes to approve or no to deny.
and I can just reply “yes” or “no” from my phone it polls for my reply and if I don’t respond within 2 minutes it denies by default (safe side)
the loop
this is the part that ties it all together
Claude Code has a /loop command that runs a prompt on a recurring interval
/loop 1m check using tgbot if there are any tasks to do and do them and then respond to the user
so now Claude is sitting there, every minute checking Telegram for new messages from me I can text it “refactor the auth module” or “what’s the status of the tests” and it just does it and when it needs approval for something it asks me through the same Telegram chat
it’s basically a personal AI developer that lives in my terminal but talks to me through my phone
tips for the brave
if you want to go full autonomous and skip the permission prompts entirely, Claude Code has a flag for that:
claude --dangerously-skip-permissions
this lets Claude run any tool without asking - no hooks, no approvals, just pure unfiltered agent action obviously use this at your own risk, but for personal projects or when you just want to let it cook it’s pretty liberating
and one more thing - if you’re on a Mac and you want this running while you’re away, your laptop is going to fall asleep and kill everything the fix is simple:
caffeinate -d
this is a built-in macOS command that prevents the display from sleeping
run it before you start your loop and your Mac will stay awake until you kill the caffeinate process
(credit to Schniz from Vercel, who is definitely not the most Gever, for teaching me the -d flag and making me a 10x dev ages ago)
so the full setup needs two terminal panes - I recommend using cmux for this, it’s the best terminal UI out there (shoutout to Malte from Vercel for tweeting about it)
terminal 1 - keep the mac awake:
caffeinate -d
terminal 2 - start claude and loop:
claude --dangerously-skip-permissions
then inside Claude:
/loop 1m check using tgbot if there are any tasks to do and do them and then respond to the user
and now you have a personal AI agent you can command from your phone while you’re out getting coffee