npx skills add ...
npx skills add iamzifei/wechat-article-publisher-skill --skill wechat-article-publisher
Publish Markdown/HTML articles to WeChat Official Account (微信公众号) drafts via API
npx skills add iamzifei/wechat-article-publisher-skill --skill wechat-article-publisher
Publish Markdown or HTML content to WeChat Official Account drafts via API, with automatic format conversion.
Located in ~/.claude/skills/wechat-article-publisher/scripts/:
WeChat API client for listing accounts and publishing articles:
Parse Markdown and extract structured data (optional, for advanced use):
Strategy: "API-First Publishing"
Unlike browser-based publishing, this skill uses direct API calls for reliable, fast publishing.
Supported File Formats:
.md files → Parsed as Markdown, converted by WeChat API.html files → Sent as HTML, formatting preservedBefore any operation, verify the API key is available:
If not set, remind user to:
.env.example to .envWECHAT_API_KEY valueGet the list of authorized WeChat accounts:
Output example:
Important:
wechatAppid for publishingFor Markdown files:
For HTML files (preserves formatting):
For 小绿书 (image-text mode):
Success response:
After successful publishing:
All API requests require the X-API-Key header:
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| wechatAppid | string | Yes | WeChat AppID |
| title | string | Yes | Article title (max 64 chars) |
| content | string | Yes | Article content (Markdown/HTML) |
| summary | string | No | Article summary (max 120 chars) |
| coverImage | string | No | Cover image URL |
| author | string | No | Author name |
| contentFormat | string | No | 'markdown' (default) or 'html' |
| articleType | string | No | 'news' (default) or 'newspic' |
| Code | Description |
|---|---|
| API_KEY_MISSING | API key not provided |
| API_KEY_INVALID | API key invalid |
| ACCOUNT_NOT_FOUND | Account not found or unauthorized |
| ACCOUNT_TOKEN_EXPIRED | Account authorization expired |
| INVALID_PARAMETER | Invalid parameter |
| WECHAT_API_ERROR | WeChat API call failed |
| INTERNAL_ERROR | Server error |
...)<title> or <h1> → Article title<img> tags → Images auto-uploaded to WeChat<p> → Auto-extracted as summaryHTML Title Extraction Priority:
<title> tag content<h1> tag contentHTML Content Extraction:
<body> exists, uses body content<html>, <head>, <!DOCTYPE> and uses remaining contentUser: "把 ~/articles/ai-tools.md 发布到微信公众号"
User: "把这个HTML文章发布到公众号:~/articles/newsletter.html"
Solution: Ask user to set up .env file with their API key.
Solution: Ask user to authorize their account on wx.limyai.com.
Solution: Ask user to re-authorize on wx.limyai.com.
Solution: May be temporary issue, retry or check WeChat service status.
A: Register and authorize your WeChat account at wx.limyai.com to get your API key.
A: Yes, use list-accounts to see all authorized accounts, then specify the target --appid.
A: Ensure images are accessible URLs. Local images are auto-uploaded but may fail if path is incorrect.
A: WeChat limits titles to 64 characters. The script will use the first 64 chars of H1.
A: news is standard article format; newspic (小绿书) is image-focused with limited text.
触发:/公众号发布 新手、「这个怎么用」「第一次用」「能干嘛」「带我走一遍」,
以及用户输入了技能名却没有给任何任务的时候。
这个模式的铁律:不假设、不索取。用户可能什么都没准备, 不要一上来就问他要文件、要 API key、要具体需求。按下面四步走:
一、先说清楚这是什么(三句话以内)
一句话:把 Markdown 文章直接发进公众号草稿箱,图片自动上传。 走的是微信官方接口,不是模拟点击,所以稳定。 发的是草稿,最终点「发表」的还是你。
二、给编号选项,让他按回车就能继续
不要问开放式问题(「你想做什么?」对新手是负担)。给 3 个选项加一个默认:
三、直接演示一遍,边做边解释
选完立刻做给他看,用示例数据,不需要他提供任何东西。 每做完一步,加一行「💡 刚才发生了什么」,一句话说明这步的意义。
四、毕业
演示完只问一个是非题:「要不要用你自己的文章真跑一遍?」
答是就进正常流程;答否就告诉他随时回来输 /公众号发布 新手。
关于前置条件:这个技能需要 公众号的 API 凭据(写在 .env 里的 WECHAT_API_KEY)。 新手模式下不要提前索取——先用示例数据演示完,到第四步真跑的时候再引导他配置, 并说清楚在哪配、怎么拿。新手最容易在这一步流失。
python parse_markdown.py <markdown_file> [--output json|html]# Check if .env file exists and contains WECHAT_API_KEY
cat .env | grep WECHAT_API_KEYpython ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py list-accounts{
"success": true,
"data": {
"accounts": [
{
"name": "我的公众号",
"wechatAppid": "wx1234567890",
"username": "gh_abc123",
"type": "subscription",
"verified": true,
"status": "active"
}
],
"total": 1
}
}python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py publish \
--appid <wechatAppid> \
--markdown /path/to/article.mdpython ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py publish \
--appid <wechatAppid> \
--html /path/to/article.htmlpython ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py publish \
--appid <wechatAppid> \
--markdown /path/to/article.md \
--type newspic{
"success": true,
"data": {
"publicationId": "uuid-here",
"materialId": "uuid-here",
"mediaId": "wechat-media-id",
"status": "published",
"message": "文章已成功发布到公众号草稿箱"
}
}X-API-Key: WECHAT_API_KEYPOST https://wx.limyai.com/api/openapi/wechat-accountsPOST https://wx.limyai.com/api/openapi/wechat-publish# Step 1: Verify API key
cat .env | grep WECHAT_API_KEY
# Step 2: List accounts
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py list-accounts
# Step 3: Publish (assuming single account with appid wx1234567890)
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py publish \
--appid wx1234567890 \
--markdown ~/articles/ai-tools.md
# Step 4: Report
# "文章已成功发布到公众号草稿箱!请登录微信公众平台预览并发布。"# Step 1: Verify API key
cat .env | grep WECHAT_API_KEY
# Step 2: List accounts
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py list-accounts
# Step 3: Publish HTML (auto-detects format)
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py publish \
--appid wx1234567890 \
--html ~/articles/newsletter.html
# Step 4: Report
# "文章已成功发布到公众号草稿箱!HTML格式已保留。请登录微信公众平台预览并发布。"Error: WECHAT_API_KEY environment variable not set.Error: ACCOUNT_NOT_FOUND - 公众号不存在或未授权Error: ACCOUNT_TOKEN_EXPIRED - 公众号授权已过期Error: WECHAT_API_ERROR - 微信接口调用失败Minimal workflow (1 command):
- list-accounts → get appid → publish → done
Full workflow (with verification):
1. Check .env → list accounts → confirm with user
2. Publish with options → report result想先看哪个?(直接回车 = 1)
1. 先看看发出去长什么样(示例)
2. 把我的 Markdown 发成草稿
3. 先讲讲要准备什么