Posts content to WeChat Official Account (微信公众号) via API or Chrome CDP. Supports article posting (文章) with HTML, markdown, or plain text input, and image-text posting (贴图, formerly 图文) with multiple images. Markdown article workflows default to converting ordinary external links into bottom citations for WeChat-friendly output. Use when user mentions "发布公众号", "post to wechat", "微信公众号", or "贴图/图文/文章".
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
Instruções da origem · Visualização somente leitura
name
baoyu-post-to-wechat
description
Posts content to WeChat Official Account (微信公众号) via API or Chrome CDP. Supports article posting (文章) with HTML, markdown, or plain text input, and image-text posting (贴图, formerly 图文) with multiple images. Markdown article workflows default to converting ordinary external links into bottom citations for WeChat-friendly output. Use when user mentions "发布公众号", "post to wechat", "微信公众号", or "贴图/图文/文章".
When this skill prompts the user, follow this tool-selection rule (priority order):
Prefer built-in user-input tools exposed by the current agent runtime — e.g., AskUserQuestion, request_user_input, clarify, ask_user, or any equivalent.
Fallback: if no such tool exists, emit a numbered plain-text message and ask the user to reply with the chosen number/answer for each question.
Batching: if the tool supports multiple questions per call, combine all applicable questions into a single call; if only single-question, ask them one at a time in priority order.
Concrete AskUserQuestion references below are examples — substitute the local equivalent in other runtimes.
Language
Respond in the user's language. If they write in Chinese, reply in Chinese; if English, English. Keep technical tokens (paths, flags, field names) in English.
EXTEND.md supports an accounts: block for managing multiple Official Accounts. With 2+ entries, the workflow inserts a Step 0.5 to prompt for account selection (or auto-selects based on default: true or --account <alias>).
Full details — compatibility rules, per-account keys, credential resolution, per-account Chrome profiles, CLI usage — in references/multi-account.md.
Pre-flight Check (Optional)
Before first use, suggest the environment check (user can skip):
Check and load EXTEND.md (see "Preferences" above). If not found, complete first-time setup before any other questions. Resolve and cache for later steps: default_theme, default_color, default_author, need_open_comment, only_fans_can_comment.
Step 1: Determine Input Type
Input
Detection
Next
HTML file
Path ends .html, file exists
Skip to Step 3
Markdown file
Path ends .md, file exists
Step 2
Plain text
Not a file path, or file doesn't exist
Save to markdown, then Step 2
Plain-text handling:
Generate slug (first 2-4 meaningful words, kebab-case; translate Chinese to English for the slug).
Save to post-to-wechat/YYYY-MM-DD/<slug>.md (create directory if needed).
Continue as a markdown file.
Step 2: Select Publishing Method and Configure
Ask method unless specified in EXTEND.md or CLI:
Method
Speed
Requires
api (Recommended)
Fast
API credentials (local IP allowlisted)
browser
Slow
Chrome + logged-in session
remote-api
Fast
API credentials + an SSH-reachable server whose IP is on the WeChat allowlist
API selected + missing credentials → run guided setup per references/api-setup.md (writes to .baoyu-skills/.env).
remote-api method: WeChat's "公众号设置 → IP 白名单" often limits API access to one or two fixed IPs. If your local machine's IP is not on that list but a cloud server's is, use remote-api: all markdown rendering, image processing, draft assembly, and HTML rewriting still happen locally, and only the outbound HTTPS calls to api.weixin.qq.com (token, uploadimg, add_material, draft/add) are tunneled through an SSH SOCKS5 dynamic port forward (ssh -N -D) so that WeChat sees the remote server as the source IP. No files are written to the remote host; AppSecret never leaves the local process. Requires only sshd and outbound network on the remote host — no Python, no agent process. See "Remote API Method" below.
Step 3: Resolve Theme/Color and Validate Metadata
Theme: CLI --theme → EXTEND.md default_theme → default (first match wins; do NOT ask if resolved).
Auto-generation: title = first H1/H2 or first sentence; summary = first paragraph, truncated to 120 chars.
Cover image (required for API article_type=news): CLI --cover → frontmatter (coverImage / featureImage / cover / image) → imgs/cover.png → first inline image → stop and request one if still missing.
Step 4: Publish
Important — never pre-convert markdown to HTML. Publishing scripts handle the conversion internally and the two methods render images differently: API renders <img> tags for upload, browser uses placeholders for paste-and-replace. Passing a pre-converted HTML breaks one or the other.
Markdown citation default: for markdown input, ordinary external links are converted to bottom citations by default. Use --no-cite only if the user explicitly wants to keep inline links. Existing HTML input is left as-is.
Any --remote-* flag implies --remote. CLI values override account-level then global remote_publish_* keys from EXTEND.md. Setting default_publish_method: remote-api also enables remote mode without --remote.
draft/add payload rules:
Endpoint: POST https://api.weixin.qq.com/cgi-bin/draft/add?access_token=ACCESS_TOKEN
article_type: news (default) or newspic
For news, include thumb_media_id (cover required)
Always include need_open_comment (default 1) and only_fans_can_comment (default 0) in the request body, even if the CLI doesn't expose them
For news, optionally include content_source_url (original article URL, shown as "阅读原文" link, max 1KB). Provide via --source-url CLI flag or frontmatter sourceUrl/contentSourceUrl/content_source_url