home / skills / jst-well-dan / skill-box / baoyu-post-to-wechat

baoyu-post-to-wechat skill

/content-pipeline/baoyu-post-to-wechat

This skill posts content to WeChat Official Account using Chrome CDP, supporting article and image-text formats with markdown and images.

This is most likely a fork of the baoyu-post-to-wechat skill from vegetapn
npx playbooks add skill jst-well-dan/skill-box --skill baoyu-post-to-wechat

Review the files below or copy the command above to add this skill to your agents.

Files (27)
SKILL.md
5.1 KB
---
name: baoyu-post-to-wechat
description: Posts content to WeChat Official Account (微信公众号) via Chrome CDP automation. Supports article posting (文章) with full markdown formatting and image-text posting (图文) with multiple images. Use when user mentions "发布公众号", "post to wechat", "微信公众号", or "图文/文章".
---

# Post to WeChat Official Account

## Script Directory

**Agent Execution**: Determine this SKILL.md directory as `SKILL_DIR`, then use `${SKILL_DIR}/scripts/<name>.ts`.

| Script | Purpose |
|--------|---------|
| `scripts/wechat-browser.ts` | Image-text posts (图文) |
| `scripts/wechat-article.ts` | Article posting (文章) |
| `scripts/md-to-wechat.ts` | Markdown → WeChat HTML |

## Preferences (EXTEND.md)

Use Bash to check EXTEND.md existence (priority order):

```bash
# Check project-level first
test -f .baoyu-skills/baoyu-post-to-wechat/EXTEND.md && echo "project"

# Then user-level (cross-platform: $HOME works on macOS/Linux/WSL)
test -f "$HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md" && echo "user"
```

┌────────────────────────────────────────────────────────┬───────────────────┐
│                          Path                          │     Location      │
├────────────────────────────────────────────────────────┼───────────────────┤
│ .baoyu-skills/baoyu-post-to-wechat/EXTEND.md           │ Project directory │
├────────────────────────────────────────────────────────┼───────────────────┤
│ $HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md     │ User home         │
└────────────────────────────────────────────────────────┴───────────────────┘

┌───────────┬───────────────────────────────────────────────────────────────────────────┐
│  Result   │                                  Action                                   │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ Found     │ Read, parse, apply settings                                               │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ Not found │ Use defaults                                                              │
└───────────┴───────────────────────────────────────────────────────────────────────────┘

**EXTEND.md Supports**: Default theme | Auto-submit preference | Chrome profile path

## Usage

### Image-Text (图文)

```bash
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 --submit
```

### Article (文章)

```bash
npx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --markdown article.md --theme grace
```

## Detailed References

| Topic | Reference |
|-------|-----------|
| Image-text parameters, auto-compression | [references/image-text-posting.md](references/image-text-posting.md) |
| Article themes, image handling | [references/article-posting.md](references/article-posting.md) |

## Feature Comparison

| Feature | Image-Text | Article |
|---------|------------|---------|
| Multiple images | ✓ (up to 9) | ✓ (inline) |
| Markdown support | Title/content extraction | Full formatting |
| Auto compression | ✓ (title: 20, content: 1000 chars) | ✗ |
| Themes | ✗ | ✓ (default, grace, simple) |

## Prerequisites

- Google Chrome
- First run: log in to WeChat Official Account (session preserved)

## Troubleshooting

| Issue | Solution |
|-------|----------|
| Not logged in | First run opens browser - scan QR to log in |
| Chrome not found | Set `WECHAT_BROWSER_CHROME_PATH` env var |
| Paste fails | Check system clipboard permissions |

## Extension Support

Custom configurations via EXTEND.md. See **Preferences** section for paths and supported options.

Overview

This skill automates posting to WeChat Official Accounts using Chrome CDP automation. It supports both image-text posts (图文) with multiple images and full-format articles (文章) with markdown-to-HTML conversion. Use it to publish drafts, convert markdown to WeChat-compatible HTML, and submit posts programmatically.

How this skill works

The skill drives a Chrome instance via the Chrome DevTools Protocol to open the WeChat Official Account backend, fill fields, upload images, and submit posts. It converts markdown to WeChat HTML when needed and offers separate entry scripts for image-text publishing and article publishing. Configuration can be extended via an EXTEND.md file and environment variables like WECHAT_BROWSER_CHROME_PATH.

When to use it

  • You want to publish markdown content to a WeChat Official Account programmatically.
  • You need to post multi-image image-text articles (up to 9 images) from local files.
  • You need article-level formatting and themes (default, grace, simple).
  • You want to automate submitting posts from CI, scripts, or local workflows.
  • You need to batch-convert markdown to WeChat-compatible HTML before publishing.

Best practices

  • Perform an initial manual login: first run opens a browser to scan QR and preserve session.
  • Define project- or user-level EXTEND.md to set theme, auto-submit, and Chrome profile path.
  • Set WECHAT_BROWSER_CHROME_PATH if Chrome isn't auto-detected on your machine.
  • Prepare images in advance and keep markdown well-structured for predictable conversion.
  • Test with --submit disabled first to verify layout before publishing live.

Example use cases

  • Publish a blog post written in markdown to WeChat as a formatted article with a chosen theme.
  • Post a multi-image news update using a local images folder and a short markdown summary.
  • Automate scheduled content deployment from a CI job that converts markdown and uploads articles.
  • Batch-convert documentation directories into WeChat-ready HTML for manual review and publishing.

FAQ

Do I need Google Chrome installed?

Yes. Chrome is required. If the skill cannot find Chrome, set WECHAT_BROWSER_CHROME_PATH to your Chrome executable.

How is login handled?

On first run the browser opens and prompts a QR scan. Session cookies are preserved for subsequent runs.

Can I use this with pure markdown?

Yes. The tool converts markdown to WeChat-compatible HTML and supports full formatting for articles.