全流程微信公众号自动发文 skill
by @16miku
Automate a full local WeChat Official Account publishing workflow: environment setup, content drafting, image prep, publishing, archiving, and optional sched...
clawhub install wechat-auto-publishing📖 About This Skill
name: wechat-auto-publishing-complete description: Use this skill to fully reproduce and operate a local end-to-end WeChat Official Account publishing workflow: prepare the environment, validate dependencies, configure non-sensitive placeholders for credentials, gather source material, draft articles, prepare cover and body images, assemble a WeChat-ready Markdown package, publish to draft, optionally submit for formal publication, poll status, archive outputs, and attach scheduling or alerting. Use whenever the user wants a complete reproducible公众号自动发文 skill with environment setup, templates, runbooks, and execution scaffolding, while keeping all secrets and personal account details outside the skill package. Key real-world findings: freepublish does not always behave like manual platform publishing for homepage visibility, production mode should often default to draft-only, image files must be validated by real format rather than extension alone, and multi-account deployments should use isolated directories.
WeChat Auto Publishing Complete
Use this skill to reproduce, document, and operate a complete local WeChat Official Account auto-publishing workflow without embedding any secrets, private account details, or personal identifiers in the skill package.
This skill is intentionally broader than a minimal workflow note. It includes the operational context needed to reproduce the workflow on a fresh machine, while still keeping all sensitive values external.
Core outcome
The desired end state is a reusable local workflow that can do the following:
1. prepare the environment on a new machine
2. gather the day’s source material
3. determine the article angle
4. draft the article in a target style
5. prepare cover.png, image1.jpg, and image2.jpg
6. assemble a publishable Markdown package
7. publish to the WeChat draft box
8. optionally complete formal publication
9. archive outputs and execution results
10. optionally attach scheduling and alerting
Required safety rule
Never store real private values in this skill package.
Do not include:
WECHAT_APP_IDWECHAT_APP_SECRETGOOGLE_API_KEYWhen documenting configuration, only include:
Skill structure
Read the bundled references depending on what the user is trying to accomplish:
references/environment-and-config.md — use when preparing a new machine or validating prerequisitesreferences/source-gathering.md — use when collecting the day’s source pool and market anglereferences/writing-style.md — use when drafting and formatting the articlereferences/image-strategy.md — use when preparing cover and body images, including gallery modereferences/publishing.md — use when publishing to draft/final and archiving outputsreferences/scheduling-and-alerting.md — use when attaching cron, wrappers, logs, and alertsreferences/security-boundary.md — use when checking what the skill must and must not containtemplates/article-template.md — use as the default publishable article skeletontemplates/env.example.txt — use as the safe non-secret environment placeholder filetemplates/run.sh — use as a starting point for a local orchestrator scripttemplates/run.production-example.sh — use as a more production-ready orchestrator template with gallery, publish mode, and time-slot supporttemplates/cron.example.txt — use as a starting point for schedulingtemplates/publish-result.example.json — use as a result artifact templatetemplates/gallery-config.example.txt — use as a local gallery config exampletemplates/cover-image-extend.example.md — use as a safe cover-image preference exampletemplates/image-gen-extend.example.md — use as a safe image-gen preference exampletemplates/workspace-tree.txt — use as a recommended directory layoutrunbook.md — use as the operator-facing execution checklistStandard execution flow
Step 1: Prepare environment
Before doing any content work, verify that the environment is reproducible on the target machine.
Confirm:
Read references/environment-and-config.md.
Step 2: Gather source material
Collect raw source material, filter it down, and compress the market angle.
Read references/source-gathering.md.
Step 3: Draft the article
Draft an article in the target style using the publishable Markdown conventions from this skill.
Read references/writing-style.md and start from templates/article-template.md when useful.
Step 4: Prepare images
Prepare:
cover.pngimage1.jpgimage2.jpgChoose image sources explicitly:
Read references/image-strategy.md.
Step 5: Assemble the package
Make sure the article package is self-contained and publishable:
article.mdcover.pngimage1.jpgimage2.jpgUse relative paths and UTF-8 encoding.
Step 6: Publish to draft
Use the local publishing pathway to send the article to WeChat draft.
Do not treat publishing as successful unless the draft step returns a meaningful success result, such as a valid media_id.
If baoyu-post-to-wechat 因依赖问题(如 simple-xml-to-json 兼容性错误)无法运行,使用备用脚本:
node templates/publish.mjs
备用脚本 publish.mjs 支持完整流程:获取 token -> 上传封面 -> 上传内图 -> Markdown 转 HTML -> 创建草稿 -> 正式发布 -> 归档结果。
Read references/publishing.md.
Step 7: Optionally complete formal publication
If the workflow includes final publication, submit, poll, and capture the final URL.
备用脚本 templates/publish.mjs 已内置正式发布功能(freepublish),如果使用备用脚本完成 Step 6,正式发布会自动执行,无需额外操作。
Step 8: Archive results
Save result artifacts, logs, identifiers, and remaining gallery state where relevant.
Step 9: Add scheduling and alerting
If the user wants timed operation, attach a wrapper script and scheduler entry.
Read references/scheduling-and-alerting.md.
Important real-world publishing boundary
freepublish is not always operationally equivalent to manual publishing in the MP backend
In practice, a workflow may successfully:
publish_idarticle_idarticle_urlbut still not behave the same way as manually publishing the draft inside the WeChat Official Account admin console, especially for homepage visibility expectations.
Therefore, the skill must distinguish between:
Recommended production modes
Mode A: draft_only (recommended production default)
auto content generation
→ auto image preparation
→ auto draft submission
→ human publishes in MP backend
Use this mode when homepage visibility and platform-consistent display matter more than full automation.
Mode B: full_publish (testing / exploratory mode)
auto content generation
→ auto draft submission
→ auto freepublish submit
→ poll result
→ archive article_url
Use this mode only when the operator explicitly accepts that API publication may not be equivalent to backend manual publication.
Multi-account deployment principle
When operating multiple public accounts, prefer:
one account = one working directory = one .env = one title history = one cron entry
This avoids credential confusion, title-history pollution, log mixing, and accidental cross-account publishing.
Image validity principle
Do not trust file extension alone.
Before publish, validate that images are:
If a file is named cover.png but is actually HEIF/HEVC, the WeChat API may reject it.
Writing quality principle
Do not directly inject scraped source titles into the body as-is.
Avoid:
...报道: in final body textPrefer:
Workflow principles
Keep the package explicit
Prefer explicit files and paths over hidden assumptions.
Keep secrets external
Configuration structure belongs inside the skill. Real credentials do not.
Keep failure handling visible
If a step fails, preserve enough output and log context for a human operator to understand what happened.
Keep image behavior configurable
Do not hard-code a single image source assumption. The workflow should make it clear whether the body images come from a local gallery, generated assets, or user-supplied files.
Reproduction checklist
A fresh-machine reproduction should be able to answer yes to all of these:
Final rule
This skill is allowed to be operationally complete, but it must remain secret-free. Every reusable process detail can go into the skill; every real credential and personal account detail must stay outside it.