Task Objective
Complete the full process of creating, laying out, and publishing WeChat Official Account articles with AI assistance.
Capabilities: Article creation, image generation and upload, draft creation, article publishing
Trigger: The user needs to create or publish a WeChat Official Account article
Usage Modes
Mode 1: Web UI (Recommended)
Visual interface supporting article management, online editing, and publishing:
# 安装依赖
pip install -r requirements.txt
Start the service (default port 8000)
uvicorn app.main:app --reload
Access in browserhttp://localhost:8000
**功能:**
- 文章CRUD操作(创建、查看、编辑、删除)
- Markdown内容编辑
- 数据库持久化(SQLite)
- 直接发布到微信公众号
- 发布历史记录
### 模式2:脚本 (命令行)
适合自动化场景,与Web UI共享数据库:
```bash
# 上传图片
python scripts/upload_media.py /path/to/image.jpg thumb
# 创建草稿
python scripts/create_draft.py --title "标题" --content "内容"
# 发布文章
python scripts/publish_article.py --media_id <草稿ID>
Data intercommunication: Articles published by scripts are automatically recorded in the database and can be viewed and managed in the Web UI.
Prerequisites
Dependencies: requests>=2.28.0, python-dotenv>=1.0.0, fastapi>=0.104.1, sqlalchemy>=2.0.35
Credential configuration:
- Configure in the .env file
WECHAT_APP_IDandWECHAT_APP_SECRET - How to obtain: WeChat Official Platform → Development → Basic Configuration
- IP whitelist configuration required
Database: Automatically creates a SQLite database (data/articles.db); no manual configuration required
Standard Process (Web UI)
1. Start the service
cd skills/good-mp-post
uvicorn app.main:app --reload
2. Create an article
- Open http://localhost:8000
- Fill in the title, author, and summary
- Write Markdown content
- Save the draft
3. Publish the article
- Click the "Publish" button in the article list
- Automatically handles cover image upload, draft creation, and publishing process
- Check the publishing status
Script Process (Command Line)
1. Create article content
- Create an article according to user needs (Markdown format)
- Refer to
assets/templates/article-template.mdfor formatting suggestions
2. Generate images
- Generate a cover image (recommended 900×383px, <5MB)
- Generate illustrations (width ≤900px)
3. Upload images
Call scripts/upload_media.py:
python scripts/upload_media.py /path/to/cover.jpg thumb # 封面图
python scripts/upload_media.py /path/to/image.png image # 正文图
4. Create a draft
Call scripts/create_draft.py:
python scripts/create_draft.py \
--title "文章标题" \
--author "作者名" \
--thumb_media_id <封面图ID> \
--content "<p>HTML正文</p>" \
--media_ids '[]'
Note: The author name must be at most 8 Chinese characters
5. Publish the article
Call scripts/publish_article.py:
python scripts/publish_article.py --media_id <草稿ID>
Resource Index
app/main.py- FastAPI main application entry pointapp/api/articles.py- Article management APIapp/api/images.py- Image upload APIapp/database.py- Database models and connectionapp/static/index.html- Web UI interfacescripts/upload_media.py- Upload images to the material libraryscripts/create_draft.py- Create an image-text draftscripts/publish_article.py- Publish the draftscripts/db_logger.py- Database logging (optional)references/api-guide.md- Detailed API documentationassets/templates/article-template.md- Article format template
Image Path Specifications (Important)
The following specifications must be followed when AI generates articles:
Do not use relative paths
❌ Incorrect example:



Correct image processing flow
- First generate the image file and save it to a temporary directory
- Call
upload_media.pyto upload to WeChat and obtain the media_id - Use placeholders or descriptive text; do not directly insert local paths
✅ Correct example:
<!-- 步骤1:生成图片 -->
<!-- 步骤2:上传图片 -->
python scripts/upload_media.py /path/to/cover.jpg thumb
<!-- 步骤3:记录 media_id,在创建草稿时使用 -->
<!-- 正文中不插入相对路径 -->
Reason
- Relative paths cannot be displayed properly during preview and publishing
- The WeChat Official Account requires uploading the image first to obtain a media_id
- The existing workflow (upload image → create draft) is correct
Key considerations
- Author name limit: maximum 8 Chinese characters
- Image validity period: cover images are permanent, body images last 3 days
- Image path: relative paths are prohibited (see the image path specification above)
- HTML requirements: use simple tags (p/h1-h3/ul/li/img/a), avoid complex CSS
- Publishing review: after publishing, WeChat review is required before it can be displayed
- Call frequency: upload 1000 times/day, create draft 100 times/day, publish 10 times/day