From agi-super-team
Automates Xiaohongshu (小红书) content publishing and draft saving with Playwright, covering title formatting, text layout, hashtag strategy, cover specs, and CES optimization. Supports image notes and carousels.
How this skill is triggered — by the user, by Claude, or both
Slash command
/agi-super-team:xhs-smart-publisherThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- Author: Daniel Li
触发词 → 填写内容 → 🔍 截图确认 → ⏳ 等待指令 → ✅ 发布/存草稿
关键:截图确认步骤不可跳过!
| 步骤 | 操作 | 阻塞? |
|---|---|---|
| 1 | 填写标题、正文、标签、上传封面 | ❌ |
| 2 | 截图发送到群 | ⚠️ 必须 |
| 3 | 等待用户确认 | ✅ 阻塞 |
| 4 | 收到"发布"→点击发布 | ❌ |
| 4 | 收到"存草稿"→点击暂存 | ❌ |
用户指令:
发布 / 确认发布 → 执行发布存草稿 / 暂存 → 保存到草稿箱| 项 | 规则 |
|---|---|
| 标题 | ≤20字,emoji+关键词+数字,公式:人群+关键词+数字+悬念+emoji |
| 正文 | 300-1000字,双换行分段,每段1-2个emoji开头,前3行放核心 |
| 标签 | #话题名(无空格) 3-8个,精准在前泛话题在后 |
| 封面 | 3:4竖版(1080×1440),大字+对比色+人物/产品占60%+ |
| 图片 | 1-18张,JPG/PNG,≤20MB/张 |
| 最佳时间 | 工作日18-22点,周末20-23点 |
将任意内容转化为小红书格式时:
人群定位+关键词+数字+悬念词+emoji
打工人必看🔥5个效率工具让你准时下班emoji 开头金句/痛点(抓注意力)
emoji 正文第一段(核心信息,≤3行)
emoji 正文第二段(展开论述)
emoji 正文第三段(补充/案例)
emoji 总结/互动引导(提问/投票)
#精准话题1 #精准话题2 #泛话题3 #泛话题4
Step 0: 确认发布内容类型
Step 1: 打开发布页面
browser(action="navigate", profile="openclaw",
targetUrl="https://creator.xiaohongshu.com/publish/publish?source=official&target=image")
Step 2: 确认发布类型
Step 3: 上传封面图片
input[type='file'] 上传封面图Step 4: 填写标题
// 找到标题输入框并设置值
const titleInput = document.querySelector('input[placeholder*="标题"]');
if(titleInput) {
titleInput.value = '标题内容(≤20字)';
titleInput.dispatchEvent(new Event('input', {bubbles: true}));
}
Step 5: 填写正文(⚠️ 最关键一步)
browser(action="act", kind="click", ref="<正文框ref>")
// 将 Markdown 转换为 HTML
const text = `要粘贴的正文内容`;
const paragraphs = text.split('\n').filter(p => p.trim());
const htmlParts = paragraphs.map(p => {
// 处理 **粗体**
p = p.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
return '<p>' + p + '</p>';
});
const html = htmlParts.join('');
// 写入编辑器
const editor = document.querySelector('.tiptap.ProseMirror');
if (editor) {
editor.focus();
editor.innerHTML = html;
editor.dispatchEvent(new Event('input', {bubbles: true}));
}
X/1000(X>0),如果仍显示 0/1000,尝试方案B/C/D(见"UI问题与解决方案")new Promise(r=>setTimeout(r,500)).then(()=>{...})Step 6: 检查排版
X/20X/1000Step 7: 🔍 截图确认(必须步骤)
browser(action="screenshot", target="host")
message(action="send", channel="telegram", target="-1003890797239",
message="📝 小红书内容已填写完毕,请确认后回复'发布'或'存草稿'",
accountId="xiaocode")
Step 8: ⏳ 等待用户确认
发布 / 确认发布 → 执行发布存草稿 / 暂存 → 保存到草稿箱修改 / 取消 → 停止流程,等待重新触发Step 9: ✅ 执行发布/存草稿
根据用户确认选择:
发布模式:
草稿模式:
相比图文,少去上传图片封面步骤
Step 1: 打开发布页面
https://creator.xiaohongshu.com/publish/publish?source=officialStep 2: 确认发布类型
Step 3: 填写标题
Step 4: 填写正文
Step 5: 🔍 截图确认(必须步骤)
Step 6: ⏳ 等待用户确认
Step 7: ✅ 执行发布/存草稿
Step 1: 上传视频
Step 2: 🔍 截图确认(必须步骤)
browser(action="screenshot", target="host") 截图Step 3: ⏳ 等待用户确认
Step 4: ✅ 执行发布
python scripts/xhs_publish.py \
--title "标题文字" \
--content "正文内容" \
--tags "话题1,话题2,话题3" \
--image "/path/to/cover.jpg" \
--mode draft \
--auto-login
参数说明:
--auto-login: 自动连接 openclaw 浏览器获取登录态--mode draft: 保存到草稿箱(默认)--mode publish: 直接发布使用 openclaw 浏览器 profile="openclaw",通过 CDP 连接 (http://127.0.0.1:18800) 自动复用登录态。
现象:标题正确(8字),但正文框显示 0/1000,browser 的 fill/type 均无法写入内容。
根因:小红书创作者平台已从 Quill.js 迁移到 Tiptap/ProseMirror(class=tiptap.ProseMirror)。普通 DOM 操作(设置 innerText/value)不触发 React 状态更新,导致:
✅ 解决方案(推荐方案):
方案A:Tiptap/ProseMirror API 直接写入(推荐)
// 将 Markdown 转换为 HTML 段落
const text = '要粘贴的正文内容\n第二段内容';
const paragraphs = text.split('\n').filter(p => p.trim());
const htmlParts = paragraphs.map(p => {
// 处理 **粗体**
p = p.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
return '<p>' + p + '</p>';
});
const html = htmlParts.join('');
// 写入 Tiptap 编辑器
const editor = document.querySelector('.tiptap.ProseMirror');
if (editor) {
editor.focus();
editor.innerHTML = html;
editor.dispatchEvent(new Event('input', {bubbles: true}));
}
方案B:Clipboard API 模拟粘贴(备选)
// 先点击正文编辑器获取焦点
document.querySelector('.tiptap.ProseMirror')?.click();
// 等待 300ms 让编辑器初始化
await new Promise(r => setTimeout(r, 300));
// 使用 Clipboard API 粘贴
const text = '要粘贴的正文内容';
const clipboardData = new DataTransfer();
clipboardData.setData('text/plain', text);
const pasteEvent = new ClipboardEvent('paste', {
clipboardData: clipboardData,
bubbles: true,
cancelable: true
});
document.querySelector('.tiptap.ProseMirror')?.dispatchEvent(pasteEvent);
方案C:executeCommand(兼容方案)
document.querySelector('.tiptap.ProseMirror')?.focus();
document.execCommand('selectAll');
document.execCommand('insertText', false, '正文内容');
验证标准:写入后正文框字数统计应显示 X/1000(X>0)。
现象:标题输入框显示字符计数如 "510/20",内容被粘贴到了标题位置。
根因:编辑器 UI 的 contenteditable 字段定位错误。
解决:
input[placeholder*="标题"] 定位.ql-editor 后等待 500ms| 错误 | 处理 |
|---|---|
| 登录过期 | 提示用户重新扫码,保存新cookie |
| 滑块验证 | 暂停等待手动完成,设置 --headless false |
| 标题超长 | 自动截断到20字并警告 |
| 图片上传失败 | 重试3次,每次间隔5秒 |
| 网络超时 | 重试3次,指数退避(5s/15s/45s) |
| 发布频率限制 | 等待60秒后重试 |
| 内容混入标题 | 保存草稿后手动修正 |
xhs-smart-publisher/
├── SKILL.md
├── scripts/
│ └── xhs_publish.py # Playwright 自动发布脚本
├── references/
│ └── platform-rules.md # 完整平台规则(从调研文档提取)
└── templates/
└── content-template.md # 排版模板示例
npx claudepluginhub aaaaqwq/agi-super-team --plugin agi-super-teamPublishes Markdown articles to Xiaohongshu (XHS) draft box with multi-image upload (cover + up to 18 images), title/body filling, and tag matching. Uses Playwright browser automation.
Guides automated publishing to WeChat Public Account, Xiaohongshu, and Feishu via wenyan-mcp APIs, Playwright browser automation, lark-mcp, with credential setup, workflows, and troubleshooting.
Publishes image and text content to Xiaohongshu (Little Red Book) via xiaohongshu-mcp HTTP API using Node.js script. Supports title, body, images, tags, and scheduled posting for automated social media content.