WeChat MP Publisher
Prepare a reviewable WeChat Official Account draft. Keep credential handling, local rendering, remote draft creation, and final publishing as separate stages.
Non-negotiable safety rules
- Never place an AppSecret, access token, AppID, account email, or secret-manager record in source files, Markdown, logs, screenshots, command arguments, or chat output.
- Read credentials at runtime from environment variables or the user's existing secret manager. Never invent a credential location.
- The npm CLI installs this skill and validates or previews HTML. It does not read credentials or call WeChat APIs. A preview may load already-uploaded HTTPS images from
mmbiz.qpic.cn. - Always run local validation and open the sandboxed local preview before any remote write.
- Ask for explicit approval after the preview is ready and before calling
draft/add, even when the initial request says to publish immediately. - Create a draft only. Never call a free-publish endpoint or bypass the user's final review in the WeChat admin console.
- Do not assume the account has a given API permission. Treat
48001as a permission boundary, not as a reason to improvise another account or endpoint.
Workflow
Identify the source article, target language, title, author, digest, canonical URL, article images, and cover image.
Read references/setup.md before touching credentials or the API.
Adapt the article for a mobile feed. Preserve meaning, shorten dense paragraphs, remove site navigation, and keep headings and calls to action restrained.
Build one root
<section>with inline styles. Read references/html-compatibility.md before finalizing HTML.Run:
npx wechat-mp-publisher@2 validate article.html npx wechat-mp-publisher@2 preview article.htmlFix every validation error. Warnings require a conscious review.
Show the user the local preview URL and a compact summary of title, digest, image count, and any remaining warnings. Local-image warnings are acceptable only at this preview stage. Ask whether to upload materials and create the remote draft.
After approval, read references/api-workflow.md, upload images, replace every local source, run
npx wechat-mp-publisher@2 validate article.html --final, create the draft only when it passes, and check every JSON response forerrcodebefore continuing.Return the draft media ID and direct the user to review and publish manually in the WeChat admin console.
Output contract
Before remote approval, return:
- final article HTML path;
- validation result;
- local preview URL;
- title, digest, canonical URL, and image count;
- one explicit approval question for draft creation.
After draft creation, return:
- draft media ID;
- account/API error details if creation failed;
- reminder that final publishing remains manual.
References
- references/setup.md: account permissions, credentials, IP whitelist, and official docs.
- references/html-compatibility.md: conservative HTML and image rules.
- references/local-preview.md: CLI install, validation, preview, and troubleshooting.
- references/api-workflow.md: stable token, image upload, cover media, draft creation, and error handling.