home / skills / questnova502 / claude-skills-sync / baoyu-post-to-wechat

baoyu-post-to-wechat skill

/skills/baoyu-post-to-wechat

This skill posts content to WeChat Official Account, supporting image-text and article formats via Chrome CDP automation.

npx playbooks add skill questnova502/claude-skills-sync --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
2.9 KB
---
name: baoyu-post-to-wechat
description: Post content to WeChat Official Account (微信公众号). Supports both article posting (文章) and image-text posting (图文).
---

# Post to WeChat Official Account (微信公众号)

Post content to WeChat Official Account using Chrome CDP automation.

## Script Directory

**Important**: All scripts are located in the `scripts/` subdirectory of this skill.

**Agent Execution Instructions**:
1. Determine this SKILL.md file's directory path as `SKILL_DIR`
2. Script path = `${SKILL_DIR}/scripts/<script-name>.ts`
3. Replace all `${SKILL_DIR}` in this document with the actual path

**Script Reference**:
| Script | Purpose |
|--------|---------|
| `scripts/wechat-browser.ts` | Image-text posts (图文) |
| `scripts/wechat-article.ts` | Full article posting (文章) |
| `scripts/md-to-wechat.ts` | Markdown → WeChat HTML conversion |
| `scripts/copy-to-clipboard.ts` | Copy content to clipboard |
| `scripts/paste-from-clipboard.ts` | Send real paste keystroke |

## Quick Usage

### Image-Text (图文) - Multiple images with title/content

```bash
# From markdown file and image directory
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --markdown article.md --images ./images/

# With explicit parameters
npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --title "标题" --content "内容" --image img1.png --image img2.png --submit
```

### Article (文章) - Full markdown with formatting

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

> **Note**: `${SKILL_DIR}` represents this skill's installation directory. Agent replaces with actual path at runtime.

## References

- **Image-Text Posting**: See `references/image-text-posting.md` for detailed image-text posting guide
- **Article Posting**: See `references/article-posting.md` for detailed article posting guide

## Prerequisites

- Google Chrome installed
- `bun` runtime (via `npx -y bun`)
- First run: log in to WeChat Official Account in the opened browser window

## Features

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

## Troubleshooting

- **Not logged in**: First run opens browser - scan QR code to log in, session is preserved
- **Chrome not found**: Set `WECHAT_BROWSER_CHROME_PATH` environment variable
- **Paste fails**: Check system clipboard permissions

## Extension Support

Custom configurations via EXTEND.md.

**Check paths** (priority order):
1. `.baoyu-skills/baoyu-post-to-wechat/EXTEND.md` (project)
2. `~/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md` (user)

If found, load before workflow. Extension content overrides defaults.

Overview

This skill automates posting to WeChat Official Accounts (微信公众号) from the command line. It supports both image-text posts (图文) and full articles (文章) and uses Chrome CDP automation to control the browser and preserve login sessions. Scripts handle markdown conversion, clipboard operations, and publishing actions.

How this skill works

The skill runs TypeScript/Node scripts that drive a Chrome instance via the Chrome DevTools Protocol. One script converts Markdown to WeChat-compatible HTML, another composes image-text posts, and a third posts full-format articles with selectable themes. The first run opens a browser for QR login; subsequent runs reuse the session. Environment variables allow configuring the Chrome binary path and other runtime options.

When to use it

  • Publish single or multi-image image-text posts from local markdown and images.
  • Publish full articles with Markdown formatting and selectable themes.
  • Automate repetitive posting workflows from scripts or CI environments.
  • Quickly move existing Markdown content into a WeChat Official Account.
  • Batch-post content where manual editor use would be too slow.

Best practices

  • Ensure Google Chrome is installed and accessible; set WECHAT_BROWSER_CHROME_PATH if needed.
  • Log in to the Official Account on first run and keep the browser session for later runs.
  • Prepare images in a dedicated folder and reference them when invoking the image-text script.
  • Use Markdown input for richer formatting and let the conversion script produce WeChat HTML.
  • Test on a draft post before using the --submit flag to avoid accidental publishing.

Example use cases

  • Convert a local Markdown article and publish it with the grace theme: run the article script with --markdown and --theme.
  • Create an image-text post from a Markdown title/content and multiple images by passing --markdown and --images.
  • Automate nightly content publishing by scripting the image-text script and using environment configs.
  • Copy prepared article content to the clipboard and paste into the online editor using the included clipboard helpers.
  • Compress long titles or content automatically for platforms that require shorter previews.

FAQ

What do I need to run this skill?

Install Google Chrome and have bun available via npx. On first run, scan the QR code in the opened browser to log into the Official Account.

How do I post multiple images?

Use the image-text script and pass multiple --image arguments or point to an images directory; the script supports up to nine images.

Can I control which Chrome binary is used?

Yes. Set the WECHAT_BROWSER_CHROME_PATH environment variable to the Chrome executable you want the automation to use.