This skill should be used when generating XiaoHongShu (小红书) style images. The AI analyzes user requirements, reads template registry to select appropriate template, extracts and merges data with template defaults, and invokes generation script with properly constructed command-line arguments.
This skill automates generation of XiaoHongShu-style images by combining AI intelligence with Playwright-driven browser automation. The AI analyzes user requests, selects templates from live registry, and orchestrates image generation process.
When to Use This Skill
Use this skill when:
User requests to generate XiaoHongShu-style images
User provides content descriptions (titles, tags, body text, etc.)
User mentions template types (避坑, 干货, OOTD, etc.) or specific keywords
Creating social media cover images or content visuals
Automating batch image production for content creation
AI Workflow
0. Prerequisites Check (MANDATORY)
Before processing any user request, check the following:
Check API KEY in config.json:bash
cat config.json
If file doesn't exist or apikey field is empty: STOP and inform user:
text
⚠️ 需要先在 config.json 中设置 apikey 才能使用图片生成功能。
请按以下步骤设置:
1. 访问 VisNote 个人主页获取 API Key:https://vis-note.netlify.app/profile,复制 API Key
2. 复制项目根目录的 example-config.json 文件,并重命名为 config.json
3. 将复制的 API Key 填入 config.json 的 "your_api_key_here" 位置
设置完成后,再次尝试生成图片。
If file exists and apikey is set: Proceed with step 1
1. Analyze User Request
Extract following information from user's request:
Content Type: 避坑/干货/教程, OOTD/探店, 语录/情感, 故事/对话, etc.
Text Content: Title, subtitle, body text, tag, author mentions
Keywords: Specific terms that map to template categories
Format Preferences: Cover style, comparison style, list style, etc.
Output Path (optional): If user explicitly specifies custom output path, use it; otherwise generate timestamped filename
2. Get Template Registry from API
Fetch the template list from the API:
text
GET /api/open/templates
Caching Strategy (IMPORTANT):
First request in conversation: Always fetch the latest template list from the API.
Subsequent requests in the same conversation:
If the user asks to "换个模板" (change template), "再生成一张" (generate another), or similar follow-up requests → Reuse the previously fetched template list from this conversation
If the user provides a completely new topic/content request → Fetch the latest template list from the API again
Examples of cache reuse:
"换个模板" → use cached template list
"再生成一张" → use cached template list
"换个风格" → use cached template list
"用其他模板试试" → use cached template list
Examples of cache invalidation (fetch new):
"生成一张关于xxx的新封面" (new topic) → fetch new template list
"帮我做一个关于yyy的图" (new content) → fetch new template list
User starts a completely new generation task → fetch new template list
Optional query parameters:
keyword: Search by template name/desc/tags (e.g., ?keyword=封面, ?keyword=正文)
Example using curl:
bash
# Get all templates
curl "https://vis-note.netlify.app/api/open/templates"
# Search for cover templates
curl "https://vis-note.netlify.app/api/open/templates?keyword=封面"
id: Unique identifier (used in --template parameter)
name: Template display name
desc: Description with use case patterns (e.g., "适合:避坑/干货/教程")
tags: Classification tags (免费, VIP, 封面, 图片)
value: Default data structure with all available fields for the template(used in --data parameter)
Critical:
Always call this API at runtime to get latest template configurations. Do NOT hardcode template information in responses.
Apply caching strategy: Reuse template list within the same conversation for follow-up requests to avoid redundant API calls.
3. Select Appropriate Template
Analyze templates from the registry array and select based on:
Template Selection Logic
Direct ID Match: If user specifies template ID (e.g., "使用 yellow 模板"), find template with matching id field and use it directly
Tag-Based Selection (Priority):
For covers/focus images: Select templates with '封面' in tags field
For body/content images: Select templates without '封面' tag, or with '图片' tag
For images with main photo: Select templates with '图片' in tags field
For comparison content: Select templates with '对比' keyword in desc or name
For tutorial/step content: Select templates with '步骤' keyword in desc or name
Category Match: Search template desc field for keywords like 避坑, 干货, OOTD, 情感, etc. that match user request
Format Match: Match format preferences from user request (对比, 封面, 清单, etc.)
Content Match: For tool/software content (Chrome插件, etc.), prefer templates with desc containing 工具/清单/测评
Fallback: Default to yellow for high-contrast visibility
Tag-Based Selection Examples
Scenario 1: Generating Cover + Content Images
Cover: Use template with tags: ['封面'] (e.g., yellow, magazine, laser-holographic, etc.)
Content: Use template without '封面' tag (e.g., glass, memo, newspaper, etc.)
Scenario 2: Image with Main Photo
Use template with tags: ['图片'] (e.g., tape-polaroid, soft-glass-border, etc.)
Scenario 3: Comparison/Before-After Content
Look for templates with '对比' in desc or name (e.g., classic-before-after, polaroid-before-after)
Scenario 4: Tutorial/Step Content
Look for templates with '步骤' in desc or name (e.g., single-image-step, double-row-step, sidebar-nav-step)
Template Analysis Process
For each template in the registry array:
Read desc field to understand use cases (format: "适合:类别1/类别2/类别3")
Read tags field to understand classification (免费, VIP, 封面, 图片)
Read value field to understand data structure and available fields
Match against user request using above selection logic
4. Extract User Data and Merge with Template Defaults
Critical: The template's value object is the foundation - it contains ALL default values including default images, colors, text, etc. Always start with this complete object and only override what user explicitly provides.
Data Extraction Rules
Title Extraction:
Explicit title format: 标题是"xxx" or 标题是'xxx'
Quoted content: Look for content in quotes that seems like a title
If not specified: Use template's value.title (template default)
Subtitle/Body Text Extraction:
Check if template's value has subtitle or bodyText fields
If user explicitly provides subtitle/body: use user value
If user doesn't explicitly provide but mentions secondary content (e.g., "OOTD 穿搭封面"):
Extract from description and fill appropriate field
Example: "生成 OOTD 穿搭封面" → subtitle could be "穿搭分享 | 日常记录"
Example: "日常碎碎念" → bodyText could be "今天天气真好\n心情超级棒"
If no user content available: Use template's value.subtitle or value.bodyText (template default)
Image Fields (Critical):
Check if template's value contains image, image2, etc.
Always keep template default images if user doesn't explicitly provide their own image paths
Template defaults ensure template works without user-supplied images
Example: Magazine template has image: '/images/jimeng-20260125.png' → keep this unless user specifies otherwise
Tag Extraction:
Look for category tags: 干货, 教程, 避坑, 分享, 笔记, 生活, 日常, etc.
Format as "xxx分享" if needed
If not specified: Use template's value.tag (template default)
Author Extraction:
Extract @mentions: @username patterns
Set as author field if template supports it
If not specified: Use template's value.author if exists (template default)
Color Extraction:
Look for hex color codes: #RRGGBB format
Set as color field if template supports it
If not specified: Use template's value.color if exists (template default)
Template-Specific Fields:
Identify ALL fields present in template's value object
For each field:
If user explicitly provides value: use user value
If user doesn't provide: use template's default value
Examples: image, image2 for comparison styles; step for tutorial styles
Merge Strategy
Start with template defaults: Copy the entirevalue object from selected template - this is your foundation and includes all required fields
Extract user-provided values: Identify what the user explicitly wants to override (title, color, etc.)
Smart fill for missing fields: If user mentions relevant content but doesn't specify exact field, intelligently assign:
Example: User says "生成 OOTD 穿搭" + title is provided
→ If template has subtitle, fill it with "穿搭分享 | 日常记录"
→ If template has tag, fill it with "生活分享"
Override with user data: Replace fields where user provided explicit values
Keep ALL template defaults: Never remove fields that exist in template's value - use template defaults for unspecified fields
Validate structure: Ensure final data object matches template's expected structure exactly
Verify success by checking exit code and output messages
Report to user:
Output file location
Template used (name and id)
Any relevant status messages
Handle errors with clear, actionable explanations:
Server startup issues
Template not found
Missing required fields
File permission issues
Template Registry API
Endpoint:GET /api/open/templates
Base URL:https://vis-note.netlify.app
Usage:
bash
# Get all templates
curl "https://vis-note.netlify.app/api/open/templates"
# Search templates by keyword
curl "https://vis-note.netlify.app/api/open/templates?keyword=封面"
Call this API with caching strategy:
First request or new topic: Always fetch the latest template list
Follow-up requests ("换个模板", "再生成一张", etc.): Reuse previously fetched template list from this conversation
This API is the single source of truth for:
All available templates and their IDs
Template descriptions and use cases
Default data structure for each template (via value field)
Field names and formats
Tag classifications
Never hardcode template information in responses, as:
Templates may be added or removed
Template data structures may change
Descriptions may be updated
New fields may be added to value objects
Caching benefits:
Reduces redundant API calls within the same conversation
Improves response speed for follow-up requests
Balances performance with data freshness (new topics still fetch latest data)
Example AI Processing
Example 1: Tool/Software Content
User Request: "帮我生成一张 Chrome插件 的图片,标题是 一键下载微博文章"
AI Processing:
Analyze Request: Tool/software content + specific title in quotes
Fetch Template Registry: Call GET /api/open/templates to get all templates
Before generating any image, the script will validate the API key by calling ${server}/api/open/check endpoint. The following checks will be performed:
API Key Existence: Verifies the API key exists in the system
Error message: "API Key 不存在"
Solution: Check your API key in config.json, get a new key from profile page
Membership Status: Checks if user is a VIP member
Error message: "您还不是会员"
Solution: Subscribe to VIP membership
Membership Expiry: Checks if VIP membership is still valid
Error message: "您的会员已过期"
Solution: Renew your VIP membership
Available Quota: Checks if user has remaining image generation quota
Error message: "生图额度已用完"
Solution: Purchase additional quota or wait for quota reset
Note: All validation errors will stop the image generation process immediately with a clear error message.