wechat-public-cli

Publish and download WeChat Public Platform content and Baijiahao articles via a local CLI.

3,891 stars

Best use case

wechat-public-cli is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Publish and download WeChat Public Platform content and Baijiahao articles via a local CLI.

Teams using wechat-public-cli should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/wechat-public-cli/SKILL.md --create-dirs "https://raw.githubusercontent.com/openclaw/skills/main/skills/ai-chen2050/wechat-public-cli/skill.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/wechat-public-cli/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How wechat-public-cli Compares

Feature / Agentwechat-public-cliStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Publish and download WeChat Public Platform content and Baijiahao articles via a local CLI.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Wechat Public CLI Skill

## Goal

Publish an Obsidian markdown article to WeChat Public Platform or Baidu Baijiahao using a local CLI.

## Requirements

- Node.js 16+
- Config file or environment variables for credentials
- Markdown file with frontmatter (author, digest, banner or banner_path, thumb_media_id optional)

## Article Template

---

title: "Test"
author: Blake
digest: Short summary
banner: "https://image.png"

---

## Install

```bash
git clone https://github.com/ai-chen2050/obsidian-wechat-public-platform.git
cd obsidian-wechat-public-platform
npm install

Or by clawdhub
claw install wechat-public-cli
```

Or install globally via npm:

```bash
npm install -g wechat-public-cli
```

If this CLI is published to npm, you can run it via npx without cloning:

```bash
npx wechat-public-cli wechat:draft --file /path/to/article.md
```

## Config

Create a JSON file in the repo root named `wechat-public.config.json`:

```json
{
	"wechat": {
		"appid": "YOUR_APP_ID",
		"secret": "YOUR_APP_SECRET",
		"accessToken": ""
	},
	"baidu": {
		"cookie": "YOUR_BJH_COOKIE",
		"token": "YOUR_BJH_TOKEN",
		"appId": "YOUR_BJH_APP_ID"
	},
	"paths": {
		"customCss": "./custom.css",
		"downloadDir": "./wechat-downloads"
	}
}
```

Env override:

- `WECHAT_APPID`, `WECHAT_SECRET`, `WECHAT_ACCESS_TOKEN`
- `BJH_COOKIE`, `BJH_TOKEN`, `BJH_APP_ID`
- `WECHAT_CUSTOM_CSS`, `WECHAT_PUBLIC_CONFIG`
- `WECHAT_DOWNLOAD_DIR`

## Build

```bash
npm run build:cli
```

## Commands

- Create WeChat draft:
    ```bash
    wechat-public-cli wechat:draft --file /path/to/article.md
    # 使用自定义 CSS
    wechat-public-cli wechat:draft --file /path/to/article.md --css /path/to/tech.css
    ```
- Publish WeChat (from file):
    ```bash
    wechat-public-cli wechat:publish --file /path/to/article.md
    # 使用自定义 CSS
    wechat-public-cli wechat:publish --file /path/to/article.md --css /path/to/business.css
    ```
- Publish WeChat (from media_id):
    ```bash
    wechat-public-cli wechat:publish --media-id YOUR_MEDIA_ID
    ```
- Send to all WeChat followers:
    ```bash
    wechat-public-cli wechat:sendall --file /path/to/article.md
    ```
- Publish Baijiahao:
    ```bash
    wechat-public-cli bjh:publish --file /path/to/article.md
    # 使用自定义 CSS
    wechat-public-cli bjh:publish --file /path/to/article.md --css /path/to/custom.css
    ```
- Convert markdown to HTML:
    ```bash
    wechat-public-cli convert --file /path/to/article.md --platform wechat
    # 使用自定义 CSS
    wechat-public-cli convert --file /path/to/article.md --platform wechat --css /path/to/style.css
    ```
- Download recent N WeChat articles:
    ```bash
    wechat-public-cli wechat:download --count 10 --out-dir ./wechat-downloads
    ```
- Get cumulative user statistics:
    ```bash
    # 查询最近7天(默认)
    wechat-public-cli wechat:stats:cumulate
    # 指定日期范围(最多30天)
    wechat-public-cli wechat:stats:cumulate --begin-date 2025-11-01 --end-date 2025-11-07
    ```
- Get published content overview statistics:
    ```bash
    # 查询最近7天(默认)
    wechat-public-cli wechat:stats:bizsummary
    # 指定日期范围(最多30天)
    wechat-public-cli wechat:stats:bizsummary --begin-date 2025-11-01 --end-date 2025-11-07
    ```

### 使用自定义 CSS 样式

所有发布命令都支持通过 `--css` 参数指定自定义样式文件:

```bash
# 使用技术类文章样式
wechat-public-cli wechat:draft --file tech-article.md --css ./styles/tech.css

# 使用营销类文章样式
wechat-public-cli wechat:publish --file marketing.md --css ./styles/marketing.css

# 使用教程类文章样式
wechat-public-cli bjh:publish --file tutorial.md --css ./styles/tutorial.css
```

## 自定义公众号格式

你可以通过定义和修改 CSS 文件,来调整发布到微信公众号的文章样式。支持为不同类型的文章使用不同的样式文件。

### CSS 文件加载优先级

1. **命令行参数** `--css` (最高优先级)
2. **配置文件** `wechat-public.config.json` 中的 `paths.customCss`
3. **默认文件** 当前目录下的 `custom.css`
4. **空样式** 如果以上都不存在,则不应用自定义样式

### 使用场景示例

#### 1. 使用默认样式

在项目根目录创建 `custom.css`,不传任何参数时自动使用:

```bash
wechat-public-cli wechat:publish --file article.md
```

#### 2. 为不同类型文章使用不同样式

创建多个 CSS 文件,通过 `--css` 参数指定:

```bash
# 技术类文章使用 tech.css
wechat-public-cli wechat:publish --file tech-article.md --css ./styles/tech.css

# 商业类文章使用 business.css
wechat-public-cli wechat:publish --file business-article.md --css ./styles/business.css

# 教程类文章使用 tutorial.css
wechat-public-cli wechat:publish --file tutorial.md --css ./styles/tutorial.css
```

#### 3. 在配置文件中指定默认样式

在 `wechat-public.config.json` 的 `paths.customCss` 字段指定默认样式文件路径:

```json
{
	"paths": {
		"customCss": "./styles/default.css"
	}
}
```

这样不传 `--css` 参数时,会使用配置文件中指定的样式。

### CSS 示例

```css
/* tech.css - 技术文章样式 */
.wechat-title {
	font-size: 2em;
	color: #2c3e50;
	font-family: "Monaco", "Consolas", monospace;
}
.wechat-banner {
	border-radius: 8px;
}
code {
	background-color: #f4f4f4;
	padding: 2px 4px;
}

/* business.css - 商业文章样式 */
.wechat-title {
	font-size: 2.2em;
	color: #c7254e;
	font-family: "Arial", "Helvetica", sans-serif;
}
```

AI 也可通过自动生成或修改 CSS 文件,实现对公众号内容格式的智能优化。

## Notes

- WeChat draft requires `thumb_media_id` or `banner`/`banner_path` in frontmatter.
- Baijiahao publish requires `banner` or `banner_path` in frontmatter.
- The CLI uploads inline images to the target platform automatically.
- `wechat:download` saves recent articles in update_time order and writes all `news_item` entries.
- `wechat:stats:cumulate` / `wechat:stats:bizsummary` must be called server-side; the date range can be at most 30 days. Results are printed as JSON to stdout.

Related Skills

name: welight-wechat-layout-publish

3891
from openclaw/skills

description: Welight standalone skill for turning an article into WeChat Official Accounts compatible Markdown/HTML, presenting built-in theme choices, and publishing to WeChat as a draft or formal post when publishing prerequisites are already configured.

Content & Documentation

wechat-publisher

3891
from openclaw/skills

一键发布 Markdown 到微信公众号草稿箱。基于 wenyan-cli,支持多主题、代码高亮、图片自动上传。

Content & Documentation

wechat-mp-reader

3891
from openclaw/skills

Read WeChat official account articles. Use the built-in browser tool to open the page and extract body text. Always append ?scene=1 to the URL.

fitclaw-public-core

3891
from openclaw/skills

Public-safe FitClaw coaching workflow covering onboarding, hydration, nutrition, and training structure. Use when demonstrating a reusable AI fitness coaching method without exposing private user data or live production configuration.

clawphone-wechat-control

3891
from openclaw/skills

处理微信会话列表、进入聊天、发送消息、处理微信内弹窗与聊天页失败排查。适用于用户要求查看微信消息、回复联系人、转发、处理聊天输入框或发送失败时。执行时必须先确认当前在微信的哪个页面,再按聊天场景一步一验。

wechat-content-creator

3891
from openclaw/skills

Create high-quality WeChat public account articles with high eCPM. Use when writing WeChat articles, optimizing titles, selecting topics, or improving content quality. Covers 8 golden opening templates, SCQA structure, long-tail keyword integration, high-value niches like legal, finance, career, and compliance guidelines. Triggers on requests like write WeChat article, 公众号文章, 爆款文案, title optimization, 选题, eCPM optimization, or 长尾关键词.

name: wechat_messaging

3891
from openclaw/skills

description: 通过微信向好友发送消息。流程:查询好友 -> 确认目标 -> 发送内容。

name: wechat_operate

3891
from openclaw/skills

description: 通过微信进行社交管理与消息发送。流程:查询目标(好友/群聊/成员) -> 确认目标 -> 发送内容(文本/图片/文件)。

wechat-comic-factory

3891
from openclaw/skills

Generate WeChat comic articles and publish them to the WeChat Official Account draft box by executing local Python pipeline scripts. Use when the user wants to create a comic series from comic_type, topic, and count, or publish the latest generated task. In this skill, “发布” and “发微信” always mean only pushing to the WeChat Official Account draft box; never reinterpret them as personal chat, group chat, or message-tool sending.

wechat-official-account

3891
from openclaw/skills

Create and publish WeChat Official Account (公众号) articles. Use when: (1) User wants to auto-post to WeChat Official Account, (2) Create draft from title + content, (3) Publish draft to 公众号, (4) Schedule or automate 公众号 article publishing. Supports API (服务号) and browser automation (个人订阅号). Browser mode: interactive QR login, login detection via page HTML analysis.

durable-files-weekly-review-public

3891
from openclaw/skills

Run a weekly token-optimization audit for durable instruction files in any OpenClaw workspace, generate a markdown report, and propose approval-gated cleanup actions. Use when users want to keep AGENTS/USER/TOOLS/MEMORY-style docs lean without silent deletions.

cubistic-public-bots

3891
from openclaw/skills

Explain how external/public bots can participate in Cubistic (cubistic.com) and help maintain the Public Bot API docs (PoW challenge + /act). Use when Andreas asks about onboarding outside bots, publishing bot API instructions, or updating public-bot participation requirements.