Claude Code via Telegram
Run Claude Code on your local machine, remote-controlled from Telegram. Send a message from your phone, Claude Code processes it locally — reads files, edits code, runs commands — and the response streams back to Telegram.
Setup Guide (Step by Step)
Step 1: Install Claude Code
Open your terminal and install Claude Code globally:
npm i -g @anthropic-ai/claude-code
Verify it’s installed:
claude --version
Step 2: Log in to Claude Code
Authenticate Claude Code (one-time):
claude login
This opens your browser for OAuth login. Once done, Claude Code is ready.
Step 3: Make sure CamelAGI is running
You need CamelAGI running with at least one Telegram agent bot:
camel serve
If you haven’t set up CamelAGI yet, run camel setup first (see the Setup Guide).
Step 4: Start Claude Code from Telegram
Open your agent bot in Telegram and type:
/claudecode
You’ll see a menu with buttons:
Claude Code (2.1.84)
Dir: ~/Desktop
[Start] [Resume Session]
[Work Dir]
Tap Start. You’ll see:
Claude Code started. Send messages.
Step 5: Send your first message
Now just type a message like you normally would:
list all TypeScript files in src/
Claude Code runs locally on your machine, and the response streams back to Telegram in real-time. You’ll see emoji reactions while it works:
- 👀 — received your message
- 💭 — thinking
- 🔧 — using a tool (running commands, reading files)
Step 6: Keep chatting
Every message you send continues the same conversation. Claude Code remembers context — you can ask follow-up questions, refer to previous results, and build on past work.
refactor the main function to use async/await
now run the tests
fix the failing test
Choosing a Working Directory
By default, Claude Code operates in ~/Desktop. To change where Claude Code works:
From the /claudecode menu
- Type
/claudecode - Tap Work Dir
- A folder browser appears with inline buttons:
📂 Select working directory:
~/projects
[📁 my-app] [📁 website]
[📁 camelagi] [📁 scripts]
[⬅ Back]
[✓ Select this folder]
- Navigate by tapping folders
- Tap ⬅ Back to go up
- Tap ✓ Select this folder to confirm
Using /workdir
You can also type /workdir directly — same folder browser.
Via config
Set it permanently in ~/.camelagi/config.yaml:
agents:
coder:
mode: claude-code
workDir: ~/projects/my-app
Switching Models
While a session is active:
- Type
/claudecode - Tap Model
- Pick from:
Current model: default
[Sonnet] [Opus]
[Haiku] [Default]
[⬅ Back]
- Sonnet — fast and capable (recommended)
- Opus — most capable, takes longer
- Haiku — fastest, good for simple tasks
- Default — whatever Claude Code uses by default
The model change applies to the next message you send.
Session Management
Starting and stopping
| Action | How |
|---|---|
| Start | /claudecode → Start |
| Stop | /claudecode → Stop |
| New session | /claudecode → New Session (clears history, starts fresh) |
Resuming previous sessions
- Type
/claudecode - Tap Sessions (or Resume Session if not active)
- See a list of previous Claude Code sessions
- Tap one to resume it — Claude Code picks up where you left off
Sessions are stored by Claude Code itself, so they survive CamelAGI restarts.
Creating a Dedicated Claude Code Agent
Instead of manually typing /claudecode every time, create an agent that’s always in Claude Code mode:
Via Telegram (/newagent)
- Open the admin bot in Telegram
- Send
/newagent - Enter a name:
Coder - Select Claude Code (local CLI) as the mode
- The template and model steps are skipped (Claude Code handles those)
- Paste a Telegram bot token (or skip)
- Approve the bot
Now every message you send to @CoderBot goes directly through Claude Code. No /claudecode needed.
Via config
agents:
coder:
name: "Coder"
mode: claude-code
workDir: ~/projects/my-app
telegram:
botToken: "YOUR_BOT_TOKEN"
allowedUsers: [YOUR_TELEGRAM_ID]
Via CLI
camel agents
# Select "Create new agent"
# Pick "Claude Code (local CLI)"
What Claude Code Can Do
When running via Telegram, Claude Code has full access to your local machine:
- Read and write files — view source code, create files, edit existing ones
- Run shell commands —
git commit,npm test,python script.py, anything - Search code — find files, grep for patterns across your codebase
- Edit code — precise replacements, refactoring, bug fixes
- Browse the web — look up documentation, APIs, error messages
- Spawn sub-agents — delegate parallel tasks
All running locally on your machine. Telegram is just the remote control.
How It Works (Technical)
You (Telegram)
│
▼
CamelAGI Agent Bot (on your server/machine)
│
▼
spawn("claude", ["-p", "your message",
"--output-format", "stream-json",
"--resume", "<session-id>",
"--dangerously-skip-permissions"])
│
▼
Claude Code (runs locally)
├── reads/writes files
├── runs commands
├── searches code
│
▼
stream-json output → DraftStream → Telegram
(real-time streaming with throttled message edits)
- First message creates a session. Claude Code returns a
session_id. - Following messages use
--resume <session_id>to continue the conversation. --dangerously-skip-permissionsis used because you can’t interactively approve from Telegram. YourallowedUsersconfig controls who has access.- Responses stream in real-time via Telegram message edits (1.2s throttle).
Troubleshooting
“Claude Code not found”
Install it:
npm i -g @anthropic-ai/claude-code
Then verify:
claude --version
“Not logged in”
Run in your terminal:
claude login
No response or very slow
Claude Code can take time on complex tasks. If it seems stuck:
- Type
/claudecode - Tap Stop
- Tap Start to begin a fresh session
“Claude Code is busy”
Only one Claude Code process runs per chat at a time. Wait for the current response, or stop and restart.
Wrong directory
Check your working directory:
- Type
/claudecode— the current dir is shown - Tap Work Dir to change it
- Or use
/workdir