wechat-publisher

告别公众号格式乱码!一行命令发布文章,100%保留样式。支持三套配色模板、青色/橙色、紫色一键切换。 包含自动发布到微信草稿箱的完整流程,支持中文封面图生成。

33 stars

Best use case

wechat-publisher is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

告别公众号格式乱码!一行命令发布文章,100%保留样式。支持三套配色模板、青色/橙色、紫色一键切换。 包含自动发布到微信草稿箱的完整流程,支持中文封面图生成。

Teams using wechat-publisher should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/wechat-publisher/SKILL.md --create-dirs "https://raw.githubusercontent.com/theneoai/awesome-skills/main/skills/persona/content/wechat-publisher/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/wechat-publisher/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How wechat-publisher Compares

Feature / Agentwechat-publisherStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

告别公众号格式乱码!一行命令发布文章,100%保留样式。支持三套配色模板、青色/橙色、紫色一键切换。 包含自动发布到微信草稿箱的完整流程,支持中文封面图生成。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# WeChat Publisher Skill

## 版本历史

| 版本 | 日期 | 更新内容 |
|-----|------|---------|
| v1.4.0 | 2026-04-06 | 初版发布 |
| v1.5.0 | 2026-04-16 | 新增 API 发布实战经验、中文字体支持、IP 白名单解决方案 |
| v1.6.0 | 2026-04-16 | 移除硬编码 AppID,安全去敏 |
| v1.7.0 | 2026-04-16 | 新增 AI Agent 文章创作经验、多模型并行工作流 |

---

## 一、微信公众号 API 发布实战经验(2026-04-16)

### 1.1 IP 白名单问题

**问题描述**:
- 妙搭云电脑使用动态 IP(阿里云),IP 会变化
- 微信公众号 API 调用需要 IP 在白名单中
- 服务器直接调用 API 会失败:`invalid ip 39.102.54.62, not in whitelist`

**解决方案**:

**方案 A:通过浏览器获取 access_token(推荐)**
```bash
# 在浏览器中打开以下 URL(替换 appid 和 secret):
https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=你的AppID&secret=你的AppSecret

# 浏览器会返回 JSON 格式的 access_token
# 复制返回结果中的 access_token 值
```

**方案 B:配置 IP 白名单**
- 在公众号后台添加可能的 IP 地址
- 注意:服务器 IP 可能是动态的,需要添加多个可能的 IP
- 妙搭云电脑当前 IP:`39.102.54.62`、`39.97.255.102`(可能变化)

### 1.2 封面图生成(中文支持)

**问题描述**:
- 服务器默认字体不支持中文,导致生成的封面图文字是方块乱码
- 需要使用支持中文的字体

**解决方案**:
```bash
# 1. 先检查可用中文字体
fc-list :lang=zh

# 2. 推荐使用 Noto Sans CJK 字体
# 字体路径:/usr/share/fonts/opentype/noto/NotoSansCJK-Black.ttc

# 3. Python PIL 示例代码
from PIL import Image, ImageDraw, ImageFont

img = Image.new('RGB', (900, 383), color='#06b6d4')
draw = ImageDraw.Draw(img)
font = ImageFont.truetype('/usr/share/fonts/opentype/noto/NotoSansCJK-Black.ttc', 56)
draw.text((450, 191), '标题文字', fill='white', anchor='mm', font=font)
img.save('cover.png')
```

### 1.3 草稿箱发布完整流程

**步骤 1:获取 access_token(通过浏览器)**
```
1. 浏览器打开:https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=你的AppID&secret=你的AppSecret
2. 复制返回的 access_token(有效期 2 小时)
```

**步骤 2:上传封面图获取 media_id**
```bash
# 使用 curl 上传图片
curl -s "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=你的TOKEN&type=thumb" \
  -F "media=@cover.png;type=image/png"

# 返回示例:
# {media_id":"vMrq-mSP3SIFyZbOzk_6TkpzzT22KaGPI6r5tTivqFzaskMCnN_U5F4-54CQ38VU",...}
```

**步骤 3:创建草稿箱文章**
```bash
curl -s "https://api.weixin.qq.com/cgi-bin/draft/add?access_token=你的TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "articles": [{
      "title": "文章标题",
      "author": "作者",
      "content": "<p>文章内容(HTML格式)</p>",
      "digest": "摘要",
      "thumb_media_id": "封面图media_id",
      "need_open_comment": 0,
      "only_fans_can_read": 0
    }]
  }'
```

### 1.4 常见错误处理

| 错误码 | 错误信息 | 解决方案 |
|-------|---------|---------|
| 40164 | invalid ip not in whitelist | 通过浏览器获取 token,或添加 IP 到白名单 |
| 40007 | invalid media_id | 必须先上传封面图获取 media_id,不能为空 |
| 40137 | invalid image format | 图片格式问题,确保是 PNG/JPG 格式 |

---

## 二、AI Agent 文章创作工作流(2026-04-16 新增)

### 2.1 多模型并行搜索策略

**核心思路**:使用多个 AI 模型并行搜索,提高信息覆盖度和时效性

```bash
# 并行搜索多个主题
web_search "Agent AI 人工智能 2026年4月 最新技术 新闻"
web_search "OpenClaw GitHub 2026年4月 AI Agent 开源"
web_search "Claude Anthropic 2026年4月 最新动态"
```

**搜索结果整合**:
- 从多个搜索结果中提取关键信息
- 交叉验证信息的准确性
- 优先选择一手信息来源(官方公告、技术博客)

### 2.2 文章结构设计

**深度分析文章标准结构**:
```
一、事件/现象级概述
   - 核心事件回顾
   - 数据支撑(用户量、下载量、市场占有率等)

二、技术原理深度剖析
   - 核心技术解读
   - 与竞品的技术对比

三、行业影响分析
   - 对既有格局的冲击
   - 新机会点识别

四、实操指南/应用场景
   - 普通人如何应对
   - 企业如何布局

五、未来展望
   - 趋势判断
   - 行动建议
```

### 2.3 爆款标题公式

**公式:年份 + 核心事件 + 悬念/情绪词**

**优秀标题示例**:
- "2026 AI Agent 爆发:从"回答问题"到"完成任务"的跨越"
- "Claude 突然要查身份证了!AI 实名制时代正式来临"
- "31万Star!2026最火开源AI神器深度解析"

### 2.4 长文创作要点

**8000字深度文章要点**:
- 每个核心观点至少 500 字的详细阐述
- 引用真实数据和案例
- 包含对比表格和示意图(用 HTML/CSS 模拟)
- 提供可操作的建议
- 结尾有金句升华主题

### 2.5 多模型协同工作流

**推荐工具组合**:
| 场景 | 推荐模型 | 理由 |
|-----|---------|------|
| 资讯搜索 | MiniMax M2.7 | 时效性强,多语言搜索 |
| 深度分析 | GLM-5.1 | 长文本理解能力强 |
| 内容创作 | Miaoda Flash | 速度快,适合初稿 |
| 标题优化 | Qwen3.6 | 中文语感好 |

---

## 三、微信公众号文章格式标准

### 3.1 格式保留关键

**微信公众号文章格式保留关键:**
- ❌ 微信编辑器过滤 `<style>` 标签
- ❌ 微信编辑器过滤 `class` 属性
- ✅ 微信编辑器保留**内联样式** `style="..."`
- ✅ 微信编辑器保留基础 HTML 标签

**列表格式关键:**
- ❌ 不用 `<ul>/<li>` 列表(会产生多余黑点)
- ✅ 用 `•` + 普通 `<p>` 段落

### 3.2 完整模板结构

```html
<!DOCTYPE html>
<html>
<body style="font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif; font-size: 15px; line-height: 1.6; color: #333; max-width: 640px; margin: 0 auto; padding: 20px;">

<!-- 标题 -->
<h1 style="font-size: 24px; font-weight: bold; color: #1a1a1a; margin-bottom: 8px;">文章标题</h1>
<p style="color: #999; font-size: 13px; margin-bottom: 20px;">日期 · 分类</p>

<!-- 标签(圆角胶囊) -->
<span style="display: inline-block; background: #e0f7fa; color: #06b6d4; padding: 2px 10px; border-radius: 20px; font-size: 13px; margin-right: 6px;">标签1</span>

<!-- 引言(青色左边框) -->
<p style="font-size: 16px; color: #555; margin: 20px 0; border-left: 4px solid #06b6d4; padding-left: 14px;">引言内容</p>

<!-- 二级标题 -->
<h2 style="font-size: 18px; font-weight: bold; color: #222; margin: 28px 0 14px; border-left: 4px solid #06b6d4; padding-left: 10px;">标题</h2>

<!-- 列表(用 • 符号,不用 <ul>/<li>) -->
<p style="margin: 8px 0; color: #444;">• 列表项1</p>
<p style="margin: 8px 0; color: #444;">• 列表项2</p>

<!-- 引用块 -->
<div style="background: #f0f9fa; border-left: 4px solid #06b6d4; padding: 12px 14px; margin: 16px 0; font-style: italic; color: #555;">
<p style="font-style: normal; color: #333;">引用内容</p>
</div>

<!-- 卡片(浅色背景+圆角+边框) -->
<div style="background: #f8feff; border-radius: 10px; padding: 14px; margin: 14px 0; border: 1px solid #cce8f0;">
<p style="font-weight: bold; color: #0891b2; font-size: 14px;">卡片标题</p>
<p style="color: #555; font-size: 13px;">卡片内容</p>
</div>

<!-- 警告块 -->
<div style="background: #fff8e1; border-left: 4px solid #ffc107; padding: 10px 14px; margin: 12px 0; font-size: 14px; color: #795548;">
<p style="margin: 0;">⚠️ 警告内容</p>
</div>

<!-- 双栏对比 -->
<div style="display: flex; gap: 12px; margin: 12px 0;">
<div style="flex: 1; background: #f8feff; border-radius: 10px; padding: 14px; border: 1px solid #cce8f0;">
<p style="font-weight: bold; color: #0891b2;">左栏标题</p>
<p style="color: #555; font-size: 12px;">左栏内容</p>
</div>
<div style="flex: 1; background: #fff5f5; border-radius: 10px; padding: 14px; border: 1px solid #ffcdd2;">
<p style="font-weight: bold; color: #c62828;">右栏标题</p>
<p style="color: #555; font-size: 12px;">右栏内容</p>
</div>
</div>

<!-- 签名 -->
<div style="text-align: center; color: #999; font-size: 13px; margin-top: 30px; padding-top: 16px; border-top: 1px solid #eee;">
<p>关注我,持续分享 👇</p>
<p style="color: #07c160; margin-top: 8px;">公众号名称</p>
</div>

</body>
</html>
```

---

## 四、配置(首次使用)

**安全提示:凭证通过环境变量传递,不要硬编码!**

```bash
export WECHAT_APP_ID="你的AppID"
export WECHAT_APP_SECRET="你的AppSecret"
```

获取方式:微信公众平台后台 → 设置与开发 → 基本配置

---

## 五、配色方案(固定风格)

| 用途 | 颜色 |
|------|------|
| 主色(标题、标签、边框) | #06b6d4(青色) |
| 标题文字 | #1a1a1a |
| 正文文字 | #444 |
| 次要文字 | #888 |
| 引用/卡片背景 | #f0f9fa / #f8feff |
| 警告背景 | #fff8e1 |
| 代码块背景 | #1a1a2e |
| 代码文字 | #a5f3fc |

---

## 六、文件结构

```
wechat-publisher/
├── SKILL.md           # 本文档(v1.7.0)
└── publish.py         # 发布脚本(可选)
```

---

## 七、注意事项

1. **封面图**:必须先上传到微信永久素材,获取 `media_id`,不能为空
2. **列表**:永远用 `•` + `<p>`,不用 `<ul>/<li>`
3. **行距**:固定 1.6
4. **段落间距**:正文 `margin: 12px 0`,列表 `margin: 8px 0`
5. **中文字体**:生成封面图时使用 `/usr/share/fonts/opentype/noto/NotoSansCJK-Black.ttc`
6. **access_token 有效期**:2 小时,注意及时刷新

---

## 八、实战案例(2026-04-16)

### 案例1:Claude 实名制文章
- **主题**:Anthropic Claude 身份验证政策深度分析
- **字数**:8000字
- **结构**:7大章节 + FAQ
- **发布**:成功上传至草稿箱

### 案例2:AI Agent 爆发文章
- **主题**:2026 AI Agent 爆发深度剖析
- **字数**:8000字
- **结构**:10大章节
- **来源**:基于多个 AI 模型并行搜索的最新资讯
- **发布**:成功上传至草稿箱

Related Skills

wechat-writer-kit

33
from theneoai/awesome-skills

公众号文章写作全流程助手(通用版)。支持多账号管理,适用于任何公众号方向。 当用户说"今天写什么"、"帮我写公众号"、"选题"、"公众号选题"、"写文章"、 "公众号文章"、"更新公众号风格"、"这篇文章写得好"、"新建公众号"时触发。 支持完整工作流:初始化/切换账号画像 → 搜索热门话题生成选题 → 选题确认 → 文章创作 → 存档到企业微信文档 → 持续学习风格。

wechat-article-reviewer

33
from theneoai/awesome-skills

微信公众号文章审核助手。当 theneoai 写完文章后 @铁蛋队长 发送文章内容时触发审核。 检查文章是否符合微信公众号发布标准:字数、内容深度、事实性、标题质量、原创度、敏感词、风格一致性、排版规范。 发现问题时提供具体整改意见,退回 theneoai 重写(最多3次),3次不通过则通知 lucas 人工介入。

wechat-article-extractor

33
from theneoai/awesome-skills

Extract metadata and content from WeChat Official Account articles. Use when user needs to parse WeChat article URLs (mp.weixin.qq.com), extract article info (title, author, content, publish time, cover image), or convert WeChat articles to structured data. Supports various article types including posts, videos, images, voice messages, and reposts.

write-skill

33
from theneoai/awesome-skills

Meta-skill for creating high-quality SKILL.md files. Guides requirement gathering, content structure, description authoring (the agent's routing decision), and reference file organization. Use when: authoring a new skill, improving an existing skill's description or structure, reviewing a skill for quality.

caveman

33
from theneoai/awesome-skills

Ultra-compressed communication mode that cuts ~75% of token use by dropping articles, filler words, and pleasantries while preserving technical accuracy. Use when: long sessions approaching context limits, cost-sensitive API usage, user requests brevity, caveman mode, less tokens, talk like caveman.

zoom-out

33
from theneoai/awesome-skills

Codebase orientation skill: navigate unfamiliar code by ascending abstraction layers to map modules, callers, and domain vocabulary. Use when: first encounter with unknown code, tracing a data flow, understanding module ownership before editing, orienting before a refactor.

to-prd

33
from theneoai/awesome-skills

Converts conversation context into a structured Product Requirements Document (PRD) and publishes it to the project issue tracker. Do NOT interview the user — synthesize what is already known. Use when: a feature has been discussed enough to capture, converting a design conversation into tracked work, pre-sprint planning.

tdd-workflow

33
from theneoai/awesome-skills

Test-driven development workflow using vertical slices (tracer bullets). Enforces behavior-first testing through public interfaces. Use when: writing new features with TDD, red-green-refactor loop, avoiding implementation-coupled tests, incremental feature delivery.

issue-triage

33
from theneoai/awesome-skills

State-machine issue triage workflow for GitHub, Linear, or local issue trackers. Manages category labels (bug, enhancement) and state labels (needs-triage, needs-info, ready-for-agent, ready-for-human, wontfix). Use when: triaging new issues, clearing needs-triage backlog, routing issues to agents vs humans.

debug-diagnose

33
from theneoai/awesome-skills

Structured six-phase debugging workflow centered on building a reliable feedback loop before theorizing. Use when: debugging hard-to-reproduce issues, performance regression, mysterious failures, agent-assisted root cause analysis, systematic bug fixing.

architecture-review

33
from theneoai/awesome-skills

Codebase architecture review using module depth analysis. Surfaces shallow modules, tight coupling, and locality violations. Proposes deepening opportunities. Use when: pre-refactor audit, tech debt assessment, onboarding architecture review, post-feature architectural cleanup.

vault-secrets-expert

33
from theneoai/awesome-skills

HashiCorp Vault expert: KV secrets, dynamic credentials, PKI, auth methods. Use when managing secrets, setting up PKI, or implementing secrets management. Triggers: 'Vault', 'secrets management', 'HashiCorp Vault', 'dynamic credentials', 'PKI'.