Logo Vincent
Back to all posts

I Built a Bot That Runs Claude Code From Chat

Claude
I Built a Bot That Runs Claude Code From Chat

Why Build This

Anyone who has used Claude Code knows how powerful it is — it can read code, modify code, run commands, and perform refactoring. But there’s one problem: you have to be in a terminal to use it.

That means you need to sit in front of your computer, open a terminal, and interact with Claude Code from there. On the go, on your phone, or want your team to use it too? No luck.

So I thought: what if we could connect Claude Code to Lark and turn it into a group chat bot?

Just @ it in the chat, and it can help you modify code, investigate issues, or run tests. No terminal needed, no SSH required — works right from your phone.

That’s how CCBot was born.

OpenClaw: The Inspiration

Before building CCBot, I studied an open-source project called OpenClaw.

OpenClaw is a self-hosted personal AI assistant built by Peter Steinberger (founder of PSPDFKit), released under the MIT license. Its core philosophy is simple: AI should run on your own devices and interact through the chat tools you already use.

It’s far more ambitious than CCBot:

  • 20+ messaging channels: WhatsApp, Telegram, Slack, Discord, Lark, WeChat, iMessage… virtually every chat tool you can think of
  • Multi-model support: OpenAI, Anthropic, Google, Ollama (local models), DeepSeek, and a dozen more AI providers
  • Native apps: macOS menu bar app, iOS app, Android app — all serving as “nodes” for the assistant, providing device-specific capabilities (camera, screen recording, voice, etc.)
  • Browser control: Controls a standalone Chrome instance via Playwright — browsing, form-filling, screenshots
  • Voice interaction: Wake word detection, continuous voice conversation, text-to-speech
  • Live Canvas: An AI-powered visual workspace where AI can render and manipulate visuals in real time
  • Automation: Scheduled tasks, webhooks, Gmail subscriptions, polling
  • Plugin system: Lean core with 70+ extensions loaded via plugins
  • Memory system: Vector storage based on LanceDB, plus workspace memory files

On the tech side, OpenClaw uses TypeScript + Node.js, managed as a pnpm monorepo, with Hono as the web gateway, Lit for the control panel UI, and SQLite + sqlite-vec for data storage and vector search. Deployment is flexible — Docker, Fly.io, Nix, or bare metal.

For security, it uses a single-operator trust model — each gateway instance has one trusted user, secured through DM pairing, whitelisting, sandboxing, and execution approval. It’s not a multi-tenant platform — it’s your personal assistant.

The biggest takeaway from OpenClaw: AI assistants shouldn’t be locked into a specific interface — they should show up in the tools you use every day.

But OpenClaw is a general-purpose AI assistant, while I wanted something more focused — specifically bringing Claude Code’s programming capabilities into Lark. No need to support 20 channels or multi-model switching — just do “Lark + Claude Code” well.

And that’s how CCBot came to be.

What Is CCBot

CCBot is an open-source Lark bot that brings Claude Code’s programming capabilities directly into Lark group chats.

In one sentence: @ CCBot in Lark is like using Claude Code in the terminal.

Key features:

  • Lark WebSocket long connection — no public IP needed, no callback URL to configure
  • Claude Code --print mode — with session context, supporting multi-turn conversations
  • PM2 process management — background daemon, one-command start/stop
  • Per-user message queue — multiple users can use it simultaneously without conflicts
  • Auto-splitting long messages — Claude’s lengthy replies are automatically split into multiple Lark messages
  • Lark Markdown rendering — code blocks, lists, bold text, and other formatting display correctly

How to Use

Installation

npm install -g @ccbot/cli

Configure the Lark Bot

  1. Create a custom app on the Lark Open Platform
  2. Add the “Bot” capability
  3. Event subscription → set to “Long Connection” mode
  4. Add event: im.message.receive_v1
  5. Grant permissions:
    • im:message.p2p_msg:readonly (receive direct messages)
    • im:message.group_at_msg:readonly (receive group @ messages)
    • im:message:send_as_bot (send messages as bot)
  6. Publish the app and note down the App ID and App Secret

Start

Navigate to your project directory and run:

ccbot start

On first launch, you’ll be prompted for configuration:

? Claude Code path: claude
? Anthropic Base URL: https://api.anthropic.com
? Anthropic Auth Token: sk-xxx
? Feishu App ID: cli_xxx
? Feishu App Secret: ***
? Timeout in ms: 300000

Configuration is saved in ccbot.json in the current directory and loaded automatically on subsequent starts.

Usage

In Lark group chats or direct messages:

  • Send a message or @ CCBot, and it will invoke Claude Code to handle your request
  • Send /new to reset the session
  • Send /stop to stop the current request
  • Send /status to check session status
  • Send /version to check the version

Management

ccbot stop      # Stop
ccbot restart   # Restart
ccbot status    # Check status
ccbot logs      # View logs
ccbot delete    # Remove from pm2

Technical Implementation

The architecture is straightforward:

Lark message → CCBot Server → Claude Code CLI (--print) → Lark reply

CCBot receives messages through Lark’s WebSocket long connection, invokes the local claude --print command to process them, and sends the results back to Lark.

Key design decisions:

  1. WebSocket long connection: Unlike traditional Lark bots that require a public IP and callback URL, CCBot uses long connection mode — it can run on an intranet machine
  2. Session management: Each user has an independent session context, making multi-turn conversations coherent
  3. Message queue: Requests from the same user are processed sequentially to avoid concurrency conflicts
  4. PM2 daemon: PM2 manages the process with auto-restart on crash and automatic log rotation

The project itself is a Lerna + Nx monorepo containing two sub-packages:

  • @ccbot/cli: Core CLI tool
  • @ccbot/index: Website (ccbot.dev)

Use Cases

  • Solo developers: Let Claude Code help you modify code right from your phone
  • Small teams: Share a Claude Code instance in a Lark group — everyone can use it
  • Remote work: Operate directly from Lark without SSH-ing into your dev machine
  • Code review: Drop code snippets into the chat and let CCBot help review them

CCBot vs OpenClaw

DimensionCCBotOpenClaw
FocusClaude Code Lark botGeneral-purpose personal AI assistant
ChannelsLark20+ channels
AI BackendClaude Code CLIMulti-model support
DeploymentOne-line npm install -gDocker/Fly.io/Nix
Native AppsNonemacOS/iOS/Android
Plugin SystemNone70+ extensions
Best ForDevelopers using Lark + Claude CodePower users wanting an all-in-one AI assistant

In short: CCBot is the screwdriver in a Swiss Army knife — does one thing, but does it well. OpenClaw is the whole Swiss Army knife.

If you just want to use Claude Code in Lark, CCBot is up and running in five minutes. If you want an all-in-one AI assistant that connects to every chat tool, supports voice, and can control a browser, check out OpenClaw.

© 2026 vincentqiao.com . All rights reserved.