post-to-xhs
- Repo stars 13,950
- Author updated Live
- Author repo xiaohongshu-mcp
- Domain
- Writing
- Compatible agents
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- Trust score
- 88 / 100 · community maintained
- Author / version / license
- @xpzouying · no license declared
- Token usage
- Lean
- Setup complexity
- Plug-and-play
- External API key
- Not required
- Operating systems
- Unspecified (assume cross-platform)
- Runtime requirements
- Python
- Permissions
-
- Read-only
- Write / modify
- Network behavior
- Local-only
- Install commands
- 26 variants
Profile is derived at build time from SKILL.md and install vectors. Subject to drift from author intent.
Heads up: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: post-to-xhs
description: > 根据用户输入自动判断发布方式和发布模式,简化发布流程。 ├─ 完整内容 + 图片/图片URL → 判断模式 → 发布流程 └─ 网页 URL → WebFetch 提取内容和图片 ├─ 有…
category: writing
runtime: Python
---
# post-to-xhs output preview
## PART A: Task fit
- Use case: > 根据用户输入自动判断发布方式和发布模式,简化发布流程。 ├─ 完整内容 + 图片/图片URL → 判断模式 → 发布流程 └─ 网页 URL → WebFetch 提取内容和图片 ├─ 有图片 → 适当总结内容 → 判断模式 → 发布流程 └─ 无图片 → 提示用户手动下载图片 runs entirely locally; runs on Python. Works with Claude Code, Cursor, Cline and 23 more..
- Inputs: target material, constraints, expected output, and acceptance criteria.
- Evidence boundary: follow “发布模式 / 工作流程 / Step 1: 判断输入类型” and do not present inference as author intent.
## PART B: Execution result
- **01** The card summarizes the use case; runtime output centers on “> 根据用户输入自动判断发布方式和发布模式,简化发布流程。 ├─ 完整内容 + 图片/图片URL → 判断模式 → 发布流程 └─ 网页 URL → WebFetch 提取内容和图片 ├─ 有图片 → 适当总结内容 → 判断模式 → 发布流程 └─ 无图片 → 提示用户手动下载图片 runs entirely locally; runs on Python. Works with Claude Code, Cursor, Cline and 23 more.”.
- **02** When the source has headings, the agent prioritizes “发布模式 / 工作流程 / Step 1: 判断输入类型” so the result follows the author’s structure.
- **03** Typical output includes task judgment, concrete steps, required commands or file edits, validation, and follow-up options.
- **04** Risk context follows the fingerprint: read files, write/modify files; mostly runs locally; usually needs no extra API key.
## Running Rules
- read files, write/modify files; mostly runs locally; usually needs no extra API key.
- Validate with a small sample before expanding scope.
- Return the result, validation criteria, and next iteration options. The source does not require a stable slash command. After installation, invoke the skill by name and describe the task.
Name target files or source material, expected output, forbidden changes, and whether network or shell access is allowed. Permission fingerprint: read files, write/modify files.
Start with a small task and check whether the result follows “发布模式 / 工作流程 / Step 1: 判断输入类型”. Inspect diffs, logs, previews, or tests before expanding scope.
Confirm the final output includes a concrete result, evidence, and next action. If it stays generic, tighten inputs, boundaries, and acceptance criteria.
---
name: post-to-xhs
description: > 根据用户输入自动判断发布方式和发布模式,简化发布流程。 ├─ 完整内容 + 图片/图片URL → 判断模式 → 发布流程 └─ 网页 URL → WebFetch 提取内容和图片 ├─ 有…
category: writing
source: xpzouying/xiaohongshu-mcp
---
# post-to-xhs
## When to use
- > 根据用户输入自动判断发布方式和发布模式,简化发布流程。 ├─ 完整内容 + 图片/图片URL → 判断模式 → 发布流程 └─ 网页 URL → WebFetch 提取内容和图片 ├─ 有图片 → 适当总结内容 → 判断模式 → 发…
- Use it when the task has clear inputs, repeatable steps, and validation criteria.
## What to provide
- Target material, scope, expected result, and forbidden changes.
- Whether network, commands, file writes, or external services are allowed.
## Execution rules
- Organize steps around “发布模式 / 工作流程 / Step 1: 判断输入类型” and keep inference separate from source facts.
- read files, write/modify files; mostly runs locally; usually needs no extra API key.
- Validate with a small sample before expanding the task.
## Output requirements
- Return the deliverable, key evidence, validation method, and next action.
- Mark missing information as unknown; do not invent commands, platforms, or dependencies. The author source anchors workflow facts; repository files anchor sources and commands; Fluxly only adds fit, limitations, and quality judgment.
skill "post-to-xhs" {
input -> user goal + target files + boundaries + acceptance criteria
context -> 发布模式 / 工作流程 / Step 1: 判断输入类型
rules -> SKILL.md triggers / order / output contract
runtime -> Python | read files, write/modify files | mostly runs locally
guardrails -> usually needs no extra API key + small-sample validation + diff/log review
output -> copyable result + checklist + next iteration
} 小红书内容发布
根据用户输入自动判断发布方式和发布模式,简化发布流程。
发布模式
- 上传图文(默认):图片 + 短文,适合日常分享
- 写长文:长篇文章 + 排版模板选择,适合深度内容。用户明确说"发长文"时使用
工作流程
用户输入
│
├─ 完整内容 + 图片/图片URL → 判断模式 → 发布流程
│
└─ 网页 URL → WebFetch 提取内容和图片
│
├─ 有图片 → 适当总结内容 → 判断模式 → 发布流程
│
└─ 无图片 → 提示用户手动下载图片
│
└─ 用户提供图片后 → 发布流程
Step 1: 判断输入类型
根据用户输入判断:
- 完整内容模式:用户提供了标题、正文内容、以及图片(本地路径或URL)
- URL 提取模式:用户只提供了一个网页 URL
如果不确定,询问用户。
Step 2: 处理内容
完整内容模式
直接使用用户提供的标题和正文,跳到 Step 3。
URL 提取模式
- 使用 WebFetch 提取网页内容
- 提取关键信息:标题、正文、图片URL
- 适当总结内容,保持:
- 关键信息完整
- 语言自然流畅
- 适合小红书阅读习惯
图片提取失败处理
如果从网页中提取不到图片URL,或图片URL无法访问,必须:
- 告知用户图片提取失败
- 提供原网页链接,请用户手动访问
- 指导用户:
- 在浏览器中打开原网页
- 右键点击想要的图片 → "图片另存为" 或 "复制图片地址"
- 将保存的图片路径或复制的图片URL提供给我
- 等待用户提供图片后再继续发布流程
示例提示语:
从网页中未能提取到可用的图片。请手动获取:
1. 打开原文链接:[URL]
2. 找到合适的配图,右键另存为本地,或复制图片地址
3. 将图片路径或URL发给我
拿到图片后我们继续发布。
Step 3: 内容检查
标题检查
标题长度必须 ≤ 38,计算规则:
- 中文字符和中文标点(《》、,。等):每个计 2
- 英文字母/数字/空格/ASCII标点:每个计 1
如果超长,自动生成符合长度要求的新标题,保持语义一致。
正文格式
- 段落之间使用双换行分隔
- 语言自然,避免机器翻译感
- 简体中文
Step 4: 发布到小红书
完整发布流程参考: references/publish-workflow.md
4.1 用户确认内容
通过 AskUserQuestion 向用户展示即将发布的内容(标题、正文、图片),获得明确确认后再继续。
4.2 选择发布模式
通过 AskUserQuestion 让用户选择发布模式:
- 无头模式(推荐):后台运行,速度快,无浏览器窗口。发布完成后直接报告结果。
- 有窗口模式:显示浏览器窗口,可以预览内容。需要用户确认后再点击发布。
AskUserQuestion 示例:
问题:选择发布模式
选项:
- 无头模式(推荐):后台快速发布,无需预览
- 有窗口模式:显示浏览器,可预览确认
4.3 写入临时文件
将标题和正文写入临时 UTF-8 文本文件。不要在 python -c 中内联中文文本。
4.4 运行发布(根据模式分流)
A. 上传图文模式(默认)
根据用户选择的模式执行发布脚本:
无头模式(添加 --headless 参数):
python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\publish_pipeline.py" --headless --title-file title.txt --content-file content.txt --image-urls "URL1" "URL2"
有窗口模式(不添加 --headless):
python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\publish_pipeline.py" --title-file title.txt --content-file content.txt --image-urls "URL1" "URL2"
其他参数:
# 发布到指定账号
python ... --account myaccount ...
# 使用本地图片
python ... --images "C:\path\to\image.jpg"
处理输出:
NOT_LOGGED_IN(exit code 1) → 脚本自动切换到有窗口模式,提示用户扫码登录,确认后重新运行READY_TO_PUBLISH(exit code 0) → 根据模式进入下一步- Exit code 2 → 报告错误
B. 写长文模式
Step B.1 — 填写长文内容 + 一键排版:
python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" long-article --title-file title.txt --content-file content.txt
可选 --images img1.jpg img2.jpg 插入图片到编辑器中。
输出中包含 TEMPLATES: [...] JSON 数组,为可用的排版模板名称列表。
Step B.2 — 让用户选择模板:
使用 AskUserQuestion 将模板名称作为选项展示给用户选择(从 TEMPLATES 输出中解析)。
Step B.3 — 选择模板:
python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" select-template --name "用户选择的模板名"
Step B.4 — 点击下一步并填写发布页正文描述:
python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" click-next-step --content-file content.txt
注意:发布页有独立的正文描述编辑器,必须通过 --content 或 --content-file 传入内容填写。
如果正文超过 1000 字,应压缩到 800 字左右再填入,保持语义不变。
Step B.5 — 用户预览确认并发布: 进入下方 4.5 步骤。
4.5 用户预览确认(仅有窗口模式 / 长文模式)
仅当用户选择有窗口模式或使用长文模式时,使用 AskUserQuestion 请用户在浏览器中检查预览,确认后再发布。
无头模式的图文发布跳过此步骤,直接进入 4.6。
4.6 点击发布
点击发布按钮:
python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" click-publish
4.7 报告结果
根据命令输出告知用户发布是否成功。
重要提示
- 绝不自动发布 - 必须获得用户确认
- 图片要求 - 上传图文模式必须有图片;写长文模式图片可选
- 长文模式 - 必须让用户选择模板,不要自动选择
- 正文描述 - 长文模式的发布页有独立正文描述框,超过 1000 字需压缩到 800 字左右
- 无头模式:使用
--headless参数自动化发布。如需登录,脚本自动切换到有窗口模式 - 如果页面结构变化导致选择器失效,参考
references/publish-workflow.md更新
账号管理
系统支持多个小红书账号,每个账号有独立的 Chrome profile。
列出账号
python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" list-accounts
添加账号
python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" add-account myaccount --alias "我的账号"
登录
# 默认账号
python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" login
# 指定账号
python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" --account myaccount login
切换账号
python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" switch-account
python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" --account otheraccount switch-account
设置默认账号
python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" set-default-account myaccount
Decide Fit First
Design Intent
How To Use It
Boundaries And Review