wewrite-wechat-ai-publishing

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

WeWrite — WeChat AI Publishing Skill

WeWrite — 微信公众号AI创作Skill

Skill by ara.so — Daily 2026 Skills collection.
WeWrite is a full-pipeline AI skill for producing WeChat Official Account (公众号) articles end-to-end: hotspot fetching → topic selection → writing → SEO → AI image generation → formatting → draft box publishing. It runs as a Claude Code skill (via
SKILL.md
) but every component also works standalone.

该Skill由ara.so开发——属于Daily 2026 Skills系列。
WeWrite是一款面向微信公众号文章的全流程AI Skill,提供端到端的创作支持:热点抓取→选题→写作→SEO优化→AI图片生成→格式排版→草稿箱发布。它作为Claude Code Skill运行(基于
SKILL.md
),同时每个组件也可独立使用。

Installation

安装步骤

As a Claude Code Skill

作为Claude Code Skill安装

bash
undefined
bash
undefined

Clone the repo

Clone the repo

git clone https://github.com/oaker-io/wewrite.git ~/.claude/skills/wewrite
git clone https://github.com/oaker-io/wewrite.git ~/.claude/skills/wewrite

Or copy into an existing project

Or copy into an existing project

cp -r wewrite ~/.claude/skills/wewrite
undefined
cp -r wewrite ~/.claude/skills/wewrite
undefined

Python Dependencies

Python依赖安装

bash
cd wewrite
pip install -r requirements.txt
bash
cd wewrite
pip install -r requirements.txt

Configuration

配置设置

bash
cp config.example.yaml config.yaml
Edit
config.yaml
:
yaml
wechat:
  appid: "${WECHAT_APPID}"         # WeChat Official Account App ID
  secret: "${WECHAT_SECRET}"       # WeChat Official Account Secret

image_gen:
  provider: "doubao"               # "doubao" or "openai"
  doubao_api_key: "${DOUBAO_API_KEY}"
  openai_api_key: "${OPENAI_API_KEY}"

output_dir: "./output"
Set environment variables instead of hardcoding secrets:
bash
export WECHAT_APPID="wx1234567890abcdef"
export WECHAT_SECRET="your_secret_here"
export DOUBAO_API_KEY="your_doubao_key"
export OPENAI_API_KEY="sk-..."

bash
cp config.example.yaml config.yaml
编辑
config.yaml
yaml
wechat:
  appid: "${WECHAT_APPID}"         # 微信公众号App ID
  secret: "${WECHAT_SECRET}"       # 微信公众号密钥

image_gen:
  provider: "doubao"               # 可选"doubao"或"openai"
  doubao_api_key: "${DOUBAO_API_KEY}"
  openai_api_key: "${OPENAI_API_KEY}"

output_dir: "./output"
通过环境变量配置敏感信息,避免硬编码:
bash
export WECHAT_APPID="wx1234567890abcdef"
export WECHAT_SECRET="your_secret_here"
export DOUBAO_API_KEY="your_doubao_key"
export OPENAI_API_KEY="sk-..."

Triggering the Full Pipeline

触发全流程创作

Once installed as a Claude Code skill, simply say:
用 demo 的配置写一篇公众号文章
Claude will execute all steps automatically using
clients/demo/style.yaml
as the client profile.
You can also specify a client:
用 clients/tech-blog 的风格,围绕今日热点写一篇公众号文章,发布到草稿箱

安装为Claude Code Skill后,只需输入:
用 demo 的配置写一篇公众号文章
Claude会自动执行所有步骤,使用
clients/demo/style.yaml
作为客户配置文件。
你也可以指定特定客户配置:
用 clients/tech-blog 的风格,围绕今日热点写一篇公众号文章,发布到草稿箱

Pipeline Steps & Scripts

流程步骤与脚本

1. Fetch Hotspots

1. 热点抓取

Scrapes real-time trending topics from Weibo, Toutiao, and Baidu.
bash
python3 scripts/fetch_hotspots.py --limit 20
python3 scripts/fetch_hotspots.py --limit 10 --json   # JSON output
Output example:
json
[
  {"rank": 1, "title": "DeepSeek R2 发布", "source": "weibo", "heat": 98200},
  {"rank": 2, "title": "A股科技板块大涨", "source": "baidu", "heat": 75300}
]
从微博、头条和百度抓取实时热门话题。
bash
python3 scripts/fetch_hotspots.py --limit 20
python3 scripts/fetch_hotspots.py --limit 10 --json   # 输出JSON格式
输出示例:
json
[
  {"rank": 1, "title": "DeepSeek R2 发布", "source": "weibo", "heat": 98200},
  {"rank": 2, "title": "A股科技板块大涨", "source": "baidu", "heat": 75300}
]

2. SEO Keyword Analysis

2. SEO关键词分析

Queries Baidu and 360 search suggestions to score keywords.
bash
python3 scripts/seo_keywords.py "AI大模型" "科技股"
python3 scripts/seo_keywords.py --json "ChatGPT" "人工智能"
Python usage:
python
from scripts.seo_keywords import analyze_keywords

results = analyze_keywords(["AI大模型", "大语言模型", "GPT-5"])
for kw in results:
    print(f"{kw['keyword']}: score={kw['score']}, volume={kw['estimated_volume']}")
查询百度和360搜索建议,对关键词进行评分。
bash
python3 scripts/seo_keywords.py "AI大模型" "科技股"
python3 scripts/seo_keywords.py --json "ChatGPT" "人工智能"
Python调用示例:
python
from scripts.seo_keywords import analyze_keywords

results = analyze_keywords(["AI大模型", "大语言模型", "GPT-5"])
for kw in results:
    print(f"{kw['keyword']}: score={kw['score']}, volume={kw['estimated_volume']}")

3. Topic Selection

3. 选题生成

Claude reads
references/topic-selection.md
and generates 10 candidate topics scored on:
  • 热度 (trending heat)
  • 契合度 (client fit)
  • 差异化 (differentiation)
Claude读取
references/topic-selection.md
,生成10个候选选题,并基于以下维度评分:
  • 热度 (trending heat)
  • 契合度 (client fit)
  • 差异化 (differentiation)

4. Framework & Writing

4. 框架与写作

Claude reads
references/frameworks.md
(5 frameworks) and
references/writing-guide.md
(de-AI style rules), then writes the article adapted to the client's tone.
Claude读取
references/frameworks.md
(5种写作框架)和
references/writing-guide.md
(去AI化写作规则),然后根据客户语气调整文章内容。

5. AI Image Generation

5. AI图片生成

bash
undefined
bash
undefined

Cover image (recommended 900×383)

封面图(推荐尺寸900×383)

python3 toolkit/image_gen.py
--prompt "科技感封面,蓝色光线,未来感"
--output output/cover.png
--size cover
python3 toolkit/image_gen.py
--prompt "科技感封面,蓝色光线,未来感"
--output output/cover.png
--size cover

Inline content image

内文配图

python3 toolkit/image_gen.py
--prompt "程序员在办公室工作,现代风格插画"
--output output/img1.png
--provider openai

Python usage:

```python
from toolkit.image_gen import generate_image

path = generate_image(
    prompt="AI机器人与人类握手,科技感插画",
    output_path="output/cover.png",
    size="cover",          # "cover" (900x383) or "content" (800x600)
    provider="doubao"      # "doubao" or "openai"
)
print(f"Generated: {path}")
python3 toolkit/image_gen.py
--prompt "程序员在办公室工作,现代风格插画"
--output output/img1.png
--provider openai

Python调用示例:

```python
from toolkit.image_gen import generate_image

path = generate_image(
    prompt="AI机器人与人类握手,科技感插画",
    output_path="output/cover.png",
    size="cover",          # 可选"cover"(900x383)或"content"(800x600)
    provider="doubao"      # 可选"doubao"或"openai"
)
print(f"Generated: {path}")

6. Formatting — Markdown → WeChat HTML

6. 格式转换——Markdown转微信HTML

WeChat requires inline styles. The converter handles this automatically.
bash
undefined
微信公众号要求内联样式,转换器会自动处理这一点。
bash
undefined

Preview in browser

在浏览器中预览

python3 toolkit/cli.py preview article.md --theme professional-clean
python3 toolkit/cli.py preview article.md --theme professional-clean

Available themes

查看可用主题

python3 toolkit/cli.py themes

Python usage:

```python
from toolkit.converter import MarkdownConverter
from toolkit.theme import load_theme

theme = load_theme("tech-modern")
converter = MarkdownConverter(theme=theme)

with open("article.md") as f:
    markdown_content = f.read()

html = converter.convert(markdown_content)
python3 toolkit/cli.py themes

Python调用示例:

```python
from toolkit.converter import MarkdownConverter
from toolkit.theme import load_theme

theme = load_theme("tech-modern")
converter = MarkdownConverter(theme=theme)

with open("article.md") as f:
    markdown_content = f.read()

html = converter.convert(markdown_content)

html is WeChat-ready with all inline styles

生成的html是符合微信要求的内联样式格式

undefined
undefined

7. Publish to WeChat Draft Box

7. 发布到微信草稿箱

bash
python3 toolkit/cli.py publish article.md \
  --cover output/cover.png \
  --title "2026年AI大模型最新进展" \
  --author "科技观察"
Python usage:
python
from toolkit.publisher import WeChatPublisher
from toolkit.wechat_api import WeChatAPI

api = WeChatAPI(appid=os.environ["WECHAT_APPID"], secret=os.environ["WECHAT_SECRET"])
publisher = WeChatPublisher(api=api)
bash
python3 toolkit/cli.py publish article.md \
  --cover output/cover.png \
  --title "2026年AI大模型最新进展" \
  --author "科技观察"
Python调用示例:
python
from toolkit.publisher import WeChatPublisher
from toolkit.wechat_api import WeChatAPI

api = WeChatAPI(appid=os.environ["WECHAT_APPID"], secret=os.environ["WECHAT_SECRET"])
publisher = WeChatPublisher(api=api)

Upload cover image first

先上传封面图

media_id = api.upload_image("output/cover.png")
media_id = api.upload_image("output/cover.png")

Push to draft box

推送至草稿箱

draft_id = publisher.create_draft( title="2026年AI大模型最新进展", content=html_content, # inline-styled HTML from converter cover_media_id=media_id, author="科技观察", digest="本文盘点2026年大模型最新进展..." # summary/excerpt ) print(f"Draft created: {draft_id}")
undefined
draft_id = publisher.create_draft( title="2026年AI大模型最新进展", content=html_content, # 来自转换器的内联样式HTML cover_media_id=media_id, author="科技观察", digest="本文盘点2026年大模型最新进展..." # 文章摘要 ) print(f"Draft created: {draft_id}")
undefined

8. Fetch Article Stats (回填数据)

8. 获取文章数据(回填)

bash
python3 scripts/fetch_stats.py --article-id "your_article_id"
bash
python3 scripts/fetch_stats.py --article-id "your_article_id"

9. Learn from Manual Edits

9. 从人工编辑中学习

bash
python3 scripts/learn_edits.py \
  --original output/draft.md \
  --edited output/final.md \
  --client demo
Extracts style rules from diffs and appends them to the client's playbook.

bash
python3 scripts/learn_edits.py \
  --original output/draft.md \
  --edited output/final.md \
  --client demo
从差异中提取风格规则,并追加到客户的规则手册中。

Client Configuration

客户配置

Each client lives in
clients/{name}/style.yaml
:
yaml
undefined
每个客户的配置存放在
clients/{name}/style.yaml
yaml
undefined

clients/my-tech-blog/style.yaml

clients/my-tech-blog/style.yaml

name: "我的科技博客" industry: "科技/AI" topics:
  • "人工智能"
  • "大模型应用"
  • "编程技术" tone: "专业严谨,偶尔幽默,面向中级开发者" theme: "tech-modern" avoid:
  • "过度营销语言"
  • "绝对化表述" wechat: appid: "${WECHAT_APPID}" secret: "${WECHAT_SECRET}"

Create a new client:

```bash
mkdir clients/my-client
cp clients/demo/style.yaml clients/my-client/style.yaml
name: "我的科技博客" industry: "科技/AI" topics:
  • "人工智能"
  • "大模型应用"
  • "编程技术" tone: "专业严谨,偶尔幽默,面向中级开发者" theme: "tech-modern" avoid:
  • "过度营销语言"
  • "绝对化表述" wechat: appid: "${WECHAT_APPID}" secret: "${WECHAT_SECRET}"

创建新客户配置:

```bash
mkdir clients/my-client
cp clients/demo/style.yaml clients/my-client/style.yaml

Edit style.yaml for your client

编辑style.yaml适配你的客户需求


---

---

Themes

主题样式

ThemeStyle
professional-clean
Clean professional (default)
tech-modern
Tech-forward blue/purple gradient
warm-editorial
Warm editorial tones
minimal
Minimal black/white
bash
python3 toolkit/cli.py themes          # list all themes with previews
python3 toolkit/cli.py preview article.md --theme warm-editorial
Custom theme (YAML):
yaml
undefined
主题风格
professional-clean
简洁专业风格(默认)
tech-modern
科技感蓝紫渐变
warm-editorial
温暖编辑风格
minimal
极简黑白风格
bash
python3 toolkit/cli.py themes          # 列出所有主题及预览
python3 toolkit/cli.py preview article.md --theme warm-editorial
自定义主题(YAML格式):
yaml
undefined

toolkit/themes/my-theme.yaml

toolkit/themes/my-theme.yaml

name: my-theme body: font-family: "'PingFang SC', sans-serif" font-size: "16px" color: "#333" line-height: "1.8" h2: color: "#1a73e8" font-weight: "bold" border-left: "4px solid #1a73e8" padding-left: "10px" blockquote: background: "#f0f4ff" border-left: "3px solid #4285f4" padding: "12px 16px" color: "#555"

---
name: my-theme body: font-family: "'PingFang SC', sans-serif" font-size: "16px" color: "#333" line-height: "1.8" h2: color: "#1a73e8" font-weight: "bold" border-left: "4px solid #1a73e8" padding-left: "10px" blockquote: background: "#f0f4ff" border-left: "3px solid #4285f4" padding: "12px 16px" color: "#555"

---

Full Pipeline — Python Orchestration

全流程Python编排

python
import subprocess
import json
import os
from toolkit.converter import MarkdownConverter
from toolkit.theme import load_theme
from toolkit.publisher import WeChatPublisher
from toolkit.wechat_api import WeChatAPI
from toolkit.image_gen import generate_image
python
import subprocess
import json
import os
from toolkit.converter import MarkdownConverter
from toolkit.theme import load_theme
from toolkit.publisher import WeChatPublisher
from toolkit.wechat_api import WeChatAPI
from toolkit.image_gen import generate_image

1. Fetch hotspots

1. 抓取热点

result = subprocess.run( ["python3", "scripts/fetch_hotspots.py", "--limit", "20", "--json"], capture_output=True, text=True ) hotspots = json.loads(result.stdout)
result = subprocess.run( ["python3", "scripts/fetch_hotspots.py", "--limit", "20", "--json"], capture_output=True, text=True ) hotspots = json.loads(result.stdout)

2. SEO analysis on top topics

2. 对热门话题进行SEO分析

from scripts.seo_keywords import analyze_keywords top_titles = [h["title"] for h in hotspots[:5]] seo_scores = analyze_keywords(top_titles)
from scripts.seo_keywords import analyze_keywords top_titles = [h["title"] for h in hotspots[:5]] seo_scores = analyze_keywords(top_titles)

3. (Claude selects topic, writes article — handled by SKILL.md)

3. (Claude负责选题和写作——由SKILL.md处理)

After Claude produces article.md:

当Claude生成article.md后:

4. Generate cover

4. 生成封面图

cover_path = generate_image( prompt="科技感封面图,蓝色渐变,数字化未来", output_path="output/cover.png", size="cover", provider=os.environ.get("IMAGE_PROVIDER", "doubao") )
cover_path = generate_image( prompt="科技感封面图,蓝色渐变,数字化未来", output_path="output/cover.png", size="cover", provider=os.environ.get("IMAGE_PROVIDER", "doubao") )

5. Convert Markdown → WeChat HTML

5. 转换Markdown为微信HTML

theme = load_theme("tech-modern") converter = MarkdownConverter(theme=theme) with open("output/article.md") as f: html = converter.convert(f.read())
theme = load_theme("tech-modern") converter = MarkdownConverter(theme=theme) with open("output/article.md") as f: html = converter.convert(f.read())

6. Publish to draft box

6. 发布到草稿箱

api = WeChatAPI( appid=os.environ["WECHAT_APPID"], secret=os.environ["WECHAT_SECRET"] ) publisher = WeChatPublisher(api=api) media_id = api.upload_image(cover_path) draft_id = publisher.create_draft( title="选定标题", content=html, cover_media_id=media_id, author="作者名" ) print(f"✅ Published draft: {draft_id}")

---
api = WeChatAPI( appid=os.environ["WECHAT_APPID"], secret=os.environ["WECHAT_SECRET"] ) publisher = WeChatPublisher(api=api) media_id = api.upload_image(cover_path) draft_id = publisher.create_draft( title="选定标题", content=html, cover_media_id=media_id, author="作者名" ) print(f"✅ Published draft: {draft_id}")

---

References Claude Uses During Pipeline

Claude在流程中使用的参考文件

These files are read automatically by Claude when executing the skill:
FilePurpose
references/topic-selection.md
10-topic scoring rules (heat × fit × differentiation)
references/frameworks.md
5 article structure templates
references/writing-guide.md
Style rules, de-AI-ification techniques
references/seo-rules.md
WeChat SEO: title length, keyword density, tags
references/visual-prompts.md
Image generation prompt templates
references/wechat-constraints.md
WeChat HTML/CSS technical limits
references/style-template.md
Client style.yaml schema documentation

执行Skill时,Claude会自动读取以下文件:
文件用途
references/topic-selection.md
10项选题评分规则(热度×契合度×差异化)
references/frameworks.md
5种文章结构模板
references/writing-guide.md
写作风格规则、去AI化技巧
references/seo-rules.md
微信公众号SEO规则:标题长度、关键词密度、标签
references/visual-prompts.md
图片生成提示词模板
references/wechat-constraints.md
微信HTML/CSS技术限制
references/style-template.md
客户style.yaml配置文件说明

Troubleshooting

故障排查

WeChat API 40001 / invalid credential
bash
undefined
微信API 40001 / 无效凭证
bash
undefined

Access token expires every 2 hours — the API wrapper auto-refreshes,

Access Token每2小时过期——API包装器会自动刷新,

but verify your appid/secret are correct:

但请确认你的appid/secret正确:

python3 -c " from toolkit.wechat_api import WeChatAPI import os api = WeChatAPI(os.environ['WECHAT_APPID'], os.environ['WECHAT_SECRET']) print(api.get_access_token()) "

**Image generation fails**
```bash
python3 -c " from toolkit.wechat_api import WeChatAPI import os api = WeChatAPI(os.environ['WECHAT_APPID'], os.environ['WECHAT_SECRET']) print(api.get_access_token()) "

**图片生成失败**
```bash

Test provider connectivity

测试服务商连通性

python3 toolkit/image_gen.py
--prompt "测试图片"
--output /tmp/test.png
--provider doubao
python3 toolkit/image_gen.py
--prompt "测试图片"
--output /tmp/test.png
--provider doubao

If doubao fails, switch to openai in config.yaml

如果doubao失败,在config.yaml中切换为openai


**Markdown conversion missing styles**
```bash

**Markdown转换丢失样式**
```bash

Verify theme loads correctly

验证主题是否正确加载

python3 -c "from toolkit.theme import load_theme; print(load_theme('tech-modern'))"
python3 -c "from toolkit.theme import load_theme; print(load_theme('tech-modern'))"

Preview output before publishing

发布前预览输出

python3 toolkit/cli.py preview article.md --theme tech-modern
python3 toolkit/cli.py preview article.md --theme tech-modern

Opens browser with rendered HTML

会在浏览器中打开渲染后的HTML


**Hotspot fetch returns empty**
```bash

**热点抓取返回空结果**
```bash

Platforms occasionally change their APIs — run with verbose:

平台偶尔会变更API——使用verbose模式运行:

python3 scripts/fetch_hotspots.py --limit 5 --verbose
python3 scripts/fetch_hotspots.py --limit 5 --verbose

Check which sources are failing; the script supports weibo/baidu/toutiao independently

检查哪个源失败;脚本支持单独使用weibo/baidu/toutiao


**Article not appearing in draft box**
- Ensure the WeChat account has **服务号** or **订阅号** API access enabled
- Check that your IP is whitelisted in the WeChat MP platform settings
- Draft box (`草稿箱`) requires `draft.add` API permission

---

**文章未出现在草稿箱**
- 确保微信账号已启用**服务号**或**订阅号**API权限
- 检查你的IP已在微信公众平台设置中加入白名单
- 草稿箱(`草稿箱`)需要`draft.add`API权限

---

Quick Reference

快速参考

bash
undefined
bash
undefined

Full standalone workflow

完整独立工作流

python3 scripts/fetch_hotspots.py --limit 20 --json > hotspots.json python3 scripts/seo_keywords.py --json "关键词1" "关键词2" python3 toolkit/image_gen.py --prompt "封面描述" --output cover.png --size cover python3 toolkit/cli.py preview article.md --theme tech-modern python3 toolkit/cli.py publish article.md --cover cover.png --title "标题"
python3 scripts/fetch_hotspots.py --limit 20 --json > hotspots.json python3 scripts/seo_keywords.py --json "关键词1" "关键词2" python3 toolkit/image_gen.py --prompt "封面描述" --output cover.png --size cover python3 toolkit/cli.py preview article.md --theme tech-modern python3 toolkit/cli.py publish article.md --cover cover.png --title "标题"

Build playbook from historical articles

从历史文章构建规则手册

python3 scripts/build_playbook.py --client demo
python3 scripts/build_playbook.py --client demo

Learn from edits

从编辑记录中学习

python3 scripts/learn_edits.py --original draft.md --edited final.md --client demo
python3 scripts/learn_edits.py --original draft.md --edited final.md --client demo

Fetch article performance data

获取文章性能数据

python3 scripts/fetch_stats.py --article-id "msgid_here"
undefined
python3 scripts/fetch_stats.py --article-id "msgid_here"
undefined