Skip to content
/

CCBot

ccbot · six-ddc/ccbot · ★ 250 · last commit 2026-05-21

Primitive shape 1 total
Hooks 1
00

Summary

CCBot — Summary

CCBot is a Python tool that creates a Telegram-to-tmux bridge for Claude Code sessions: one Telegram topic maps 1:1 to one tmux window, which maps 1:1 to one Claude Code session. Unlike Telegram bots that wrap the Claude Code SDK (creating isolated API sessions), CCBot operates directly on tmux — it reads terminal output via libtmux and sends keystrokes back, so the tmux session remains the source of truth and the developer can attach/detach from the terminal at any time. Features include real-time notifications for assistant responses, tool calls, and permissions; interactive UI buttons for ExitPlanMode and AskUserQuestion; voice message transcription via OpenAI; multi-session management via thread-per-topic; a SessionStart hook auto-associating tmux windows with Claude sessions; and persistent state surviving restarts. Distributed as a pip/uv package (ccbot), it ships a ccbot CLI binary and a ccbot hook subcommand for Claude Code hook integration. Compared to the seeds, CCBot is closest to agent-os or claude-conductor in its "minimal infrastructure, no prompt framework" philosophy, but uniquely occupies the Telegram-channel remote-control niche.

01

Overview

CCBot — Overview

Origin

Personal project by six-ddc. 19 contributors. 250 stars. Python. MIT license. Active development, last commit 2026-05-21.

Philosophy

"The key insight is that it operates on tmux, not the Claude Code SDK. Your Claude Code process stays exactly where it is, in a tmux window on your machine. CCBot simply reads its output and sends keystrokes to it."

"Switch from desktop to phone mid-conversation — Claude is working on a refactor? Walk away, keep monitoring and responding from Telegram."

"Switch back to desktop anytime — Since the tmux session was never interrupted, just tmux attach and you're back in the terminal with full scrollback and context."

"In fact, CCBot itself was built this way — iterating on itself through Claude Code sessions monitored and driven from Telegram via CCBot."

Core Design Decision: tmux as source of truth

Other Telegram bots for Claude Code wrap the SDK to create separate API sessions — those sessions are isolated from the terminal and can't be resumed there. CCBot takes the opposite approach: tmux is the source of truth, the terminal is never interrupted, and Telegram is just a remote view+control interface.

Multi-Language Documentation

README in English, Chinese, and Russian.

02

Architecture

CCBot — Architecture

Distribution

  • pip/uv: uv tool install git+https://github.com/six-ddc/ccmux.git (note: repo URL in README uses ccmux not ccbot)
  • pipx: pipx install git+https://github.com/six-ddc/ccmux.git
  • Source: git clone && uv sync

Platform

  • Linux/macOS (requires tmux)
  • Python >= 3.12

Architecture Diagram

Telegram (user's phone)
    ↓ Bot API (HTTP polling)
CCBot daemon (Python, asyncio)
    ↓ libtmux
tmux session → window → pane
    ↓ Claude Code process (unmodified)

Directory Structure

src/ccbot/
  main.py          — Entry point: dispatches to hook.hook_main() or bot polling
  bot.py           — Telegram bot handlers (commands, callbacks, messages)
  config.py        — Configuration from ~/.ccbot/.env
  hook.py          — Claude Code SessionStart hook handler + installer
  tmux_manager.py  — libtmux session/window management
  session.py       — Session state
  session_monitor.py — Terminal output monitoring + polling
  monitor_state.py — State machine for monitoring
  terminal_parser.py — Parse terminal output for Claude responses
  transcript_parser.py — Parse conversation transcripts
  handlers/        — Telegram handler modules
    callback_data.py
    message_queue.py
    message_sender.py
    history.py
    directory_browser.py
    interactive_ui.py
    status_polling.py
    response_builder.py
  telegram_sender.py — Safe message sending helpers
  screenshot.py    — Terminal screenshot
  transcribe.py    — Voice message transcription (OpenAI)
  markdown_v2.py   — Telegram MarkdownV2 formatting
  utils.py         — Utilities (ccbot_dir, etc.)
tests/             — pytest tests

Configuration

~/.ccbot/.env:

TELEGRAM_BOT_TOKEN=...
ALLOWED_USERS=123456789
# Optional:
TMUX_SESSION_NAME=ccbot       # default
CLAUDE_COMMAND=claude          # command for new windows
MONITOR_POLL_INTERVAL=2.0      # seconds
OPENAI_API_KEY=...             # for voice transcription

Required Runtime

  • Python >= 3.12
  • tmux (in PATH)
  • claude CLI (in PATH)
  • Telegram bot token (from @BotFather)
  • Telegram group with Threaded Mode enabled
03

Components

CCBot — Components

CLI Binary

Binary Description
ccbot Start the Telegram bot polling loop
ccbot hook SessionStart hook handler (called by Claude Code)
ccbot hook --install Auto-install hook in ~/.claude/settings.json

Telegram Bot Commands

Command Description
/start Show welcome message
/history Browse conversation history with pagination (newest first)
/screenshot Take screenshot of terminal
/esc Send Escape key to Claude session
/kill Kill the associated tmux window
/unbind Unbind topic from tmux window
/<command> Any unknown slash command is forwarded to Claude Code
Text message Forwarded to Claude Code via tmux keystrokes
Photo Downloaded and forwarded as file path to Claude Code
Voice Transcribed via OpenAI API, forwarded as text

Interactive UI (Inline Keyboard Buttons)

  • AskUserQuestion — Navigate agent permission prompts via inline keyboard
  • ExitPlanMode — Button to exit Claude Code's plan mode
  • Permission prompts — Approve/deny via inline buttons
  • Directory browser — Browse filesystem to create new Claude sessions
  • History pagination — Navigate message history

Claude Code Hook

ccbot hook installs a SessionStart hook that writes window_id → session_id mappings to ~/.ccbot/session_map.json. This auto-associates tmux windows with Claude sessions even after /clear or session restarts.

Hook entry in ~/.claude/settings.json:

{
  "hooks": {
    "SessionStart": [
      {"hooks": [{"type": "command", "command": "ccbot hook", "timeout": 5}]}
    ]
  }
}

State Files

  • ~/.ccbot/.env — Configuration
  • ~/.ccbot/session_map.json — tmux window ↔ Claude session ID mappings
  • Thread bindings and read offsets — persist in memory across restarts (exact path unknown)

Key Dependencies

  • python-telegram-bot[rate-limiter]>=21.0 — Telegram Bot API
  • libtmux>=0.37.0 — tmux control library
  • chatgpt-md-converter (chatgpt_md_converter) — HTML message formatting
  • httpx — HTTP client
  • Pillow — Screenshot image handling
  • aiofiles — Async file I/O
  • telegramify-markdown — Markdown → Telegram-safe format
05

Prompts

CCBot — Prompts

CCBot is a remote-control bridge, not a prompt framework. It contains no agent prompt files. The CLAUDE.md in the repo is minimal.

Excerpt 1: main.py — Entry Point Docstring

"""Application entry point — CLI dispatcher and bot bootstrap.

Handles two execution modes:
  1. `ccbot hook` — delegates to hook.hook_main() for Claude Code hook processing.
  2. Default — configures logging, initializes tmux session, and starts the
     Telegram bot polling loop via bot.create_bot().
"""

Prompting technique: Not a prompt — this is a code docstring. Included to illustrate the "two modes" architecture.

Excerpt 2: hook.py — Hook Docstring (Claude Code Integration)

"""Hook subcommand for Claude Code session tracking.

Called by Claude Code's SessionStart hook to maintain a window↔session
mapping in <CCBOT_DIR>/session_map.json. Also provides `--install` to
auto-configure the hook in ~/.claude/settings.json.

This module must NOT import config.py (which requires TELEGRAM_BOT_TOKEN),
since hooks run inside tmux panes where bot env vars are not set.
Config directory resolution uses utils.ccbot_dir() (shared with config.py).
"""

Prompting technique: Not a prompt — design constraint documentation. The notable pattern: hooks run in a different environment (tmux pane) than the bot daemon, so the hook subcommand is designed to not require the bot's config. This is an important architectural isolation.

Excerpt 3: README — Voice Integration Spec

From README:

Voice messages — Voice messages are transcribed via OpenAI and forwarded as text.
...
OPENAI_API_KEY — OpenAI API key for voice message transcription
OPENAI_BASE_URL — https://api.openai.com/v1 — OpenAI API base URL (for proxies or compatible APIs)

Prompting technique: API delegation — voice is not transcribed locally but via OpenAI API, with OPENAI_BASE_URL supporting proxy/compatible API endpoints (useful for local Whisper-compatible APIs).

Note

CCBot ships no .claude/commands/, skills, or behavioral prompt files. It is infrastructure, not a methodology.

09

Uniqueness

CCBot — Uniqueness

differs_from_seeds

CCBot has no meaningful parallel in the 11 seeds. The seeds address agent methodology, prompting, and memory — CCBot addresses remote session control via Telegram. The closest analogy is claude-conductor (Archetype 4: markdown scaffold) in that both are minimal infrastructure tools, but claude-conductor focuses on structured markdown templates while CCBot focuses on bridging a messaging app to a terminal. CCBot is architecturally inverted from IM.codes (also in this batch): IM.codes builds a full three-tier server infrastructure for remote access, whereas CCBot is a thin Python daemon that directly controls tmux on the same machine via Telegram Bot API.

Positioning

CCBot is the Telegram channel of the "remote control for coding agents" design space. It targets developers who already use Telegram and want zero infrastructure overhead — no servers, no Docker, no self-hosting. Just a bot token and a Python package. The constraint is locality: CCBot requires Claude Code to run on the same machine as the CCBot daemon (no remote machine support without SSH).

Observable Failure Modes

  1. Same-machine requirement: CCBot must run on the machine where Claude Code runs; no built-in remote machine support
  2. VPS permissions: on headless servers, Claude Code requires --dangerously-skip-permissions (documented: CLAUDE_COMMAND=IS_SANDBOX=1 claude --dangerously-skip-permissions)
  3. Poll-based monitoring: 2-second poll interval means up to 2s notification delay; not real-time like PTY streaming
  4. tmux dependency: requires tmux to be running
  5. Telegram bot dependencies: requires BotFather setup, group with Threaded Mode enabled
  6. Message formatting: always HTML via chatgpt-md-converter; no MarkdownV2 runtime switch
  7. Single maintainer: 19 contributors but project is one person's personal tool

What Is Genuinely Novel

  • tmux-as-source-of-truth design: developer can always tmux attach and resume in terminal — no lock-in to bot interface
  • Multi-topic = multi-session: Telegram's threaded topics map naturally to parallel agent sessions
  • Interactive UI for Claude Code primitives (AskUserQuestion, ExitPlanMode, permission prompts) via Telegram inline keyboards
  • Voice message support with configurable OpenAI API endpoint (supports local Whisper-compatible APIs via OPENAI_BASE_URL)
  • Self-referential origin story: "CCBot itself was built this way — iterating on itself through Claude Code sessions monitored and driven from Telegram via CCBot"
04

Workflow

CCBot — Workflow

Setup Workflow

  1. Create Telegram bot via @BotFather, get token
  2. Enable Threaded Mode in BotFather settings for the bot
  3. Create ~/.ccbot/.env with TELEGRAM_BOT_TOKEN and ALLOWED_USERS
  4. Install ccbot: uv tool install git+https://github.com/six-ddc/ccmux.git
  5. Install hook: ccbot hook --install (writes SessionStart hook to ~/.claude/settings.json)
  6. Start bot: ccbot

Normal Session Workflow

  1. Open Telegram group
  2. Create a new topic (thread) → triggers directory browser
  3. Browse to project directory → creates new tmux window and Claude Code session
  4. Claude Code session appears in tmux; bot starts monitoring
  5. Send messages from Telegram → forwarded as keystrokes to tmux
  6. Claude responds → notification sent to Telegram topic
  7. Agent needs permission? → inline keyboard buttons appear
  8. Agent needs plan mode exit? → ExitPlanMode button appears
  9. Walk away from desk → continue monitoring/responding from phone
  10. Return to desk → tmux attach to same session

Session Resume Workflow

  1. Existing Claude session in a directory? → pick it from "Resume sessions" in the bot
  2. Session auto-discovered via ~/.ccbot/session_map.json

Hook Operation

When Claude Code starts a new session, the SessionStart hook runs ccbot hook which:

  1. Reads CLAUDE_SESSION_ID from environment
  2. Finds the current tmux window ID
  3. Writes {window_id: session_id} to ~/.ccbot/session_map.json

Phase → Artifact Map

Phase Artifact
Hook install ~/.claude/settings.json with SessionStart entry
Session start ~/.ccbot/session_map.json entry
Monitor loop Telegram messages sent to topic
Voice message OpenAI transcription → text sent to Claude
Screenshot Pillow PNG → sent to Telegram
06

Memory Context

CCBot — Memory & Context

Memory Architecture

CCBot has minimal state management:

  • ~/.ccbot/session_map.json — tmux window ID ↔ Claude session ID mappings (persists hook-registered associations)
  • Thread bindings (Telegram topic ↔ tmux window) — in-memory with persistence surviving restarts
  • Read offsets — track which messages have been sent to Telegram (prevents duplicates on restart)

What CCBot Reads

  • Terminal output via libtmux poll (every 2 seconds by default)
  • transcript_parser.py — parses Claude Code conversation transcripts
  • terminal_parser.py — parses raw terminal output for Claude responses

What CCBot Does Not Store

  • No conversation history archive beyond what Claude Code itself maintains
  • No vector DB or semantic memory
  • No context injection into Claude sessions

Session State Machine

monitor_state.py maintains a state machine tracking each Claude session's current state (idle, running, waiting for input, plan mode, etc.) to determine when to send Telegram notifications.

Cross-Session Handoff

Yes — via ~/.ccbot/session_map.json. Even after restarting the bot, session associations are restored. The Claude session itself is untouched (lives in tmux).

Memory Type

File-based (JSON). Minimal.

07

Orchestration

CCBot — Orchestration

Multi-Agent Support

Yes — via multi-topic design. Each Telegram topic = one tmux window = one Claude Code session. Multiple topics allow parallel session monitoring.

Orchestration Pattern

None (from CCBot's perspective). Each session is independent. CCBot does not coordinate agents — it provides per-session monitoring and keystroke injection.

Execution Mode

Continuous background daemon (asyncio polling loop).

Isolation Mechanism

tmux pane (OS process isolation). Each session is an independent tmux window, each in its own directory.

Multi-Model Support

No. CCBot is model-agnostic — it operates on tmux keystrokes regardless of what command runs in the window. CLAUDE_COMMAND=claude is configurable, so any terminal agent command works.

Consensus Mechanism

None.

Prompt Chaining

No.

The Key Architectural Philosophy

CCBot is a transparent pass-through. It does not modify what Claude Code sees or does; it only provides a communication channel between Telegram and the tmux session. The agent runs exactly as it would without CCBot.

Voice Transcription

For voice messages, CCBot makes an API call to OpenAI's transcription endpoint before forwarding to tmux. This is the only non-transparent operation: voice → text conversion happens outside the tmux/Claude loop, via OpenAI (or compatible proxy).

08

Ui Cli Surface

CCBot — UI & CLI Surface

CLI Binary

  • Name: ccbot
  • Type: Python CLI with two modes: daemon (ccbot) and hook (ccbot hook)
  • Subcommands: default (bot daemon), hook, hook --install

UI Surface: Telegram

CCBot's entire UI is Telegram:

Feature Telegram implementation
Session list Topics in Telegram group
Real-time output Messages in topic thread
Agent interaction Keyboard message input
Permission prompts Inline keyboard buttons
Plan mode exit Inline keyboard button
Directory browser Callback-driven inline keyboard
Message history Paginated inline keyboard navigation
Voice input Voice message → OpenAI transcription
Photo upload Photo → file path forwarded to Claude
Terminal screenshot Pillow PNG sent as image message
Session monitoring Push notifications (Telegram bot push)

Push Notifications

Telegram's native notification system provides push notifications. When Claude needs input or completes a response, a Telegram notification fires on the user's phone.

IDE Integration

None directly. CCBot works alongside any terminal/IDE workflow.

Observability

  • Terminal screenshots via /screenshot command
  • Message history via /history with pagination
  • State persisted in ~/.ccbot/session_map.json

Cross-Tool Portability

High — CCBot operates on tmux keystrokes, not on any specific agent API. CLAUDE_COMMAND is configurable to run any terminal-based agent.

Related frameworks

same archetype · same primary tool · same memory type

BMAD-METHOD ★ 48k

Provides a full agile delivery lifecycle with named expert-persona AI collaborators that elicit the human's best thinking rather…

Agent OS ★ 4.6k

Extracts implicit codebase conventions into token-efficient markdown standards files and injects them selectively into AI agent…

Claude Conductor ★ 367

Gives Claude Code a persistent, cross-linked, auto-analyzed documentation system so it retains codebase context across sessions.

Spec-Driver (Greenfield Spec-Driven Development) ★ 25

Prevents spec rot in AI-assisted development by making implementation changes flow back into evergreen, authoritative specs via…

Anthropic Knowledge Work Plugins ★ 16k

Role-specialized plugin bundles with live MCP connectors that turn Claude into a domain expert for enterprise knowledge workers.

Codex Integration for Claude Code (skill-codex) ★ 1.3k

Single Claude Code skill that handles Codex CLI invocation correctly (stdin blocking, thinking token suppression, session resume)…