wechat-publisher
Skill2 starsChanged 8 months agoApache-2.0View on GitHub
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. Use when user mentions "发布公众号", "post to wechat", "微信公众号", or "贴图/图文/文章".
- Pipes a download into a shell
- Reads credentials
11 other projects use a version of this.
Adopted by
Most recently taken up by
- Kianzzz/Zhouxing-skill-publictheir own version, first seen Nov 8, 2026
- antonailog/skillstheir own version, first seen Nov 1, 2026
- wdhorizon/skillstheir own version, first seen Oct 13, 2026
- YiShu5/claude-skillstheir own version, first seen Sep 20, 2026
- Zhangs-11/zs-skillstheir own version, first seen Aug 12, 2026
- peterpanstechland/wechat-publisher-skilltheir own version, first seen Jul 13, 2026
Other versions11 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 11
- zrt-ai-lab/opencode-skills★ 277same name
- wpsnote/wpsnote-skills★ 184same name
- YiShu5/claude-skills★ 131same name
- kaiye/skills★ 19same name
- Kianzzz/Zhouxing-skill-public★ 4same name
- Zhangs-11/zs-skills★ 2same name
- antonailog/skills★ 1same name
- StanleyChanH/WeChat-Publisher-Skill★ 1same name
- wdhorizon/skills★ 1same name
- peterpanstechland/wechat-publisher-skill★ 0same name
1 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository27 other files it gives its agents.
- ai-hotspot-collectorSkill
- article-multi-publisherSkill
- article-pipeline-skillSkill
- character-ip-risk-checkSkill
- chrome-extension-devSkill
- chrome-extension-e2e-automationSkill
- chrome-extension-publishSkill
- chrome-extension-social-promoSkill
- chrome-webstore-image-generatorSkill
- code-reviewSkill
- fund-querySkill
- github-trending-writerSkill
- lark-workflow-doc-to-slidesSkill
- notionSkill
- playwright-twitter-accessSkill
- post-to-xhsSkill
- rewrite-skillSkill
- small-capital-investingSkill
- technical-article-preflightSkill
- technical-article-reviewSkill
- technical-spoken-rewriteSkill
- tencent-dev-community-publisherSkill
- toutiao-publisherSkill
- url-readerSkill
- wechat-article-formatterSkill
- wechat-article-generatorSkill
- wechat-sticker-publisherSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
58 rules. About 0 are common, 35 are distinctive, and 23 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈35
Distinctive · estimate
This author's own choices. Worth a look.
23
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 29
Before using this skill on a freshly cloned machine, treat setup in three layers:
- Distinctive: line 34
run doctor / environment checks
- Distinctive: line 62
Treat this as the only recommended article path on a fresh clone:
- Very specific: line 74
keep using scripts/wechat-publish.ts as the standard entry
- Distinctive: line 78
If you need direct control:
- Distinctive: line 87
When the source is a technical article, publishing is not the first validation step.
- Very specific: line 89
Run technical-article-review on the Markdown source and apply blocking fixes.
- Very specific: line 90
Run technical-article-preflight for source, cover, images, regenerated HTML, and local preview readiness.
- Very specific: line 91
Run scripts/wechat-publish.ts <article.md> --dry-run and inspect the resolved source, title, author, cover, comments, and theme path.
- Distinctive: line 113
Use Bash to check EXTEND.md existence (priority order):
- Distinctive: line 139
EXTEND.md Supports: Default theme | Default color | Default publishing method (api/browser) | Default author | Default open-comment switch …
- Very specific: line 164
Color presets: only used by the legacy internal markdown renderer.
- Distinctive: line 175
Do not skip this unless the user explicitly tells you to bypass preflight.
- Distinctive: line 230
Check and load EXTEND.md settings (see Preferences section above).
- Distinctive: line 232
CRITICAL: If not found, complete first-time setup BEFORE any other steps or questions.
- Distinctive: line 243
Only if the user explicitly wants interactive setup instead of copying templates should you fall back to the guided first-time setup flow.
- Distinctive: line 257
Run this prep flow first:
- Distinctive: line 267
If the article reads like a good commentary but lacks reproducibility, revise the markdown first.
- Distinctive: line 269
Do not move a first draft directly into HTML or WeChat publish just because the user asked for a WeChat article.
- Distinctive: line 274
add a short “minimum prerequisites / how to run” section when the post discusses code or experiments
- Distinctive: line 277
add one concrete “first run” or “minimum workflow” path when the article is recommendation-heavy
- Distinctive: line 280
Before touching HTML, verify that the markdown source actually reflects the review conclusions.
- Distinctive: line 284
no old HTML was patched as a shortcut while markdown stayed stale
- Distinctive: line 287
Ensure the article bundle has:
- Distinctive: line 289
all inline images present on disk and referenced from the final markdown / HTML
- Distinctive: line 295
keep text within a safe inner area.
- Very specific: line 296
prefer manual line breaks for long variable names such as TIME_BUDGET, peak_vram_mb, evaluate_bpb
- Very specific: line 299
prefer render-svg-cover.py so the browser engine renders local fonts correctly
- Distinctive: line 300
do not use thumbnail-style exporters or font-limited SVG renderers for the final publish cover
- Distinctive: line 304
If the source of truth is markdown, re-run the formatter after edits instead of patching old HTML by hand.
- Distinctive: line 314
Only after this prep flow is complete should you proceed to Step 1 / Step 4 publishing.
- Very specific: line 325
If the article package contains article-api.html, use it for API publishing.
- Very specific: line 326
If the article package contains article-preview.md, use it for browser automation publishing.
- Distinctive: line 336
Create directory and save file:
- Very specific: line 389
After location choice, prompt for values and write to .env:
- Very specific: line 402
If the resolved theme is default / grace / simple / modern, normalize it to mist-blue for the standard repo-local formatter path
- Distinctive: line 407
Treat as legacy-compat only.
- Very specific: line 419
If the article package is expected to be reused across platforms, prefer keeping platform-specific badges or labels out of the WeChat …
- Very specific: line 426
Use CLI --cover if provided.
- Distinctive: line 430
If still missing, auto-generate a cover image and continue:
- Distinctive: line 439
If the article package provides a custom SVG cover, prefer rendering that instead of generating a new generic PNG:
- Distinctive: line 449
If auto-generation or SVG rendering fails, stop and request a manual cover image.
- Very specific: line 454
If you provide --cover for browser publishing, also make sure that same file is inserted inline in the article body.
- Distinctive: line 475
If no method is pinned, it prefers API when credentials exist, otherwise browser.
- Distinctive: line 476
If API is blocked by WeChat IP whitelist, it may fall back to browser publishing automatically.
- Very specific: line 477
If the user explicitly asks for api or browser, obey that request even when EXTEND.md defaults differ.
- Very specific: line 479
When an article bundle already provides article-api.html, prefer passing that file directly to the API script.
- Distinctive: line 493
Verify which drafts would be kept vs deleted
- Very specific: line 500
CRITICAL: Always include --theme parameter.
- Distinctive: line 506
Always resolve and send:
- Distinctive: line 512
If script parameters do not expose the two comment fields, still ensure final API request body includes resolved values.
- Very specific: line 521
If --profile, --author, --theme, or --color are omitted, the browser script should fall back to wechat-publisher/EXTEND.md when those …
- Very specific: line 524
If the resolved cover image matches one of the inline article images, the browser script should open the cover chooser inside …
- Very specific: line 527
If the cover image does not exist in body content, a separate local-cover upload may still be attempted, but it is less reliable than 从正文选择.
- Very specific: line 528
If WeChat API publishing is blocked by IP whitelist or unavailable, prefer the browser method with article-preview.md.
- Very specific: line 607
Use article-preview.md as the browser source.
- Distinctive: line 608
Keep the intended cover image inside the body image set.
- Very specific: line 609
Prefer the same file for --cover and the first inline image when deterministic cover behavior matters.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Post to WeChat Official Account
Language
Match user's language: Respond in the same language the user uses. If user writes in Chinese, respond in Chinese. If user writes in English, respond in English.
Script Directory
Agent Execution: Determine this SKILL.md directory as SKILL_DIR, then use ${SKILL_DIR}/scripts/<name> (supports .ts and .py).
| Script | Purpose |
scripts/wechat-publish.ts | Unified article entry: delegate to API or browser based on wechat-publisher defaults/current environment |
scripts/wechat-browser.ts | Image-text posts (图文) |
scripts/wechat-article.ts | Article posting via browser (文章) |
scripts/wechat-api.ts | Article posting via API (文章) |
scripts/md-to-wechat.ts | Legacy internal markdown renderer (compatibility path only) |
scripts/check-permissions.ts | Verify environment & permissions |
scripts/generate-cover-image.py | Generate topic-aligned cover image (imgs/cover.png) from markdown/title |
scripts/render-svg-cover.py | Render custom SVG cover layouts to WeChat-safe PNG (prefer local resvg, fallback to Chrome) |
Reproducibility Boundary
Before using this skill on a freshly cloned machine, treat setup in three layers:
- Repo-local reproducible layer
- install runtime deps
- bootstrap repo-local config files
- run doctor / environment checks
- Machine-local API layer
- requires real WeChat API credentials and current IP whitelist
- Machine-local browser layer
- requires Chrome login session and desktop automation permissions
Reference: references/reproducibility.md
Fresh-clone bootstrap (execute this before anything else):
cd wechat-publisher
bun install
bun scripts/bootstrap-local.ts --project-root ..
bun scripts/check-permissions.ts --project-root ..This bootstrap does not make API/browser publishing magically portable by itself. It only makes the repo-local part reproducible:
- config file locations
- preferred formatter Python runtime
- runtime dependencies
- cover renderer availability
- dry-run / preflight checks
Canonical Path
Treat this as the only recommended article path on a fresh clone:
cd wechat-publisher
bun install
bun scripts/bootstrap-local.ts --project-root ..
bun scripts/check-permissions.ts --project-root ..
bun scripts/wechat-publish.ts /abs/path/article.md --dry-runThen choose the real publish mode:
- keep using
scripts/wechat-publish.tsas the standard entry - let it delegate to API or browser based on config / current environment
- expect Markdown input to be rendered through the repo-local
wechat-article-formatterwithmist-blue
If you need direct control:
scripts/wechat-api.ts <article.md>is the direct API entryscripts/wechat-article.ts --markdown <article.md>is the direct browser entry
But these are still secondary entries. The canonical path is scripts/wechat-publish.ts.
Publishing Gate
When the source is a technical article, publishing is not the first validation step. Before invoking the real API/browser publish path:
- Run
technical-article-reviewon the Markdown source and apply blocking fixes. - Run
technical-article-preflightfor source, cover, images, regenerated HTML, and local preview readiness. - Run
scripts/wechat-publish.ts <article.md> --dry-runand inspect the resolved source, title, author, cover, comments, and theme path. - Publish only when the dry-run output matches the intended article package.
Exception: if the user explicitly asks only to test API credentials, list/delete drafts, or inspect environment permissions, skip article preflight because no article is being published.
Incorrect Or Legacy Paths
Mark these as non-standard when helping users:
- Running
scripts/md-to-wechat.tsdirectly as the primary flow- This is legacy compatibility only.
- Assuming
default/grace/simple/modernare the active project themes- Standard repo-local publishing now normalizes these to
mist-blue.
- Standard repo-local publishing now normalizes these to
- Running
check-permissions.tsbeforebootstrap-local.ts- You can get misleading results because the preferred formatter runtime may not exist yet.
- Publishing Markdown from a fresh clone before the formatter venv exists
- This is the exact failure mode that previously caused “doctor passed but publish formatting still broke”.
- Treating API/browser publishing as fully repo-reproducible
- Actual publish still depends on credentials, whitelist, login state, and desktop permissions.
Preferences (EXTEND.md)
Use Bash to check EXTEND.md existence (priority order):
# Check project-level first
test -f .baoyu-skills/wechat-publisher/EXTEND.md && echo "project"
# Then user-level (cross-platform: $HOME works on macOS/Linux/WSL)
test -f "$HOME/.baoyu-skills/wechat-publisher/EXTEND.md" && echo "user"┌────────────────────────────────────────────────────────┬───────────────────┐ │ Path │ Location │ ├────────────────────────────────────────────────────────┼───────────────────┤ │ .baoyu-skills/wechat-publisher/EXTEND.md │ Project directory │ ├────────────────────────────────────────────────────────┼───────────────────┤ │ $HOME/.baoyu-skills/wechat-publisher/EXTEND.md │ User home │ └────────────────────────────────────────────────────────┴───────────────────┘
┌───────────┬───────────────────────────────────────────────────────────────────────────┐ │ Result │ Action │ ├───────────┼───────────────────────────────────────────────────────────────────────────┤ │ Found │ Read, parse, apply settings │ ├───────────┼───────────────────────────────────────────────────────────────────────────┤ │ Not found │ Run first-time setup (references/config/first-time-setup.md) → Save → Continue │ └───────────┴───────────────────────────────────────────────────────────────────────────┘
EXTEND.md Supports: Default theme | Default color | Default publishing method (api/browser) | Default author | Default open-comment switch | Default fans-only-comment switch | Chrome profile path
First-time setup: references/config/first-time-setup.md
Minimum supported keys (case-insensitive, accept 1/0 or true/false):
| Key | Default | Mapping |
default_author | empty | Fallback for author when CLI/frontmatter not provided |
need_open_comment | 1 | articles[].need_open_comment in draft/add request |
only_fans_can_comment | 0 | articles[].only_fans_can_comment in draft/add request |
Recommended EXTEND.md example:
default_theme: mist-blue
default_publish_method: api
default_author: 宝玉
need_open_comment: 1
only_fans_can_comment: 0
chrome_profile_path: /path/to/chrome/profileTheme options: mist-blue (recommended), ai-tech (alternate), legacy default/grace/simple/modern (auto-normalized to mist-blue in the standard path)
Color presets: only used by the legacy internal markdown renderer. The repo-local preferred formatter path ignores default_color.
Value priority:
- CLI arguments
- Frontmatter
- EXTEND.md
- Skill defaults
Pre-flight Check
On first use in a freshly cloned repo, run the environment check before attempting publish. Do not skip this unless the user explicitly tells you to bypass preflight.
cd ${SKILL_DIR}
bun install
npx -y bun ${SKILL_DIR}/scripts/bootstrap-local.ts --project-root ..
npx -y bun ${SKILL_DIR}/scripts/check-permissions.ts --project-root ..Checks: Chrome, profile isolation, Bun, Accessibility, clipboard, paste keystroke, API credentials, Chrome conflicts.
If any check fails, stop the publish attempt and report the blocking item with the fix:
| Check | Fix |
| Chrome | Install Chrome or set WECHAT_BROWSER_CHROME_PATH env var |
| Profile dir | Ensure ~/.local/share/wechat-browser-profile is writable |
| Bun runtime | curl -fsSL https://bun.sh/install | bash |
| Accessibility (macOS) | System Settings → Privacy & Security → Accessibility → enable terminal app |
| Clipboard copy | Ensure Swift/AppKit available (macOS Xcode CLI tools: xcode-select --install) |
| Paste keystroke (macOS) | Same as Accessibility fix above |
| Paste keystroke (Linux) | Install xdotool (X11) or ydotool (Wayland) |
| API credentials | Follow guided setup in Step 2, or manually set in .baoyu-skills/.env |
| Repo runtime deps | Run cd wechat-publisher && bun install |
| Project bootstrap files | Run bun scripts/bootstrap-local.ts --project-root .. from wechat-publisher/ |
Image-Text Posting (图文)
For short posts with multiple images (up to 9):
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --markdown article.md --images ./images/
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --title "标题" --content "内容" --image img.png --submitSee references/image-text-posting.md for details.
Article Posting Workflow (文章)
Copy this checklist and check off items as you complete them:
Publishing Progress:
- [ ] Step 0: Load preferences (EXTEND.md)
- [ ] Step 0.5: Prepare article package for submission
- [ ] Step 1: Determine input type
- [ ] Step 2: Select method and configure credentials
- [ ] Step 3: Resolve theme/color and validate metadata
- [ ] Step 3.5: Auto-generate cover if missing
- [ ] Step 4: Publish to WeChat
- [ ] Step 5: Report completionStep 0: Load Preferences
Check and load EXTEND.md settings (see Preferences section above).
CRITICAL: If not found, complete first-time setup BEFORE any other steps or questions.
For a freshly cloned repo, run the deterministic bootstrap path first:
cd ${SKILL_DIR}
bun install
bun scripts/bootstrap-local.ts --project-root ..
bun scripts/check-permissions.ts --project-root ..Only if the user explicitly wants interactive setup instead of copying templates should you fall back to the guided first-time setup flow.
Resolve and store these defaults for later steps:
default_theme(defaultmist-blue)default_color(legacy internal renderer only; omit if not set)default_authorneed_open_comment(default1)only_fans_can_comment(default0)
The direct scripts also read wechat-publisher/EXTEND.md, so CLI runs stay aligned with these defaults even when the agent is not manually passing every field.
Step 0.5: Prepare Article Package For Submission
For technical articles, do NOT jump directly from markdown draft to WeChat publish. Run this prep flow first:
- Review the article for technical publish readiness
- For technical posts, review the markdown with
technical-article-reviewbefore formatting/publishing. - This applies even if the article was drafted just now in the same turn.
- Focus on:
- fact vs inference separation
- whether time-sensitive numbers are caveated
- whether at least one mechanism and one reproducible path are present
- whether failure cases / boundaries are explicit
- If the article reads like a good commentary but lacks reproducibility, revise the markdown first.
- Unless the user explicitly asked for review-only, treat the review as a direct input to source revision in the same turn.
- Do not move a first draft directly into HTML or WeChat publish just because the user asked for a WeChat article.
- For technical posts, review the markdown with
- Revise the markdown draft before HTML conversion
- Preferred fixes:
- replace unsupported exact numbers with dated approximate values unless you can verify them
- add a short “minimum prerequisites / how to run” section when the post discusses code or experiments
- turn slogan paragraphs into mechanism + condition statements
- reduce speculative wording around internal implementation details
- add one concrete “first run” or “minimum workflow” path when the article is recommendation-heavy
- Preferred fixes:
- Confirm the review fixes landed in the source draft
- Before touching HTML, verify that the markdown source actually reflects the review conclusions.
- Minimum check:
- top blocking findings were fixed in the source article
- newly added setup steps or commands are traceable to README, code, or docs
- no old HTML was patched as a shortcut while markdown stayed stale
- Verify cover and inline images before publish
- Ensure the article bundle has:
- one cover image at
imgs/cover.png(or explicit--cover) - all inline images present on disk and referenced from the final markdown / HTML
- one cover image at
- Cover-specific checks:
- preferred cover size is
900x383 - reserve a safe text area for title/subtitle; do not let chips or side cards overlap it
- assume Chinese technical titles may need two full lines
- preferred cover size is
- For custom diagrams:
- keep text within a safe inner area; do not let long labels touch card edges
- prefer manual line breaks for long variable names such as
TIME_BUDGET,peak_vram_mb,evaluate_bpb - export SVG to PNG using a tool/path that preserves the original canvas ratio
- For custom SVG covers with Chinese text:
- prefer
render-svg-cover.pyso the browser engine renders local fonts correctly - do not use thumbnail-style exporters or font-limited SVG renderers for the final publish cover
- prefer
- Do not rely on thumbnail-style SVG export paths that silently turn 16:9 diagrams into cropped square PNGs.
- Ensure the article bundle has:
- Regenerate the final HTML from the revised markdown
- If the source of truth is markdown, re-run the formatter after edits instead of patching old HTML by hand.
- Then re-apply project visual styling if you use a custom article theme outside the formatter defaults.
- Do one final local verification pass
- Confirm:
- title/summary/author metadata are correct
- images load
- lists and numbering render correctly
- theme/colors did not fall back to formatter defaults unexpectedly
- Confirm:
Only after this prep flow is complete should you proceed to Step 1 / Step 4 publishing.
Step 1: Determine Input Type
| Input Type | Detection | Action |
| HTML file | Path ends with .html, file exists | Skip to Step 3 |
| Markdown file | Path ends with .md, file exists | Continue to Step 2 |
| Plain text | Not a file path, or file doesn't exist | Save to markdown, continue to Step 2 |
HTML file preference:
- If the article package contains
article-api.html, use it for API publishing. - If the article package contains
article-preview.md, use it for browser automation publishing. This path keeps real image references and lets the browser workflow reinsert images reliably. article-wechat.htmlis the preferred file for manual copy/paste into the WeChat editor, not the first choice for browser automation.article-api.htmlshould be considered the API-safe variant when long URLs, lists, or WeChat line-breaking quirks need special handling.- For browser automation, the most reliable cover strategy is to keep the chosen cover image inside the article body as a real inline image, ideally near the top of
article-preview.md. - For custom HTML input, the browser script now auto-detects local
<img src>paths relative to the HTML file.data-local-pathis still acceptable, but no longer required for normal local image bundles. - For markdown sources, standalone badge marker lines such as
[!AI] [!推荐]are treated as source-side artifacts and stripped before rendering to WeChat HTML.
Plain Text Handling:
- Generate slug from content (first 2-4 meaningful words, kebab-case)
- Create directory and save file:
mkdir -p "$(pwd)/post-to-wechat/$(date +%Y-%m-%d)"
# Save content to: post-to-wechat/yyyy-MM-dd/[slug].md- Continue processing as markdown file
Slug Examples:
- "Understanding AI Models" →
understanding-ai-models - "人工智能的未来" →
ai-future(translate to English for slug)
Step 2: Select Publishing Method and Configure
Resolve publishing method (do not ask unless the user explicitly wants to choose):
| Method | Speed | Requirements |
api (Default if available) | Fast | API credentials |
browser | Slow | Chrome, login session |
Use this order:
- obey explicit CLI / user request
- else use EXTEND.md
default_publish_method - else prefer
apiif credentials exist - else use
browser
If API Selected - Check Credentials:
# Check project-level
test -f .baoyu-skills/.env && grep -q "WECHAT_APP_ID" .baoyu-skills/.env && echo "project"
# Check user-level
test -f "$HOME/.baoyu-skills/.env" && grep -q "WECHAT_APP_ID" "$HOME/.baoyu-skills/.env" && echo "user"If Credentials Missing - Guide Setup:
WeChat API credentials not found.
To obtain credentials:
1. Visit https://mp.weixin.qq.com
2. Go to: 开发 → 基本配置
3. Copy AppID and AppSecret
Where to save?
A) Project-level: .baoyu-skills/.env (this project only)
B) User-level: ~/.baoyu-skills/.env (all projects)After location choice, prompt for values and write to .env:
WECHAT_APP_ID=<user_input>
WECHAT_APP_SECRET=<user_input>Step 3: Resolve Theme/Color and Validate Metadata
- Resolve theme (first match wins, do NOT ask user if resolved):
- CLI
--themeargument - EXTEND.md
default_theme(loaded in Step 0) - Fallback:
mist-blue - If the resolved theme is
default/grace/simple/modern, normalize it tomist-bluefor the standard repo-local formatter path
- CLI
- Resolve color (first match wins):
- CLI
--colorargument - EXTEND.md
default_color(loaded in Step 0) - Treat as legacy-compat only; the standard repo-local formatter path ignores it
- CLI
- Validate metadata from frontmatter (markdown) or HTML meta tags (HTML input):
| Field | If Missing |
| Title | Prompt: "Enter title, or press Enter to auto-generate from content" |
| Summary | Prompt: "Enter summary, or press Enter to auto-generate (recommended for SEO)" |
| Author | Use fallback chain: CLI --author → frontmatter author → EXTEND.md default_author |
Recommended practice:
- Set
default_authorinwechat-publisher/EXTEND.mdfor the public account, instead of relying on empty author fields at publish time. - If the article package is expected to be reused across platforms, prefer keeping platform-specific badges or labels out of the WeChat markdown source, or let
md-to-wechat.tsstrip standalone badge lines.
Auto-Generation Logic:
- Title: First H1/H2 heading, or first sentence
- Summary: First paragraph, truncated to 120 characters
- Cover Image Check (required for API
article_type=news):- Use CLI
--coverif provided. - Else use frontmatter (
coverImage,featureImage,cover,image). - Else check article directory default path:
imgs/cover.png. - Else fallback to first inline content image.
- If still missing, auto-generate a cover image and continue:
- Use CLI
python3 ${SKILL_DIR}/scripts/generate-cover-image.py \
--markdown <markdown_file> \
--out <article_dir>/imgs/cover.png \
--bootstrap-pillow- If the article package provides a custom SVG cover, prefer rendering that instead of generating a new generic PNG:
python3 ${SKILL_DIR}/scripts/render-svg-cover.py \
--svg <article_dir>/imgs/cover.svg \
--out <article_dir>/imgs/cover.png \
--size 900x383wechat-api.tsandwechat-article.tsnow auto-detectcover.svgvariants and render them to PNG before upload.- If auto-generation or SVG rendering fails, stop and request a manual cover image.
Browser-mode cover note:
- The current WeChat browser editor does not expose a stable plain file-input path for article covers.
- The reliable browser flow is
从正文选择: the cover image should also exist in the article body. - If you provide
--coverfor browser publishing, also make sure that same file is inserted inline in the article body. Otherwise cover upload may be unreliable on newer editor revisions.
Step 4: Publish to WeChat
CRITICAL: Publishing scripts handle markdown conversion internally. Do NOT pre-convert markdown to HTML — pass the original markdown file directly. This ensures the API method renders images as <img> tags (for API upload) while the browser method uses placeholders (for paste-and-replace workflow).
API method (accepts .md or .html):
npx -y bun ${SKILL_DIR}/scripts/wechat-api.ts <file> --theme <theme> [--color <color>] [--title <title>] [--summary <summary>] [--author <author>] [--cover <cover_path>]Unified method dispatch (preferred when another tool/skill is delegating WeChat publishing):
npx -y bun ${SKILL_DIR}/scripts/wechat-publish.ts <source> [--title <title>] [--summary <summary>] [--author <author>] [--cover <cover_path>]Behavior:
wechat-publish.tschooses API or browser insidewechat-publisher.- It reads
default_publish_methodfromwechat-publisher/EXTEND.mdwhen present. - If no method is pinned, it prefers API when credentials exist, otherwise browser.
- If API is blocked by WeChat IP whitelist, it may fall back to browser publishing automatically.
- If the user explicitly asks for
apiorbrowser, obey that request even when EXTEND.md defaults differ.
When an article bundle already provides article-api.html, prefer passing that file directly to the API script.
For browser automation on generated article bundles, prefer article-preview.md over article-wechat.html.
Draft management via API:
npx -y bun ${SKILL_DIR}/scripts/wechat-api.ts --draft-list --count 10
npx -y bun ${SKILL_DIR}/scripts/wechat-api.ts --draft-delete <media_id>
npx -y bun ${SKILL_DIR}/scripts/wechat-api.ts --draft-delete-title "文章标题" --keep-latest 1 --dry-runRecommended cleanup flow:
- First run
--draft-listor--draft-delete-title ... --dry-run - Verify which drafts would be kept vs deleted
- Then rerun without
--dry-run
API list rendering note:
- WeChat's
draft/addrendering for native<ul>/<ol>is inconsistent and may produce empty bullets or broken numbering in the editor preview. - The API path should normalize article lists into paragraph-based bullet/number lines before publishing, instead of sending raw list tags when stable rendering matters.
CRITICAL: Always include --theme parameter. Never omit it, even if using default. Only include --color if explicitly set by user or EXTEND.md.
draft/add payload rules:
- Use endpoint:
POST https://api.weixin.qq.com/cgi-bin/draft/add?access_token=ACCESS_TOKEN article_type:news(default) ornewspic- For
news, includethumb_media_id(cover is required) - Always resolve and send:
need_open_comment(default1)only_fans_can_comment(default0)
authorresolution: CLI--author→ frontmatterauthor→ EXTEND.mddefault_author- Cover fallback order for direct script use:
--cover→ frontmatter cover fields →imgs/cover.png→images/cover-wide.png→ first inline image
If script parameters do not expose the two comment fields, still ensure final API request body includes resolved values.
Browser method (accepts --markdown or --html):
npx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --markdown <markdown_file> --theme <theme> [--color <color>]
npx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --html <html_file>If --profile, --author, --theme, or --color are omitted, the browser script should fall back to wechat-publisher/EXTEND.md when those defaults are present.
Browser cover behavior:
- If the resolved cover image matches one of the inline article images, the browser script should open the cover chooser inside
#js_cover_area, use从正文选择, select that image, and confirm the crop dialog. - This is the preferred path for generated article bundles and current WeChat editor revisions.
- The crop step must wait for a visible
确认or完成button before clicking; hidden dialog buttons are not reliable in newer editor revisions. - If the cover image does not exist in body content, a separate local-cover upload may still be attempted, but it is less reliable than
从正文选择. - If WeChat API publishing is blocked by IP whitelist or unavailable, prefer the browser method with
article-preview.md. - For custom HTML bundles with relative local images, the browser script will now infer content images directly from
<img src>and can reuse the first matching image as cover when--coverpoints to the same local file.
Step 5: Completion Report
For API method, include draft management link:
WeChat Publishing Complete!
Input: [type] - [path]
Method: API
Theme: [theme name] [color if set]
Article:
• Title: [title]
• Summary: [summary]
• Images: [N] inline images
• Comments: [open/closed], [fans-only/all users]
Result:
✓ Draft saved to WeChat Official Account
• media_id: [media_id]
Next Steps:
→ Manage drafts: https://mp.weixin.qq.com (登录后进入「内容管理」→「草稿箱」)
Files created:
[• post-to-wechat/yyyy-MM-dd/slug.md (if plain text)]
[• slug.html (converted)]For Browser method:
WeChat Publishing Complete!
Input: [type] - [path]
Method: Browser
Theme: [theme name] [color if set]
Article:
• Title: [title]
• Summary: [summary]
• Images: [N] inline images
Result:
✓ Draft saved to WeChat Official Account
Files created:
[• post-to-wechat/yyyy-MM-dd/slug.md (if plain text)]
[• slug.html (converted)]Detailed References
| Topic | Reference |
| Image-text parameters, auto-compression | references/image-text-posting.md |
| Article themes, image handling | references/article-posting.md |
| Cover image generation | references/cover-generation.md |
Feature Comparison
| Feature | Image-Text | Article (API) | Article (Browser) |
| Plain text input | ✗ | ✓ | ✓ |
| HTML input | ✗ | ✓ | ✓ |
| Markdown input | Title/content | ✓ | ✓ |
| Multiple images | ✓ (up to 9) | ✓ (inline) | ✓ (inline) |
| Themes | ✗ | ✓ | ✓ |
| Auto-generate metadata | ✗ | ✓ | ✓ |
Default cover fallback (imgs/cover.svg, imgs/cover.png, images/cover-wide.png) | ✗ | ✓ | ✓ |
Comment control (need_open_comment, only_fans_can_comment) | ✗ | ✓ | ✗ |
| Requires Chrome | ✓ | ✗ | ✓ |
| Requires API credentials | ✗ | ✓ | ✗ |
| Speed | Medium | Fast | Slow |
Browser article best practice:
- Use
article-preview.mdas the browser source. - Keep the intended cover image inside the body image set.
- Prefer the same file for
--coverand the first inline image when deterministic cover behavior matters.
Prerequisites
For API method:
- WeChat Official Account API credentials
- Guided setup in Step 2, or manually set in
.baoyu-skills/.env
For Browser method:
- Google Chrome
- First run: log in to WeChat Official Account (session preserved)
Config File Locations (priority order):
- Environment variables
<cwd>/.baoyu-skills/.env~/.baoyu-skills/.env
Troubleshooting
| Issue | Solution |
| Missing API credentials | Follow guided setup in Step 2 |
| Access token error | Check if API credentials are valid and not expired |
| Not logged in (browser) | First run opens browser - scan QR to log in |
| Chrome not found | Set WECHAT_BROWSER_CHROME_PATH env var |
| Title/summary missing | Use auto-generation or provide manually |
| No cover image | Add frontmatter cover or place imgs/cover.png / imgs/cover.svg in the article directory |
| Cover style mismatched topic | Run scripts/generate-cover-image.py --markdown <file> --bootstrap-pillow for a standard cover, or create imgs/cover.svg and render it with scripts/render-svg-cover.py |
| Cover script missing Pillow | Re-run with --bootstrap-pillow to auto-create venv and install Pillow |
| SVG cover looks cropped or squeezed | Re-render with scripts/render-svg-cover.py; do not use thumbnail-style exporters like qlmanage -t |
| SVG cover shows missing Chinese glyphs | Use the Chrome-based SVG renderer; avoid font-limited renderers for CJK covers |
| Wrong comment defaults | Check EXTEND.md keys need_open_comment and only_fans_can_comment |
| Paste fails | Check system clipboard permissions |
API returns invalid ip | Switch to browser publishing or add the current egress IP to the WeChat API whitelist |
| API article shows empty bullets or broken numbering | Normalize native <ul>/<ol> into paragraph-based list lines before draft/add; do not rely on raw list tags for final WeChat rendering |
| Browser HTML input loses local images | Use the updated browser script that auto-detects local <img src> paths, or add data-local-path explicitly for non-standard bundles |
| Inline diagram looks cropped or text is cut off | Re-export SVG to PNG with the original aspect ratio preserved; verify labels stay inside the card safe area before publishing |
| Draft card shows a gray placeholder instead of a cover | Re-publish with article-preview.md and ensure the cover image also exists as an inline body image so the browser script can use 从正文选择 |
| Browser draft has body images but no cover | Use the same local image as both --cover and the first inserted body image; current stable browser flow depends on selecting cover from body content |
Extension Support
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

