npx skills add ...
npx skills add iamzifei/xiaohongshu-images-skill --skill xiaohongshu-images
Transform markdown/HTML into styled 3:4 ratio images for Xiaohongshu
npx skills add iamzifei/xiaohongshu-images-skill --skill xiaohongshu-images
This skill transforms markdown, HTML, or text content into beautifully styled HTML pages with AI-generated cover images, then captures them as sequential screenshots at 3:4 ratio for Xiaohongshu posting.
The skill performs the following workflow:
prompts/default.md in this skill's directory/baoyu-cover-image skill to generate a cover image based on the article content~/Dev/obsidian/{account_folder}/articles/<date-title>/xhs-preview.htmlThe skill determines the output account folder using the following priority:
--account ParameterIf the user specifies --account, use the corresponding folder:
If no --account is specified, try to infer from the input file path:
If the account cannot be determined from the path (e.g., raw content input), use template-based mapping:
| Template | Account Folder |
|---|---|
default | 10_在悉尼和稀泥 |
mom-reading-club | 12_妈妈在读 |
| Account | Folder |
|---|---|
james-cn | 10_在悉尼和稀泥 |
james-en | 11_BuildWithJames |
mom-reading-club | 12_妈妈在读 |
When the user invokes this skill, follow these steps:
The user will provide one of the following:
/path/to/article.md)If the input is unclear, ask the user to provide either a file path, URL, or paste the content directly.
Read the prompt template from this skill's directory:
Use the Read tool to get the prompt template content. This template defines the HTML/CSS styling specifications.
From the content, extract:
Create the output folder path as: ~/Dev/obsidian/{account_folder}/articles/<date>-<sanitized-title>/
_attachments/ subfolder⚠️ COMPLIANCE CHECK: Before generating, ensure the image concept complies with Xiaohongshu community guidelines (Section 11 of the prompt template). The image must:
Use the /baoyu-cover-image skill to generate the cover image:
Or if the content is not yet saved, pass the content directly to the skill.
Style Selection:
tech - AI, coding, digital topicswarm - Personal stories, emotional contentbold - Controversial, attention-grabbing topicsminimal - Simple, zen-like contentplayful - Fun, casual, beginner-friendly contentnature - Wellness, health, organic topicsretro - History, vintage, traditional topicselegant - Business, professional content (default)Special: Mom Reading Club Template
When using the mom-reading-club template, override the default cover style with calligraphy & ink-wash illustration (书法水墨风):
Use --no-title flag since Xiaohongshu covers typically use visual-only images without embedded text.
Move the generated image to the correct location:
imgs/cover.png relative to the article~/Dev/obsidian/{account_folder}/articles/<date>-<title>/_attachments/cover-xhs.png⚠️ COMPLIANCE CHECK: Before generating HTML, review the text content for compliance:
Using the prompt template and the user's content:
Parse the content to identify:
Generate complete HTML following the template specifications:
Important HTML Structure:
~/Dev/obsidian/{account_folder}/articles/<date>-<title>/xhs-preview.htmlAfter generating the HTML, capture sequential screenshots of the .container element at exact 3:4 aspect ratio:
Screenshot Specifications:
.container element, not the full pageCapture Process:
.container element has overflow-y: auto, making it internally scrollablescrollTop = 0 and increment through the content.container content:
container.screenshot() to capture only the container element (excludes page background)~/Dev/obsidian/{account_folder}/articles/<date>-<title>/_attachments/:
xhs-01.png, xhs-02.png, xhs-03.png, etc.Use the screenshot script:
Script Output:
After completion, report to the user:
This skill depends on:
/baoyu-cover-image skill for cover image generation (must be installed in ~/.claude/skills/)User: Create a styled article page from this markdown:
Assistant Actions:
prompts/default.md10_在悉尼和稀泥)~/Dev/obsidian/10_在悉尼和稀泥/articles/2024-01-14-my-article-title//baoyu-cover-image skill with --no-title flag to generate cover imageimgs/cover.png to _attachments/cover-xhs.png~/Dev/obsidian/10_在悉尼和稀泥/articles/2024-01-14-my-article-title/xhs-preview.html~/Dev/obsidian/10_在悉尼和稀泥/articles/2024-01-14-my-article-title/_attachments/xhs-01.png, etc.Example with --account parameter:
Assistant Actions:
--account mom-reading-club specified → use 12_妈妈在读~/Dev/obsidian/12_妈妈在读/articles/2024-01-14-article-title/Example with path inference:
Assistant Actions:
12_妈妈在读 → infer account folder~/Dev/obsidian/12_妈妈在读/articles/2024-01-14-xxx/Users can provide custom prompt templates by:
.md file in the prompts/ directoryExample: "Use the xiaohongshu-style template for this article"
| Template | Description | Best For |
|---|---|---|
default | Standard style with New Yorker-style illustrations | General articles |
mom-reading-club | Calligraphy & ink-wash style with TsangerJinKai02 font | Mom Reading Club (妈妈读书会) brand content |
Use this template for all "Mom Reading Club" branded content:
Features:
If the /baoyu-cover-image skill fails:
If screenshot capture fails:
This skill requires:
pip install playwright && playwright install chromium)/baoyu-cover-image skill installed in ~/.claude/skills/Install dependencies:
IMPORTANT: All generated content must comply with Xiaohongshu community guidelines.
| Category | Examples | Action |
|---|---|---|
| Absolute claims | 最好、最佳、第一、国家级 | Remove or rephrase |
| Exaggerated effects | 一分钟见效、立刻瘦10斤 | Remove or add disclaimers |
| Medical/Financial advice | Health tips, investment suggestions | Add disclaimer: "本内容不构成医疗/投资建议" |
| Inappropriate imagery | Nudity, violence, political symbols | Regenerate with appropriate content |
| False information | Pseudoscience, unverified claims | Verify or remove |
| Defamatory content | Attacks on brands/individuals | Remove entirely |
触发:/小红书配图 新手、「这个怎么用」「第一次用」「能干嘛」「带我走一遍」,
以及用户输入了技能名却没有给任何任务的时候。
这个模式的铁律:不假设、不索取。用户可能什么都没准备, 不要一上来就问他要文件、要 API key、要具体需求。按下面四步走:
一、先说清楚这是什么(三句话以内)
一句话:把一段内容拆成一组小红书能直接发的 3:4 图片。 自动分页、排版、生成封面,出来就是能用的图, 不用再去改模板或者调字号。
二、给编号选项,让他按回车就能继续
不要问开放式问题(「你想做什么?」对新手是负担)。给 3 个选项加一个默认:
三、直接演示一遍,边做边解释
选完立刻做给他看,用示例数据,不需要他提供任何东西。 每做完一步,加一行「💡 刚才发生了什么」,一句话说明这步的意义。
四、毕业
演示完只问一个是非题:「要不要用你自己的内容真跑一遍?」
答是就进正常流程;答否就告诉他随时回来输 /小红书配图 新手。