| name | wechat-studio |
| description | 微信公众号内容创作全流程工具,支持 Markdown 主题排版、Dan Koe 风格写作、AI 去痕、图片上传、图文草稿和小绿书发布。Use this skill when the user asks about WeChat Official Account publishing, converting Markdown to WeChat HTML, uploading images to WeChat, creating drafts, writing in Dan Koe style, or removing AI writing traces (humanize). Also trigger when the user mentions 微信排版, 公众号发文, 公众号格式, 文章排版成微信格式, 微信图文, 小绿书, or any WeChat content workflow — even if they don't explicitly say "wechat-studio". |
WeChat Studio
微信公众号内容创作全流程工具:Markdown 排版、写作助手、AI 去痕、图片上传、草稿发布。
路径解析(重要)
本 skill 的脚本位于 SKILL.md 所在目录下。执行任何脚本之前,必须先确定本文件的实际路径,并以此推导脚本目录。
规则: 以下文档中所有 $SKILL_DIR 占位符应替换为本 SKILL.md 文件所在的目录路径。
例如:如果本文件位于 /Users/xxx/Desktop/AI/skills/wechat-studio/SKILL.md,则 $SKILL_DIR = /Users/xxx/Desktop/AI/skills/wechat-studio。
SKILL_DIR="<本 SKILL.md 文件所在目录的绝对路径>"
功能一:Markdown → 微信 HTML
convert.mjs 直接将 Markdown 渲染为带主题样式的微信公众号 HTML,无需 AI 参与。
node "$SKILL_DIR/scripts/convert.mjs" -i article.md -t autumn-warm -o article.html
node "$SKILL_DIR/scripts/convert.mjs" -i article.md -t spring-fresh
图片会自动替换为 <!-- IMG:0 -->、<!-- IMG:1 --> 占位符,按 Markdown 中出现顺序编号。
可用主题:
| 主题 | 说明 |
|---|
autumn-warm | 秋日暖光,橙色调,温暖治愈(默认) |
spring-fresh | 春日清新,绿色调,清爽明快 |
ocean-calm | 海洋静谧,蓝色调,沉稳专业 |
custom | 自定义主题,使用 AI 提示词渲染(type: ai) |
功能二:风格写作(Dan Koe)
触发条件: 用户提到"用 Dan Koe 风格写"、"帮我写一篇文章"、"写一篇关于…的文章"
读取 $SKILL_DIR/references/dan-koe-writing.md 获取完整写作规范,按其中的结构和语气要求生成文章。更详细的模板和金句库见 $SKILL_DIR/writers/dan-koe.yaml。
功能三:图片上传
上传本地图片
node "$SKILL_DIR/scripts/upload-image.mjs" /path/to/image.jpg
node "$SKILL_DIR/scripts/upload-image.mjs" --json images.json
node "$SKILL_DIR/scripts/upload-image.mjs" --json images.json --output upload-result.json
node "$SKILL_DIR/scripts/upload-image.mjs" --json images.json --no-cache
batch JSON 格式(images.json):
["images/photo1.jpg", "images/photo2.png", "images/photo3.webp"]
选项:
--json <file>:从 JSON 文件读取路径列表进行批量上传
--output <file>:将批量上传结果写入 JSON 文件(可供后续 replace-images.mjs 使用)
--no-cache:跳过缓存,强制重新上传
单张输出:
{ "success": true, "media_id": "xxx", "wechat_url": "https://mmbiz..." }
批量输出(JSON 数组):
[
{ "file": "img1.jpg", "success": true, "media_id": "xxx", "wechat_url": "https://mmbiz..." },
{ "file": "img2.png", "success": true, "media_id": "yyy", "wechat_url": "https://mmbiz..." }
]
下载在线图片并上传
node "$SKILL_DIR/scripts/download-upload.mjs" "https://example.com/image.png"
node "$SKILL_DIR/scripts/download-upload.mjs" --json urls.json
node "$SKILL_DIR/scripts/download-upload.mjs" --json urls.json --output upload-result.json
node "$SKILL_DIR/scripts/download-upload.mjs" --json urls.json --no-cache
图片会自动压缩(超过 5MB 时)再上传。相同内容的图片会命中本地缓存,跳过重复上传。
缓存文件位于 ~/.config/wechat-studio/upload-cache.json,以文件 MD5 为 key。
替换 HTML 占位符
上传完成后,用 replace-images.mjs 将 HTML 中的 <!-- IMG:N --> 自动替换为对应的微信图片 <img> 标签:
node "$SKILL_DIR/scripts/replace-images.mjs" \
--html article.html \
--result upload-result.json \
--output article-final.html
选项:
--html:输入 HTML 文件路径
--result:上传结果 JSON 文件(由 --output 参数生成)
--output:输出 HTML 文件路径(不指定则输出到 stdout)
占位符 <!-- IMG:0 --> 对应结果数组第 0 项,<!-- IMG:1 --> 对应第 1 项,以此类推。
功能四:创建图文草稿
Step 1: 准备草稿 JSON 文件(draft.json)
{
"articles": [{
"title": "文章标题",
"content": "<p>完整 HTML 内容(已替换图片 URL)</p>",
"thumb_media_id": "封面图的素材 ID",
"author": "作者名",
"digest": "文章摘要,最多 120 字",
"need_open_comment": 0,
"only_fans_can_comment": 0
}]
}
Step 2: 创建草稿
node "$SKILL_DIR/scripts/create-draft.mjs" draft.json
输出:
{ "success": true, "media_id": "草稿的 media_id" }
功能五:创建小绿书(图片帖)
node "$SKILL_DIR/scripts/create-image-post.mjs" \
-t "标题" -c "描述文字" --images photo1.jpg,photo2.jpg
node "$SKILL_DIR/scripts/create-image-post.mjs" \
-t "标题" -m article.md
node "$SKILL_DIR/scripts/create-image-post.mjs" \
-t "标题" --images photo1.jpg --dry-run
输出:
{ "success": true, "media_id": "xxx", "image_count": 2, "uploaded_ids": ["id1", "id2"] }
功能六:AI 去痕(Humanizer-zh)
触发条件: 用户提到"去除 AI 痕迹"、"让文章更自然"、"humanize"
读取 $SKILL_DIR/references/humanizer-zh.md 获取完整的 22 种 AI 写作模式和 5 条核心去痕规则,按其中的规范处理文本并输出质量评分。
功能七:Server Mode(远程代理)
当本地机器无法直连微信 API(如没有固定 IP 白名单)时,可以在远程服务器上部署 proxy-server.mjs,本地客户端通过 HTTP 调用远程服务器的 API。
服务端部署
node "$SKILL_DIR/scripts/proxy-server.mjs" --port 8080 --secret your-proxy-secret
PROXY_PORT=8080 PROXY_SECRET=your-proxy-secret node "$SKILL_DIR/scripts/proxy-server.mjs"
服务端暴露以下接口(均为 POST,需 X-Proxy-Secret 请求头认证):
/api/access-token — 获取 Access Token
/api/upload-material — 上传图片素材(multipart/form-data)
/api/create-draft — 创建图文草稿(JSON)
客户端配置
配置 proxy 后,所有上传/草稿脚本自动走远程服务器,无需修改调用方式。
环境变量:
export WECHAT_PROXY_URL=http://your-server:8080
export WECHAT_PROXY_SECRET=your-proxy-secret
配置文件:
proxy:
url: http://your-server:8080
secret: your-proxy-secret
配置
需要微信凭证才能使用上传/草稿功能(convert、写作、去痕无需凭证)。
方式一:环境变量
export WECHAT_APP_ID=your_appid
export WECHAT_SECRET=your_secret
方式二:配置文件(按优先级从高到低)
./wechat-studio.yaml # 项目本地(最高优先级)
~/.wechat-studio.yaml # 用户目录
~/.config/wechat-studio/config.yaml # 全局配置
wechat:
appid: your_appid
secret: your_secret
compress_images: true
max_image_width: 1920
max_image_size: 5242880
http_timeout: 30
proxy:
url: http://your-server:8080
secret: your-proxy-secret
典型工作流
发布一篇 Markdown 文章
方式一:一键发布(推荐)
node "$SKILL_DIR/scripts/upload-image.mjs" --json images.json --output upload-result.json
node "$SKILL_DIR/scripts/publish.mjs" -i article.md -r upload-result.json -t autumn-warm -o article-final.html
node "$SKILL_DIR/scripts/upload-image.mjs" cover.jpg
node "$SKILL_DIR/scripts/create-draft.mjs" draft.json
方式二:分步操作
node "$SKILL_DIR/scripts/convert.mjs" -i article.md -t autumn-warm -o article.html
node "$SKILL_DIR/scripts/upload-image.mjs" --json images.json --output upload-result.json
node "$SKILL_DIR/scripts/replace-images.mjs" \
--html article.html \
--result upload-result.json \
--output article-final.html
node "$SKILL_DIR/scripts/upload-image.mjs" cover.jpg
node "$SKILL_DIR/scripts/create-draft.mjs" draft.json
发布小绿书
node "$SKILL_DIR/scripts/create-image-post.mjs" \
-t "九月摄影精选" -c "光影记录日常" \
--images sep01.jpg,sep02.jpg,sep03.jpg
File Structure
scripts/
convert.mjs # Markdown → 微信 HTML(代码渲染,无需 AI)
upload-image.mjs # 上传本地图片到微信
download-upload.mjs # 下载在线图片并上传
replace-images.mjs # 替换 HTML 中的 <!-- IMG:N --> 占位符
publish.mjs # 一键:Markdown → 替换图片 → 最终 HTML
create-draft.mjs # 创建图文草稿
create-image-post.mjs # 创建小绿书
proxy-server.mjs # 微信 API 远程代理服务器(Server Mode)
lib/
args.mjs # CLI 参数解析工具
config.mjs # 配置加载(env > YAML > 默认值)
wechat.mjs # 微信 API(token、上传、草稿、远程代理)
image.mjs # 图片压缩(sharp)
renderer.mjs # 基于 marked 的微信 HTML 渲染器
replace.mjs # HTML 占位符替换逻辑
theme.mjs # 主题 YAML 加载
themes/ # 主题 YAML 文件
writers/ # 写作风格 YAML 文件
references/ # 参考文档(写作指南、去痕规则)