Skip to content

WaterTian/cc-bot

Repository files navigation

CC-BOT

Develop project from group chat — by Claude Code
接 AI 进群里开发项目 — 飞书(Lark)

IM group  →  Monitor  →  Intent  →  Claude acts  →  Chat reply
one plugin, any project, zero backend.

version   install   im   node   platform   MIT


Why CC-BOT?

The Problem

Team members want a lightweight way to ask questions and trigger project actions from the group chat — "what's the progress?", "run tests", "deploy staging", "why is build failing?" — without switching to terminals, dashboards, or ticket systems. Existing chat-bots require bespoke backends per project and rarely integrate with an AI coding agent.

The Solution

CC-BOT is a Claude Code plugin that listens to IM group messages, routes natural-language intents to per-project actions (you define them), runs them through Claude, and replies back to the group. One plugin, any number of projects — each project has its own profile.intents dict mapping intent → action description, and the same Claude Code brain executes them.

为什么做 CC-BOT?

问题

团队希望在群里就能快速查询和触发项目操作 — 「进度怎么样?」「跑一下测试」「部署灰度」「构建为什么失败?」 — 而不用切到终端、仪表盘或工单系统。现有的聊天机器人通常需要为每个项目定制后端,并且很少与 AI 编程助手打通。

解决方案

CC-BOT 是一个 Claude Code 插件,监听 IM 群消息,把自然语言意图路由到项目特定操作(由你定义),通过 Claude 执行,结果回到群里。一份插件、任意项目 — 每个项目有自己的 profile.intents 字典(意图 → 动作描述),同一个 Claude Code 脑子来执行。

Tip

Windows users: Use npm i -g @anthropic-ai/claude-code instead of the native installer to avoid Bun memory crashes (oven-sh/bun#25082). cc-bot's Monitor runs long-lived, amplifying Bun's memory pressure.

Windows 用户: 建议用 npm i -g @anthropic-ai/claude-code 代替原生安装器,规避 Bun 内存崩溃;cc-bot 的 Monitor 是长驻进程,会放大 Bun 的内存问题。


Features

Interactive Setup
5-stage wizard
auto-detect IDs

IM-agnostic
Lark today
adapter pattern

Per-project Intents
JSON-defined
Claude executes

Crash-resistant
3-layer defense
PID lock · EPIPE · state heal

█▌

HUD-aware
statusline shim
tees cc-hud if installed

Install

Inside Claude Code in your target project, run these in order:

/plugin marketplace add WaterTian/cc-bot
/plugin install cc-bot@cc-bot
/reload-plugins
/cc-bot:setup
  • Line 1 — register the plugin source (GitHub repo)

  • Line 2 — download to ~/.claude/plugins/cache/. CC will pop a scope selector; pick one:

    选项 适用场景 Recommendation
    Install for you (user scope) You plan to use cc-bot across many projects ✅ 日常推荐
    Install for all collaborators (project scope) Team project, want teammates to auto-get cc-bot on clone ✅ 团队项目
    Install for you, in this repo only (local scope) First-time try, don't pollute other projects ✅ 快速试用
  • Line 3 — hot-reload plugin list without restarting CC (new since CC 2.1.x; faster than /exit + re-open)

  • Line 4 — enter the interactive setup wizard (lark-cli auto-install, OAuth login, chat picker via AskUserQuestion cards, config auto-fill)

Note

/reload-plugins 不可用或命令表仍没出现 /cc-bot:*,退一步 /exit 重开 Claude Code 即可。


Updating

When a new release is announced, run these in each project using cc-bot:

/plugin marketplace update cc-bot    # refresh manifest (detects new version)
/plugin update cc-bot@cc-bot         # fetch new version into cache
/reload-plugins                      # apply in current session
/cc-bot:doctor                       # verify: first line prints "cc-bot v<new-version>"
  • Before upgrading — run /cc-bot:doctor first; it compares installed version with the latest GitHub release and prints the upgrade hint if drifted, plus flags stale permissions or profile issues.
  • After upgrading — run /cc-bot:doctor again to confirm the new version is active; or run /cc-bot:start and the group online notification will show cc-bot v<new-version> 已上线. Setup's greeting + completion lines also carry v<version> (since v0.1.4) for the same reason.

Stable permission pattern (auto-registered since v0.1.3)

CC's plugin cache is version-indexed (~/.claude/plugins/cache/cc-bot/cc-bot/<version>/). After each upgrade the Monitor launch path points to a new version dir, so CC would otherwise re-prompt for permission.

Since v0.1.3, /cc-bot:setup auto-writes a wildcard rule to <project>/.claude/settings.local.json. As of v0.1.11 the wildcard covers the entire runtime/*.js directory (was just poll.js), so future runtime tools (e.g. check-image-size.js) no longer require re-running setup:

Bash(node C:/Users/*/.claude/plugins/cache/cc-bot/cc-bot/*/runtime/*.js *)

You won't be prompted for any cc-bot runtime tool on future version upgrades.

For v0.1.2 or earlier installs (pre-auto): after you update, re-run /cc-bot:setup — step 9 is idempotent and will append the rule. Or add it manually.

Migrating from v0.1.10 or earlier (had the older runtime/poll.js --project * rule): re-run /cc-bot:setup once — it appends the new runtime/*.js * wildcard while keeping the old single-file rule intact for backwards compatibility.

Since v0.1.6/cc-bot:setup step 9 additionally registers a UserPromptSubmit / Stop hook pair into ~/.claude/settings.json so main-window typing automatically pauses group-message handling (poll.js skips emit + sends a one-shot placeholder, randomly picked from a 14-phrase pool since v0.1.9). After upgrading to v0.1.6 you must re-run /cc-bot:setup once to activate the hook — the three §Updating commands above only pull new code; they don't touch user-global settings.json.


From source (development / contributors)
git clone https://github.com/WaterTian/cc-bot.git

In your target project, launch Claude Code with the local plugin dir:

cd /your/project
claude --plugin-dir /absolute/path/to/cc-bot

Then /cc-bot:setup. Skips marketplace install — loads straight from the local repo. Ideal for iterating on cc-bot itself.


Quick Start — what /cc-bot:setup does

Setup prints a version banner on start (cc-bot v<X.Y.Z> setup — <project>, since v0.1.4) then runs through these steps — fully interactive via AskUserQuestion cards, no blind typing:

  1. Detect lark-cli — auto-install via npm i -g @larksuite/cli if missing
  2. OAuth login — guide you through Lark Open Platform app creation (scope checklist provided), then browser Device Flow login
  3. Pick target chat — list bot's chats via AskUserQuestion card; or one-click create a new chat (bot auto-joins, you become owner)
  4. Auto-detect IDsbot_app_id / admin_open_id pulled from lark-cli auth list, zero manual entry
  5. Write config — generate .cc-bot/profiles/active.json + state.json + .gitignore
  6. Register statusline shim — tees stdin JSON to hud-stdin.json (for bot's HUD intent) + cc-hud rendering (if installed, for status bar)
  7. Register Monitor permission (v0.1.3+) — append a wildcard rule to <project>/.claude/settings.local.json, so cc-bot version upgrades never re-prompt for Monitor launch permission

Every step is idempotent — rerun /cc-bot:setup anytime, it skips what's already done.

Then /cc-bot:start (or just say "开bot" / "start bot" in the main session) — bot comes online in ≤ 5s. Group notification shows cc-bot v<X.Y.Z> 已上线.


How It Works

Main session ── Monitor(persistent) ── node poll.js ── every 30s: IMAdapter.listRecentMessages()
                                                    ├─ dedupe via state.last_processed_time + poll.emitted
                                                    └─ stdout: NEW_MSG|msg_id|sender|text|ts
                                                               ↓ Monitor → notification
                                                         main session → intent routing → adapter.sendText

CC's statusLine ── cc-bot shim ── write hud-stdin.json (for bot's HUD intent)
                                └─ tee cc-hud (optional, for status bar rendering)
HTTP polling
30s fixed interval
VPN-proxy safe
no WS disconnect
3-layer defense
PID lockfile
stdout EPIPE self-kill
state future-value heal
Per-project isolation
.cc-bot/ per project
profiles · runtime · bot_temp
zero cross-contamination

Commands

Command What it does
/cc-bot:setup First-run interactive wizard (idempotent, safe to re-run)
/cc-bot:start · 开bot / start bot Start Monitor + send online notification to chat
/cc-bot:stop · 关bot / stop bot Stop Monitor + send offline notification
/cc-bot:new-profile <name> Create new profile from template
/cc-bot:switch <name> Switch active profile (auto-stops running bot first)
/cc-bot:doctor Read-only health check — version drift, profile validity, runtime state, zombie permissions, shim registration

Main session also accepts natural-language triggers (开bot / 关bot / switch to xxx).


Profile Intents — Per-project Customization

Each project has its own .cc-bot/profiles/active.json. The intents dict maps natural-language intents to action descriptions Claude executes when the group triggers them. Typical examples (you pick the keys and describe the actions freely):

{
  "intents": {
    "deploy": "Run `bash scripts/deploy.sh production`, report stdout tail",
    "run_tests": "Run `npm test`, report pass/fail counts + first failure trace",
    "query_logs": "Use mcp__cloudbase__logs to fetch last 20 error logs, summarize",
    "build_preview": "Run `npm run build:preview`, upload artifact to <paths.bot_temp_abs>, reply with link"
  }
}

Works for any project type — Web / mini-program / Node service / Python data pipeline / mobile app. If you can script it, you can intent-route it.


Prerequisites

  • Claude Code — uses Skill / Monitor / TaskStop / AskUserQuestion tools
  • lark-clinpm i -g @larksuite/cli + lark-cli auth login (setup wizard will guide this)
  • ShellWindows: Git Bash required (cmd.exe / PowerShell mangle special characters in argv); macOS / Linux: system bash works out of the box
  • Optional: cc-hud — install for prettier status bar (/plugin install cc-hud@WaterTian-cc-hud); cc-bot shim tees it automatically

快速开始(中文)

在目标项目里运行 /cc-bot:setup,开场一行打印当前版本(cc-bot v<X.Y.Z> setup — <project>,v0.1.4 起),然后交互式向导会:

  1. 检测 lark-cli — 未装自动 npm i -g @larksuite/cli
  2. OAuth 登录引导 — 带你去飞书开放平台建应用(附必需 scope 清单),完成浏览器 Device Flow 登录
  3. 选目标群 — 用 AskUserQuestion 卡片列 bot 所在群,或一键新建(bot 自动入群、你成为群主)
  4. 自动探测 IDbot_app_id / admin_open_idlark-cli auth list 直接取,不用手填
  5. 写配置 — 生成 .cc-bot/profiles/active.json + state.json + .gitignore
  6. 注册 statusline shim — 落盘 stdin JSON(给 bot 用)+ 可选透传 cc-hud(渲染状态栏)
  7. 注册 Monitor 通配权限(v0.1.3+)— 向 <project>/.claude/settings.local.json append 通配规则,cc-bot 版本升级不再弹 Monitor 启动权限询问

然后 /cc-bot:start(或主会话直接说「开bot」)。群里上线通知首行是 cc-bot v<X.Y.Z> 已上线


Per-project Layout

Component Location Distribution
SKILL · adapter · poll.js · commands · templates ${CLAUDE_PLUGIN_ROOT}/ plugin version
Chat IDs · project root · members · intents <project>/.cc-bot/profiles/active.json per-project (gitignored)
state · cache · pid · dedupe · bot_temp <project>/.cc-bot/runtime/ + .cc-bot/bot_temp/ per-project (gitignored)

One plugin, many projects in parallel — zero cross-contamination.


Extend to a New IM

cc-bot ships with Lark. Adding WeCom / DingTalk / Slack / Discord / etc:

  1. Add adapters/<im>.js extending IMAdapter (see adapters/base.js) — implement listRecentMessages / sendText / sendImage / downloadResource / getUser
  2. Add factory branch in runtime/poll.js: if (im.type === '<im>') { ... }
  3. Set im.type in profile.active.json to the new IM name
  4. Add skills/<im>-bot/SKILL.md or extend existing one

Privacy Protection

Repo ships a pre-commit scanner that blocks real IM IDs (cli_* / ou_* / oc_* / om_*) / real-name blocklist / api-secret patterns from entering commits. One-time setup — see CLAUDE.md §Git 提交隐私防护.


Star History

Star History Chart

MIT License © Water

About

Develop project from group chat — by Claude Code. 接 AI 进群里开发项目。

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors