Navigation

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

  1. Type /claudecode
  2. Tap Work Dir
  3. A folder browser appears with inline buttons:
📂 Select working directory:
~/projects

[📁 my-app]    [📁 website]
[📁 camelagi]  [📁 scripts]
[⬅ Back]
[✓ Select this folder]
  1. Navigate by tapping folders
  2. Tap ⬅ Back to go up
  3. 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:

  1. Type /claudecode
  2. Tap Model
  3. 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 /claudecodeStart
Stop /claudecodeStop
New session /claudecodeNew Session (clears history, starts fresh)

Resuming previous sessions

  1. Type /claudecode
  2. Tap Sessions (or Resume Session if not active)
  3. See a list of previous Claude Code sessions
  4. 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)

  1. Open the admin bot in Telegram
  2. Send /newagent
  3. Enter a name: Coder
  4. Select Claude Code (local CLI) as the mode
  5. The template and model steps are skipped (Claude Code handles those)
  6. Paste a Telegram bot token (or skip)
  7. 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 commandsgit 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-permissions is used because you can’t interactively approve from Telegram. Your allowedUsers config 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:

  1. Type /claudecode
  2. Tap Stop
  3. 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:

  1. Type /claudecode — the current dir is shown
  2. Tap Work Dir to change it
  3. Or use /workdir