Skip to content

majiabin2020/Claude-Code-WeChat-Gateway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claude Code WeChat Gateway

Bridge WeChat ClawBot messages to a local claude CLI session via the official WeChat ilink API — no Claude development channels required.

把微信 ClawBot 消息桥接到本地 claude 命令行,无需依赖 Claude development channels。


Architecture

WeChat User
    │
    ▼
WeChat ClawBot (ilink API)
    │  long-poll (getupdates)
    ▼
wechat-channel.ts  ◄──── this project
    │  spawn
    ▼
claude CLI (-p, --session-id)
    │
    ▼
Current working directory / tools
    │
    ▼
Reply text ──► WeChat user

Each WeChat sender gets an isolated Claude session. Sessions, chat history, and long-term summaries are persisted under ~/.claude/channels/wechat/.


Prerequisites

  • Bun >= 1.0
  • claude CLI installed and working locally (claude --version)
  • A WeChat account eligible for ClawBot

Installation

git clone https://github.com/majiabin2020/Claude-Code-WeChat-Gateway.git
cd Claude-Code-WeChat-Gateway
bun install

Login

Run the setup tool to authenticate via QR code:

bun setup.ts

Scan the QR code with WeChat. Credentials are saved to:

~/.claude/channels/wechat/account.json

Re-run bun setup.ts if the bot token expires.


Start

bun run start

The gateway will:

  1. Long-poll the WeChat ilink API for incoming messages
  2. Maintain a separate Claude session per WeChat sender
  3. Call the local claude -p CLI directly
  4. Send Claude's reply back to WeChat

Usage

Send any message to your WeChat ClawBot. The gateway forwards it to Claude and replies in the chat.

Built-in commands:

Command Effect
/reset Clear context, session, and history for your user
/clear Same as /reset
清空上下文 Same as /reset (Chinese alias)
重置上下文 Same as /reset (Chinese alias)

Data Files

Path Content
~/.claude/channels/wechat/account.json WeChat bot credentials
~/.claude/channels/wechat/cli_sessions.json Per-sender Claude session IDs
~/.claude/channels/wechat/chat_history.json Recent message history
~/.claude/channels/wechat/chat_summary.json Long-term conversation summaries

Troubleshooting

Symptom Check
No reply at all Is claude runnable in the terminal?
No WeChat polling started. in logs Check credentials / re-run bun setup.ts
Claude processing failed Local Claude CLI call failed — check claude config
WeChat reply failed ilink API error — check network / token expiry
Session expired error Re-run bun setup.ts to refresh the bot token

Project Structure

├── wechat-channel.ts   # Main gateway: WeChat polling + Claude CLI bridge
├── setup.ts            # WeChat QR login tool
├── package.json
├── tsconfig.json
└── bun.lock

License

MIT


Author

majiabin2020

About

Bridge WeChat ClawBot messages to local Claude CLI via the official ilink API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors