Multi-session Claude Code dispatch from Telegram
Project description
Claude Bridge
Dispatch Claude Code agents from your phone via Telegram. Create agents, assign them to projects, dispatch tasks, get notified when done.
How It Works
You (Telegram)
│
▼
Bridge Channel Server (TypeScript) Polls Telegram via grammy
│ Pushes messages into Claude session
│ mcp.notification (push) Retries if not acknowledged in 30s
▼
Claude Code session (Bridge Bot) Messages arrive as <channel> tags
│ CLAUDE.md for intent mapping
│ bridge_dispatch(agent, prompt) reply(chat_id, text) sends back
▼
claude --agent --worktree -p "task" Each task = isolated Claude Code agent
│
▼
Stop hook → on_complete.py Updates SQLite, queues notification
Channel server delivers to Telegram
Quick Start
# 1. Clone and install
git clone https://github.com/hieutrtr/claude-bridge.git ~/projects/claude-bridge
cd ~/projects/claude-bridge
pipx install -e . # or: pip3 install -e . --break-system-packages
# 2. Install Bun (channel server runtime)
curl -fsSL https://bun.sh/install | bash
# 3. Build channel server
bun run build
# 4. Run setup wizard
bridge-cli setup
The wizard asks for your Telegram bot token, creates the bridge-bot project, deploys the channel server, and installs the watcher cron. Done in under 2 minutes.
Prerequisites
| What | Why |
|---|---|
| Python 3.11+ | Bridge core |
| Bun | Channel server runtime |
| Claude Code CLI | claude --version to verify |
| Telegram account | You send commands from your phone |
Installation
Step 1: Clone and install
git clone https://github.com/hieutrtr/claude-bridge.git ~/projects/claude-bridge
cd ~/projects/claude-bridge
# Option A: pipx (recommended — isolated, clean)
brew install pipx
pipx install -e .
# Option B: pip with --break-system-packages (Homebrew Python)
pip3 install -e . --break-system-packages
# Option C: venv
python3 -m venv ~/.claude-bridge/venv
~/.claude-bridge/venv/bin/pip install -e .
# Then use: ~/.claude-bridge/venv/bin/bridge-cli (or add to PATH)
This gives you the bridge-cli command.
Step 2: Install Bun and build
curl -fsSL https://bun.sh/install | bash
exec $SHELL
bun run build
This bundles channel/server.ts into a single JS file included in the package.
Step 3: Create a Telegram bot
- Open Telegram, search for @BotFather
- Send
/newbot, follow the prompts - Copy the bot token
Step 4: Run the setup wizard
bridge-cli setup
The wizard:
- Asks for your bot token → saves to
~/.claude-bridge/config.json - Asks for bridge-bot directory → creates
CLAUDE.md+.mcp.json - Deploys the channel server to
~/.claude-bridge/channel/dist/ - Installs the watcher cron (runs every minute)
- Prints the startup command
Or non-interactive:
bridge-cli setup --token "<your-token>" --bot-dir ~/projects/bridge-bot --no-prompt
Step 5: Start the Bridge Bot
cd ~/projects/bridge-bot
claude --dangerously-load-development-channels server:bridge --dangerously-skip-permissions
Step 6: Pair your Telegram account
DM your bot on Telegram (send any message). In the Claude Code session:
/telegram:access pair <code>
/telegram:access policy allowlist
Step 7: Verify
bridge-cli doctor
All checks should pass. Send /help to your bot on Telegram.
Usage
Create an agent
From Telegram:
/create backend ~/projects/my-api "API development"
Or natural language:
set up an agent called backend for ~/projects/my-api, it does API development
Dispatch a task
dispatch backend add pagination to /users endpoint
The agent works in an isolated git worktree. When done, you get a Telegram notification.
Check status
/status — all running tasks
/agents — list all agents
/history backend — past tasks with cost
/kill backend — stop a running task
Agent teams
/create backend ~/projects/api "API development"
/create frontend ~/projects/web "React UI"
/create-team fullstack --lead backend --members frontend
/team-dispatch fullstack "build user profile page with API and UI"
Restarting
cd ~/projects/bridge-bot
claude --dangerously-load-development-channels server:bridge --dangerously-skip-permissions
All Commands
Telegram Commands
| Command | Description |
|---|---|
/create <name> <path> "<purpose>" |
Register a new agent |
/delete <name> |
Remove an agent |
/agents |
List all agents |
/dispatch <agent> "<task>" |
Send a task (queues if busy) |
/status [agent] |
Show running tasks |
/kill <agent> |
Stop a running task |
/history <agent> |
Task history with cost |
/queue [agent] |
Show queued tasks |
/cancel <task_id> |
Cancel a queued task |
/set-model <agent> <model> |
Change model (sonnet/opus/haiku) |
/cost [agent] |
Cost summary |
/create-team <name> --lead <a> --members <b,c> |
Create team |
/team-dispatch <team> "<task>" |
Dispatch to team |
/team-status <team> |
Team progress |
CLI Commands
| Command | Description |
|---|---|
bridge-cli setup |
Interactive setup wizard |
bridge-cli doctor |
Check installation health |
bridge-cli doctor --fix |
Auto-repair issues |
bridge-cli uninstall |
Remove data, config, cron |
bridge-cli setup-cron |
Install watcher cron |
bridge-cli remove-cron |
Remove watcher cron |
bridge-cli --version |
Print version |
Architecture
~/.claude-bridge/
├── config.json Bot token, settings
├── bridge.db SQLite: agents, tasks, teams
├── messages.db SQLite: message queue
├── channel/dist/ Deployed channel server
├── watcher.log Cron output
└── workspaces/ Per-agent task results
~/projects/bridge-bot/
├── CLAUDE.md Bridge Bot routing rules
└── .mcp.json Channel server config
~/.claude/agents/
└── bridge--*.md Agent definitions
Key Details
| What | Detail |
|---|---|
| Channel server | TypeScript/Bun, push via notifications/claude/channel |
| Message delivery | Push + 30s retry (5 retries max) |
| Notification queue | Prevents stdio interleaving during tool calls |
| Stop hook | In project's .claude/settings.local.json (not frontmatter) |
| Session UUID | Unique per task: uuid5(session_id + task_id) |
| Worktree | Each task in isolated git worktree |
| Queue | Auto-queue when busy, auto-dequeue on completion |
Development
# Python tests (370+ tests)
pipx install -e . # or: pip3 install -e . --break-system-packages
python3 -m pytest tests/ --ignore=tests/test_mcp_server.py -v
# TypeScript tests (43 tests)
cd channel && bun test
# Build channel server
bun run build
# Run any CLI command
bridge-cli <command>
Troubleshooting
| Problem | Fix |
|---|---|
| Bot doesn't respond | bridge-cli doctor to check. Kill zombie processes: ps aux | grep "bun.*server" |
| Stop hook not firing | bridge-cli doctor --fix redeploys channel server |
| Task stuck as "running" | Watcher cron catches within 1 minute. Or: bridge-cli watcher |
| Multiple bots conflict | Only one session can poll a bot token. Kill old processes first |
| Double notifications | Already fixed — on_complete.py marks tasks as reported |
| Clean removal | bridge-cli uninstall --force |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claude_agent_bridge-0.1.0.tar.gz.
File metadata
- Download URL: claude_agent_bridge-0.1.0.tar.gz
- Upload date:
- Size: 158.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8cdc67ca9f4a5682c763c70cb68ca513c9e139e6ce04e327b35817f051e40147
|
|
| MD5 |
20e1a5d5a5299319274527a682d6214a
|
|
| BLAKE2b-256 |
0a1295d688434a5c0a435195bd49b4e49e0d3038ab529e50b9ea2b5b6421f7a1
|
File details
Details for the file claude_agent_bridge-0.1.0-py3-none-any.whl.
File metadata
- Download URL: claude_agent_bridge-0.1.0-py3-none-any.whl
- Upload date:
- Size: 142.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edff1941df45f7c130a88b60dd36a2182b9a86cb6308b9ba7dc7431e06fe98bd
|
|
| MD5 |
0574cb753416a1232fc11801cf1cd986
|
|
| BLAKE2b-256 |
82010f0fff3ad9e83e88fd52a2bcc4a344270d63963fb6042b9398bdb5fa8671
|